Source: libtool
Version: 2.4.6
Severity: wishlist
Tags: patch
User: reproducible-builds@lists.alioth.debian.org
Usertags: timestamps fileordering hostname umask
X-Debbugs-Cc: reproducible-builds@lists.alioth.debian.org

Hi!

While working on the “reproducible builds” effort [1], we have noticed
that libtool could not be built reproducibly.

The attached patch removes extra timestamps from the build system and
ensure a stable file order when creating the source archive as well as replacing uses of the `hostname` command with the fixed string "localhost". Once applied, libtool can be built reproducibly in our current experimental framework.

I also added to rules: dh_strip_nondeterminism -i/-a to the makefile before the compress stage.

 [1]: https://wiki.debian.org/ReproducibleBuilds
   * deterministic tar archives by sorting by name.

Author: rain1 <ra...@openmailbox.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- libtool-2.4.6.orig/aclocal.m4
+++ libtool-2.4.6/aclocal.m4
@@ -1104,8 +1104,8 @@ m4_if([$1], [v7],
       # Must skip GNU tar: if it does not support --format= it doesn't create
       # ustar tarball either.
       (tar --version) >/dev/null 2>&1 && continue
-      am__tar='tar chf - "$$tardir"'
-      am__tar_='tar chf - "$tardir"'
+      am__tar='tar --sort=name chf - "$$tardir"'
+      am__tar_='tar --sort=name chf - "$tardir"'
       am__untar='tar xf -'
       ;;
     pax)
@@ -1114,8 +1114,8 @@ m4_if([$1], [v7],
       am__untar='pax -r'
       ;;
     cpio)
-      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
-      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+      am__tar='find "$$tardir" -print | LC_ALL=C sort -z | cpio -o -H $1 -L'
+      am__tar_='find "$tardir" -print | LC_ALL=C sort -z | cpio -o -H $1 -L'
       am__untar='cpio -i -H $1 -d'
       ;;
     none)
--- libtool-2.4.6.orig/libltdl/aclocal.m4
+++ libtool-2.4.6/libltdl/aclocal.m4
@@ -1104,8 +1104,8 @@ m4_if([$1], [v7],
       # Must skip GNU tar: if it does not support --format= it doesn't create
       # ustar tarball either.
       (tar --version) >/dev/null 2>&1 && continue
-      am__tar='tar chf - "$$tardir"'
-      am__tar_='tar chf - "$tardir"'
+      am__tar='tar --sort=name chf - "$$tardir"'
+      am__tar_='tar --sort=name chf - "$tardir"'
       am__untar='tar xf -'
       ;;
     pax)
@@ -1114,8 +1114,8 @@ m4_if([$1], [v7],
       am__untar='pax -r'
       ;;
     cpio)
-      am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
-      am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+      am__tar='find "$$tardir" -print | LC_ALL=C sort -z | cpio -o -H $1 -L'
+      am__tar_='find "$tardir" -print | LC_ALL=C sort -z | cpio -o -H $1 -L'
       am__untar='cpio -i -H $1 -d'
       ;;
     none)
   * set the hostname to a reproducible dummy value.
Author: rain1 <ra...@openmailbox.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- libtool-2.4.6.orig/m4/autobuild.m4
+++ libtool-2.4.6/m4/autobuild.m4
@@ -22,7 +22,7 @@ AC_DEFUN([AB_INIT],
   fi
   AC_MSG_NOTICE([autobuild revision... $AB_VERSION])
 
-  hostname=`hostname`
+  hostname="debian"
   if test "$hostname"; then
     AC_MSG_NOTICE([autobuild hostname... $hostname])
   fi
   * change all instances of executing `hostname` with constant string "localhost"

Author: rain1 <ra...@openmailbox.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- libtool-2.4.6.orig/configure
+++ libtool-2.4.6/configure
@@ -577,7 +577,7 @@ exec 6>&1
 # Name of the host.
 # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
 # so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+ac_hostname="localhost"
 
 #
 # Initializations.
@@ -2259,7 +2259,7 @@ cat <<_ASUNAME
 ## Platform. ##
 ## --------- ##
 
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+hostname = "localhost"
 uname -m = `(uname -m) 2>/dev/null || echo unknown`
 uname -r = `(uname -r) 2>/dev/null || echo unknown`
 uname -s = `(uname -s) 2>/dev/null || echo unknown`
@@ -3499,7 +3499,7 @@ $as_echo "$as_me: autobuild project... $
   { $as_echo "$as_me:${as_lineno-$LINENO}: autobuild revision... $AB_VERSION" >&5
 $as_echo "$as_me: autobuild revision... $AB_VERSION" >&6;}
 
-  hostname=`hostname`
+  hostname="localhost"
   if test "$hostname"; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: autobuild hostname... $hostname" >&5
 $as_echo "$as_me: autobuild hostname... $hostname" >&6;}
@@ -29655,7 +29655,7 @@ generated by GNU Autoconf 2.69.  Invocat
   CONFIG_COMMANDS = $CONFIG_COMMANDS
   $ $0 $@
 
-on `(hostname || uname -n) 2>/dev/null | sed 1q`
+on localhost
 "
 
 _ACEOF
@@ -31426,7 +31426,7 @@ $as_echo X"$file" |
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
 # Generated automatically by $as_me ($PACKAGE) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# Libtool was configured on host localhost:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 
 # Provide generalized library-building support services.
--- libtool-2.4.6.orig/libltdl/configure
+++ libtool-2.4.6/libltdl/configure
@@ -573,7 +573,7 @@ exec 6>&1
 # Name of the host.
 # hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,
 # so uname gets run too.
-ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+ac_hostname="localhost"
 
 #
 # Initializations.
@@ -1901,7 +1901,7 @@ cat <<_ASUNAME
 ## Platform. ##
 ## --------- ##
 
-hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+hostname = "localhost"
 uname -m = `(uname -m) 2>/dev/null || echo unknown`
 uname -r = `(uname -r) 2>/dev/null || echo unknown`
 uname -s = `(uname -s) 2>/dev/null || echo unknown`
@@ -13769,7 +13769,7 @@ generated by GNU Autoconf 2.69.  Invocat
   CONFIG_COMMANDS = $CONFIG_COMMANDS
   $ $0 $@
 
-on `(hostname || uname -n) 2>/dev/null | sed 1q`
+on localhost
 "
 
 _ACEOF
@@ -14947,7 +14947,7 @@ $as_echo X"$file" |
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
 # Generated automatically by $as_me ($PACKAGE) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# Libtool was configured on host localhost:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 
 # Provide generalized library-building support services.
--- libtool-2.4.6.orig/m4/autobuild.m4
+++ libtool-2.4.6/m4/autobuild.m4
@@ -22,7 +22,7 @@ AC_DEFUN([AB_INIT],
   fi
   AC_MSG_NOTICE([autobuild revision... $AB_VERSION])
 
-  hostname="debian"
+  hostname="localhost"
   if test "$hostname"; then
     AC_MSG_NOTICE([autobuild hostname... $hostname])
   fi
   * `hostname` tool changed to "localhost" in m4/libtool.m4.

Author: rain1 <ra...@openmailbox.org>

---
The information above should follow the Patch Tagging Guidelines, please
checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
are templates for supplementary fields that you might want to add:

Origin: <vendor|upstream|other>, <url of original patch>
Bug: <url in upstream bugtracker>
Bug-Debian: https://bugs.debian.org/<bugnumber>
Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
Forwarded: <no|not-needed|url proving that it has been forwarded>
Reviewed-By: <name and email of someone who approved the patch>
Last-Update: <YYYY-MM-DD>

--- libtool-2.4.6.orig/m4/libtool.m4
+++ libtool-2.4.6/m4/libtool.m4
@@ -728,7 +728,7 @@ _LT_CONFIG_SAVE_COMMANDS([
     cat <<_LT_EOF >> "$cfgfile"
 #! $SHELL
 # Generated automatically by $as_me ($PACKAGE) $VERSION
-# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# Libtool was configured on host localhost:
 # NOTE: Changes made to this file will be lost: look at ltmain.sh.
 
 # Provide generalized library-building support services.
#!/usr/bin/make -f
# debian/rules for the Debian GNU Libtool package.
# Copyright © 2003, 2004 Scott James Remnant <sc...@netsplit.com>

# Uncomment this to turn on verbose mode. 
#export DH_VERBOSE=1

DEBIAN_REVISION=$(strip $(shell dpkg-parsechangelog | awk -F: '/^Version:/ 
{print $$NF}'))

# if doing a binary-arch build, the Makefiles still want to update the
# info files; force them not to
ifneq (,$(wildcard /usr/bin/makeinfo))
  MAKEINFO = makeinfo
else
  export MAKEINFO=true
endif

# libltdl needs to conform to policy
export DEB_CFLAGS_MAINT_PREPEND = -Wall
ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
        INSTALL_PROGRAM += -s
endif

# Build libltdl the right way (tm)
DEB_HOST_ARCH      ?= $(shell dpkg-architecture -qDEB_HOST_ARCH)
DEB_HOST_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
ifeq ($(DEB_BUILD_GNU_TYPE), $(DEB_HOST_GNU_TYPE))
        confflags += --build=$(DEB_HOST_GNU_TYPE)
        make_check = yes
else
        confflags += --build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE)
        make_check = no
endif

ifneq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
        make_check = no
endif

# Takes too long
#ifeq (m68k, $(DEB_HOST_ARCH))
#       make_check = no
#endif

clean: 
        dh_testdir
        dh_testroot
        rm -f build-stamp build-indep-stamp config-stamp
        dh_clean

        [ ! -f Makefile ] || $(MAKE) -k distclean
#       -rm config.log
#       find . -name 'stamp-*' | xargs rm -f
#       find . -name 'configure' | xargs rm -f
#       rm -f *.in */*.in
#       rm -f *.m4 */*.m4
#       find tests -name '*.in' -o -name '*.m4' | xargs rm -f
#       find libltdl/config -type f -a ! -name '*.m4sh' -a ! -name 'mkstamp' | 
xargs rm -f
#       rm -f libltdl/Makefile.am
#       rm -f libltdl/m4/ltversion.m4
#       rm -f COPYING INSTALL commit tests-failed
#       rm -f doc/libtool.info-1 doc/libtool.info-2
#       rm -f tests/testsuite
#       rm -f doc/version.texi doc/notes.txt doc/stamp-vti doc/libtool.info
# Undo the version change if there is any.
#       sed -i -e 's/@VERSION@.*/@VERSION@/' libtoolize.in
#       sed -i -e 's/^\(#.*@VERSION@\).*/\1/' build-aux/ltmain.in
#       sed -i -e 's/^VERSION.*/VERSION=@VERSION@/' build-aux/ltmain.in

config: config-stamp
Makefile: config-stamp
config-stamp:
        dh_testdir

        sed -i -e 's/^#.*progname.*@VERSION@$$/& Debian-$(DEBIAN_REVISION)/' 
libtoolize.in
        sed -i -e 's/^#.*progname.*@VERSION@$$/& Debian-$(DEBIAN_REVISION)/' 
build-aux/ltmain.in
        sed -i -e 's/^VERSION.*/VERSION="@VERSION@ Debian-$(DEBIAN_REVISION)"/' 
build-aux/ltmain.in

        touch README-release

        ./bootstrap --force --no-git
        CONFIG_SHELL=/bin/bash /bin/bash ./configure \
                --prefix=/usr \
                --libdir=\$${prefix}/lib/$(DEB_HOST_MULTIARCH) \
                $(confflags) \
                $(shell dpkg-buildflags --export=cmdline)
        touch config-stamp


build: build-arch build-indep

build-arch: build-stamp
build-stamp: config-stamp
        dh_testdir

        $(MAKE)

#       The system libtool script in Debian must be able to support
#       invoking gcc as cc
        echo '# ### BEGIN LIBTOOL TAG CONFIG: BINCC' >> libtool
        sed -n -e '/^# ### BEGIN LIBTOOL CONFIG/,/^# ### END LIBTOOL CONFIG/p' 
< libtool \
                | grep -B 2 -A 1 -e '^LTCC=' -e '^CC=' \
                | sed '/^--/d;s/gcc/cc/g' >> libtool
        echo '# ### END LIBTOOL TAG CONFIG: BINCC' >> libtool
        echo >> libtool

#       The system libtool script in Debian must be able to support
#       invoking g++ both by the g++ and c++ names.
        sed -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: CXX$$/,/^# ### END LIBTOOL 
TAG CONFIG: CXX$$/p' < libtool \
                | sed -e 's/CONFIG: CXX/CONFIG: BINCXX/g' \
                      -e 's/g++/c++/g' >> libtool
        echo >> libtool

#       Add our BINCC and BINCXX tags
        sed -e 's/^\(available_tags\)=\"\(.*\)\"/\1=\"\2 BINCC BINCXX\"/' \
                < libtool > libtool.tags
        mv libtool.tags libtool

#       Don't hardcode gcc path information, and don't use nostdlib
        sed -e 's/^\(predep_objects\)=.*/\1=""/' \
            -e 's/^\(postdep_objects\)=.*/\1=""/' \
            -e 's/^\(compiler_lib_search_path\)=.*/\1=""/' \
            -e 's:^\(sys_lib_search_path_spec\)=.*:\1="/lib/ /usr/lib/ 
/usr/X11R6/lib/ /usr/local/lib/":' \
            -e 's/^\(archive_cmds=\".*\) -nostdlib /\1 /' \
            -e 's/^\(archive_expsym_cmds=\".*\) -nostdlib /\1 /' \
            < libtool > libtool.gcc-indep
        mv libtool.gcc-indep libtool

#       Make libtool executable again
        chmod 755 libtool

ifeq ($(make_check), yes)
#       Now make sure it works
        -$(MAKE) check || touch tests-failed
        -cat test-suite.log
        -cat tests/testsuite.log
        @test ! -f tests-failed
endif

        touch build-stamp

build-indep: build-indep-stamp
build-indep-stamp:
#       This generated HTML page goes into libtool-doc.
        cd doc && $(MAKEINFO) libtool.texi
        cd doc && $(MAKEINFO) --html --no-split libtool.texi

        touch build-indep-stamp

install: build
        dh_testdir
        dh_testroot
        dh_prep
        dh_installdirs

        $(MAKE) prefix=$(CURDIR)/debian/tmp/usr install
        rm -f debian/tmp/usr/share/info/dir

        dh_install $(if $(filter true,$(MAKEINFO)),-Nlibtool-doc) \
                --fail-missing --sourcedir=debian/tmp

# Build architecture-independent files here.
binary-indep: build-indep install
        dh_testdir -i
        dh_testroot -i

        # Create symlinks to the one in autotools-dev
        rm -f debian/libtool/usr/share/libtool/build-aux/config.guess
        ln -s ../../misc/config.guess debian/libtool/usr/share/libtool/build-aux
        rm -f debian/libtool/usr/share/libtool/build-aux/config.sub
        ln -s ../../misc/config.sub debian/libtool/usr/share/libtool/build-aux

        dh_installdocs -i
        dh_installinfo -plibtool-doc
        dh_installexamples -i
        dh_installchangelogs -i ChangeLog
        dh_link -i
        dh_lintian -i
        dh_strip_nondeterminism -i
        dh_compress -i
        dh_fixperms -i
        dh_installdeb -i
        dh_gencontrol -i
        dh_md5sums -i
        dh_builddeb -i

# Build architecture-dependent files here.
binary-arch: build-arch install
        dh_testdir -a
        dh_testroot -a

        dh_installdocs -plibtool-bin
        dh_installdocs -plibltdl7
        mkdir -p debian/libltdl-dev/usr/share/doc
        cd debian/libltdl-dev/usr/share/doc && ln -sf libltdl7 libltdl-dev
        dh_installchangelogs -plibtool-bin
        dh_installchangelogs -plibltdl7 ChangeLog
        dh_strip -a
        dh_lintian -a
        dh_link -a
        dh_strip_nondeterminism -a
        dh_compress -a
        dh_fixperms -a
        dh_makeshlibs -a -V
        dh_installdeb -a
        dh_shlibdeps -a
        dh_gencontrol -a
        dh_md5sums -a
        dh_builddeb -a

binary: binary-indep binary-arch
.PHONY: build build-arch build-indep clean config patch unpatch binary-indep 
binary-arch binary install
_______________________________________________
Reproducible-builds mailing list
Reproducible-builds@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/reproducible-builds

Reply via email to