[pacman-dev] [PATCH] makepkg: only remove static libraries if they have a shared version
It is fairly common that packages contain static libraries with no shared counterpart. These should not be removed with !staticlibs. Signed-off-by: Allan McRae <allan@archlinux.org> --- doc/PKGBUILD.5.txt | 2 +- doc/makepkg.conf.5.txt | 2 +- scripts/makepkg.sh.in | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index 4ac7dc1..6c5ef84 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -250,7 +250,7 @@ A normal sync or upgrade will not use its value. *staticlibs*;; Leave static library (.a) files in packages. Specify `!staticlibs` to - remove them. + remove them (if they have a shared counterpart). *emptydirs*;; Leave empty directories in packages. diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt index be5b809..ef64d17 100644 --- a/doc/makepkg.conf.5.txt +++ b/doc/makepkg.conf.5.txt @@ -162,7 +162,7 @@ Options *staticlibs*;; Leave static library (.a) files in packages. Specify `!staticlibs` to - remove them. + remove them (if they have a shared counterpart). *emptydirs*;; Leave empty directories in packages. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index b2cc8e2..67bd7f1 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1584,7 +1584,13 @@ tidy_install() { if check_option "staticlibs" "n"; then msg2 "$(gettext "Removing static library files...")" - find . ! -type d -name "*.a" -exec rm -f -- '{}' + + local sl=($(find . ! -type d -name "*.a")) + local l + for l in "${sl[@]}"; do + if [[ -f "${l%.a}.so" ]]; then + rm -f "$l" + fi + done fi if check_option "emptydirs" "n"; then -- 1.8.4.2
On Thu, Oct 31, 2013 at 11:25:36PM +1000, Allan McRae wrote:
It is fairly common that packages contain static libraries with no shared counterpart. These should not be removed with !staticlibs.
Signed-off-by: Allan McRae <allan@archlinux.org> --- doc/PKGBUILD.5.txt | 2 +- doc/makepkg.conf.5.txt | 2 +- scripts/makepkg.sh.in | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index 4ac7dc1..6c5ef84 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -250,7 +250,7 @@ A normal sync or upgrade will not use its value.
*staticlibs*;; Leave static library (.a) files in packages. Specify `!staticlibs` to - remove them. + remove them (if they have a shared counterpart).
*emptydirs*;; Leave empty directories in packages. diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt index be5b809..ef64d17 100644 --- a/doc/makepkg.conf.5.txt +++ b/doc/makepkg.conf.5.txt @@ -162,7 +162,7 @@ Options
*staticlibs*;; Leave static library (.a) files in packages. Specify `!staticlibs` to - remove them. + remove them (if they have a shared counterpart).
*emptydirs*;; Leave empty directories in packages. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index b2cc8e2..67bd7f1 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1584,7 +1584,13 @@ tidy_install() {
if check_option "staticlibs" "n"; then msg2 "$(gettext "Removing static library files...")" - find . ! -type d -name "*.a" -exec rm -f -- '{}' + + local sl=($(find . ! -type d -name "*.a"))
Prone to rampant word splitting and glob expansion.
+ local l + for l in "${sl[@]}"; do
-for ... +while read -rd '' l; do
+ if [[ -f "${l%.a}.so" ]]; then + rm -f "$l"
Maybe we shouldn't use -f here, since we would probably care about deletion failures?
+ fi + done
-done +done < <(find . ! -type d -name "*.a" -print0)
fi
if check_option "emptydirs" "n"; then -- 1.8.4.2
On 31/10/13 23:38, Dave Reisner wrote:
On Thu, Oct 31, 2013 at 11:25:36PM +1000, Allan McRae wrote:
It is fairly common that packages contain static libraries with no shared counterpart. These should not be removed with !staticlibs.
Signed-off-by: Allan McRae <allan@archlinux.org> --- doc/PKGBUILD.5.txt | 2 +- doc/makepkg.conf.5.txt | 2 +- scripts/makepkg.sh.in | 8 +++++++- 3 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index 4ac7dc1..6c5ef84 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -250,7 +250,7 @@ A normal sync or upgrade will not use its value.
*staticlibs*;; Leave static library (.a) files in packages. Specify `!staticlibs` to - remove them. + remove them (if they have a shared counterpart).
*emptydirs*;; Leave empty directories in packages. diff --git a/doc/makepkg.conf.5.txt b/doc/makepkg.conf.5.txt index be5b809..ef64d17 100644 --- a/doc/makepkg.conf.5.txt +++ b/doc/makepkg.conf.5.txt @@ -162,7 +162,7 @@ Options
*staticlibs*;; Leave static library (.a) files in packages. Specify `!staticlibs` to - remove them. + remove them (if they have a shared counterpart).
*emptydirs*;; Leave empty directories in packages. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index b2cc8e2..67bd7f1 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1584,7 +1584,13 @@ tidy_install() {
if check_option "staticlibs" "n"; then msg2 "$(gettext "Removing static library files...")" - find . ! -type d -name "*.a" -exec rm -f -- '{}' + + local sl=($(find . ! -type d -name "*.a"))
Prone to rampant word splitting and glob expansion.
+ local l + for l in "${sl[@]}"; do
-for ... +while read -rd '' l; do
+ if [[ -f "${l%.a}.so" ]]; then + rm -f "$l"
Maybe we shouldn't use -f here, since we would probably care about deletion failures?
Agreed. I have pushed the updated version to my working branch.
+ fi + done
-done +done < <(find . ! -type d -name "*.a" -print0)
fi
if check_option "emptydirs" "n"; then -- 1.8.4.2
On 31/10/2013 14:25, Allan McRae wrote:
It is fairly common that packages contain static libraries with no shared counterpart. These should not be removed with !staticlibs.
Why not let packagers do their job and add staticlibs. Using "!staticlibs" will no more ensure that static libs are cleaned. This make usage of this option less simple and clear than before. -- Sébastien "Seblu" Luttringer https://www.seblu.net GPG: 0x2072D77A
On 01/11/13 01:40, Sébastien Luttringer wrote:
On 31/10/2013 14:25, Allan McRae wrote:
It is fairly common that packages contain static libraries with no shared counterpart. These should not be removed with !staticlibs.
Why not let packagers do their job and add staticlibs. Using "!staticlibs" will no more ensure that static libs are cleaned. This make usage of this option less simple and clear than before.
I have struck many packages where we have to use options=('staticlibs') and then manually remove a bunch of static libraries because one needs to be kept. I see this as making packaging more simple, because I no longer need to check whether to apply !staticlibs to a package - it will just do the right thing. A
participants (3)
-
Allan McRae
-
Dave Reisner
-
Sébastien Luttringer