diff options
| -rw-r--r-- | debian/changelog | 7 | ||||
| -rw-r--r-- | hook-functions | 67 | 
2 files changed, 53 insertions, 21 deletions
diff --git a/debian/changelog b/debian/changelog index 8932889..40363ad 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,18 +2,19 @@ initramfs-tools (0.88) UNRELEASED; urgency=low    [ maximilian attems ]    * debian/changelog: Fix missing colons in closes. -    * hook-functions: Add a proper /sys walking dep_add_modules() for a minimal      initramfs on MODULES=dep. (closes: #395526) -    * mkinitramfs.8: Add examples section, plus improve description of the      low-level tool and how it fits with update-initramfs.    [ David Härdeman ]    * init: Remove cryptopts parsing, not official bootparam. cryptsetup scripts      parse /proc/cmdline themselves (even in the Etch version). +  * hook-functions: Change copy_exec to use the same source and +    destination path if only one argument is given. +  * hook-funcions: document how copy_exec determines the target path. - -- maximilian attems <maks@debian.org>  Tue, 01 May 2007 18:56:40 +0200 + -- maximilian attems <maks@debian.org>  Tue, 01 May 2007 19:23:10 +0200  initramfs-tools (0.87b) unstable; urgency=low diff --git a/hook-functions b/hook-functions index 12faeff..6c75b5f 100644 --- a/hook-functions +++ b/hook-functions @@ -55,24 +55,55 @@ manual_add_modules()  	done  } -# $1 is source -# $2 is relative destination +# $1 is the source path (e.g. /usr/bin/time) +# $2 is the relative destination (e.g. /usr or /usr/time) +# +# The destination is interpreted in the same way "cp" would, meaning +# (assuming /bin is a directory): +# +#   "copy_exec /usr/bin/time /bin"        -> /bin/time +#   "copy_exec /usr/bin/time /bin/mytime" -> /bin/mytime +#  +# If $2 is left out, the same destination path as for the source arg will +# be used and directories will be created as needed, so: +# +#   "copy_exec /usr/bin/time"             -> /usr/bin/time +#  copy_exec() { -	final_destination=${DESTDIR}/${2}/`basename ${1}` +	local source target destination final_destination x nonoptlib +	local libname dirname + +	source="${1}" +	if [ -n "${2}" ]; then +		target="${2}" +	else +		if [ ! -e "${DESTDIR}/$(dirname "${1}")" ]; then +			mkdir -p "${DESTDIR}/$(dirname "${1}")" +		fi +		target="${1}" +	fi + +	if [ -d "${DESTDIR}/${target}" ]; then +		destination="${target}/$(basename "${source}")" +	else +		destination="${target}" +	fi +	final_destination="${DESTDIR}/${destination}" +  	if [ -L "$final_destination" ]; then -		if ! [ `readlink ${final_destination}` = "${1}" ]; then -			echo "W:copy_exec: Not copying ${1} to \$DESTDIR${2}/`basename ${1}`, which is already a copy of `readlink ${final_destination}`" >&2 +		if [ $(readlink "${final_destination}") != "${source}" ]; then +			echo "W:copy_exec: Not copying ${source} to \$DESTDIR${destination}, which is already a copy of $(readlink ${final_destination})" >&2  			return  		fi  	else -		ln -s ${1} ${DESTDIR}/${2} -		if [ -n "${verbose}" ] && [ "${verbose}" = "y" ]; then -			echo "Adding binary ${1}" +		ln -s ${source} ${DESTDIR}/${destination} +		if [ "${verbose}" = "y" ]; then +			echo "Adding binary ${source}"  		fi  	fi  	# Copy the dependant libraries -	for x in $(ldd ${1} 2>/dev/null | sed -e ' +	for x in $(ldd ${source} 2>/dev/null | sed -e '  	    /\//!d;  	    /linux-gate/d;  	    /=>/ {s/.*=>[[:blank:]]*\([^[:blank:]]*\).*/\1/}; @@ -80,19 +111,19 @@ copy_exec() {  		# Try to use non-optimised libraries where possible.  		# We assume that all HWCAP libraries will be in tls. -		nonoptlib=$(echo ${x} | sed -e 's#/lib/tls.*/\(lib.*\)#/lib/\1#') +		nonoptlib=$(echo "${x}" | sed -e 's#/lib/tls.*/\(lib.*\)#/lib/\1#') -		if [ -e ${nonoptlib} ]; then -			x=${nonoptlib} +		if [ -e "${nonoptlib}" ]; then +			x="${nonoptlib}"  		fi -		libname=$(basename ${x}) -		dirname=$(dirname ${x}) +		libname=$(basename "${x}") +		dirname=$(dirname "${x}") -		mkdir -p ${DESTDIR}/${dirname} -		if [ ! -e ${DESTDIR}/${dirname}/${libname} ]; then -			ln -s ${x} ${DESTDIR}/${dirname} -			if [ -n "${verbose}" ] && [ "${verbose}" = "y" ]; then +		mkdir -p "${DESTDIR}/${dirname}" +		if [ ! -e "${DESTDIR}/${dirname}/${libname}" ]; then +			ln -s "${x}" "${DESTDIR}/${dirname}" +			if [ "${verbose}" = "y" ]; then  				echo "Adding library ${x}"  			fi  		fi  | 
