[pacman-dev,v2] makepkg: add the $startdir to package .BUILDINFO

Message ID 20191115143212.1098895-1-eschwartz@archlinux.org
State Accepted, archived
Headers show
Series [pacman-dev,v2] makepkg: add the $startdir to package .BUILDINFO | expand

Commit Message

Eli Schwartz Nov. 15, 2019, 2:32 p.m. UTC
This value is needed for reproducible builds. The reason is because
$BUILDDIR changes its behavior depending on whether it is the same as
$startdir, and the result is that we cannot know whether $srcdir (the
path that is potentially embedded into the final package) is actually
"$BUILDDIR/src" or "$BUILDDIR/$pkgbase/src".

Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
---

v2: add documentation and bump the format version. I went with '2'
rather than require a pre-release bump to get a 'real number' which we
might forget, so if anything else gets added in the current patch
release cycle (unlikely?) we can just skip the bumping.

 doc/BUILDINFO.5.asciidoc | 3 +++
 scripts/makepkg.sh.in    | 3 ++-
 2 files changed, 5 insertions(+), 1 deletion(-)

Comments

Allan McRae Nov. 26, 2019, 1:50 a.m. UTC | #1
On 16/11/19 12:32 am, Eli Schwartz wrote:
> This value is needed for reproducible builds. The reason is because
> $BUILDDIR changes its behavior depending on whether it is the same as
> $startdir, and the result is that we cannot know whether $srcdir (the
> path that is potentially embedded into the final package) is actually
> "$BUILDDIR/src" or "$BUILDDIR/$pkgbase/src".
> 
> Signed-off-by: Eli Schwartz <eschwartz@archlinux.org>
> ---
> 
> v2: add documentation and bump the format version. I went with '2'
> rather than require a pre-release bump to get a 'real number' which we
> might forget, so if anything else gets added in the current patch
> release cycle (unlikely?) we can just skip the bumping.

Ack.

A

Patch

diff --git a/doc/BUILDINFO.5.asciidoc b/doc/BUILDINFO.5.asciidoc
index 3db1e12f..bb300e18 100644
--- a/doc/BUILDINFO.5.asciidoc
+++ b/doc/BUILDINFO.5.asciidoc
@@ -53,6 +53,9 @@  BUILDINFO file format.
 *builddir*::
 	The directory where the package was built.
 
+*startdir*::
+	The directory from which makepkg was executed.
+
 *buildenv (array)*::
 	The build environment specified in makepkg.conf.
 
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index 2deb61da..ca3e7459 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -626,7 +626,7 @@  write_pkginfo() {
 }
 
 write_buildinfo() {
-	write_kv_pair "format" "1"
+	write_kv_pair "format" "2"
 
 	write_kv_pair "pkgname" "$pkgname"
 	write_kv_pair "pkgbase" "$pkgbase"
@@ -643,6 +643,7 @@  write_buildinfo() {
 	write_kv_pair "packager" "${PACKAGER}"
 	write_kv_pair "builddate" "${SOURCE_DATE_EPOCH}"
 	write_kv_pair "builddir"  "${BUILDDIR}"
+	write_kv_pair "startdir"  "${startdir}"
 	write_kv_pair "buildenv" "${BUILDENV[@]}"
 	write_kv_pair "options" "${OPTIONS[@]}"