pmb/aportgen/busybox_static.py: fix distfile collisions (MR 1949)
Same fix as MR 1947, but for busybox_static.py instead of musl.py. While at it, order the imports alphabetically.
This commit is contained in:
parent
178931f992
commit
b4a205d4db
|
@ -1,18 +1,15 @@
|
||||||
# Copyright 2020 Oliver Smith
|
# Copyright 2020 Oliver Smith
|
||||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
import glob
|
|
||||||
import os
|
|
||||||
import pmb.helpers.run
|
|
||||||
import pmb.aportgen.core
|
import pmb.aportgen.core
|
||||||
import pmb.parse.apkindex
|
import pmb.build
|
||||||
import pmb.chroot.apk
|
import pmb.chroot.apk
|
||||||
import pmb.chroot.apk_static
|
import pmb.chroot.apk_static
|
||||||
|
import pmb.helpers.run
|
||||||
|
import pmb.parse.apkindex
|
||||||
|
|
||||||
|
|
||||||
def generate(args, pkgname):
|
def generate(args, pkgname):
|
||||||
# Install busybox-static in chroot to get verified apks
|
|
||||||
arch = pkgname.split("-")[2]
|
arch = pkgname.split("-")[2]
|
||||||
pmb.chroot.apk.install(args, ["busybox-static"], "buildroot_" + arch)
|
|
||||||
|
|
||||||
# Parse version from APKINDEX
|
# Parse version from APKINDEX
|
||||||
package_data = pmb.parse.apkindex.package(args, "busybox")
|
package_data = pmb.parse.apkindex.package(args, "busybox")
|
||||||
|
@ -20,32 +17,17 @@ def generate(args, pkgname):
|
||||||
pkgver = version.split("-r")[0]
|
pkgver = version.split("-r")[0]
|
||||||
pkgrel = version.split("-r")[1]
|
pkgrel = version.split("-r")[1]
|
||||||
|
|
||||||
# Copy the apk file to the distfiles cache
|
# Prepare aportgen tempdir inside and outside of chroot
|
||||||
pattern = (args.work + "/cache_apk_" + arch + "/busybox-static-" +
|
tempdir = "/tmp/aportgen"
|
||||||
version + ".*.apk")
|
pmb.chroot.root(args, ["rm", "-rf", tempdir])
|
||||||
glob_result = glob.glob(pattern)
|
pmb.helpers.run.user(args, ["mkdir", "-p", f"{args.work}/aportgen",
|
||||||
if not len(glob_result):
|
f"{args.work}/chroot_native/{tempdir}"])
|
||||||
raise RuntimeError("Could not find aport " + pattern + "!"
|
|
||||||
" Update your aports_upstream git repo"
|
|
||||||
" to the latest version, delete your http cache"
|
|
||||||
" (pmbootstrap zap -hc) and try again.")
|
|
||||||
path = glob_result[0]
|
|
||||||
path_target = (args.work + "/cache_distfiles/busybox-static-" +
|
|
||||||
version + "-" + arch + ".apk")
|
|
||||||
if not os.path.exists(path_target):
|
|
||||||
pmb.helpers.run.root(args, ["cp", path, path_target])
|
|
||||||
|
|
||||||
# Hash the distfile
|
|
||||||
hashes = pmb.chroot.user(args, ["sha512sum",
|
|
||||||
"busybox-static-" + version + "-" + arch + ".apk"],
|
|
||||||
"buildroot_" + arch, "/var/cache/distfiles",
|
|
||||||
output_return=True)
|
|
||||||
|
|
||||||
# Write the APKBUILD
|
# Write the APKBUILD
|
||||||
channel_cfg = pmb.config.pmaports.read_config_channel(args)
|
channel_cfg = pmb.config.pmaports.read_config_channel(args)
|
||||||
mirrordir = channel_cfg["mirrordir_alpine"]
|
mirrordir = channel_cfg["mirrordir_alpine"]
|
||||||
pmb.helpers.run.user(args, ["mkdir", "-p", args.work + "/aportgen"])
|
apkbuild_path = f"{args.work}/chroot_native/{tempdir}/APKBUILD"
|
||||||
with open(args.work + "/aportgen/APKBUILD", "w", encoding="utf-8") as handle:
|
with open(apkbuild_path, "w", encoding="utf-8") as handle:
|
||||||
apkbuild = f"""\
|
apkbuild = f"""\
|
||||||
# Automatically generated aport, do not edit!
|
# Automatically generated aport, do not edit!
|
||||||
# Generator: pmbootstrap aportgen {pkgname}
|
# Generator: pmbootstrap aportgen {pkgname}
|
||||||
|
@ -70,18 +52,21 @@ def generate(args, pkgname):
|
||||||
_target="$(arch_to_hostspec $_arch)"
|
_target="$(arch_to_hostspec $_arch)"
|
||||||
|
|
||||||
source="
|
source="
|
||||||
busybox-static-$pkgver-r$pkgrel-$_arch.apk::$_mirror/{mirrordir}/main/$_arch/busybox-static-$pkgver-r$pkgrel.apk
|
busybox-static-$pkgver-r$pkgrel-$_arch-{mirrordir}.apk::$_mirror/{mirrordir}/main/$_arch/busybox-static-$pkgver-r$pkgrel.apk
|
||||||
"
|
"
|
||||||
|
|
||||||
package() {{
|
package() {{
|
||||||
mkdir -p "$pkgdir/usr/$_target"
|
mkdir -p "$pkgdir/usr/$_target"
|
||||||
cd "$pkgdir/usr/$_target"
|
cd "$pkgdir/usr/$_target"
|
||||||
tar -xf $srcdir/busybox-static-$pkgver-r$pkgrel-$_arch.apk
|
tar -xf $srcdir/busybox-static-$pkgver-r$pkgrel-$_arch-{mirrordir}.apk
|
||||||
rm .PKGINFO .SIGN.*
|
rm .PKGINFO .SIGN.*
|
||||||
}}
|
}}
|
||||||
"""
|
"""
|
||||||
for line in apkbuild.split("\n"):
|
for line in apkbuild.split("\n"):
|
||||||
handle.write(line[12:].replace(" " * 4, "\t") + "\n")
|
handle.write(line[12:].replace(" " * 4, "\t") + "\n")
|
||||||
|
|
||||||
# Hashes
|
# Generate checksums
|
||||||
handle.write("sha512sums=\"" + hashes.rstrip() + "\"\n")
|
pmb.build.init(args)
|
||||||
|
pmb.chroot.root(args, ["chown", "-R", "pmos:pmos", tempdir])
|
||||||
|
pmb.chroot.user(args, ["abuild", "checksum"], working_dir=tempdir)
|
||||||
|
pmb.helpers.run.user(args, ["cp", apkbuild_path, f"{args.work}/aportgen"])
|
||||||
|
|
Loading…
Reference in New Issue