[pacman-dev] [PATCH] makepkg: record build information in .BUILDINFO
This information can be used to reproduce build conditions, which can then be used to determine if a package builds reproducibly. Signed-off-by: Allan McRae <allan@archlinux.org> --- scripts/makepkg.sh.in | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 6ededa3..1fd3ff1 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -223,7 +223,7 @@ run_pacman() { else cmd=("$PACMAN_PATH" "$@") fi - if [[ $1 != -@(T|Qq) ]]; then + if [[ $1 != -@(T|Qq|Q) ]]; then if type -p sudo >/dev/null; then cmd=(sudo "${cmd[@]}") else @@ -1143,19 +1143,21 @@ write_pkginfo() { [[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]//+([[:space:]])/ }" [[ $makedepends ]] && printf "makedepend = %s\n" "${makedepends[@]}" [[ $checkdepends ]] && printf "checkdepend = %s\n" "${checkdepends[@]}" +} - local it - for it in "${packaging_options[@]}"; do - check_option "$it" "y" - case $? in - 0) - printf "makepkgopt = %s\n" "$it" - ;; - 1) - printf "makepkgopt = %s\n" "!$it" - ;; - esac - done +write_buildinfo() { + msg2 "$(gettext "Generating %s file...")" ".BUILDINFO" + + local pkglist=($(run_pacman -Q | sed "s# #-#")) + printf "installed = %s\n" "${pkglist[@]}" + + printf "cppflags = %s\n" "$cppflags" + printf "cflags = %s\n" "$cflags" + printf "cxxflags = %s\n" "$cxxflags" + printf "ldflags = %s\n" "$ldflags" + + printf "buildenv = %s\n" "${BUILDENV[@]}" + printf "options = %s\n" "${OPTIONS[@]}" } create_package() { @@ -1172,8 +1174,9 @@ create_package() { pkgarch=$(get_pkg_arch) write_pkginfo > .PKGINFO + write_buildinfo > .BUILDINFO - local comp_files=('.PKGINFO') + local comp_files=('.PKGINFO' '.BUILDINFO') # check for changelog/install files for i in 'changelog/.CHANGELOG' 'install/.INSTALL'; do @@ -1958,6 +1961,13 @@ GPGKEY=${_GPGKEY:-$GPGKEY} PACKAGER=${_PACKAGER:-$PACKAGER} CARCH=${_CARCH:-$CARCH} +# record initial build environment +cppflags="$CPPFLAGS" +cflags="$CFLAGS" +cxxflags="$CXXFLAGS" +ldflags="$LDFLAGS" + + if (( ! INFAKEROOT )); then if (( EUID == 0 )); then error "$(gettext "Running %s as root is not allowed as it can cause permanent,\n\ -- 2.5.3
Nice idea! But what about: - LDLIBS? (And possibly other variables?) - Autotools' configure options? - non-C/C++ packages? It is probably hard to centralize this kind of information indepently of the language / compiler. However adding CFLAGS, etc., to non-C/C++ packages will create unnecessary noise. -- Pierre Neidhardt Television is a medium because anything well done is rare. -- attributed to both Fred Allen and Ernie Kovacs
On 03/10/15 18:01, Pierre Neidhardt wrote:
Nice idea! But what about: - LDLIBS? (And possibly other variables?) - Autotools' configure options? - non-C/C++ packages?
All of those are standard makepkg.conf options. Anything beyond that should be specified in the PKGBUILD for a build to be deterministic.
It is probably hard to centralize this kind of information indepently of the language / compiler. However adding CFLAGS, etc., to non-C/C++ packages will create unnecessary noise.
On Sat, 3 Oct 2015 22:18:17 +1000 Allan McRae <allan@archlinux.org> wrote:
On 03/10/15 18:01, Pierre Neidhardt wrote:
Nice idea! But what about: - LDLIBS? (And possibly other variables?) - Autotools' configure options? - non-C/C++ packages?
All of those are standard makepkg.conf options. Anything beyond that should be specified in the PKGBUILD for a build to be deterministic.
Except they change over time.
It is probably hard to centralize this kind of information indepently of the language / compiler. However adding CFLAGS, etc., to non-C/C++ packages will create unnecessary noise.
On 04/10/15 00:30, Doug Newgard wrote:
On Sat, 3 Oct 2015 22:18:17 +1000 Allan McRae <allan@archlinux.org> wrote:
On 03/10/15 18:01, Pierre Neidhardt wrote:
Nice idea! But what about: - LDLIBS? (And possibly other variables?) - Autotools' configure options? - non-C/C++ packages?
All of those are standard makepkg.conf options. Anything beyond that should be specified in the PKGBUILD for a build to be deterministic.
Except they change over time.
Which is exactly the point of recording them...
participants (3)
-
Allan McRae
-
Doug Newgard
-
Pierre Neidhardt