Skip to content

Commit

Permalink
拷贝安装脚本时若找不到配置的文件,输出warning提示
Browse files Browse the repository at this point in the history
  • Loading branch information
Handsome08 committed Jul 16, 2024
1 parent f4af010 commit aba16ac
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions DebUOS/Packaging.DebUOS/DebUOSPackageFileStructCreator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -370,27 +370,43 @@ public void CreatePackagingFolder(DebUOSConfiguration configuration)
File.WriteAllText(controlFile, stringBuilder.ToString(), encoding);
}

if (File.Exists(configuration.DebPostinstFile))
if (ExistsConfigurationFile(nameof(configuration.DebPostinstFile), configuration.DebPostinstFile))
{
var postinstFile = Path.Join(packingFolder, "DEBIAN", "postinst");
File.Copy(configuration.DebPostinstFile, postinstFile);
}
if (File.Exists(configuration.DebPrermFile))
if (ExistsConfigurationFile(nameof(configuration.DebPrermFile), configuration.DebPrermFile))
{
var prermFile = Path.Join(packingFolder, "DEBIAN", "prerm");
File.Copy(configuration.DebPrermFile, prermFile);
}
if (File.Exists(configuration.DebPostrmFile))
if (ExistsConfigurationFile(nameof(configuration.DebPostrmFile), configuration.DebPostrmFile))
{
var postrmFile = Path.Join(packingFolder, "DEBIAN", "postrm");
File.Copy(configuration.DebPostrmFile, postrmFile);
}
if (File.Exists(configuration.DebPreinstFile))
if (ExistsConfigurationFile(nameof(configuration.DebPreinstFile), configuration.DebPreinstFile))
{
var preinstFile = Path.Join(packingFolder, "DEBIAN", "preinst");
File.Copy(configuration.DebPreinstFile, preinstFile);
}
}

private bool ExistsConfigurationFile(string fileName, string? configurationFile)
{
if (string.IsNullOrEmpty(configurationFile))
{
return false;
}

if (!File.Exists(configurationFile))
{
Logger.LogWarning($"配置了 {fileName} 文件, 但是 '{configurationFile}' 不存在");
return false;
}

return true;
}

static class FolderUtils
{
Expand Down

0 comments on commit aba16ac

Please sign in to comment.