[arch-projects] [RFC] [PATCH] [mkinitcpio] Fix add_binary() when -b BASEDIR is used.
Gerardo Exequiel Pozzi
vmlinuz386 at yahoo.com.ar
Mon Nov 21 00:36:17 EST 2011
Maybe the fix is wrong because the usage of chroot? Please review.
mkinitcpio fails silently when a binary is installed on $BASEDIR
(for example $BASEDIR/usr/bin/curl with all sodeps) but outside $BASEDIR curl and deps is not installed.
----
A simple hook
build() {
add_binary "/usr/bin/curl"
}
----
Before the fix:
-> Parsing hook: [curl]
adding file: /usr/bin/curl
adding symlink: /lib/librt.so.1 -> /lib/librt-2.14.1.so
adding file: /lib/librt-2.14.1.so
adding dir: /usr/lib
adding symlink: /usr/lib/libz.so.1 -> /usr/lib/libz.so.1.2.5
adding file: /usr/lib/libz.so.1.2.5
adding symlink: /lib/libpthread.so.0 -> /lib/libpthread-2.14.1.so
adding file: /lib/libpthread-2.14.1.so
With this fix applied:
-> Parsing hook: [curl]
adding file: /usr/bin/curl
adding dir: /usr/lib
adding symlink: /usr/lib/libcurl.so.4 -> /usr/lib/libcurl.so.4.2.0
adding file: /usr/lib/libcurl.so.4.2.0
adding symlink: /lib/librt.so.1 -> /lib/librt-2.14.1.so
adding file: /lib/librt-2.14.1.so
adding symlink: /usr/lib/libz.so.1 -> /usr/lib/libz.so.1.2.5
adding file: /usr/lib/libz.so.1.2.5
adding symlink: /lib/libpthread.so.0 -> /lib/libpthread-2.14.1.so
adding file: /lib/libpthread-2.14.1.so
adding symlink: /usr/lib/libssh2.so.1 -> /usr/lib/libssh2.so.1.0.1
adding file: /usr/lib/libssh2.so.1.0.1
adding file: /usr/lib/libssl.so.1.0.0
adding file: /usr/lib/libcrypto.so.1.0.0
adding symlink: /lib/libdl.so.2 -> /lib/libdl-2.14.1.so
adding file: /lib/libdl-2.14.1.so
---
functions | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/functions b/functions
index ef4463e..78d62d5 100644
--- a/functions
+++ b/functions
@@ -300,16 +300,20 @@ add_binary() {
# always add the binary itself
_add_file "${dest#$BASEDIR}" "$binary" "$mode"
- lddout=$(ldd "$binary" 2>/dev/null) || return 1 # not a binary!
+ if [[ -z $BASEDIR ]]; then
+ lddout=$(ldd "$binary" 2>/dev/null) || return 1 # not a binary!
+ else
+ lddout=$(chroot $BASEDIR ldd "${binary#$BASEDIR}" 2>/dev/null) || return 1 # not a binary!
+ fi
# resolve sodeps
regex='(/.+) \(0x[a-fA-F0-9]+\)'
while read line; do
[[ "$line" =~ $regex ]] && sodep=${BASH_REMATCH[1]} || continue
- if [[ -f "$sodep" ]]; then # -f follows symlinks, don't believe it!
- if [[ ! -L $sodep ]]; then
- _add_file "$sodep" "$BASEDIR$sodep" "$(stat -c %a "$sodep")"
+ if [[ -f "$BASEDIR$sodep" ]]; then # -f follows symlinks, don't believe it!
+ if [[ ! -L $BASEDIR$sodep ]]; then
+ _add_file "$sodep" "$BASEDIR$sodep" "$(stat -c %a "$BASEDIR$sodep")"
else
resolved=$(readlink -e "$BASEDIR$sodep")
dirname=${resolved%/*}
--
1.7.7.3
More information about the arch-projects
mailing list