--- /usr/lib/alterator/backend3/livecd-install.orig 2012-05-24 20:34:41.000000000 +0400 +++ /usr/lib/alterator/backend3/livecd-install 2012-09-30 16:45:37.264009748 +0400 @@ -83,11 +83,51 @@ # unpack squashfs image # +no_unsquashfs=yes + do_install() { local img="$1";shift local dst="$1";shift local percent1= + local unpacked= + local free= + local live_mount= + local retval=0 + local blk_tot pct pct_prev dpct + +if [ "x$no_unsquashfs" = "xyes" ] ; then + + live_mount="$( mount | sed '/ type squashfs /!d; s/^.* on [ ]*\([^ ]\+\) type squashfs .*$/\1/')" + if [ "x$live_mount" = "x" ] ; then + do_notify_error "Can't find squashfs mount point" + return 1 + fi + unpacked="$(du -sb ${live_mount} | sed 's,^[ ]*\([0-9]\+\).*$,\1,')" + if [ "x$unpacked" = "x" ] ; then + do_notify_error "Can't calculate unpacked squashfs size" + return 1 + fi + free=$(free_space "$dst") + if [ $unpacked -gt $free ]; then + do_notify_error "No free space to unpack squashfs image" + return 1 + fi + do_notify_stage install + blk_tot=$[ ${unpacked} / 1024 ] + tar cf - . --exclude=dev --exclude=mnt --exclude=proc --exclude=sys \ + | { + cd ${dst} + LANG=C LC_ALL=C tar xfvR - \ + | { + pct_prev=0 ; + while read dum blk dum ; do + blk=${blk/:/}; + pct=$[ $blk * 100 / $tot ]; + dpct=$[ $pct - $pct_prev ] ; + if test $dpct -ge 1 ; then + pct_prev=$pct + do_notify_status "$pct" + fi + done + } + } + mkdir -p -- ${dst}/{dev,mnt,proc,sys} + +else # default: if ! [ -r "$img" ]; then do_notify_error "Can't read squashfs image $img" @@ -106,14 +146,14 @@ percent1="$((percent1/99))" # calculate size necessary for unpacked squashfs image - local unpacked=$(sqfs_size "$img") + unpacked=$(sqfs_size "$img") if [ -z "$unpacked" ]; then do_notify_error "Can't calculate unpacked squashfs size" return 1 fi - local free=$(free_space "$dst") + free=$(free_space "$dst") if [ $unpacked -gt $free ]; then do_notify_error "No free space to unpack squashfs image" @@ -122,7 +162,7 @@ do_notify_stage install - unsquashfs -force -no-progress -info -dest "$dst" "$img" 2>/dev/null | + { unsquashfs -force -no-progress -info -dest "$dst" "$img" 2>/dev/null ; retval=$? ; } | { local i=0 local progress=0 @@ -136,6 +176,11 @@ fi done } + if [ $retval -ne 0 ] ; then + do_notify_error "Can't read squashfs image $img" + return 1 + fi +fi #end of unsquashfs ... # Set right perms on root directory of installed system chmod 0755 "$dst"