[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#338405: initramfs-tools: Duplicate files and inadequate use of busybox.



Hi,
The attached patch could be the first step towards fixing the problem. It removes the --dereference flag from the cpio command line. This makes it possible to create a smaller cpio archive with /bin/sh being a symlink to /bin/busybox. The other changes in the patch are necessary so that everything still works as before (i.e., it's now not possible to just symlink the wanted files when creating the structure in $DESTDIR, the files have to be copied there).

Michal
diff -Nurp initramfs-tools-0.57b/hook-functions initramfs-tools-0.57b.michich/hook-functions
--- initramfs-tools-0.57b/hook-functions	2006-03-20 19:27:07.000000000 +0100
+++ initramfs-tools-0.57b.michich/hook-functions	2006-03-26 15:17:39.000000000 +0200
@@ -47,7 +47,7 @@ manual_add_modules()
 		fi
 
 		mkdir -p "${DESTDIR}/$(dirname "${mam_x}")"
-		ln -s "${mam_x}" "${DESTDIR}/$(dirname "${mam_x}")"
+		cp -L "${mam_x}" "${DESTDIR}/$(dirname "${mam_x}")"
 		if [ -n "${verbose}" -a "${verbose}" = "y" ]; then
 			echo "Adding module ${mam_x}"
 		fi
@@ -64,7 +64,7 @@ copy_exec() {
 			return
 		fi
 	else
-		ln -s ${1} ${DESTDIR}/${2}
+		cp -L ${1} ${DESTDIR}/${2}
 	fi
 
 	# Copy the dependant libraries
@@ -87,7 +87,7 @@ copy_exec() {
 
 		mkdir -p ${DESTDIR}/${dirname}
 		if [ ! -e ${DESTDIR}/${dirname}/${libname} ]; then
-			ln -s ${x} ${DESTDIR}/${dirname}
+			cp -L ${x} ${DESTDIR}/${dirname}
 		fi
 	done
 }
diff -Nurp initramfs-tools-0.57b/mkinitramfs initramfs-tools-0.57b.michich/mkinitramfs
--- initramfs-tools-0.57b/mkinitramfs	2006-03-21 11:56:18.000000000 +0100
+++ initramfs-tools-0.57b.michich/mkinitramfs	2006-03-26 15:32:53.000000000 +0200
@@ -175,13 +175,10 @@ if [ "${MODULES}" = "netboot" ]; then
 	auto_add_modules net
 fi
 
-# Have to do each file, because cpio --dereference doesn't recurse down
-# symlinks.
-
-ln -s /usr/lib/klibc/bin/* ${DESTDIR}/bin
-ln -s /lib/klibc-*.so ${DESTDIR}/lib
+cp -L /usr/lib/klibc/bin/* ${DESTDIR}/bin
+cp -L /lib/klibc-*.so ${DESTDIR}/lib
 copy_exec /usr/share/initramfs-tools/init /init
-cp -a /usr/share/initramfs-tools/scripts/* "${DESTDIR}/scripts"
+cp -pRL /usr/share/initramfs-tools/scripts/* "${DESTDIR}/scripts"
 for f in $(cd ${CONFDIR}/scripts && \
 	find . \( -name '*.dpkg*' -prune -o -name '*~' -prune \) \
 		-o -type f -print); do
@@ -198,14 +195,14 @@ echo "ROOT=${ROOT}" > ${DESTDIR}/conf/co
 # Busybox
 rm -f ${DESTDIR}/bin/sh
 copy_exec ${BUSYBOXDIR}/busybox /bin/busybox
-ln -s ${BUSYBOXDIR}/busybox ${DESTDIR}/bin/sh
+(cd ${DESTDIR}/bin; ln -s busybox sh)
 
 # Modutils
 copy_exec /sbin/modprobe /sbin
 copy_exec /sbin/depmod /sbin
 copy_exec /sbin/rmmod /sbin
 mkdir -p "${DESTDIR}/etc/modprobe.d"
-cp -a /etc/modprobe.d/* "${DESTDIR}/etc/modprobe.d"
+cp -pRL /etc/modprobe.d/* "${DESTDIR}/etc/modprobe.d"
 
 run_scripts /usr/share/initramfs-tools/hooks
 run_scripts "${CONFDIR}"/hooks
@@ -215,7 +212,7 @@ if [ -e "${CONFDIR}/DSDT.aml" ]; then
 	copy_exec "${CONFDIR}/DSDT.aml" /
 fi
 
-(cd "${DESTDIR}" && find . | cpio --quiet --dereference -o -H newc | gzip -9 >"${outfile}") || exit 1
+(cd "${DESTDIR}" && find . | cpio --quiet -o -H newc | gzip -9 >"${outfile}") || exit 1
 
 if [ -s "${__TMPCPIOGZ}" ]; then
     cat "${__TMPCPIOGZ}" >>"${outfile}" || exit 1

Reply to: