|
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 |
|
| 98 |
if [ "x$no_unsquashfs" = "xyes" ] ; then |
| 99 |
|
| 100 |
live_mount="$(mount | grep -E "^${img} " | sed 's,^.* on \([^ ]\+\) .*$,\1,')" |
| 101 |
if [ "x$live_mount" = "x" ] ; then |
| 102 |
do_notify_error "Can't read squashfs image $img" |
| 103 |
return 1 |
| 104 |
fi |
| 105 |
unpacked="$(du -sb ${live_mount} | sed 's,^[ ]*\([0-9]\+\).*$,\1,')" |
| 106 |
if [ "x$unpacked" = "x" ] ; then |
| 107 |
do_notify_error "Can't calculate unpacked squashfs size" |
| 108 |
return 1 |
| 109 |
fi |
| 110 |
free=$(free_space "$dst") |
| 111 |
if [ $unpacked -gt $free ]; then |
| 112 |
do_notify_error "No free space to unpack squashfs image" |
| 113 |
return 1 |
| 114 |
fi |
| 115 |
do_notify_stage install |
| 116 |
local dirlist=$(ls ${live_mount} | grep -vE "dev|image|mnt|proc|sys") |
| 117 |
local ndirs=`echo $dirlist | wc -w` |
| 118 |
if [ $ndirs -eq 0 ] ; then |
| 119 |
do_notify_error "Can't read squashfs image $img" |
| 120 |
return 1 |
| 121 |
fi |
| 122 |
local ndirs_done=0 |
| 123 |
for d in $dirlist ; do |
| 124 |
cp -a ${live_mount}/${d} ${dst}/ |
| 125 |
ndirs_done=$((${ndirs_done}+1)) |
| 126 |
do_notify_status "$(( ${ndirs_done} * 100 / ${ndirs} ))" |
| 127 |
done |
| 128 |
mkdir -p -- ${dst}/{dev,mnt,proc,sys} |
| 129 |
|
| 130 |
else # default: |
| 91 |
|
131 |
|
| 92 |
if ! [ -r "$img" ]; then |
132 |
if ! [ -r "$img" ]; then |
| 93 |
do_notify_error "Can't read squashfs image $img" |
133 |
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-134
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 |
| 129 |
|
169 |
|
| 130 |
while read ignore; do |
170 |
while read ignore; do |
| 131 |
[ $progress -gt 100 ] && continue |
171 |
[ $progress -gt 100 ] && continue |
| 132 |
((i += 1)) |
172 |
((i += 1)) |
| 133 |
if [ $i -gt $percent1 ]; then |
173 |
if [ $i -gt $percent1 ]; then |
| 134 |
do_notify_status "$((progress++))" |
174 |
do_notify_status "$((progress++))" |
|
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" |