Browse Source

pkg: fedora: Remove the kernel-ark tree after building a source RPM

Dorian Stoll 2 years ago
parent
commit
8340a87f8a

+ 8 - 2
.github/workflows/fedora-37.yml

@@ -46,8 +46,14 @@ jobs:
         git config --global user.email "surfacebot@users.noreply.github.com"
         git config --global user.name "surfacebot"
 
-        # Build the .rpm packages
-        python3 build-linux-surface.py
+        # Build source RPM packages
+        python3 build-linux-surface.py --mode srpm --ark-dir kernel-ark --outdir srpm
+
+        # Remove the kernel-ark tree to get as much free disk space as possible
+        rm -rf kernel-ark
+
+        # Build binary RPM packages
+        rpmbuild -rb --define "_rpmdir $PWD/out" srpm/*.src.rpm
 
     - name: Sign packages
       env:

+ 8 - 2
.github/workflows/fedora-38.yml

@@ -46,8 +46,14 @@ jobs:
         git config --global user.email "surfacebot@users.noreply.github.com"
         git config --global user.name "surfacebot"
 
-        # Build the .rpm packages
-        python3 build-linux-surface.py
+        # Build source RPM packages
+        python3 build-linux-surface.py --mode srpm --ark-dir kernel-ark --outdir srpm
+
+        # Remove the kernel-ark tree to get as much free disk space as possible
+        rm -rf kernel-ark
+
+        # Build binary RPM packages
+        rpmbuild -rb --define "_rpmdir $PWD/out" srpm/*.src.rpm
 
     - name: Sign packages
       env:

+ 20 - 4
pkg/fedora/kernel-surface/build-ark.py

@@ -73,6 +73,13 @@ parser.add_argument(
     nargs="+",
 )
 
+parser.add_argument(
+    "--mode",
+    help="Whether to build a source RPM or binary RPMs.",
+    choices=["rpms", "srpm"],
+    default="rpms",
+)
+
 parser.add_argument(
     "--outdir",
     help="The directory where the built RPM files will be saved.",
@@ -153,9 +160,13 @@ for config in configs:
 system("git add redhat/configs/custom-overrides/generic")
 system("git commit -m 'Merge %s config'" % args.package_name)
 
-cmd = []
-cmd.append("make")
-cmd.append("dist-rpms")
+cmd = ["make"]
+
+if args.mode == "rpms":
+    cmd.append("dist-rpms")
+else:
+    cmd.append("dist-srpm")
+
 cmd.append("SPECPACKAGE_NAME='kernel-%s'" % args.package_name)
 cmd.append("DISTLOCALVERSION='.%s'" % args.package_name)
 cmd.append("BUILD='%s'" % args.package_release)
@@ -166,6 +177,11 @@ if len(buildopts) > 0:
 # Build RPMS
 system(" ".join(cmd))
 
+if args.mode == "rpms":
+    rpmdir = "RPMS"
+else:
+    rpmdir = "SRPMS"
+
 # Copy built RPMS to output directory
 os.makedirs(outdir, exist_ok=True)
-system("cp -r redhat/rpm/RPMS/* '%s'" % outdir)
+system("cp -r redhat/rpm/%s/* '%s'" % (rpmdir, outdir))

+ 35 - 2
pkg/fedora/kernel-surface/build-linux-surface.py

@@ -1,5 +1,6 @@
 #!/usr/bin/env python3
 
+import argparse
 import subprocess
 import sys
 from pathlib import Path
@@ -37,6 +38,35 @@ KERNEL_BUILDOPTS = "+up +baseonly -debuginfo -doc -headers -efiuki"
 
 #####################################################################
 
+parser = argparse.ArgumentParser(usage="Build a Fedora kernel with linux-surface patches")
+
+parser.add_argument(
+    "--ark-dir",
+    help="The local path to the kernel-ark repository.",
+    default="kernel-ark",
+)
+
+parser.add_argument(
+    "--ark-url",
+    help="The remote path to the kernel-ark repository.",
+    default="https://gitlab.com/cki-project/kernel-ark",
+)
+
+parser.add_argument(
+    "--mode",
+    help="Whether to build a source RPM or binary RPMs.",
+    choices=["rpms", "srpm"],
+    default="rpms",
+)
+
+parser.add_argument(
+    "--outdir",
+    help="The directory where the built RPM files will be saved.",
+    default="out",
+)
+
+args = parser.parse_args()
+
 # The directory where this script is saved.
 script = Path(sys.argv[0]).resolve().parent
 
@@ -74,8 +104,11 @@ if not sb_avail:
 # Expand globs
 surface_patches = sorted(patches.glob("*.patch"))
 
-cmd = []
-cmd += [script / "build-ark.py"]
+cmd = [script / "build-ark.py"]
+cmd += ["--ark-dir", args.ark_dir]
+cmd += ["--ark-url", args.ark_url]
+cmd += ["--mode", args.mode]
+cmd += ["--outdir", args.outdir]
 cmd += ["--package-name", PACKAGE_NAME]
 cmd += ["--package-tag", PACKAGE_TAG]
 cmd += ["--package-release", PACKAGE_RELEASE]