Add pmbootstrap checksum --verify (!1788)

Download all sources and verify their checksums.

This will be used in pmaports.git CI, if ci:skip-build is set in the
commit message (currently it just skips the build, and we don't test if
the source checksums are valid or not).
This commit is contained in:
Oliver Smith 2019-05-19 22:04:55 +02:00
parent 110b5821ac
commit b4c301974e
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB
5 changed files with 22 additions and 4 deletions

View file

@ -18,7 +18,6 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
""" """
# Exported functions # Exported functions
from pmb.build.init import init from pmb.build.init import init
from pmb.build.checksum import checksum
from pmb.build.envkernel import package_kernel from pmb.build.envkernel import package_kernel
from pmb.build.menuconfig import menuconfig from pmb.build.menuconfig import menuconfig
from pmb.build.newapkbuild import newapkbuild from pmb.build.newapkbuild import newapkbuild

View file

@ -24,7 +24,8 @@ import pmb.helpers.run
import pmb.helpers.pmaports import pmb.helpers.pmaports
def checksum(args, pkgname): def check(args, pkgname):
""" Fetch all sources and update the checksums in the APKBUILD. """
pmb.build.init(args) pmb.build.init(args)
pmb.build.copy_to_buildpath(args, pkgname) pmb.build.copy_to_buildpath(args, pkgname)
logging.info("(native) generate checksums for " + pkgname) logging.info("(native) generate checksums for " + pkgname)
@ -35,3 +36,15 @@ def checksum(args, pkgname):
source = args.work + "/chroot_native/home/pmos/build/APKBUILD" source = args.work + "/chroot_native/home/pmos/build/APKBUILD"
target = pmb.helpers.pmaports.find(args, pkgname) + "/" target = pmb.helpers.pmaports.find(args, pkgname) + "/"
pmb.helpers.run.user(args, ["cp", source, target]) pmb.helpers.run.user(args, ["cp", source, target])
def verify(args, pkgname):
""" Fetch all sources and verify their checksums. """
pmb.build.init(args)
pmb.build.copy_to_buildpath(args, pkgname)
logging.info("(native) verify checksums for " + pkgname)
# Fetch and verify sources, "fetch" alone does not verify them:
# https://github.com/alpinelinux/abuild/pull/86
pmb.chroot.user(args, ["abuild", "fetch", "verify"],
working_dir="/home/pmos/build")

View file

@ -119,7 +119,10 @@ def build_init(args):
def checksum(args): def checksum(args):
for package in args.packages: for package in args.packages:
pmb.build.checksum(args, package) if args.verify:
pmb.build.checksum.verify(args, package)
else:
pmb.build.checksum.check(args, package)
def chroot(args): def chroot(args):

View file

@ -478,6 +478,9 @@ def arguments():
# Action: checksum / aportgen / build # Action: checksum / aportgen / build
checksum = sub.add_parser("checksum", help="update aport checksums") checksum = sub.add_parser("checksum", help="update aport checksums")
checksum.add_argument("--verify", action="store_true", help="download"
" sources and verify that the checksums of the"
" APKBUILD match, instead of updating them")
aportgen = sub.add_parser("aportgen", help="generate a postmarketOS" aportgen = sub.add_parser("aportgen", help="generate a postmarketOS"
" specific package build recipe (aport/APKBUILD)") " specific package build recipe (aport/APKBUILD)")
build = sub.add_parser("build", help="create a package for a" build = sub.add_parser("build", help="create a package for a"

View file

@ -134,7 +134,7 @@ def test_aportgen_device_wizard(args, monkeypatch):
# Build the device package # Build the device package
pkgname = "device-testsuite-testdevice" pkgname = "device-testsuite-testdevice"
pmb.build.checksum(args, pkgname) pmb.build.checksum.check(args, pkgname)
pmb.build.package(args, pkgname, "armhf", force=True) pmb.build.package(args, pkgname, "armhf", force=True)
# Abort on overwrite confirmation # Abort on overwrite confirmation