From dacde204c91b9c5cb25ac793c17e13d287187b57 Mon Sep 17 00:00:00 2001 From: Levente Polyak Date: Sun, 18 Jul 2021 18:27:14 +0200 Subject: [PATCH] makerepropkg: use correct devtools makepkg.conf files from dist Use the recorded buildtool in order to download the matching dist package and use the appropriate makepkg.conf for reproducing the package. This is required as the flags are not recorded in the BUILDINFO hence we need to provide the matching config that declared those flags. --- Makefile | 3 ++- README.md | 11 +++++++++++ makerepropkg.in | 33 ++++++++++++++++++++++++++++++++- 3 files changed, 45 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 7b991f5..6e0b3dd 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ V=20210202 +BUILDTOOLVER ?= $(V)-git PREFIX = /usr/local MANDIR = $(PREFIX)/share/man @@ -92,7 +93,7 @@ edit = sed -e "s|@pkgdatadir[@]|$(PREFIX)/share/devtools|g" %: %.in Makefile lib/common.sh @echo "GEN $@" @$(RM) "$@" - @{ echo -n 'm4_changequote([[[,]]])'; cat $@.in; } | m4 -P --define=m4_devtools_version=$V | $(edit) >$@ + @{ echo -n 'm4_changequote([[[,]]])'; cat $@.in; } | m4 -P --define=m4_devtools_version=$(BUILDTOOLVER) | $(edit) >$@ @chmod a-w "$@" @chmod +x "$@" @bash -O extglob -n "$@" diff --git a/README.md b/README.md index 0f5d8f2..c4bc8f4 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,17 @@ as following. git config format.subjectprefix 'devtools] [PATCH' ``` +## Building + +When building official distro packages the `BUILDTOOLVER` needs to be set to the +exact label of the release package in order to allow to detect the exactly used +devtools version. This is required for reproducible builds to fetch the according +files like `makepkg.conf`. + +```sh +BUILDTOOLVER="${pkgver}-${pkgrel}-${arch}" make all +``` + ## Releasing 1. bump the version in the Makefile diff --git a/makerepropkg.in b/makerepropkg.in index ec9cd36..70abcbe 100755 --- a/makerepropkg.in +++ b/makerepropkg.in @@ -81,6 +81,18 @@ get_pkgfile() { return 1 } +get_makepkg_conf() { + local fname=${1} + local makepkg_conf="${2}" + if ! buildtool_file=$(get_pkgfile "${fname}"); then + error "failed to retrieve ${fname}" + return 1 + fi + msg2 "using makepkg.conf from ${fname}" + bsdtar xOqf "${buildtool_file/file:\/\//}" usr/share/devtools/makepkg-x86_64.conf > "${makepkg_conf}" + return 0 +} + usage() { cat << __EOF__ usage: ${BASH_SOURCE[0]##*/} [options] @@ -185,7 +197,26 @@ for fname in "${installed[@]}"; do exit 1 fi done -printf '%s\n' "${allpkgfiles[@]}" | mkarchroot -M @pkgdatadir@/makepkg-x86_64.conf -U "${archroot_args[@]}" "${buildroot}"/root - || exit 1 + +trap 'rm -rf $TEMPDIR' EXIT INT TERM QUIT +TEMPDIR=$(mktemp -d --tmpdir makerepropkg.XXXXXXXXXX) + +makepkg_conf="${TEMPDIR}/makepkg.conf" +# anything before buildtool support is pinned to the last none buildtool aware release +if [[ -z "${BUILDTOOL}" ]]; then + get_makepkg_conf "devtools-20210202-3-any" "${makepkg_conf}" || exit 1 +# prefere to assume devtools up until matching makepkg version so repository packages remain reproducible +elif [[ "${BUILDTOOL}" = makepkg ]] && (( $(vercmp "${BUILDTOOLVER}" 6.0.1) <= 0 )); then + get_makepkg_conf "devtools-20210202-3-any" "${makepkg_conf}" || exit 1 +# all devtools builds +elif [[ "${BUILDTOOL}" = devtools ]] && get_makepkg_conf "${BUILDTOOL}-${BUILDTOOLVER}" "${makepkg_conf}"; then + true +# fallback to current makepkg.conf +else + warning "Unknown buildtool (${BUILDTOOL}-${BUILDTOOLVER}), using fallback" + makepkg_conf=@pkgdatadir@/makepkg-x86_64.conf +fi +printf '%s\n' "${allpkgfiles[@]}" | mkarchroot -M "${makepkg_conf}" -U "${archroot_args[@]}" "${buildroot}"/root - || exit 1 # use makechrootpkg to prep the build directory makechrootpkg -r "${buildroot}" -l "${chroot}" -- --packagelist || exit 1