[arch-projects] [RFC] [PATCH] [mkinitcpio] Fix add_binary() when -b BASEDIR is used.
Dave Reisner
d at falconindy.com
Mon Nov 21 09:11:41 EST 2011
On Mon, Nov 21, 2011 at 02:36:17AM -0300, Gerardo Exequiel Pozzi wrote:
> 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
>
Yeah that's definitely wrong.
> 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!
Nope -- we can't use chroot. I don't want to require root for generating
images (even if it is only for -b). I'll take a look at this when I get a chance.
> + 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
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://mailman.archlinux.org/pipermail/arch-projects/attachments/20111121/3ac09d7f/attachment.asc>
More information about the arch-projects
mailing list