cookutils rev 1020

cook: handle rsum more stable, fix working with sets when copy() isn't used; modules/compressor: find executables and libs beyond [/usr]?/[s]?bin/; modules/deps: don't process *.la files by default; doc/receipts-v2.md: add chapter 'Dependency tracking'.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Dec 23 15:03:39 2017 +0200 (2017-12-23)
parents f92f75dce828
children ee2f3d4790a4
files cook doc/receipts-v2.md modules/compressor modules/deps
line diff
     1.1 --- a/cook	Thu Dec 07 14:31:28 2017 +0200
     1.2 +++ b/cook	Sat Dec 23 15:03:39 2017 +0200
     1.3 @@ -881,6 +881,16 @@
     1.4  
     1.5  	title 'Pack: %s' "$PACKAGE $VERSION$arch"
     1.6  
     1.7 +	# Get set name for specified package from $SPLIT variable
     1.8 +	local set=$(echo $SPLIT \
     1.9 +				| awk -vpkg="$PACKAGE" '
    1.10 +					BEGIN { RS = " "; FS = ":"; }
    1.11 +					{ if ($1 == pkg && $2) { print "-" $2; exit; } }')
    1.12 +	# Change set, make filelist and folderlist for new set
    1.13 +	export     src="$WOK/$pkg/source/$PACKAGE-$VERSION$set"
    1.14 +	export install="$WOK/$pkg/install$set"
    1.15 +	export DESTDIR="$install"
    1.16 +
    1.17  	if grep -q ^genpkg_rules $receipt; then
    1.18  		_ 'Executing: %s' 'genpkg_rules'
    1.19  		set -e; cd $pkgdir; mkdir -p $fs
    1.20 @@ -991,44 +1001,17 @@
    1.21  	tazpkg=$(ls *.tazpkg)
    1.22  	packit_quality
    1.23  	footer "$(_ 'Package "%s" created' "$tazpkg")"
    1.24 -	update_packages_db
    1.25 -}
    1.26 -
    1.27 -
    1.28 -# Calculate release checksum: usually it does not change on "just recook".
    1.29 -# Release checksum is md5sum of file containing md5sums of:
    1.30 -# a) all files, b) receipt, and c) description.txt.
    1.31 -# Md5sum of the package file will change every time because of embedded timestamps;
    1.32 -# release checksum based only on files content, and will change only when files change.
    1.33 -# (Pitfall: ownership and permissions...)
    1.34 -
    1.35 -release_checksum() {
    1.36 -	local pack=$1
    1.37 -	local rsum_file=$(mktemp)
    1.38 -
    1.39 -	cp $pack/md5sum $rsum_file
    1.40 -	md5sum $pack/receipt | sed 's| [^ ]*/| |' >> $rsum_file
    1.41 -	[ -e "$pack/description.txt" ] &&
    1.42 -		md5sum $pack/description.txt | sed 's| [^ ]*/| |' >> $rsum_file
    1.43 -
    1.44 -	local rsum=$(md5sum $rsum_file | awk '{print $1}')
    1.45 -	rm $rsum_file
    1.46 -	local rsumold=$(awk -F$'\t' -vpkg="$PACKAGE" '
    1.47 -		{if ($1 == pkg) { print $9; exit; }}' $PKGS/packages.info)
    1.48 -
    1.49 -	[ "$rsum" == "$rsumold" ] && rsum=''
    1.50 -
    1.51 -	echo $rsum
    1.52  }
    1.53  
    1.54  
    1.55  # Verify package quality and consistency.
    1.56  
    1.57  packit_quality() {
    1.58 -	#action 'QA: checking for broken link...'
    1.59 -	#link=$(find $fs/usr -type l -follow)
    1.60 -	#[ "$link" ] && echo -e "\nERROR: broken link in filesystem"
    1.61 -	#status
    1.62 +	local rsum rsumold='' rsum_changed old_file
    1.63 +	local pi="$PKGS/packages.info" fl="$cache/files.list"
    1.64 +	local pkg_file="$PKGS/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg"
    1.65 +	local rsum_file=$(mktemp) rsum_file_old=$(mktemp) tmpdir=$(mktemp -d)
    1.66 +
    1.67  
    1.68  	if [ "${COOKOPTS/skip-log-errors/}" == "$COOKOPTS" ]; then
    1.69  		# Exit if any error found in log file.
    1.70 @@ -1038,6 +1021,7 @@
    1.71  		fi
    1.72  	fi
    1.73  
    1.74 +
    1.75  	[ -n "$CAT" ] && CATEGORY="${CAT%|*}"	# allow meta-packages in v2 receipts
    1.76  
    1.77  	if [ "${COOKOPTS/empty-pkg/}" == "$COOKOPTS" ]; then
    1.78 @@ -1052,27 +1036,80 @@
    1.79  	fi
    1.80  
    1.81  
    1.82 -	# Find and remove old package(s) only if "release checksum" has changed
    1.83 -	rsum=$(release_checksum $pack)
    1.84 -	if [ -n "$rsum" ]; then
    1.85 +	# Calculate release checksum: usually it does not change on "just recook".
    1.86 +	# Release checksum is md5sum of file containing md5sums of:
    1.87 +	# a) all files, b) receipt, and c) description.txt.
    1.88 +	# Md5sum of the package file will change every time because of embedded timestamps;
    1.89 +	# release checksum based only on files content, and will change only when files change.
    1.90 +	# (Pitfall: ownership and permissions...)
    1.91 +
    1.92 +	# Calculate rsum for new package
    1.93 +	cp $pack/md5sum $rsum_file
    1.94 +	md5sum $pack/receipt | sed 's| [^ ]*/| |' >> $rsum_file
    1.95 +	[ -e "$pack/description.txt" ] &&
    1.96 +		md5sum $pack/description.txt | sed 's| [^ ]*/| |' >> $rsum_file
    1.97 +	rsum=$(md5sum $rsum_file | awk '{print $1}')
    1.98 +
    1.99 +	# Calculate rsum for existing previous "old" package
   1.100 +	if [ -f "$pkg_file" ]; then
   1.101 +		# don't trust database entry, check the package file
   1.102 +		cd $tmpdir
   1.103 +		cpio -F "$pkg_file" -i md5sum receipt description.txt >/dev/null 2>&1
   1.104 +		cp ./md5sum $rsum_file_old
   1.105 +		md5sum ./receipt | sed 's| [^ ]*/| |' >> $rsum_file_old
   1.106 +		[ -e "./description.txt" ] &&
   1.107 +			md5sum ./description.txt | sed 's| [^ ]*/| |' >> $rsum_file_old
   1.108 +		rsumold=$(md5sum $rsum_file_old | awk '{print $1}')
   1.109 +		cd - >/dev/null
   1.110 +	fi
   1.111 +
   1.112 +	# Clean
   1.113 +	rm $rsum_file $rsum_file_old
   1.114 +	rm -r $tmpdir
   1.115 +
   1.116 +
   1.117 +	touch $pi $broken
   1.118 +
   1.119 +
   1.120 +	# Find and remove old package only if "release checksum" has changed
   1.121 +
   1.122 +	if [ "$rsum" != "$rsumold" ]; then
   1.123  		old_file=$(awk -F$'\t' -vname="$PACKAGE" '{
   1.124  			if ($1 == name) printf("%s-%s.tazpkg", $1, $2);
   1.125 -			}' $PKGS/packages.info)
   1.126 +			}' $pi)		# <name>-<version><extra_version>.tazpkg
   1.127  		if [ -f "$PKGS/$old_file" ]; then
   1.128  			action 'Removing old package "%s"' "$old_file"
   1.129  			rm -f "$PKGS/$old_file"
   1.130  			status
   1.131  		fi
   1.132 -		# package changed, substitute old package by new
   1.133 +		# package changed, substitute old package by new one
   1.134  		mv -f $pkgdir/taz/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg $PKGS
   1.135 +		_ 'The release checksum has changed.'
   1.136  	else
   1.137  		# package not changed, remove new package
   1.138  		rm -f $pkgdir/taz/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
   1.139 +		_ 'The release checksum has not changed.'
   1.140  	fi
   1.141  
   1.142 +
   1.143  	sed -i "/^${pkg}$/d" $broken
   1.144 -	#action 'Removing source tree...'
   1.145 -	#rm -f $WOK/$pkg/source; status
   1.146 +
   1.147 +
   1.148 +	# Update packages database every time after successful build
   1.149 +
   1.150 +	# packages.info (unsorted, located near to packages)
   1.151 +	unset_receipt; . $pack/receipt
   1.152 +	SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
   1.153 +	DEPENDS=$(echo $DEPENDS) # remove newlines, tabs and multiple spaces from variable
   1.154 +	sed -i "/^$PACKAGE\t/d" $pi		# remove old entry
   1.155 +	cat >> $pi <<EOT
   1.156 +$PACKAGE	$VERSION$EXTRAVERSION	$CATEGORY	$SHORT_DESC	$WEB_SITE	$TAGS	$SIZES	$DEPENDS	$rsum	$PROVIDE
   1.157 +EOT
   1.158 +
   1.159 +	# files.list (uncompressed, unsorted, located in $cache)
   1.160 +	touch $fl
   1.161 +	sed -i "/^$PACKAGE: /d" $fl
   1.162 +	sed  "s/^/$PACKAGE: \0/" $pack/files.list >> $fl
   1.163  }
   1.164  
   1.165  
   1.166 @@ -1394,15 +1431,6 @@
   1.167  	action 'Copying folders and files...'
   1.168  	local i j k filelist=$(mktemp) folderlist=$(mktemp)
   1.169  
   1.170 -	# Get set name for specified package from $SPLIT variable
   1.171 -	local set=$(echo $SPLIT \
   1.172 -				| awk -vpkg="$PACKAGE" '
   1.173 -					BEGIN { RS = " "; FS = ":"; }
   1.174 -					{ if ($1 == pkg && $2) { print "-" $2; exit; } }')
   1.175 -	# Change set, make filelist and folderlist for new set
   1.176 -	export     src="$WOK/$pkg/source/$PACKAGE-$VERSION$set"
   1.177 -	export install="$WOK/$pkg/install$set"
   1.178 -	export DESTDIR="$install"
   1.179  	IFS=$'\n'
   1.180  	cd $install
   1.181  	find ! -type d | sed 's|\.||' > $filelist
   1.182 @@ -1492,36 +1520,6 @@
   1.183  }
   1.184  
   1.185  
   1.186 -# Update packages database every time after successful build
   1.187 -
   1.188 -update_packages_db() {
   1.189 -	# packages.info (unsorted, located near to packages)
   1.190 -	local pi="$PKGS/packages.info"
   1.191 -	unset_receipt; . $pack/receipt
   1.192 -	SIZES=$(echo $PACKED_SIZE $UNPACKED_SIZE | sed 's|\.0||g')
   1.193 -
   1.194 -	DEPENDS=$(echo $DEPENDS) # remove newlines, tabs and multiple spaces from variable
   1.195 -
   1.196 -	rsum=$(release_checksum $pack)
   1.197 -	if [ -n "$rsum" ]; then
   1.198 -		_ 'The release checksum has changed.\n'
   1.199 -
   1.200 -		sed -i "/^$PACKAGE\t/d" $pi		# remove old entry
   1.201 -		cat >> $pi <<EOT
   1.202 -$PACKAGE	$VERSION$EXTRAVERSION	$CATEGORY	$SHORT_DESC	$WEB_SITE	$TAGS	$SIZES	$DEPENDS	$rsum	$PROVIDE
   1.203 -EOT
   1.204 -
   1.205 -		# files.list (uncompressed, unsorted, located in $cache)
   1.206 -		local fl="$cache/files.list"
   1.207 -		touch $fl
   1.208 -		sed -i "/^$PACKAGE: /d" $fl
   1.209 -		sed  "s/^/$PACKAGE: \0/" $pack/files.list >> $fl
   1.210 -	else
   1.211 -		_ 'The release checksum has not changed.\n'
   1.212 -	fi
   1.213 -}
   1.214 -
   1.215 -
   1.216  # Update split.db once for receipt
   1.217  
   1.218  update_split_db() {
     2.1 --- a/doc/receipts-v2.md	Thu Dec 07 14:31:28 2017 +0200
     2.2 +++ b/doc/receipts-v2.md	Sat Dec 23 15:03:39 2017 +0200
     2.3 @@ -343,3 +343,167 @@
     2.4  Thirdly, make `genpkg_rules()` as usual. *Cook* will switch to the required
     2.5  set automatically based on conformity between packages and sets that you
     2.6  described in the `$SPLIT` variable on the first step. That's all.
     2.7 +
     2.8 +
     2.9 +Dependency tracking
    2.10 +-------------------
    2.11 +
    2.12 +Many packages use `libtool`, created during the `configure` processing.
    2.13 +This `libtool` contains one old and well-known (in narrow circles) “feature”
    2.14 +that is expressed in the fact that unnecessary dependencies are added to
    2.15 +libraries and executable files. Read about it:
    2.16 +
    2.17 +  * [Bug 655517 - using --as-needed in LDFLAGS is not respected and it links
    2.18 +    on unneeded libs](https://bugzilla.gnome.org/show_bug.cgi?id=655517)
    2.19 +  * [Project:Quality Assurance/As-needed](https://wiki.gentoo.org/wiki/Project:Quality_Assurance/As-needed)
    2.20 +
    2.21 +Links above recommend to add `-Wl,--as-needed` to the LDFLAGS variable. You can
    2.22 +use short statement `fix ld` in the beginning (to add `-Wl,--as-needed` to the
    2.23 +LDFLAGS) and `fix libtool` just after the `configure` invocation (to
    2.24 +additionally fix just created `libtool`). Example of using:
    2.25 +
    2.26 +```bash
    2.27 +compile_rules() {
    2.28 +    fix ld
    2.29 +    ./configure \
    2.30 +        --sysconfdir=/etc \
    2.31 +        $CONFIGURE_ARGS &&
    2.32 +    fix libtool &&
    2.33 +    make && make install
    2.34 +}
    2.35 +```
    2.36 +
    2.37 +You should not use `fix libtool` if you not see file named `libtool` in the root
    2.38 +of the sources tree after the `configure` done. It will not lead to an error,
    2.39 +although there will be no sense in it.
    2.40 +
    2.41 +You can check dependencies of separate files using one of the next methods:
    2.42 +
    2.43 +```bash
    2.44 +ldd /path/to/file
    2.45 +
    2.46 +readelf -d /path/to/file | grep NEEDED
    2.47 +```
    2.48 +
    2.49 +You can check dependencies of entire package using the command:
    2.50 +
    2.51 +```bash
    2.52 +cook package_name --deps
    2.53 +```
    2.54 +
    2.55 +You can note a significant decrease in the number of dependencies. For example:
    2.56 +
    2.57 +  * for **fontconfig**:
    2.58 +    * before: bzlib freetype liblzma libpng16 libxml2 zlib
    2.59 +    * after: freetype libxml2
    2.60 +  * for **at-spi2-core**:
    2.61 +    * before: dbus glib libffi pcre util-linux-blkid util-linux-mount
    2.62 +      util-linux-uuid xorg-libICE xorg-libSM xorg-libX11 xorg-libXau
    2.63 +      xorg-libXdmcp xorg-libXext xorg-libXi xorg-libXtst xorg-libxcb zlib
    2.64 +    * after: dbus glib xorg-libX11 xorg-libXtst
    2.65 +
    2.66 +For some packages nothing will change.
    2.67 +
    2.68 +
    2.69 +### Dependency tracking for development packages
    2.70 +
    2.71 +This is a separate and complex issue.
    2.72 +
    2.73 +Dependency info may be extracted from `.pc`, `.la` and `.h` files. Extracting
    2.74 +dependencies from the header files (`.h`) is non-trivial task due to conditional
    2.75 +branching and can not be realized using simple tools.
    2.76 +
    2.77 +As for `.la` files — Gentoo
    2.78 +[recommend](https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Handling_Libtool_Archives)
    2.79 +to remove them in most cases. As they stated, `.la` files may be useful only
    2.80 +for static libraries (`.a` files). Currently, dependency tracking tool doesn't
    2.81 +use `.la` files unless you provide special argument `--la`:
    2.82 +
    2.83 +```bash
    2.84 +cook fontconfig --deps --la
    2.85 +```
    2.86 +
    2.87 +It turns that `.pc` files are the only development files that describe
    2.88 +dependencies of development packages. Usually `configure` script checks
    2.89 +dependencies using something like this:
    2.90 +
    2.91 +```bash
    2.92 +pkg-config --exists --print-errors "gtk-doc >= 1.15"
    2.93 +pkg-config --exists --print-errors "xrender >= 0.6"
    2.94 +```
    2.95 +
    2.96 +Dependency tracking tools tries to find the package that contains required
    2.97 +libraries, then to determine `*-dev` package that corresponds to found package.
    2.98 +
    2.99 +For example, file `/usr/lib/pkgconfig/cairo.pc` contains the line:
   2.100 +
   2.101 +```
   2.102 +Requires.private:   gobject-2.0   glib-2.0 >= 2.14   pixman-1 >= 0.30.0
   2.103 +    fontconfig >= 2.2.95   freetype2 >= 9.7.3   libpng    xcb-shm    x11-xcb
   2.104 +    xcb >= 1.6   xcb-render >= 1.6   xrender >= 0.6   x11   xext
   2.105 +```
   2.106 +
   2.107 +Finding next files shows the dependencies:
   2.108 +
   2.109 +```
   2.110 +gobject-2.0.pc   glib-2.0.pc   pixman-1.pc   fontconfig.pc   freetype2.pc
   2.111 +    libpng.pc   xcb-shm.pc   x11-xcb.pc   xcb.pc   xcb-render.pc   xrender.pc
   2.112 +    x11.pc   xext.pc
   2.113 +```
   2.114 +
   2.115 +Next example using file `/usr/lib/pkgconfig/apr-1.pc`:
   2.116 +
   2.117 +```
   2.118 +prefix=/usr
   2.119 +exec_prefix=${prefix}
   2.120 +libdir=${exec_prefix}/lib
   2.121 +APR_MAJOR_VERSION=1
   2.122 +
   2.123 +Libs: -L${libdir} -lapr-${APR_MAJOR_VERSION} -luuid -lrt -lcrypt  -lpthread -ldl
   2.124 +```
   2.125 +
   2.126 +Finding next files shows the runtime dependencies and then full dependencies;
   2.127 +`*-dev` packages are the full packages.
   2.128 +
   2.129 +```
   2.130 +libapr-1.so    libuuid.so      librt.so   libcrypt.so   libpthread.so   libdl.so
   2.131 +     |             |               |           |              |            |    
   2.132 +     v             v               v           v              v            v    
   2.133 +    apr     util-linux-uuid   glibc-base  glibc-base     glibc-base   glibc-base
   2.134 +     |             |               |           |              |            |    
   2.135 +     v             v               v           v              v            v
   2.136 +  apr-dev  util-linux-uuid-dev glibc-dev   glibc-dev      glibc-dev    glibc-dev
   2.137 +
   2.138 +```
   2.139 +
   2.140 +Note, sometimes required files may be found in the two or many packages, for
   2.141 +example, `libdl.so` exists therein packages:
   2.142 +
   2.143 +  * `glibc-base`
   2.144 +  * `uclibc-armv4eb`
   2.145 +  * `uclibc-armv4l`
   2.146 +  * `uclibc-armv4tl`
   2.147 +  * `uclibc-armv5l`
   2.148 +  * `uclibc-armv6l`
   2.149 +  * `uclibc-cross-compiler-armv4eb`
   2.150 +  * `uclibc-cross-compiler-armv4l`
   2.151 +  * `uclibc-cross-compiler-armv4tl`
   2.152 +  * `uclibc-cross-compiler-armv5l`
   2.153 +  * `uclibc-cross-compiler-armv6l`
   2.154 +  * `uclibc-cross-compiler-i486`
   2.155 +  * `uclibc-cross-compiler-mips`
   2.156 +  * `uclibc-cross-compiler-mips64`
   2.157 +  * `uclibc-cross-compiler-mipsel`
   2.158 +  * `uclibc-cross-compiler-powerpc`
   2.159 +  * `uclibc-cross-compiler-sh4`
   2.160 +  * `uclibc-cross-compiler-sparc`
   2.161 +  * `uclibc-cross-compiler-x86_64`
   2.162 +  * `uclibc-i486`
   2.163 +  * `uclibc-mips`
   2.164 +  * `uclibc-mips64`
   2.165 +  * `uclibc-mipsel`
   2.166 +  * `uclibc-powerpc`
   2.167 +  * `uclibc-sh4`
   2.168 +  * `uclibc-sparc`
   2.169 +  * `uclibc-x86_64`
   2.170 +
     3.1 --- a/modules/compressor	Thu Dec 07 14:31:28 2017 +0200
     3.2 +++ b/modules/compressor	Sat Dec 23 15:03:39 2017 +0200
     3.3 @@ -77,9 +77,31 @@
     3.4  }
     3.5  
     3.6  
     3.7 +# Find ELF files
     3.8 +
     3.9 +find_elf() {
    3.10 +	local i ifs="$IFS"
    3.11 +	IFS=$'\n'
    3.12 +	find $fs -type f \
    3.13 +	| while read i; do
    3.14 +		# output of `readelf -h <file> is human-readable information,
    3.15 +		# we interested in the next line:
    3.16 +		#  Type:                              EXEC (Executable file)
    3.17 +		# or
    3.18 +		#  Type:                              DYN (Shared object file)
    3.19 +		if [ "$(readelf -h "$i" 2>/dev/null \
    3.20 +			| sed -n '/Type:/ s|.*: *\([^ ]*\) .*|\1|p')" == "$1" ]; then
    3.21 +			echo "$i"		# $1 = { EXEC | DYN }
    3.22 +		fi
    3.23 +	done
    3.24 +	IFS="$ifs"
    3.25 +}
    3.26 +
    3.27 +
    3.28  # Calculating different sizes
    3.29  
    3.30  sizes() {
    3.31 +	local ifs="$IFS"; IFS=$'\n'
    3.32  	case $1 in
    3.33  		man) find $install/usr/share/man          -type f                                       -exec ls -l \{\} \; ;;
    3.34  		png) find $install                        -type f -name '*.png'                         -exec ls -l \{\} \; ;;
    3.35 @@ -91,9 +113,17 @@
    3.36  		mo2) find $fs/usr/share/locale            -type f -name '*.mo'                          -exec ls -l \{\} \; ;;
    3.37  		gz)  find $install                        -type f -name '*.gz' ! -path '*/share/man/*'  -exec ls -l \{\} \; ;;
    3.38  		zip) find $install                        -type f -name '*.zip'                         -exec ls -l \{\} \; ;;
    3.39 -		str) find $fs -type f \( -name '*.so*' -o -name '*.a' -o -name '*.pyc' -o -name '*.pyo' \
    3.40 -				-o -name '.packlist' -o -name '*.pm' -o -name '*.pl' -o -name '*.pod' \) -exec ls -l \{\} \; ;;
    3.41 +		strip)
    3.42 +			{
    3.43 +				find_elf EXEC
    3.44 +				find_elf DYN
    3.45 +				find $fs -type f \( -name '*.a' -o -name '*.pyc' -o -name '*.pyo' \
    3.46 +				-o -name '.packlist' -o -name '*.pm' -o -name '*.pl' -o -name '*.pod' \)
    3.47 +			} \
    3.48 +			| xargs ls -l
    3.49 +			;;
    3.50  	esac | awk '{s+=$5}END{print s}'
    3.51 +	IFS="$ifs"
    3.52  }
    3.53  
    3.54  
    3.55 @@ -606,6 +636,9 @@
    3.56  strip_package() {
    3.57  	[ "${COOKOPTS/!strip/}" != "$COOKOPTS" ] && return
    3.58  
    3.59 +	local i ifs="$IFS"
    3.60 +	IFS=$'\n'
    3.61 +
    3.62  	case "$ARCH" in
    3.63  		arm*|x86_64) export STRIP="$HOST_SYSTEM-strip" ;;
    3.64  		*)           export STRIP='strip' ;;
    3.65 @@ -614,22 +647,17 @@
    3.66  	size0=0
    3.67  	size1=0
    3.68  	time0=$(get_time)
    3.69 +	oldsize=$(sizes strip)
    3.70  
    3.71 -	# Strip executable files
    3.72 -	for dir in $fs/bin $fs/sbin $fs/usr/bin $fs/usr/sbin $fs/usr/games; do
    3.73 -		if [ -d "$dir" ]; then
    3.74 -			oldsize=$(find $dir -type f -exec ls -l '{}' \; | awk '{s+=$5}END{print s}')
    3.75 -			find $dir -type f -exec $STRIP -s '{}' 2>/dev/null \;
    3.76 -			newsize=$(find $dir -type f -exec ls -l '{}' \; | awk '{s+=$5}END{print s}')
    3.77 -			size0=$((size0 + oldsize)); size1=$((size1 + newsize))
    3.78 -		fi
    3.79 -	done
    3.80 +	# Strip executable files & shared libraries
    3.81 +	while read i; do
    3.82 +		$STRIP -s "$i" 2>/dev/null
    3.83 +	done <<EOT
    3.84 +$(find_elf EXEC; find_elf DYN)
    3.85 +EOT
    3.86  
    3.87 -	oldsize=$(sizes str)
    3.88 -
    3.89 -	# Strip shared and static libraries
    3.90 -	find $fs -name '*.so*' -exec $STRIP -s '{}' 2>/dev/null \;
    3.91 -	find $fs -name '*.a'   -exec $STRIP -d '{}' 2>/dev/null \;
    3.92 +	# Strip static libraries
    3.93 +	find $fs -name '*.a' -exec $STRIP -d '{}' 2>/dev/null \;
    3.94  
    3.95  	# Nullify timestamps of files in ar archives
    3.96  	# Skip empty 8-byte archives (hi, musl-libc package)
    3.97 @@ -655,13 +683,14 @@
    3.98  	echo "$perlfiles" | xargs rm -f 2>/dev/null
    3.99  	echo "$perlfiles" | awk 'BEGIN{FS=OFS="/"}{$NF="";print}' | xargs rmdir -p 2>/dev/null
   3.100  
   3.101 -	# Strip Perl files (*.pm and *.pl) from documentation inside (if not disabled)
   3.102 +	# Strip documentation inside Perl files (*.pm and *.pl) (if not disabled)
   3.103  	[ "${COOKOPTS/!perlz/}" == "$COOKOPTS" ] &&
   3.104  		find $fs -type f \( -name '*.pm' -o -name '*.pl' \) -exec sed -i '/^=/,/^=cut/d' '{}' \;
   3.105  
   3.106 -	newsize=$(sizes str)
   3.107 +	newsize=$(sizes strip)
   3.108  
   3.109 -	comp_summary "$time0" "$((size0 + oldsize))" "$((size1 + newsize))"
   3.110 +	comp_summary "$time0" "$oldsize" "$newsize"
   3.111 +	IFS="$ifs"
   3.112  }
   3.113  
   3.114  
     4.1 --- a/modules/deps	Thu Dec 07 14:31:28 2017 +0200
     4.2 +++ b/modules/deps	Sat Dec 23 15:03:39 2017 +0200
     4.3 @@ -166,6 +166,7 @@
     4.4  				s("xorg-xcb-util-image-dev",  "xcb-util-image-dev");
     4.5  				s("xorg-xcb-util-renderutil-dev", "xcb-util-renderutil-dev");
     4.6  				s("eudev-dev", "udev-dev");
     4.7 +				s("util-linux-uuid",     "ossp-uuid");
     4.8  				s("util-linux-uuid-dev", "ossp-uuid-dev");
     4.9  				s("polkit-pam-dev", "polkit-dev");
    4.10  				s("nspr", "palemoon"); # I doubt app may depend on Palemoon
    4.11 @@ -186,7 +187,7 @@
    4.12  					$0 != "gcc")
    4.13  						print gensub(" ", "|", "g");
    4.14  			}';;
    4.15 -	esac >>$tmptmp
    4.16 +	esac
    4.17  }
    4.18  
    4.19  
    4.20 @@ -206,8 +207,9 @@
    4.21  					printf("[%s]\n", i);
    4.22  			}
    4.23  		}
    4.24 -	' $2 | tr '\n' ' ')"
    4.25 -	outpkg "${res% }"
    4.26 +	' $2 | tr '\n' ' ' | sed 's| $||')"
    4.27 +
    4.28 +	outpkg "$res"
    4.29  }
    4.30  
    4.31  
    4.32 @@ -215,22 +217,29 @@
    4.33  # Also can process some development files
    4.34  
    4.35  tp_ldd() {
    4.36 +	local tmptmp libs variables pcs pkg pkgs out
    4.37  	unset IFS
    4.38  	tmptmp=$(mktemp)
    4.39  
    4.40  	case $1 in
    4.41  		*.la)
    4.42 -			# found dependencies in the *.la files
    4.43 -			libs=$(. $1; echo $dependency_libs)
    4.44 -			for i in $libs; do
    4.45 -				case $i in
    4.46 -					-l*)  indb "lib${i#-l}.so" $db_so;; # FIXME: I'm not sure it's about a *.so, but *.a often absent
    4.47 -					*.la) indb "$i" $db_la;;
    4.48 -				esac
    4.49 -			done
    4.50 +			if [ -n "$la" ]; then								# use with --la
    4.51 +				# found dependencies in the *.la files
    4.52 +				libs=$(. $1; echo $dependency_libs)
    4.53 +				for i in $libs; do
    4.54 +					case $i in
    4.55 +						-l*)  indb "${i/-l/lib}.so" $db_so >>$tmptmp;; # FIXME: I'm not sure it's about a *.so, but *.a often absent
    4.56 +						*.la) indb "$i" $db_la >>$tmptmp;;
    4.57 +					esac
    4.58 +				done
    4.59 +			fi
    4.60  			;;
    4.61  		*.pc)
    4.62  			# found dependencies in the *.pc files
    4.63 +			variables=$(mktemp)
    4.64 +			grep '^[a-zA-Z_][a-zA-Z_]*=' $1 > $variables
    4.65 +			. $variables
    4.66 +			rm $variables
    4.67  			# Syntax examples:
    4.68  			# Requires: glib-2.0 gobject-2.0
    4.69  			# Requires.private: gmodule-no-export-2.0
    4.70 @@ -241,7 +250,7 @@
    4.71  				isitlib=$(echo $i | tr -d '<=>0-9.')
    4.72  				# if it contains only comparisons, numbers, dot - it is not lib, skip
    4.73  				[ -n "$isitlib" ] || continue
    4.74 -				indb "$i.pc" $db_pc
    4.75 +				indb "$i.pc" $db_pc >>$tmptmp
    4.76  			done
    4.77  			# Syntax examples:
    4.78  			# Libs: -L${libdir} -lgio-2.0
    4.79 @@ -249,7 +258,31 @@
    4.80  			libs=$(grep '^Libs' $1 | cut -d: -f2 | tr '\n' ' ')
    4.81  			for i in $libs; do
    4.82  				case $i in
    4.83 -					-l*) indb "lib${i#-l}.so" $db_so;;
    4.84 +					-L*) eval LIBDIR="${i#-L}";;
    4.85 +					-l*)
    4.86 +						eval i="$i"		# substitute variables
    4.87 +#echo ">i='$i'" >&2
    4.88 +						pkg=$(indb "lib${i#-l}.so" $db_so)
    4.89 +#echo ">>pkg='$pkg'" >&2
    4.90 +						pkgs=$(awk -F$'\t' -vpkg="$pkg" '{if (index(" " $2 " ", " " pkg " ")) print $2;}' /home/slitaz/cache/split.db)
    4.91 +#echo ">>pkgs='$pkgs'" >&2
    4.92 +						unset out
    4.93 +						for j in $pkgs; do
    4.94 +							# seadrch for <pkg>-dev
    4.95 +							case $j in $pkg-dev) out=$j; break;;
    4.96 +							esac
    4.97 +						done
    4.98 +#echo ">>'$out'" >&2
    4.99 +						[ -z "$out" ] &&
   4.100 +						for j in $pkgs; do
   4.101 +							# if not found previously, search for <any>-dev
   4.102 +							case $j in *-dev) out=$j; break;;
   4.103 +							esac
   4.104 +						done
   4.105 +#echo ">>'$out'" >&2
   4.106 +						echo ${out:-$pkg}
   4.107 +#echo >&2
   4.108 +						;;
   4.109  				esac
   4.110  			done
   4.111  			;;
   4.112 @@ -263,10 +296,12 @@
   4.113  			echo 'python'
   4.114  			;;
   4.115  		*)
   4.116 -			LD_PRELOAD= LD_TRACE_LOADED_OBJECTS=1 /lib/ld-linux* "$1" 2>/dev/null | \
   4.117 -			sed 's| =>.*||; s| (.*||; s|\t||' | \
   4.118 -			while read i; do
   4.119 -				indb "$i" $db_so
   4.120 +#			LD_PRELOAD= LD_TRACE_LOADED_OBJECTS=1 /lib/ld-linux* "$1" 2>/dev/null | \
   4.121 +#			sed 's| =>.*||; s| (.*||; s|\t||' | \
   4.122 +			readelf -dW "$1" 2>/dev/null \
   4.123 +			| sed -n '/NEEDED/ s|.*\[\(.*\)\]|\1|p' \
   4.124 +			| while read i; do
   4.125 +				indb "$i" $db_so >>$tmptmp
   4.126  			done
   4.127  			;;
   4.128  	esac
   4.129 @@ -307,7 +342,7 @@
   4.130  	IFS=$'\n'
   4.131  	while read file; do
   4.132  		tp_ldd "$WOK/$1/taz/$pkg-$VERSION/fs$file"
   4.133 -	done < $WOK/$1/taz/$pkg-$VERSION/files.list | sort -u | grep -v "^$pkg$"
   4.134 +	done < $WOK/$1/taz/$pkg-$VERSION/files.list | sort -u | grep -v "^$pkg$" | sed '/^$/d'
   4.135  done
   4.136  
   4.137  newline