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>
This commit is contained in:
Allan McRae 2015-10-17 00:57:12 +00:00
parent 9cdfd18739
commit 137ea39fa1

View file

@ -223,7 +223,7 @@ run_pacman() {
else else
cmd=("$PACMAN_PATH" "$@") cmd=("$PACMAN_PATH" "$@")
fi fi
if [[ $1 != -@(T|Qq) ]]; then if [[ $1 != -@(T|Qq|Q) ]]; then
if type -p sudo >/dev/null; then if type -p sudo >/dev/null; then
cmd=(sudo "${cmd[@]}") cmd=(sudo "${cmd[@]}")
else else
@ -1147,19 +1147,23 @@ write_pkginfo() {
[[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]//+([[:space:]])/ }" [[ $optdepends ]] && printf "optdepend = %s\n" "${optdepends[@]//+([[:space:]])/ }"
[[ $makedepends ]] && printf "makedepend = %s\n" "${makedepends[@]}" [[ $makedepends ]] && printf "makedepend = %s\n" "${makedepends[@]}"
[[ $checkdepends ]] && printf "checkdepend = %s\n" "${checkdepends[@]}" [[ $checkdepends ]] && printf "checkdepend = %s\n" "${checkdepends[@]}"
}
local it write_buildinfo() {
for it in "${packaging_options[@]}"; do msg2 "$(gettext "Generating %s file...")" ".BUILDINFO"
check_option "$it" "y"
case $? in printf "builddir = %s\n" "${BUILDDIR}"
0)
printf "makepkgopt = %s\n" "$it" local sum="$(openssl dgst -sha256 "${BUILDFILE}")"
;; sum=${sum##* }
1)
printf "makepkgopt = %s\n" "!$it" printf "pkgbuild_sha256sum = %s\n" $sum
;;
esac printf "buildenv = %s\n" "${BUILDENV[@]}"
done printf "options = %s\n" "${OPTIONS[@]}"
local pkglist=($(run_pacman -Q | sed "s# #-#"))
printf "installed = %s\n" "${pkglist[@]}"
} }
create_package() { create_package() {
@ -1176,8 +1180,9 @@ create_package() {
pkgarch=$(get_pkg_arch) pkgarch=$(get_pkg_arch)
write_pkginfo > .PKGINFO write_pkginfo > .PKGINFO
write_buildinfo > .BUILDINFO
local comp_files=('.PKGINFO') local comp_files=('.PKGINFO' '.BUILDINFO')
# check for changelog/install files # check for changelog/install files
for i in 'changelog/.CHANGELOG' 'install/.INSTALL'; do for i in 'changelog/.CHANGELOG' 'install/.INSTALL'; do