Skip to content

Commit

Permalink
Tools: Sign RPMs
Browse files Browse the repository at this point in the history
  • Loading branch information
cyanfish committed Apr 1, 2024
1 parent 6456d1f commit da601be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion NAPS2.Tools/Project/Packaging/PackageCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public int Run(PackageOptions opts)
DebPackager.PackageDeb(GetPackageInfoForConfig());
break;
case PackageType.Rpm:
RpmPackager.PackageRpm(GetPackageInfoForConfig());
RpmPackager.PackageRpm(GetPackageInfoForConfig(), opts.NoSign);
break;
case PackageType.Flatpak:
FlatpakPackager.Package(GetPackageInfoForConfig(), opts.NoPre);
Expand Down
23 changes: 16 additions & 7 deletions NAPS2.Tools/Project/Packaging/RpmPackager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ namespace NAPS2.Tools.Project.Packaging;

public static class RpmPackager
{
public static void PackageRpm(PackageInfo pkgInfo)
public static void PackageRpm(PackageInfo pkgInfo, bool noSign)
{
var rpmPath = pkgInfo.GetPath("rpm");
Output.Info($"Packaging rpm: {rpmPath}");

Output.Verbose("Building binaries");
var runtimeId = pkgInfo.Platform == Platform.LinuxArm ? "linux-arm64" : "linux-x64";
Cli.Run("dotnet", $"clean NAPS2.App.Gtk -c Release -r {runtimeId}");
Cli.Run("dotnet", $"publish NAPS2.App.Gtk -c Release -r {runtimeId} --self-contained /p:DebugType=None /p:DebugSymbols=false");
Cli.Run("dotnet",
$"publish NAPS2.App.Gtk -c Release -r {runtimeId} --self-contained /p:DebugType=None /p:DebugSymbols=false");

Output.Verbose("Creating package");

Expand Down Expand Up @@ -61,21 +62,29 @@ public static void PackageRpm(PackageInfo pkgInfo)
File.Copy(
Path.Combine(Paths.SolutionRoot, "LICENSE"),
Path.Combine(targetDir, "LICENSE.txt"));

// Create symlinks
var binDir = Path.Combine(filesDir, "usr/bin");
Directory.CreateDirectory(binDir);
Cli.Run("ln", $"-s /usr/lib/naps2/naps2 {Path.Combine(binDir, "naps2")}");

// Compress files
Cli.Run("tar", $"-zcvf {workingDir}/SOURCES/naps2-{pkgInfo.VersionNumber}.tar.gz {Path.GetFileName(filesDir)}", workingDir: workingDir);

Cli.Run("tar", $"-zcvf {workingDir}/SOURCES/naps2-{pkgInfo.VersionNumber}.tar.gz {Path.GetFileName(filesDir)}",
workingDir: workingDir);

// Build RPM
var arch = pkgInfo.Platform == Platform.LinuxArm ? "aarch64" : "x86_64";
Cli.Run("rpmbuild", $"{dirArg} -ba --target {arch} {workingDir}/SPECS/naps2.spec");
var sourceRpmPath = Path.Combine(workingDir, $"RPMS/{arch}/naps2-{pkgInfo.VersionNumber}-1.{arch}.rpm");

// Sign
if (!noSign)
{
Cli.Run("rpmsign", $"--addsign {sourceRpmPath}");
}

// Copy to output
File.Copy(Path.Combine(workingDir, $"RPMS/{arch}/naps2-{pkgInfo.VersionNumber}-1.{arch}.rpm"), rpmPath, true);
File.Copy(sourceRpmPath, rpmPath, true);

Output.OperationEnd($"Packaged rpm: {rpmPath}");
}
Expand Down

0 comments on commit da601be

Please sign in to comment.