makerepropkg: support checking multiple split packages

By specifying multiple package files, we assume they are all from the
same PKGBUILD, and try to check them all against the produced artifacts.
Since the buildinfo should be comparable for all of them, we simply use
the first one passed on the command line.

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
Signed-off-by: Levente Polyak <anthraxx@archlinux.org>
This commit is contained in:
Eli Schwartz 2019-12-08 15:07:00 -05:00 committed by Levente Polyak
parent 53fe5c67a1
commit 51842a1676
No known key found for this signature in database
GPG Key ID: FC1B547C8D8172C8
2 changed files with 29 additions and 19 deletions

View File

@ -7,12 +7,12 @@ makerepropkg - Rebuild a package to see if it is reproducible
Synopsis Synopsis
-------- --------
makerepropkg [OPTIONS] <package_file> makerepropkg [OPTIONS] <package_file>...
Description Description
----------- -----------
Given the path to a built pacman package, attempt to rebuild it using the Given the path to a built pacman package(s), attempt to rebuild it using the
PKGBUILD in the current directory. The package will be built in an environment PKGBUILD in the current directory. The package will be built in an environment
as closely matching the environment of the initial package as possible, by as closely matching the environment of the initial package as possible, by
building up a chroot to match the information exposed in the package's building up a chroot to match the information exposed in the package's
@ -20,6 +20,10 @@ linkman:BUILDINFO[5] manifest. On success, the resulting package will be
compared to the input package, and makerepropkg will report whether the compared to the input package, and makerepropkg will report whether the
artifacts are identical. artifacts are identical.
When given multiple packages, additional package files are assumed to be split
packages and will be treated as additional artifacts to compare during the
verification step.
This implements a verifier for pacman/libalpm packages in accordance with the This implements a verifier for pacman/libalpm packages in accordance with the
link:https://reproducible-builds.org/[Reproducible Builds] project. link:https://reproducible-builds.org/[Reproducible Builds] project.

View File

@ -117,10 +117,13 @@ check_root
if [[ -n $1 ]]; then if [[ -n $1 ]]; then
pkgfile="$1" pkgfile="$1"
if ! bsdtar -tqf "${pkgfile}" .BUILDINFO >/dev/null 2>&1; then splitpkgs=("$@")
error "file is not a valid pacman package: '%s'" "${pkgfile}" for f in "${splitpkgs[@]}"; do
exit 1 if ! bsdtar -tqf "${f}" .BUILDINFO >/dev/null 2>&1; then
fi error "file is not a valid pacman package: '%s'" "${f}"
exit 1
fi
done
else else
error "no package file specified. Try '${BASH_SOURCE[0]##*/} -h' for more information. " error "no package file specified. Try '${BASH_SOURCE[0]##*/} -h' for more information. "
exit 1 exit 1
@ -176,23 +179,26 @@ arch-nspawn "${buildroot}/${chroot}" \
--bind="${PWD}:/startdir" \ --bind="${PWD}:/startdir" \
--bind="${SRCDEST}:/srcdest" \ --bind="${SRCDEST}:/srcdest" \
/chrootbuild -C --noconfirm --log --holdver --skipinteg /chrootbuild -C --noconfirm --log --holdver --skipinteg
ret=$?
if (( $? == 0 )); then if (( ${ret} == 0 )); then
msg2 "built succeeded! built packages can be found in ${buildroot}/${chroot}/pkgdest" msg2 "built succeeded! built packages can be found in ${buildroot}/${chroot}/pkgdest"
msg "comparing artifacts..." msg "comparing artifacts..."
comparefiles=("${pkgfile}" "${buildroot}/${chroot}/pkgdest/${pkgfile##*/}") for pkgfile in "${splitpkgs[@]}"; do
if cmp -s "${comparefiles[@]}"; then comparefiles=("${pkgfile}" "${buildroot}/${chroot}/pkgdest/${pkgfile##*/}")
msg2 "Package successfully reproduced!" if cmp -s "${comparefiles[@]}"; then
exit 0 msg2 "Package '%s' successfully reproduced!" "${pkgfile}"
else else
warning "Package is not reproducible. :(" ret=1
sha256sum "${comparefiles[@]}" warning "Package '%s' is not reproducible. :(" "${pkgfile}"
if (( diffoscope )); then sha256sum "${comparefiles[@]}"
diffoscope "${comparefiles[@]}" if (( diffoscope )); then
diffoscope "${comparefiles[@]}"
fi
fi fi
fi done
fi fi
# the package either failed to build, or was unreproducible # return failure from chrootbuild, or the reproducibility status
exit 1 exit ${ret}