View | Details | Raw Unified | Return to bug 27786
Collapse All | Expand All

(-)/usr/lib/alterator/backend3/livecd-install.orig (-3 / +58 lines)
Lines 83-93 Link Here
83
# unpack squashfs image
83
# unpack squashfs image
84
#
84
#
85
85
86
no_unsquashfs=yes
87
86
do_install()
88
do_install()
87
{
89
{
88
    local img="$1";shift
90
    local img="$1";shift
89
    local dst="$1";shift
91
    local dst="$1";shift
90
    local percent1=
92
    local percent1=
93
    local unpacked=
94
    local free=
95
    local live_mount=
96
    local retval=0
97
    local blk_tot pct pct_prev dpct
98
    local curr_dir=`pwd`
99
100
if [ "x$no_unsquashfs" = "xyes" ] ; then
101
102
	    live_mount="$( mount | sed '/ type squashfs /!d; s/^.* on [ ]*\([^ ]\+\) type squashfs .*$/\1/')"
103
	    if [ "x$live_mount" = "x" ] ; then
104
		    do_notify_error "Can't find squashfs mount point"
105
		    return 1
106
	    fi
107
	    unpacked="$(du -sb ${live_mount} | sed 's,^[ ]*\([0-9]\+\).*$,\1,')"
108
	    if [ "x$unpacked" = "x" ] ; then
109
            	do_notify_error "Can't calculate unpacked squashfs size"
110
	        return 1
111
	    fi
112
    	    free=$(free_space "$dst")
113
    	    if [ $unpacked -gt $free ]; then
114
 	    	do_notify_error "No free space to unpack squashfs image"
115
	        return 1
116
	    fi
117
	    do_notify_stage install
118
           blk_tot=$[ ${unpacked} / 1024 ]
119
	    cd ${live_mount}
120
           tar cf - . --exclude=dev --exclude=mnt --exclude=proc --exclude=sys \
121
	    | { 
122
		cd ${dst}
123
		LANG=C LC_ALL=C tar xfvR - \
124
		| {
125
		   pct_prev=0 ; 
126
  		   while read dum blk dum  ; do
127
			blk=${blk/:/};
128
			pct=$[ $blk * 100 / $tot ];
129
			dpct=$[ $pct - $pct_prev ] ; 
130
			if test $dpct -ge 1 ; then
131
				pct_prev=$pct
132
				do_notify_status "$pct"
133
			fi
134
		   done
135
		  }
136
             }
137
	    mkdir -p -- ${dst}/{dev,mnt,proc,sys}
138
	    cd ${curr_dir}
139
140
else # default:
91
141
92
    if ! [ -r "$img" ]; then
142
    if ! [ -r "$img" ]; then
93
        do_notify_error "Can't read squashfs image $img"
143
        do_notify_error "Can't read squashfs image $img"
Lines 106-119 Link Here
106
    percent1="$((percent1/99))"
146
    percent1="$((percent1/99))"
107
147
108
    # calculate size necessary for unpacked squashfs image
148
    # calculate size necessary for unpacked squashfs image
109
    local unpacked=$(sqfs_size "$img")
149
    unpacked=$(sqfs_size "$img")
110
150
111
    if [ -z "$unpacked" ]; then
151
    if [ -z "$unpacked" ]; then
112
        do_notify_error "Can't calculate unpacked squashfs size"
152
        do_notify_error "Can't calculate unpacked squashfs size"
113
        return 1
153
        return 1
114
    fi
154
    fi
115
   
155
   
116
    local free=$(free_space "$dst")
156
    free=$(free_space "$dst")
117
157
118
    if [ $unpacked -gt $free ]; then
158
    if [ $unpacked -gt $free ]; then
119
        do_notify_error "No free space to unpack squashfs image"
159
        do_notify_error "No free space to unpack squashfs image"
Lines 122-128 Link Here
122
162
123
    do_notify_stage install
163
    do_notify_stage install
124
164
125
    unsquashfs -force -no-progress -info -dest "$dst" "$img" 2>/dev/null |
165
  { unsquashfs -force -no-progress -info -dest "$dst" "$img" 2>/dev/null ; retval=$? ; } |
126
    {
166
    {
127
        local i=0
167
        local i=0
128
        local progress=0
168
        local progress=0
Lines 136-141 Link Here
136
             fi
176
             fi
137
        done
177
        done
138
    }
178
    }
179
    if [ $retval -ne 0 ] ; then
180
            do_notify_error "Can't read squashfs image $img"
181
            return 1
182
    fi
183
fi #end of unsquashfs ...
139
184
140
    # Set right perms on root directory of installed system
185
    # Set right perms on root directory of installed system
141
    chmod 0755 "$dst"
186
    chmod 0755 "$dst"

Return to bug 27786