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