[pacman-dev] [PATCH] makepkg: make strip options configurable
The newly added variables STRIP_BINARIES, STRIP_SHARED and STRIP_STATIC, that are set in makepkg.conf, specify the strip options used on binaries and shared and static libraries. In addition, files are now stripped more aggressively by default. Implements FS#13592 the way it was suggested by Allan in the comments. Signed-off-by: Cedric Staniewski <cedric@gmx.ca> --- configure.ac | 9 +++++++++ doc/Makefile.am | 14 ++++++++++++-- doc/makepkg.conf.5.txt | 12 ++++++++++++ etc/Makefile.am | 3 +++ etc/makepkg.conf.in | 6 ++++++ scripts/makepkg.sh.in | 6 +++--- 6 files changed, 45 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 80e41a6..faf774f 100644 --- a/configure.ac +++ b/configure.ac @@ -186,6 +186,9 @@ GCC_GNU89_INLINE_CC # Host-dependant definitions SIZECMD="stat -L -c %s" SEDINPLACE="sed -i" +STRIP_BINARIES="--strip-all" +STRIP_SHARED="--strip-unneeded" +STRIP_STATIC="--strip-debug" case "${host_os}" in *bsd*) SIZECMD="stat -L -f %z" @@ -199,6 +202,9 @@ case "${host_os}" in host_os_darwin=yes SIZECMD="/usr/bin/stat -L -f %z" SEDINPLACE="/usr/bin/sed -i ''" + STRIP_BINARIES="" + STRIP_SHARED="-S" + STRIP_STATIC="-S" ;; esac @@ -206,6 +212,9 @@ AM_CONDITIONAL([CYGWIN], test "x$host_os_cygwin" = "xyes") AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes") AC_SUBST(SIZECMD) AC_SUBST(SEDINPLACE) +AC_SUBST(STRIP_BINARIES) +AC_SUBST(STRIP_SHARED) +AC_SUBST(STRIP_STATIC) # Check for architecture, used in default makepkg.conf # (Note single space left after CARCHFLAGS) diff --git a/doc/Makefile.am b/doc/Makefile.am index fcbcab8..ce1adab 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -66,6 +66,12 @@ else REAL_PACKAGE_VERSION = $(PACKAGE_VERSION) endif +#### Taken from the autoconf scripts Makefile.am #### +edit = sed \ + -e 's|@STRIP_BINARIES[@]|$(STRIP_BINARIES)|g' \ + -e 's|@STRIP_SHARED[@]|$(STRIP_SHARED)|g' \ + -e 's|@STRIP_STATIC[@]|$(STRIP_STATIC)|g' + man_MANS = dist_man_MANS = $(ASCIIDOC_MANS) repo-remove.8 @@ -93,8 +99,12 @@ A2X_OPTS = \ --xsltproc-opts='-param man.endnotes.list.enabled 0 -param man.endnotes.are.numbered 0' # These rules are due to the includes and files of the asciidoc text -$(ASCIIDOC_MANS): asciidoc.conf footer.txt - a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.txt +$(ASCIIDOC_MANS): asciidoc.conf footer.txt Makefile + @echo GEN $@; + @rm -f $@.tmp + @test -f $(srcdir)/$@.txt && $(edit) $(srcdir)/$@.txt >$@.tmp || true + a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.tmp + @rm -f $@.tmp %.html: %.txt asciidoc $(ASCIIDOC_OPTS) -a linkcss $*.txt diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt index 88c4cbb..359db68 100644 --- a/doc/makepkg.conf.5.txt +++ b/doc/makepkg.conf.5.txt @@ -135,6 +135,18 @@ Options affects both generation and checking. The current valid options are: `md5`, `sha1`, `sha256`, `sha384`, and `sha512`. +**STRIP_BINARIES=**"@STRIP_BINARIES@":: + Options to be used when stripping binaries. See `strip''s man page + for details. + +**STRIP_SHARED=**"@STRIP_SHARED@":: + Options to be used when stripping shared libraries. See `strip''s + man page for details. + +**STRIP_STATIC=**"@STRIP_STATIC@":: + Options to be used when stripping static libraries. See `strip''s + man page for details. + **MAN_DIRS=(**{usr{,/local}{,/share},opt/*}/{man,info} ...**)**:: If `zipman` is specified in the OPTIONS array, this variable will instruct makepkg where to look to compress manual (man and info) diff --git a/etc/Makefile.am b/etc/Makefile.am index 55c28c3..25f1834 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -13,6 +13,9 @@ edit = sed \ -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \ -e 's|@PKGEXT[@]|$(PKGEXT)|g' \ -e 's|@SRCEXT[@]|$(SRCEXT)|g' \ + -e 's|@STRIP_BINARIES[@]|$(STRIP_BINARIES)|g' \ + -e 's|@STRIP_SHARED[@]|$(STRIP_SHARED)|g' \ + -e 's|@STRIP_STATIC[@]|$(STRIP_STATIC)|g' \ -e 's|@CARCH[@]|$(CARCH)|g' \ -e 's|@CHOST[@]|$(CHOST)|g' \ -e 's|@ARCHSWITCH[@]|$(ARCHSWITCH)|g' \ diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in index 3a3a415..032a7fc 100644 --- a/etc/makepkg.conf.in +++ b/etc/makepkg.conf.in @@ -72,6 +72,12 @@ OPTIONS=(strip docs libtool emptydirs zipman purge) #-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512 INTEGRITY_CHECK=(md5) +#-- Options to be used when stripping binaries. See `man strip' for details. +STRIP_BINARIES="@STRIP_BINARIES@" +#-- Options to be used when stripping shared libraries. See `man strip' for details. +STRIP_SHARED="@STRIP_SHARED@" +#-- Options to be used when stripping static libraries. See `man strip' for details. +STRIP_STATIC="@STRIP_STATIC@" #-- Manual (man and info) directories to compress (if zipman is specified) MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info}) #-- Doc directories to remove (if !docs is specified) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index 0688e7c..e2d6cef 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -853,11 +853,11 @@ tidy_install() { *compressed-encoding*) # Skip compressed binaries ;; *application/x-sharedlib*) # Libraries (.so) - /usr/bin/strip -S "$binary";; + /usr/bin/strip $STRIP_SHARED "$binary";; *application/x-archive*) # Libraries (.a) - /usr/bin/strip -S "$binary";; + /usr/bin/strip $STRIP_STATIC "$binary";; *application/x-executable*) # Binaries - /usr/bin/strip "$binary";; + /usr/bin/strip $STRIP_BINARIES "$binary";; esac done fi -- 1.6.5.6
Cedric Staniewski wrote:
The newly added variables STRIP_BINARIES, STRIP_SHARED and STRIP_STATIC, that are set in makepkg.conf, specify the strip options used on binaries and shared and static libraries. In addition, files are now stripped more aggressively by default.
Implements FS#13592 the way it was suggested by Allan in the comments.
Signed-off-by: Cedric Staniewski <cedric@gmx.ca> ---
Awesome. This is exactly how I wanted this implemented. I will give it a full test later. However, what is this change?
diff --git a/doc/Makefile.am b/doc/Makefile.am index fcbcab8..ce1adab 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am ...
@@ -93,8 +99,12 @@ A2X_OPTS = \ --xsltproc-opts='-param man.endnotes.list.enabled 0 -param man.endnotes.are.numbered 0'
# These rules are due to the includes and files of the asciidoc text -$(ASCIIDOC_MANS): asciidoc.conf footer.txt - a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.txt +$(ASCIIDOC_MANS): asciidoc.conf footer.txt Makefile + @echo GEN $@; + @rm -f $@.tmp + @test -f $(srcdir)/$@.txt && $(edit) $(srcdir)/$@.txt >$@.tmp || true + a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.tmp + @rm -f $@.tmp
%.html: %.txt asciidoc $(ASCIIDOC_OPTS) -a linkcss $*.txt
As an aside for anyone testing this out, do not use it on glibc and the install the resulting package as it may have issues with threading... Allan
On 12/14/2009 02:42 AM, Allan McRae wrote:
However, what is this change?
diff --git a/doc/Makefile.am b/doc/Makefile.am index fcbcab8..ce1adab 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am ...
@@ -93,8 +99,12 @@ A2X_OPTS = \ --xsltproc-opts='-param man.endnotes.list.enabled 0 -param man.endnotes.are.numbered 0'
# These rules are due to the includes and files of the asciidoc text -$(ASCIIDOC_MANS): asciidoc.conf footer.txt - a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.txt +$(ASCIIDOC_MANS): asciidoc.conf footer.txt Makefile + @echo GEN $@; + @rm -f $@.tmp + @test -f $(srcdir)/$@.txt && $(edit) $(srcdir)/$@.txt >$@.tmp || true + a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.tmp + @rm -f $@.tmp
%.html: %.txt asciidoc $(ASCIIDOC_OPTS) -a linkcss $*.txt
It is needed to get the correct default values in makepkg.conf man page:
+**STRIP_BINARIES=**"@STRIP_BINARIES@":: [...] +**STRIP_SHARED=**"@STRIP_SHARED@":: [...] +**STRIP_STATIC=**"@STRIP_STATIC@"::
There are no os-dependent values in the documentation yet, so I had to add these lines to be able to replace strings with actual values. It only makes a difference on darwin, though.
Cedric Staniewski wrote:
On 12/14/2009 02:42 AM, Allan McRae wrote:
However, what is this change?
diff --git a/doc/Makefile.am b/doc/Makefile.am index fcbcab8..ce1adab 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am ...
@@ -93,8 +99,12 @@ A2X_OPTS = \ --xsltproc-opts='-param man.endnotes.list.enabled 0 -param man.endnotes.are.numbered 0'
# These rules are due to the includes and files of the asciidoc text -$(ASCIIDOC_MANS): asciidoc.conf footer.txt - a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.txt +$(ASCIIDOC_MANS): asciidoc.conf footer.txt Makefile + @echo GEN $@; + @rm -f $@.tmp + @test -f $(srcdir)/$@.txt && $(edit) $(srcdir)/$@.txt >$@.tmp || true + a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.tmp + @rm -f $@.tmp
%.html: %.txt asciidoc $(ASCIIDOC_OPTS) -a linkcss $*.txt
It is needed to get the correct default values in makepkg.conf man page:
Ah, I missed that completely! Saying that, I have no idea how it does what it does, so I will let Dan review that part... :P Allan
The newly added variables STRIP_BINARIES, STRIP_SHARED and STRIP_STATIC, that are set in makepkg.conf, specify the strip options used on binaries and shared and static libraries. In addition, files are now stripped more aggressively by default. Implements FS#13592 the way it was suggested by Allan in the comments. Signed-off-by: Cedric Staniewski <cedric@gmx.ca> --- There are only two minor changes in this patch compared to the initial one. * removed an unneeded "@rm -f $@.tmp" from the following code section: # These rules are due to the includes and files of the asciidoc text $(ASCIIDOC_MANS): asciidoc.conf footer.txt Makefile @echo GEN $@; @rm -f $@.tmp @test -f $(srcdir)/$@.txt && $(edit) $(srcdir)/$@.txt >$@.tmp || true a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.tmp @rm -f $@.tmp * changed an output message to reflect the new default strip options - msg2 "$(gettext "Stripping debugging symbols from binaries and libraries...")" + msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")" configure.ac | 9 +++++++++ doc/Makefile.am | 13 +++++++++++-- doc/makepkg.conf.5.txt | 12 ++++++++++++ etc/Makefile.am | 3 +++ etc/makepkg.conf.in | 6 ++++++ scripts/makepkg.sh.in | 8 ++++---- 6 files changed, 45 insertions(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 80e41a6..faf774f 100644 --- a/configure.ac +++ b/configure.ac @@ -186,6 +186,9 @@ GCC_GNU89_INLINE_CC # Host-dependant definitions SIZECMD="stat -L -c %s" SEDINPLACE="sed -i" +STRIP_BINARIES="--strip-all" +STRIP_SHARED="--strip-unneeded" +STRIP_STATIC="--strip-debug" case "${host_os}" in *bsd*) SIZECMD="stat -L -f %z" @@ -199,6 +202,9 @@ case "${host_os}" in host_os_darwin=yes SIZECMD="/usr/bin/stat -L -f %z" SEDINPLACE="/usr/bin/sed -i ''" + STRIP_BINARIES="" + STRIP_SHARED="-S" + STRIP_STATIC="-S" ;; esac @@ -206,6 +212,9 @@ AM_CONDITIONAL([CYGWIN], test "x$host_os_cygwin" = "xyes") AM_CONDITIONAL([DARWIN], test "x$host_os_darwin" = "xyes") AC_SUBST(SIZECMD) AC_SUBST(SEDINPLACE) +AC_SUBST(STRIP_BINARIES) +AC_SUBST(STRIP_SHARED) +AC_SUBST(STRIP_STATIC) # Check for architecture, used in default makepkg.conf # (Note single space left after CARCHFLAGS) diff --git a/doc/Makefile.am b/doc/Makefile.am index fcbcab8..d2f6b35 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -66,6 +66,12 @@ else REAL_PACKAGE_VERSION = $(PACKAGE_VERSION) endif +#### Taken from the autoconf scripts Makefile.am #### +edit = sed \ + -e 's|@STRIP_BINARIES[@]|$(STRIP_BINARIES)|g' \ + -e 's|@STRIP_SHARED[@]|$(STRIP_SHARED)|g' \ + -e 's|@STRIP_STATIC[@]|$(STRIP_STATIC)|g' + man_MANS = dist_man_MANS = $(ASCIIDOC_MANS) repo-remove.8 @@ -93,8 +99,11 @@ A2X_OPTS = \ --xsltproc-opts='-param man.endnotes.list.enabled 0 -param man.endnotes.are.numbered 0' # These rules are due to the includes and files of the asciidoc text -$(ASCIIDOC_MANS): asciidoc.conf footer.txt - a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.txt +$(ASCIIDOC_MANS): asciidoc.conf footer.txt Makefile + @echo GEN $@; + @test -f $(srcdir)/$@.txt && $(edit) $(srcdir)/$@.txt >$@.tmp || true + a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.tmp + @rm -f $@.tmp %.html: %.txt asciidoc $(ASCIIDOC_OPTS) -a linkcss $*.txt diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt index 88c4cbb..359db68 100644 --- a/doc/makepkg.conf.5.txt +++ b/doc/makepkg.conf.5.txt @@ -135,6 +135,18 @@ Options affects both generation and checking. The current valid options are: `md5`, `sha1`, `sha256`, `sha384`, and `sha512`. +**STRIP_BINARIES=**"@STRIP_BINARIES@":: + Options to be used when stripping binaries. See `strip''s man page + for details. + +**STRIP_SHARED=**"@STRIP_SHARED@":: + Options to be used when stripping shared libraries. See `strip''s + man page for details. + +**STRIP_STATIC=**"@STRIP_STATIC@":: + Options to be used when stripping static libraries. See `strip''s + man page for details. + **MAN_DIRS=(**{usr{,/local}{,/share},opt/*}/{man,info} ...**)**:: If `zipman` is specified in the OPTIONS array, this variable will instruct makepkg where to look to compress manual (man and info) diff --git a/etc/Makefile.am b/etc/Makefile.am index 55c28c3..25f1834 100644 --- a/etc/Makefile.am +++ b/etc/Makefile.am @@ -13,6 +13,9 @@ edit = sed \ -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \ -e 's|@PKGEXT[@]|$(PKGEXT)|g' \ -e 's|@SRCEXT[@]|$(SRCEXT)|g' \ + -e 's|@STRIP_BINARIES[@]|$(STRIP_BINARIES)|g' \ + -e 's|@STRIP_SHARED[@]|$(STRIP_SHARED)|g' \ + -e 's|@STRIP_STATIC[@]|$(STRIP_STATIC)|g' \ -e 's|@CARCH[@]|$(CARCH)|g' \ -e 's|@CHOST[@]|$(CHOST)|g' \ -e 's|@ARCHSWITCH[@]|$(ARCHSWITCH)|g' \ diff --git a/etc/makepkg.conf.in b/etc/makepkg.conf.in index 3a3a415..032a7fc 100644 --- a/etc/makepkg.conf.in +++ b/etc/makepkg.conf.in @@ -72,6 +72,12 @@ OPTIONS=(strip docs libtool emptydirs zipman purge) #-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512 INTEGRITY_CHECK=(md5) +#-- Options to be used when stripping binaries. See `man strip' for details. +STRIP_BINARIES="@STRIP_BINARIES@" +#-- Options to be used when stripping shared libraries. See `man strip' for details. +STRIP_SHARED="@STRIP_SHARED@" +#-- Options to be used when stripping static libraries. See `man strip' for details. +STRIP_STATIC="@STRIP_STATIC@" #-- Manual (man and info) directories to compress (if zipman is specified) MAN_DIRS=({usr{,/local}{,/share},opt/*}/{man,info}) #-- Doc directories to remove (if !docs is specified) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index cf71070..d5a8b25 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -846,18 +846,18 @@ tidy_install() { fi if [[ $(check_option strip) = y && -n ${STRIP_DIRS[*]} ]]; then - msg2 "$(gettext "Stripping debugging symbols from binaries and libraries...")" + msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")" local binary find ${STRIP_DIRS[@]} -type f 2>/dev/null | while read binary ; do case "$(file -biz "$binary")" in *compressed-encoding*) # Skip compressed binaries ;; *application/x-sharedlib*) # Libraries (.so) - /usr/bin/strip -S "$binary";; + /usr/bin/strip $STRIP_SHARED "$binary";; *application/x-archive*) # Libraries (.a) - /usr/bin/strip -S "$binary";; + /usr/bin/strip $STRIP_STATIC "$binary";; *application/x-executable*) # Binaries - /usr/bin/strip "$binary";; + /usr/bin/strip $STRIP_BINARIES "$binary";; esac done fi -- 1.6.5.7
Cedric Staniewski wrote:
The newly added variables STRIP_BINARIES, STRIP_SHARED and STRIP_STATIC, that are set in makepkg.conf, specify the strip options used on binaries and shared and static libraries. In addition, files are now stripped more aggressively by default.
Implements FS#13592 the way it was suggested by Allan in the comments.
Signed-off-by: Cedric Staniewski <cedric@gmx.ca> ---
There are only two minor changes in this patch compared to the initial one.
* removed an unneeded "@rm -f $@.tmp" from the following code section:
# These rules are due to the includes and files of the asciidoc text $(ASCIIDOC_MANS): asciidoc.conf footer.txt Makefile @echo GEN $@; @rm -f $@.tmp @test -f $(srcdir)/$@.txt && $(edit) $(srcdir)/$@.txt >$@.tmp || true a2x $(A2X_OPTS) --asciidoc-opts="$(ASCIIDOC_OPTS)" $@.tmp @rm -f $@.tmp
* changed an output message to reflect the new default strip options
- msg2 "$(gettext "Stripping debugging symbols from binaries and libraries...")" + msg2 "$(gettext "Stripping unneeded symbols from binaries and libraries...")"
<snip> Updated on my working branch. We need to remember that message when release time comes or else it will likely be missed in translation updates. Allan
participants (2)
-
Allan McRae
-
Cedric Staniewski