Bug#242319: mkbimage: random image contents
Yann Dirson
Yann Dirson <dirson@debian.org>, 242319@bugs.debian.org
Tue, 6 Apr 2004 00:06:16 +0200
--45Z9DzgjV8m4Oswq
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Package: grub
Version: 0.93+cvs20031021-8
Severity: normal
1. When extracting the image tarball into a dir, the dir is not cleaned
first, resulting in possible extraneous files (my previous tarball was
b0rked, and with the correct one I had 2 stage2 files in my tree, which
caused failure)
2. When using e2tools (and possibly mtools), only boot/grub contents was
copied. This patch recreates all dirs and copies all files; although not
perfect, that should be sufficient for most purposes.
I also changed one more thing to make this script a bit more idiomatically
correct, with the idea of allowing it to run "set -e" some day.
--
Yann Dirson <ydirson@altern.org> | Why make M$-Bill richer & richer ?
Debian-related: <dirson@debian.org> | Support Debian GNU/Linux:
Pro: <yann.dirson@fr.alcove.com> | Freedom, Power, Stability, Gratuity
http://ydirson.free.fr/ | Check <http://www.debian.org/>
--45Z9DzgjV8m4Oswq
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="mkbimage.diff"
--- /bin/mkbimage 2003-08-09 14:19:43.000000000 +0200
+++ /export/work/yann/ltt/mkbimage 2004-04-05 23:53:50.000000000 +0200
@@ -178,9 +178,12 @@
esac
if [ "$offset" = 0 ] && which $cp > /dev/null ; then
- $mkdir ${image}:/boot
- $mkdir ${image}:/boot/grub
- $cp ${image}1/boot/grub/* ${image}:/boot/grub/
+ for dir in $(cd ${image}1 && find -type d) ; do
+ $mkdir ${image}:$dir
+ done
+ for file in $(cd ${image}1 && find -type f) ; do
+ $cp ${image}1/$file ${image}:$file
+ done
elif [ "`id -u`" = "0" ] ; then
losetup $lo_options /dev/loop1 $image
mkdir ${image}.mnt
@@ -355,7 +358,8 @@
mkbimage_mkfs
# then untar the files
-mkdir ${image}1 2>/dev/null
+[ ! -e ${image}1 ] || { echo "${image}1 exists, please remove it first"; exit 1;}
+mkdir -p ${image}1
$decompress $tarfile | tar -C ${image}1 $debug -xf -
# copy the untarred files into the filesystem image
@@ -364,7 +368,7 @@
#We verify that the stage2 exists and we search the name
stage2_os_name=`find ${image}1 -name stage2 -type f`
-[ ! $stage2_os_name ] && { echo "I can't find stage2!"; exit 1;}
+[ -r "$stage2_os_name" ] || { echo "I can't find stage2!"; exit 1;}
#------------------------- GRUB stuff
if [ "$image_type" = "hd" ]; then
@@ -408,4 +412,6 @@
Enjoy!
EOF
+rm -rf ${image}1
+
exit 0
--45Z9DzgjV8m4Oswq--