rev |
line source |
pascal@17635
|
1 #!/bin/sh
|
pascal@17635
|
2
|
pascal@17635
|
3 [ $(id -u) -eq 0 ] || exec su -c "$0 $@"
|
pascal@17635
|
4
|
pascal@17635
|
5 DIALOG=dialog
|
pascal@17635
|
6
|
pascal@17635
|
7 ddq()
|
pascal@17635
|
8 {
|
pascal@17635
|
9 dd $@ 2> /dev/null
|
pascal@17635
|
10 }
|
pascal@17635
|
11
|
pascal@17635
|
12 get()
|
pascal@17635
|
13 {
|
pascal@18670
|
14 od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An "$2" 2>/dev/null ||
|
pascal@21542
|
15 hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %u\n\"" "$2"
|
pascal@17635
|
16 }
|
pascal@17635
|
17
|
pascal@17635
|
18 bytes2bin()
|
pascal@17635
|
19 {
|
pascal@17635
|
20 for i in $@ ; do
|
pascal@17635
|
21 printf '\\\\x%02X' $(($i&255))
|
pascal@17635
|
22 done | xargs echo -en
|
pascal@17635
|
23 }
|
pascal@17635
|
24
|
pascal@17635
|
25 words2bin()
|
pascal@17635
|
26 {
|
pascal@17635
|
27 for i in $@ ; do
|
pascal@17635
|
28 printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255))
|
pascal@17635
|
29 done | xargs echo -en
|
pascal@17635
|
30 }
|
pascal@17635
|
31
|
pascal@17635
|
32 gettazboot()
|
pascal@17635
|
33 {
|
pascal@21542
|
34 echo -e "\nCreating $(basename $1) ..."
|
pascal@21542
|
35 X=$(($(get 20 /mnt/$ISO) - 0xC0))
|
pascal@21542
|
36 [ $X -lt 30000 ] && X=$((0x7FF0))
|
pascal@18670
|
37 O=$(($(get 64 "$ISO") - 0xC0))
|
pascal@21542
|
38 L=$(($X - $(get 24 "$ISO") - $O))
|
pascal@18140
|
39 S=$((32+$L))
|
pascal@18140
|
40 P=$((($S+511)/512))
|
pascal@18140
|
41 E=$((4096-(32*$P)))
|
pascal@18140
|
42 words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \
|
pascal@18140
|
43 -2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1
|
pascal@21542
|
44 ddq bs=1 count=$(echo $L) skip=$(echo $O) if="$ISO" >> $1
|
pascal@17635
|
45 }
|
pascal@17635
|
46
|
pascal@17635
|
47 uncpio()
|
pascal@17635
|
48 {
|
pascal@17635
|
49 [ -s "$1" ] || return
|
pascal@17635
|
50 echo -en "\n Extracting $(basename $1) ..."
|
pascal@17635
|
51 case $(get 0 $1) in
|
pascal@17635
|
52 *35615) ( zcat || gunzip ) ;;
|
pascal@17635
|
53 *14333) unxz ;;
|
pascal@17635
|
54 *\ 93) unlzma ;;
|
pascal@17635
|
55 *) cat ;;
|
pascal@17635
|
56 esac < $1 | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 )
|
pascal@17635
|
57 }
|
pascal@17635
|
58
|
pascal@17635
|
59 dotwait()
|
pascal@17635
|
60 {
|
pascal@17635
|
61 echo -n "${1:-Install filesystem}.."
|
pascal@17635
|
62 touch /tmp/wait
|
pascal@17930
|
63 [ "$REQUEST_URI" ] && return
|
pascal@17635
|
64 while [ -e /tmp/wait ]; do
|
pascal@17635
|
65 echo -n "." > /dev/tty
|
pascal@17635
|
66 sleep 1
|
pascal@17635
|
67 done &
|
pascal@17635
|
68 }
|
pascal@17635
|
69
|
pascal@17635
|
70 getuuid()
|
pascal@17635
|
71 {
|
pascal@17635
|
72 dev=$(mount | sed "/ $(echo $mnt | sed 's|/|\\/|g') /!d;s/ .*//;s|/dev/||;q")
|
pascal@17635
|
73 [ "$dev" ] &&
|
pascal@17635
|
74 blkid | sed "/$dev:/!d;s/.* UUID=.\\([^ ]*\\)\".*/\\1/" ||
|
pascal@17635
|
75 echo "/dev/hda1"
|
pascal@17635
|
76 }
|
pascal@17635
|
77
|
pascal@17635
|
78 tazusbinitfs()
|
pascal@17635
|
79 {
|
pascal@17635
|
80 PAD=$(($(stat -c %s $1) % 4))
|
pascal@17635
|
81 [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1
|
pascal@17635
|
82 mkdir -p /tmp/fs$$/etc /tmp/fs$$/lib /tmp/fs$$/home
|
pascal@21542
|
83 cp -a /etc/locale.conf /etc/locale.conf /tmp/fs$$/etc 2> /dev/null
|
pascal@17635
|
84 cat > /tmp/fs$$/init1 <<EOT
|
pascal@17635
|
85 #!/bin/sh
|
pascal@17635
|
86 sed -i 's|sbin/init|init2|' /init
|
pascal@17635
|
87 exec /init
|
pascal@17635
|
88 EOT
|
pascal@17635
|
89 cat > /tmp/fs$$/init2 <<EOT
|
pascal@17635
|
90 #!/bin/sh
|
pascal@17635
|
91
|
pascal@17635
|
92 mount -t proc /proc /proc
|
pascal@21542
|
93 for i in /lib/modules/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
|
pascal@17635
|
94 v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2> /dev/null)
|
pascal@17635
|
95 mount / -o remount,rw
|
pascal@17635
|
96 mkdir /mnt/dos
|
pascal@17635
|
97 rm -f /cmdline 2> /dev/null
|
pascal@17635
|
98 mount / -o remount,ro
|
pascal@17635
|
99 mnt=/mnt/dos/\${v#*/}
|
pascal@17635
|
100 dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q')
|
pascal@17635
|
101 echo "Mount \$dev in /mnt/dos for \$v..." | tee -a /run/boot.log
|
pascal@17635
|
102 mount \$dev /mnt/dos
|
pascal@17635
|
103 if [ ! -d /mnt/dos/slitaz ]; then
|
pascal@17635
|
104 umount /mnt/dos 2> /dev/null
|
pascal@17635
|
105 (blkid /dev/[sh]d* || blkid) | while read dev line; do
|
pascal@17635
|
106 case "\$line" in
|
pascal@17635
|
107 *ntfs*|*vfat*|*msdos*) ;;
|
pascal@17635
|
108 *) continue ;;
|
pascal@17635
|
109 esac
|
pascal@17635
|
110 mount \${dev%:} /mnt/dos
|
pascal@17635
|
111 [ -d /mnt/dos/slitaz ] && break
|
pascal@17635
|
112 umount /mnt/dos
|
pascal@17635
|
113 done
|
pascal@17635
|
114 fi
|
pascal@17932
|
115 $([ "$2" ] || echo '# ')mount.posixovl -F \$mnt -- -oallow_other -odefault_permissions -osuid
|
pascal@17635
|
116 mount --bind \$mnt /home
|
pascal@21542
|
117 mount -o size=0,ro -t tmpfs tmpfs \$mnt
|
pascal@17635
|
118 umount /proc
|
pascal@17635
|
119 exec /sbin/init
|
pascal@17635
|
120 EOT
|
pascal@17635
|
121 chmod 755 /tmp/fs$$/init?
|
pascal@21542
|
122 ln -s /sqfs/bin/gzip /bin 2> /dev/null
|
pascal@17635
|
123 ( cd /tmp/fs$$ ; find * | cpio -o -H newc ) | gzip -9 >> $1
|
pascal@17635
|
124 rm -rf /tmp/fs$$
|
pascal@17635
|
125 }
|
pascal@17635
|
126
|
pascal@17635
|
127 mkinitrd()
|
pascal@17635
|
128 {
|
pascal@17635
|
129 echo -en "\nCreating $(basename $1) "
|
pascal@17635
|
130 fs=/tmp/fs$$
|
pascal@17635
|
131 for i in bin lib dev proc tmp mnt etc ; do
|
pascal@17635
|
132 mkdir -p $fs/$i
|
pascal@17635
|
133 done
|
pascal@21542
|
134 for i in /dev/null /dev/tty /dev/tty[012] /dev/fuse /dev/[hs]d* \
|
pascal@21542
|
135 /dev/console ; do
|
pascal@17635
|
136 cp -a $2$i $fs/dev/
|
pascal@17635
|
137 done
|
pascal@23149
|
138 for i in /bin/busybox $(which mount.posixovl) $(which blkid) \
|
pascal@23149
|
139 $(which ntfs-3g); do
|
pascal@17635
|
140 cp $(LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $i | \
|
pascal@17635
|
141 sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') $fs/lib
|
pascal@17635
|
142 cp $i $fs/bin
|
pascal@17635
|
143 done
|
pascal@21542
|
144 cp -a /sqfs/lib/ld-* /tmp/fs/lib 2> /dev/null ||
|
pascal@17635
|
145 cp -a /lib/ld-* $fs/lib
|
pascal@17635
|
146 for i in $(busybox | sed '/Current/,$!d'); do
|
pascal@17635
|
147 [ -e $fs/bin/${i%,} ] || ln -s busybox $fs/bin/${i%,}
|
pascal@17635
|
148 done
|
pascal@17635
|
149 ln -s /proc/mounts $fs/etc/mtab
|
pascal@17635
|
150 sed 's/ .*//' /proc/modules | while read mod ; do
|
pascal@17635
|
151 find /lib/modules/ | grep $mod.ko | \
|
pascal@17635
|
152 sed 's|.*|cp & $fs/lib|' | sh
|
pascal@17635
|
153 done
|
pascal@17635
|
154 cat > $fs/init <<EOT
|
pascal@17635
|
155 #!/bin/sh
|
pascal@17635
|
156
|
pascal@17635
|
157 arg()
|
pascal@17635
|
158 {
|
pascal@17635
|
159 grep -q \$1 /proc/cmdline &&
|
pascal@17635
|
160 val="\$(sed "s/.*\$1=\\([^ ]*\\).*/\\1/" < /proc/cmdline)" &&
|
pascal@17635
|
161 echo "\$2 \$val"
|
pascal@17635
|
162 }
|
pascal@17635
|
163
|
pascal@17635
|
164 mount -t proc /proc /proc
|
pascal@17635
|
165 arg debug "shell" && debug=true && set -x
|
pascal@17635
|
166 for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2
|
pascal@17635
|
167 arg mount "Mount device"
|
pascal@23149
|
168 dsk=\$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q')
|
pascal@23149
|
169 mount \$dsk /mnt || mount.ntfs \$dsk /mnt
|
pascal@17635
|
170 arg subroot "Change root to directory"
|
pascal@17635
|
171 if [ -d /mnt/\$val ]; then
|
pascal@17635
|
172 umount /mnt 2> /dev/null
|
pascal@17635
|
173 (blkid /dev/[sh]d* || blkid) | while read dev line; do
|
pascal@17635
|
174 case "\$line" in
|
pascal@17635
|
175 *ntfs*|*vfat*|*msdos*) ;;
|
pascal@17635
|
176 *) continue ;;
|
pascal@17635
|
177 esac
|
pascal@17635
|
178 mount \${dev%:} /mnt
|
pascal@17635
|
179 [ -d /mnt/\$val ] && break
|
pascal@17635
|
180 umount /mnt
|
pascal@17635
|
181 done
|
pascal@17635
|
182 fi
|
pascal@23149
|
183
|
pascal@23149
|
184 $([ "$3" ] || echo -n '# ')mount.posixovl -F /mnt/\$val -- -oallow_other -odefault_permissions -osuid
|
pascal@17635
|
185 mount --bind /mnt /mnt/\$val/mnt/dos
|
pascal@21542
|
186 mount -o size=0,ro -t tmpfs tmpfs /mnt/\$val/mnt/dos/\$val
|
pascal@17635
|
187 LDSO=\$(ls /mnt/\$val/lib/ld-* | sed q)
|
pascal@17635
|
188 export LD_LIBRARY_PATH=\$val/lib:\$val/usr/lib:/lib
|
pascal@17635
|
189 [ "$debug" = "true" ] && sh
|
pascal@17635
|
190 umount /proc
|
pascal@17635
|
191 exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init
|
pascal@17635
|
192 EOT
|
pascal@17635
|
193 chmod +x $fs/init
|
pascal@17635
|
194 ( cd $fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null
|
pascal@17635
|
195 rm -rf $fs /tmp/wait
|
pascal@17635
|
196 }
|
pascal@17635
|
197
|
pascal@17635
|
198 ls_r()
|
pascal@17635
|
199 {
|
pascal@17635
|
200 ls -r $@ 2> /dev/null || ls $@
|
pascal@17635
|
201 }
|
pascal@17635
|
202
|
pascal@17635
|
203 doinstall()
|
pascal@17635
|
204 {
|
pascal@17932
|
205 unset useposixovl
|
pascal@17934
|
206 blkid | grep $(df $mnt | sed '$!d;s/ .*/:/') | \
|
pascal@17932
|
207 grep -qiE "(msdos|vfat|ntfs)" && useposixovl=YES
|
pascal@19029
|
208 case "$mnt" in
|
pascal@19029
|
209 *mkzip*) useposixovl=YES
|
pascal@19029
|
210 esac
|
pascal@17635
|
211 mkdir -p $mnt/slitaz/boot $mnt/slitaz/mnt/dos
|
pascal@17932
|
212 [ "$useposixovl" ] &&
|
pascal@17635
|
213 if ! mount.posixovl -F $mnt/slitaz -- \
|
pascal@17635
|
214 -oallow_other -odefault_permissions -osuid; then
|
pascal@17635
|
215 echo "Can't install SliTaz. Abort."
|
pascal@17635
|
216 sleep 5
|
pascal@17635
|
217 return 1
|
pascal@17635
|
218 fi
|
pascal@17635
|
219 dotwait "Install root filesystem in /slitaz.."
|
pascal@17635
|
220 if [ "$1" ]; then
|
pascal@18240
|
221 ls_r $media/boot/rootfs*gz | \
|
pascal@17635
|
222 xargs cat > $mnt/slitaz/boot/rootfs.gz
|
pascal@17932
|
223 tazusbinitfs $mnt/slitaz/boot/rootfs.gz $useposixovl
|
pascal@17635
|
224 initrd=rootfs.gz
|
pascal@17635
|
225 extraargs="/home=$(getuuid)/slitaz rdinit=/init1"
|
pascal@17635
|
226 else
|
pascal@18240
|
227 for i in $(ls_r $media/boot/rootfs*gz); do
|
pascal@17635
|
228 uncpio $i $mnt/slitaz
|
pascal@17635
|
229 done
|
pascal@17635
|
230 for i in $packages_list; do
|
pascal@17635
|
231 tazpkg get-install $i --root=$mnt/slitaz
|
pascal@17635
|
232 done
|
pascal@17635
|
233 for i in $packages_dir/*.tazpkg; do
|
pascal@17635
|
234 [ -s "$i" ] &&
|
pascal@17635
|
235 tazpkg install $i --root=$mnt/slitaz
|
pascal@17635
|
236 done
|
pascal@17635
|
237 cp -a /etc/locale.conf $mnt/slitaz/etc 2> /dev/null
|
pascal@17635
|
238 cp -a /etc/keymap.conf $mnt/slitaz/etc 2> /dev/null
|
pascal@17932
|
239 mkinitrd $mnt/slitaz/boot/initrd $mnt/slitaz $useposixovl
|
pascal@17635
|
240 initrd=initrd
|
pascal@17635
|
241 extraargs="mount=$(getuuid) subroot=slitaz"
|
pascal@17635
|
242 fi
|
pascal@17635
|
243 echo -en "\nInstall boot files..."
|
pascal@20158
|
244 for i in $media/boot/bzImage* $media/boot/*pxe* \
|
pascal@18240
|
245 $media/boot/isolinux/he* $media/boot/isolinux/opt* \
|
pascal@18240
|
246 $media/README $media/boot/memtest* ; do
|
pascal@17635
|
247 [ -s $i ] && cp $i $mnt/slitaz/boot
|
pascal@17635
|
248 done
|
pascal@21542
|
249 for i in $mnt/slitaz/boot/memtest $mnt/slitaz/boot/*pxe ; do
|
pascal@17635
|
250 [ $(get 0 $i 2> /dev/null || echo 0) -eq 23117 ] &&
|
pascal@17635
|
251 mv $i $i.exe
|
pascal@17635
|
252 done
|
pascal@20158
|
253 bzimage=$(cd $mnt/slitaz/boot ; ls bzimage*)
|
pascal@21542
|
254 cp /etc/keymap.conf /etc/locale.conf $mnt/slitaz/etc 2> /dev/null
|
pascal@20158
|
255 gettazboot $mnt/slitaz/boot/tazboot.exe # autoappend 64 suffix
|
pascal@17635
|
256 unix2dos > $mnt/slitaz/boot/tazboot.cmd <<EOT
|
pascal@17635
|
257 kernel=/slitaz/boot/bzimage
|
pascal@17635
|
258 initrd=/slitaz/boot/$initrd
|
pascal@21822
|
259 $extraargs autologin
|
pascal@17635
|
260 EOT
|
pascal@21553
|
261 uudecode - <<EOT | gunzip > $mnt/slitaz/boot/slitaz.pif
|
pascal@21553
|
262 begin-base64 644 -
|
pascal@21553
|
263 H4sIAAAAAAACA8XPxUHGMBTA8X9ecb/glgFwv+FO23zeI+7ucMFhCjZgEEZh
|
pascal@21553
|
264 Ctzd4Rf3PFbtQHGLG9BmfmZqdlE/tSmw2LfePzOzWDK0OsQXpPHvFGfZBmL5
|
pascal@21553
|
265 f3Zns98NuG1BbTrbWj0OFMypSKfT4kYCurKuRleWlBEth2qUTYFBKjg746pI
|
pascal@21553
|
266 2nZaIT/v9vWwbeuqi9fPznLlSPFLLuK22/0lLT09/BDhXgWKO1f9aLKxOObE
|
pascal@21553
|
267 EhLuVvO4FksSwaH5qbHpvkle0TyzND82NK+doRVeZgGGbIw0XD2QwV9SnAN/
|
pascal@21553
|
268 ACxDxwMAAA==
|
pascal@21553
|
269 ====
|
pascal@21553
|
270 EOT
|
pascal@17635
|
271 unix2dos $mnt/slitaz/boot/he* $mnt/slitaz/boot/opt* \
|
pascal@17635
|
272 $mnt/slitaz/boot/README
|
pascal@17635
|
273 [ -d $mnt/slitaz/usr/sbin -a ! -x $mnt/slitaz/usr/sbin/mount.posixovl ] &&
|
pascal@17635
|
274 cp $(which mount.posixovl) $mnt/slitaz/usr/sbin
|
pascal@19033
|
275 if [ "$useposixovl" ] && grep -qs " $mnt " /proc/mounts &&
|
pascal@17932
|
276 [ ! -d $mnt/boot/grub ]; then
|
pascal@17929
|
277 mkdir -p $mnt/boot/grub
|
pascal@17930
|
278 echo -en "\nInstall grub in /boot/grub..."
|
pascal@17929
|
279 cp -a /usr/lib/grub/*/* $mnt/boot/grub
|
pascal@17929
|
280 cat > $mnt/boot/grub/menu.lst <<EOT
|
pascal@17929
|
281 # /boot/grub/menu.lst: GRUB boot loader configuration.
|
pascal@17929
|
282
|
pascal@17929
|
283 # By default, boot the first entry.
|
pascal@17929
|
284 default 0
|
pascal@17929
|
285
|
pascal@17929
|
286 # Boot automatically after 8 secs.
|
pascal@17929
|
287 timeout 8
|
pascal@17929
|
288
|
pascal@17929
|
289 title Microsoft Windows
|
pascal@17929
|
290 chainloader +1
|
pascal@17929
|
291
|
pascal@17929
|
292 EOT
|
pascal@17929
|
293 dev=$(grep " $mnt " /proc/mounts | awk '{ print $1 }')
|
pascal@17929
|
294 base=${dev//[0-9]/}
|
pascal@17929
|
295 dd if=$base bs=32k count=1 of=$mnt/boot/grub/$(basename $base)
|
pascal@17929
|
296 cat > $mnt/boot/grub/uninstall-grub.sh <<EOT
|
pascal@17929
|
297 #!/bin/sh
|
pascal@17929
|
298
|
pascal@17929
|
299 [ -s /boot/grub/$(basename $base) ] &&
|
pascal@17929
|
300 dd if=/boot/grub/$(basename $base) of=$base
|
pascal@17929
|
301 EOT
|
pascal@17929
|
302 grub-install --no-floppy --root-directory=$mnt $base
|
pascal@17929
|
303 fi
|
pascal@17932
|
304 if [ -s $mnt/boot/grub/menu.lst ] &&
|
pascal@20158
|
305 ! grep -q /slitaz/boot/$bzimage $mnt/boot/grub/menu.lst; then
|
pascal@20158
|
306 echo -en "\nUpdate /boot/grub/menu.lst..."
|
pascal@17932
|
307 cat >> $mnt/boot/grub/menu.lst <<EOT
|
pascal@17932
|
308 title SliTaz GNU/Linux $(cat $mnt/slitaz/etc/slitaz-release)
|
pascal@21822
|
309 kernel /slitaz/boot/$bzimage $extraargs autologin
|
pascal@17932
|
310 initrd /slitaz/boot/$initrd
|
pascal@17932
|
311
|
pascal@17932
|
312 EOT
|
pascal@17932
|
313 fi
|
pascal@17635
|
314 rm -f /tmp/wait
|
pascal@17932
|
315 [ "$useposixovl" ] && umount $mnt/slitaz
|
pascal@17635
|
316 return 0
|
pascal@17635
|
317 }
|
pascal@17635
|
318
|
pascal@17635
|
319 windev()
|
pascal@17635
|
320 {
|
pascal@17924
|
321 if [ -b "$1" ]; then
|
pascal@17924
|
322 device=$1
|
pascal@17928
|
323 elif [ "$1" ]; then
|
pascal@17932
|
324 echo "Invalid Linux/Windows partition"
|
pascal@17928
|
325 return 1
|
pascal@17924
|
326 else
|
pascal@17932
|
327 DEV="$(blkid | grep -iE "(msdos|vfat|ntfs|ext[234]|xfs|btrfs)" | sed 's/:.*//;s|/dev/||')"
|
pascal@17924
|
328 [ "$DEV" ] || return
|
pascal@17635
|
329 cat > /tmp/dialog$$ <<EOT
|
pascal@20771
|
330 $DIALOG --clear --title " Select your Linux/Windows partition " \
|
pascal@17932
|
331 --menu "\nPlease select the Linux/Windows partition according to its known size.
|
pascal@20771
|
332 The data will be kept untouched.\n" 17 70 8 \
|
pascal@17635
|
333 $(for i in $DEV ; do
|
pascal@17635
|
334 label="$(blkid | sed "/$i:/!d;s/.*://;s/[^ ]*UUID=[^ ]* //g;s/LABEL=//")"
|
pascal@17635
|
335 echo -n "/dev/$i \"$(($(cat /sys/block/*/$i/size)/2048))MB $label\" "
|
pascal@17635
|
336 done)
|
pascal@17635
|
337 EOT
|
pascal@17924
|
338 exec 3>&1
|
pascal@17924
|
339 [ $? -eq 0 ] || return
|
pascal@17924
|
340 device=$(. /tmp/dialog$$ 2>&1 1>&3)
|
pascal@17924
|
341 exec 3>&-
|
pascal@17924
|
342 rm -f /tmp/dialog$$
|
pascal@17924
|
343 fi
|
pascal@17635
|
344 mnt=/tmp/mnt$$
|
pascal@17635
|
345 mkdir -p $mnt && mount $device $mnt
|
pascal@17635
|
346 }
|
pascal@17635
|
347
|
pascal@17635
|
348 extra_packages()
|
pascal@17635
|
349 {
|
pascal@17635
|
350 packages_list=
|
pascal@17635
|
351 packages_dir=
|
pascal@20771
|
352 $DIALOG --clear --title " Extra packages " \
|
pascal@17635
|
353 --defaultno --yesno \
|
pascal@20771
|
354 "Do you want to add extra packages ?" 7 70
|
pascal@17635
|
355 [ $? -eq 0 ] || return
|
pascal@17635
|
356 [ -s /var/lib/tazpkg/packages.txt ] || tazpkg recharge
|
pascal@18240
|
357 if [ -s $media/boot/vmlinuz-$(uname -r) ]; then
|
pascal@17635
|
358 cat > /tmp/dialog$$ <<EOT
|
pascal@20771
|
359 $DIALOG --clear --title " Select the packages " \
|
pascal@17635
|
360 --separate-output \
|
pascal@17635
|
361 --cancel-label "Skip" \
|
pascal@17635
|
362 --checklist "Please select the packages you want to install. Try with the first letter." \
|
pascal@18240
|
363 0 0 0 \\
|
pascal@17635
|
364 EOT
|
pascal@17635
|
365 awk -F\| '{ printf "%s \"%s\" off ",$1,$3 }' \
|
pascal@17635
|
366 /var/lib/tazpkg/packages.desc >> /tmp/dialog$$
|
pascal@17635
|
367 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
|
pascal@17635
|
368 [ $? -eq 0 ] && packages_list="$(cat /tmp/dialog.out$$)"
|
pascal@17635
|
369 fi
|
pascal@17635
|
370 cat > /tmp/dialog$$ <<EOT
|
pascal@17635
|
371 $DIALOG --clear \
|
paul@17671
|
372 --title "Please select the directory with every custom package to install." \
|
pascal@20771
|
373 --cancel-label "Skip" --dselect $PWD 13 78
|
pascal@17635
|
374 EOT
|
pascal@17635
|
375 sh /tmp/dialog$$ 2> /tmp/dialog.out$$
|
pascal@17635
|
376 [ $? -eq 0 ] && packages_dir="$(cat /tmp/dialog.out$$)"
|
pascal@17635
|
377 rm -f /tmp/dialog$$ /tmp/dialog.out$$
|
pascal@17635
|
378 }
|
pascal@17635
|
379
|
pascal@17635
|
380 _install()
|
pascal@17635
|
381 {
|
pascal@17635
|
382 extra_packages
|
pascal@20771
|
383 $DIALOG --clear --title " SliTaz UMSDOS way installation " \
|
pascal@17635
|
384 --yes-label "Install" --yesno \
|
pascal@17635
|
385 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
|
paul@17935
|
386 Linux/DOS/Windows partition. You can see your files from /mnt/dos.\n\n
|
pascal@17635
|
387 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
|
pascal@17635
|
388 To uninstall SliTaz, you have only to remove this directory.
|
pascal@17635
|
389 The file \\boot.ini or \\config.sys may be modified too.\n\n
|
pascal@20771
|
390 SliTaz may run slowly on the 'UMSDOS way' installation due to the
|
pascal@17635
|
391 posixovl filesystem. The 'TAZUSB way' installation runs faster.\n\n
|
pascal@17635
|
392 To do a traditional installation with disk partitioning,
|
pascal@20771
|
393 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
|
pascal@17635
|
394 [ $? -eq 0 ] || return
|
pascal@17635
|
395 doinstall
|
pascal@17635
|
396 }
|
pascal@17635
|
397
|
pascal@17635
|
398 readtazbootconf()
|
pascal@17635
|
399 {
|
pascal@17635
|
400 kernel="$(sed '/^kernel=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
|
pascal@17635
|
401 initrd="$(sed '/^initrd=/!d;s/.*=//' $mnt/slitaz/boot/tazboot.cmd)"
|
pascal@17635
|
402 cmdline="$(sed '/^kernel=/d;/^initrd=/d' $mnt/slitaz/boot/tazboot.cmd)"
|
pascal@17635
|
403 }
|
pascal@17635
|
404
|
pascal@17635
|
405 bootinstalled()
|
pascal@17635
|
406 {
|
pascal@17635
|
407 [ "$(which kexec)" ] || return
|
pascal@17635
|
408 [ -x $mnt/slitaz$1 ] || return
|
pascal@17635
|
409 [ -s $mnt/slitaz/boot/tazboot.cmd ] || return
|
pascal@17635
|
410 readtazbootconf
|
pascal@17659
|
411 kexec -l $kernel --initrd $initrd --command-line "$cmdline" || return
|
pascal@17635
|
412 umount $mnt
|
pascal@17635
|
413 rm -rf $mnt
|
pascal@18240
|
414 quit "kexec -e"
|
pascal@17635
|
415 }
|
pascal@17635
|
416
|
pascal@17635
|
417 mkzip()
|
pascal@17635
|
418 {
|
pascal@17635
|
419 device=
|
pascal@17635
|
420 packages_list=
|
pascal@17635
|
421 packages_dir=
|
pascal@19029
|
422 mnt=/tmp/mkzipmnt$$
|
pascal@17635
|
423 mkdir -p $mnt
|
pascal@17930
|
424 $1 $2 || return
|
pascal@18140
|
425 for i in bootlace.com grubinst.exe grldr ; do
|
pascal@18140
|
426 wget -O $mnt/slitaz/boot/$i http://mirror.slitaz.org/boot/$i
|
pascal@18140
|
427 done
|
pascal@17635
|
428 readtazbootconf
|
pascal@17636
|
429 cat > $mnt/slitaz/boot/menu.lst <<EOT
|
pascal@17635
|
430 title SliTaz
|
pascal@17635
|
431 kernel $kernel $cmdline
|
pascal@17635
|
432 initrd $initrd
|
pascal@17635
|
433
|
pascal@17635
|
434 EOT
|
pascal@17635
|
435 while read file title; do
|
pascal@17637
|
436 file=$(ls $mnt/slitaz/boot/*$file* 2> /dev/null)
|
pascal@17637
|
437 [ -s "$file" ] && cat >> $mnt/slitaz/boot/menu.lst <<EOT
|
pascal@17635
|
438 title $title
|
pascal@17637
|
439 kernel ${file#$mnt}
|
pascal@17635
|
440
|
pascal@17635
|
441 EOT
|
pascal@17635
|
442 done <<EOT
|
pascal@17635
|
443 memtest MemTest
|
pascal@17635
|
444 pxe Web boot
|
pascal@17635
|
445 EOT
|
pascal@17636
|
446 unix2dos $mnt/slitaz/boot/menu.lst
|
pascal@17636
|
447 unix2dos > $mnt/slitaz/boot/install.txt <<EOT
|
pascal@17659
|
448 For DOS users (real mode only):
|
pascal@17659
|
449
|
pascal@17659
|
450 Start SliTaz with \\slitaz\\boot\\tazboot.exe
|
pascal@17659
|
451
|
pascal@17659
|
452
|
pascal@17635
|
453 For NT/2000/XP users:
|
pascal@17635
|
454
|
pascal@17635
|
455 1- Move the files grldr and menu.lst into the root directory
|
pascal@17635
|
456
|
pascal@17635
|
457 C:\\> copy \\slitaz\\boot\\grldr \\
|
pascal@17635
|
458 C:\\> copy \\slitaz\\boot\\menu.lst \\
|
pascal@17635
|
459
|
pascal@17635
|
460 2- Remove boot.ini attributes
|
pascal@17635
|
461
|
pascal@17635
|
462 C:\\> attrib -r -h -s boot.ini
|
pascal@17635
|
463
|
pascal@17635
|
464 3- Append the following line to boot.init
|
pascal@17635
|
465
|
pascal@17635
|
466 C:\\grldr="slitaz"
|
pascal@17635
|
467
|
pascal@17635
|
468 4- Restore boot.ini attributes
|
pascal@17635
|
469
|
pascal@17635
|
470 C:\\> attrib +r +h +s boot.ini
|
pascal@17635
|
471
|
pascal@17635
|
472 See http://diddy.boot-land.net/grub4dos/files/README_GRUB4DOS.txt
|
pascal@18140
|
473 and http://xpt.sourceforge.net/techdocs/nix/disk/boot/boot07-GrubForDosInfo/ar01s03.html
|
pascal@17635
|
474 EOT
|
pascal@18140
|
475 ( cd $mnt ; echo 'See \slitaz\boot\install.txt to launch SliTaz.' | \
|
pascal@18670
|
476 zip -zr9 $(basename "$ISO" .iso).zip slitaz )
|
pascal@19033
|
477 [ "$(which advzip)" ] &&
|
pascal@19033
|
478 echo "Recompressing $(basename "$ISO" .iso).zip ..." &&
|
pascal@19033
|
479 advzip -z4 $mnt/*.zip
|
pascal@17635
|
480 mv $mnt/*.zip .
|
pascal@19029
|
481 du -h $PWD/$(basename "$ISO" .iso).zip
|
pascal@17636
|
482 umount $mnt
|
pascal@17636
|
483 rm -rf $mnt
|
pascal@17635
|
484 }
|
pascal@17635
|
485
|
pascal@17635
|
486 install()
|
pascal@17635
|
487 {
|
pascal@17924
|
488 windev $1 || return
|
pascal@17635
|
489 packages_list=
|
pascal@17635
|
490 packages_dir=
|
pascal@17924
|
491 if [ "$1" ]; then
|
pascal@17924
|
492 doinstall
|
pascal@17924
|
493 else
|
pascal@17924
|
494 _install && bootinstalled /sbin/init
|
pascal@17924
|
495 fi
|
pascal@17635
|
496 umount $mnt
|
pascal@17635
|
497 rm -rf $mnt
|
pascal@17635
|
498 }
|
pascal@17635
|
499
|
pascal@17635
|
500 inst2zip()
|
pascal@17635
|
501 {
|
pascal@17924
|
502 if [ "$1" ]; then
|
pascal@17930
|
503 mkzip doinstall
|
pascal@17924
|
504 else
|
pascal@17924
|
505 mkzip _install
|
pascal@17924
|
506 fi
|
pascal@17635
|
507 }
|
pascal@17635
|
508
|
pascal@17635
|
509 _installtaz()
|
pascal@17635
|
510 {
|
pascal@20771
|
511 $DIALOG --clear --title " SliTaz TAZUSB way installation " \
|
pascal@17635
|
512 --yes-label "Install" --yesno \
|
pascal@17635
|
513 "\nSliTaz will be installed in the subdirectory \\slitaz of the current
|
paul@17935
|
514 Linux/DOS/Windows partition. You can see your files from /mnt/dos.\n\n
|
pascal@17635
|
515 You can start SliTaz with \\slitaz\\boot\\tazboot.exe\n\n
|
pascal@17635
|
516 To uninstall SliTaz, you have only to remove this directory.
|
pascal@17635
|
517 The file \\boot.ini or \\config.sys may be modified too.\n\n
|
pascal@17635
|
518 The filesystem is loaded entirely into memory upon boot to
|
paul@19451
|
519 increase responsiveness. Only /home lands on the hard disk.\n\n
|
pascal@17635
|
520 To do a traditional installation with disk partitioning,
|
pascal@20771
|
521 start SliTaz Live with the 'SliTaz RAM boot' menu.\n" 19 70
|
pascal@17635
|
522 [ $? -eq 0 ] || return
|
pascal@17635
|
523 doinstall tazusblike
|
pascal@17635
|
524 }
|
pascal@17635
|
525
|
pascal@17635
|
526 installtaz()
|
pascal@17635
|
527 {
|
pascal@17924
|
528 windev $1 || return
|
pascal@17635
|
529 packages_list=
|
pascal@17635
|
530 packages_dir=
|
pascal@17924
|
531 if [ "$1" ]; then
|
pascal@17924
|
532 doinstall tazusblike
|
pascal@17924
|
533 else
|
pascal@17924
|
534 _installtaz && bootinstalled /boot/bzimage
|
pascal@17924
|
535 fi
|
pascal@17635
|
536 umount $mnt
|
pascal@17635
|
537 rm -rf $mnt
|
pascal@17635
|
538 }
|
pascal@17635
|
539
|
pascal@17635
|
540 insttaz2zip()
|
pascal@17635
|
541 {
|
pascal@17924
|
542 if [ "$1" ]; then
|
pascal@17930
|
543 mkzip doinstall tazusblike
|
pascal@17924
|
544 else
|
pascal@17924
|
545 mkzip _installtaz
|
pascal@17924
|
546 fi
|
pascal@17635
|
547 }
|
pascal@17635
|
548
|
pascal@17635
|
549 bootiso()
|
pascal@17635
|
550 {
|
pascal@18799
|
551 cd /tmp
|
pascal@18240
|
552 for i in $(ls_r $media/boot/rootfs*gz); do
|
pascal@17635
|
553 grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64
|
pascal@17635
|
554 cat $i
|
pascal@17635
|
555 n=$((4 - ($(stat -c %s $i) % 4)))
|
pascal@17635
|
556 [ $n -eq 4 ] || dd if=/dev/zero bs=1 count=$n
|
pascal@18799
|
557 done > initrd$$
|
pascal@21822
|
558 cmdline="autologin lang=$LANG"
|
pascal@18799
|
559 [ -s /etc/keymap.conf ] && cmdline="$cmdline kmap=$(cat /etc/keymap.conf)"
|
pascal@18799
|
560 [ -s /etc/TZ ] && cmdline="$cmdline tz=$(cat /etc/TZ)"
|
pascal@18799
|
561 rm -f cmdline initrd 2> /dev/null
|
pascal@18799
|
562 getcustomconf kexec >/dev/null
|
pascal@18799
|
563 [ -s cmdline ] && cmdline="$cmdline $(cat cmdline)" && rm cmdline
|
pascal@18799
|
564 [ -s initrd ] && cat initrd >> initrd$$ && rm initrd
|
pascal@18240
|
565 kernel=$media/boot/bzImage
|
pascal@17635
|
566 grep -q ' lm ' /proc/cpuinfo && [ -s ${kernel}64 ] && kernel=${kernel}64
|
pascal@17635
|
567 . /etc/locale.conf
|
pascal@18799
|
568 kexec -l $kernel --initrd initrd$$ --command-line "$cmdline" &&
|
pascal@18799
|
569 rm -f initrd$$
|
pascal@18240
|
570 quit "kexec -e"
|
pascal@17635
|
571 }
|
pascal@17635
|
572
|
pascal@17635
|
573 tazboot()
|
pascal@17635
|
574 {
|
pascal@17928
|
575 if [ -z "$1" ]; then
|
pascal@20771
|
576 $DIALOG --clear --title " SliTaz bootloader for DOS " \
|
pascal@17928
|
577 --yes-label "Install" --yesno \
|
pascal@17635
|
578 "\nThe file TAZBOOT.EXE will be created in the top directory. It supports
|
pascal@17635
|
579 any linux kernel, multiple initramfs, a kernel command line and
|
pascal@17635
|
580 an ISO image file loopback (retrieves files from an ISO file).\n\n
|
pascal@20771
|
581 Usage: tazboot.exe [[@commands]|[kernel=<bzimage>]
|
pascal@17635
|
582 [initrd=<rootfs>[,<rootfs2>...]] [bootfrom=<isofile>] cmdline args ...]\n\n
|
pascal@17635
|
583 Defaults: tazboot @tazboot.cmd or tazboot kernel=bzImage auto\n\n\
|
pascal@17635
|
584 Examples for tazboot.cmd:\n\n\
|
pascal@17635
|
585 bootfrom=\\isos\\slitaz-4.0.iso\n\
|
pascal@17635
|
586 kernel=boot/bzImage\n\
|
pascal@17635
|
587 initrd=boot/rootfs4.gz,boot/rootfs3.gz,boot/rootfs2.gz,boot/rootfs1.gz\n\
|
pascal@21822
|
588 autologin\n\n\
|
pascal@17635
|
589 kernel=\\slitaz\\vmlinuz root=/dev/sda5 ro\n\n
|
pascal@20771
|
590 Unlike GRUB4DOS, it doesn't require unfragmented ISO image files.\n" 0 0
|
pascal@17928
|
591 [ $? -eq 0 ] || return
|
pascal@17928
|
592 fi
|
pascal@17635
|
593 gettazboot tazboot.exe
|
pascal@19029
|
594 du -h $PWD/tazboot.exe
|
pascal@17635
|
595 }
|
pascal@17635
|
596
|
pascal@17635
|
597 md5()
|
pascal@17635
|
598 {
|
pascal@17635
|
599 dotwait "Checking files"
|
pascal@19432
|
600 ( cd $media ; ${md5sum:-md5sum -c md5sum*} 2>&1 | sort ) > /tmp/data
|
pascal@17928
|
601 unset md5sum
|
pascal@17635
|
602 rm -f /tmp/wait
|
pascal@17928
|
603 if [ "$1" ]; then
|
pascal@17924
|
604 cat /tmp/data
|
pascal@17924
|
605 else
|
pascal@20771
|
606 $DIALOG --clear --title " Checked files " \
|
pascal@18240
|
607 --textbox /tmp/data 0 0
|
pascal@17924
|
608 fi
|
pascal@17635
|
609 rm -f /tmp/data
|
pascal@17635
|
610 }
|
pascal@17635
|
611
|
pascal@17635
|
612 gotcdfile()
|
pascal@17635
|
613 {
|
pascal@18240
|
614 for i in "$media/$1" "$media/*/$1" "$media/*/isolinux/$1" ; do
|
pascal@17635
|
615 file=$(ls $i 2> /dev/null | sed q)
|
pascal@17635
|
616 [ -s "$file" ] && break
|
pascal@17635
|
617 done
|
pascal@17635
|
618 }
|
pascal@17635
|
619
|
pascal@17635
|
620 sha()
|
pascal@17635
|
621 {
|
pascal@17635
|
622 gotcdfile 'sha*sum*'
|
pascal@17635
|
623 sha=$(basename $file)
|
pascal@18240
|
624 md5sum="${sha%sum*}sum -c ${file#$media/}"
|
pascal@17928
|
625 md5 $@
|
pascal@17635
|
626 }
|
pascal@17635
|
627
|
pascal@17635
|
628 readme()
|
pascal@17635
|
629 {
|
pascal@17635
|
630 gotcdfile 'README*'
|
pascal@17924
|
631 if [ "$1" ]; then
|
pascal@17924
|
632 cat $file
|
pascal@17924
|
633 else
|
pascal@20771
|
634 $DIALOG --clear --title " Readme " --textbox $file 0 0
|
pascal@17924
|
635 fi
|
pascal@17635
|
636 }
|
pascal@17635
|
637
|
pascal@17635
|
638 bzimage()
|
pascal@17635
|
639 {
|
pascal@17928
|
640 if [ -z "$1" ]; then
|
pascal@20771
|
641 $DIALOG --clear --title " Create linux.exe ? " \
|
pascal@17924
|
642 --yes-label "Install" --yesno \
|
pascal@17635
|
643 "\nLinux.exe launches the linux kernel under DOS (in real mode only).
|
pascal@17635
|
644 The cmdline arguments are supported except initrd=,
|
pascal@17635
|
645 vga= (you can try 'rdev -v') and mem= (partially).
|
pascal@20771
|
646 \nExample:\nC:\\> linux.exe root=/dev/hda2 ro panic=60\n" 12 70
|
pascal@17924
|
647 [ $? -eq 0 ] || return
|
pascal@17924
|
648 fi
|
pascal@18240
|
649 cp $media/boot/bzImage linux.exe
|
pascal@19029
|
650 du -h $PWD/linux.exe
|
pascal@17635
|
651 }
|
pascal@17635
|
652
|
pascal@17635
|
653 memtest()
|
pascal@17635
|
654 {
|
pascal@17924
|
655 if [ -z "$1" ]; then
|
pascal@20771
|
656 $DIALOG --clear --title " Create memtest.exe ? " \
|
pascal@17924
|
657 --yes-label "Install" --yesno \
|
pascal@17635
|
658 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
|
pascal@17635
|
659 computers. BIOS based memory tests are a quick, cursory check and often
|
pascal@20771
|
660 miss many of the failures that are detected by Memtest86.\n" 0 0
|
pascal@17924
|
661 [ $? -eq 0 ] || return
|
pascal@17924
|
662 fi
|
pascal@17924
|
663 gotcdfile 'memtest*' && cp $file memtest.exe
|
pascal@19029
|
664 du -h $PWD/memtest.exe
|
pascal@17635
|
665 }
|
pascal@17635
|
666
|
pascal@17635
|
667 mkfat12()
|
pascal@17635
|
668 {
|
pascal@17635
|
669 [ $(($(get 0 $1) - 0x5A4D)) -eq 0 ] || return
|
pascal@17635
|
670 J=$(($(get 3 $1 1) + 0x02))
|
pascal@17635
|
671 R=$((1 + $(get 497 $1 1) + 1 + ($(get 500 $1)-1)/32))
|
pascal@17635
|
672 [ $R -lt 2500 ] || return
|
pascal@17635
|
673 [ $((($(get 500 $1)-1) & 31)) -lt 30 ] &&
|
pascal@17635
|
674 ddq if=$file bs=32 count=1 seek=$(($R*16 - 1)) of=/dev/fd0
|
pascal@17635
|
675 G="18 0 2 0 0 0 0 0"
|
pascal@17635
|
676 [ $J -gt 25 ] || G=""
|
pascal@17635
|
677 F=0
|
pascal@17635
|
678 for i in 1 2 3; do
|
pascal@17635
|
679 F=$((((2880-$R-$F-$F)*3+1023)/1024))
|
pascal@17635
|
680 done
|
pascal@17635
|
681 bytes2bin 0xEB $J 0x90 0x20 0x20 0x20 0x20 0x20 0x20 0x20 0x20 \
|
pascal@17635
|
682 0 2 2 $(($R%256)) $(($R/256)) 2 64 0 64 11 0xF0 $F 0 \
|
pascal@17635
|
683 $G | ddq bs=1 of=/dev/fd0
|
pascal@17635
|
684 ddq if=/dev/zero bs=512 count=$((4+$F+$F)) seek=$R of=/dev/fd0
|
pascal@17635
|
685 for i in $R $(($R+$F)) ; do
|
pascal@17635
|
686 bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0
|
pascal@17635
|
687 done
|
pascal@17635
|
688 echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0
|
pascal@17635
|
689 }
|
pascal@17635
|
690
|
pascal@17635
|
691 mkfloppy()
|
pascal@17635
|
692 {
|
pascal@21542
|
693 dotwait "Create a $(basename $1 .exe) boot floppy"
|
pascal@17635
|
694 ddq if=$1 of=/dev/fd0
|
pascal@17635
|
695 mkfat12 $1
|
pascal@17635
|
696 rm -f /tmp/wait
|
pascal@17635
|
697 }
|
pascal@17635
|
698
|
pascal@17635
|
699 fdmemtest()
|
pascal@17635
|
700 {
|
pascal@17924
|
701 if [ -z "$1" ]; then
|
pascal@20771
|
702 $DIALOG --clear --title " Create a Memtest86 boot floppy " \
|
pascal@17924
|
703 --yes-label "Create floppy" --yesno \
|
pascal@17635
|
704 "\nMemtest86 is a thorough, stand alone memory test for x86 architecture
|
pascal@17635
|
705 computers. BIOS based memory tests are a quick, cursory check and often
|
pascal@17635
|
706 miss many of the failures that are detected by Memtest86.\n\n
|
pascal@20771
|
707 Please insert a blank disk in floppy drive.\n" 0 0
|
pascal@17924
|
708 [ $? -eq 0 ] || return
|
pascal@17924
|
709 fi
|
pascal@17924
|
710 gotcdfile 'memtest*' && mkfloppy $file
|
pascal@17635
|
711 }
|
pascal@17635
|
712
|
pascal@17635
|
713 pxe()
|
pascal@17635
|
714 {
|
pascal@20762
|
715 gotcdfile '?pxe*'
|
pascal@17928
|
716 if [ -z "$1" ]; then
|
pascal@21542
|
717 $DIALOG --clear --title " Create $(basename $file .exe).exe ? " \
|
pascal@17928
|
718 --yes-label "Install" --yesno \
|
pascal@17635
|
719 "\nBoot your operating system from the internet and enjoy a full system
|
pascal@17635
|
720 working entirely in RAM with speed and stability in mind. The Linux Kernel
|
pascal@17635
|
721 and the complete SliTaz compressed root filesystem will be loaded into RAM
|
pascal@20771
|
722 from the Web using PXE and HTTP protocols.\n" 0 0
|
pascal@17928
|
723 [ $? -eq 0 ] || return
|
pascal@17928
|
724 fi
|
pascal@21542
|
725 cp $file $(basename $file .exe).exe
|
pascal@21542
|
726 du -h $PWD/$(basename $file .exe).exe
|
pascal@17635
|
727 }
|
pascal@17635
|
728
|
pascal@17635
|
729 fdpxe()
|
pascal@17635
|
730 {
|
pascal@17924
|
731 if [ -z "$1" ]; then
|
pascal@20771
|
732 $DIALOG --clear --title " Create a SliTaz Web boot floppy " \
|
pascal@17924
|
733 --yes-label "Create floppy" --yesno \
|
pascal@17635
|
734 "\nBoot your operating system from the internet and enjoy a full system
|
pascal@17635
|
735 working entirely in RAM with speed and stability in mind. The Linux Kernel
|
pascal@17635
|
736 and the complete SliTaz compressed root filesystem will be loaded into RAM
|
pascal@17635
|
737 from the Web using PXE and HTTP protocols.\n\n
|
pascal@20771
|
738 Please insert a blank disk in floppy drive.\n" 0 0
|
pascal@17924
|
739 [ $? -eq 0 ] || return
|
pascal@17924
|
740 fi
|
pascal@20762
|
741 gotcdfile '?pxe*' && mkfloppy $file
|
pascal@17924
|
742 }
|
pascal@17924
|
743
|
pascal@17924
|
744 menuitem()
|
pascal@17924
|
745 {
|
pascal@17924
|
746 [ "$3" ] && shift
|
pascal@17924
|
747 echo -en "\"$1\" \"$2\""
|
pascal@17635
|
748 }
|
pascal@17635
|
749
|
pascal@17635
|
750 gotposixovl()
|
pascal@17635
|
751 {
|
pascal@19425
|
752 mount.posixovl 2>&1 | grep -qi usage && gotcdfile 'rootfs*.gz' &&
|
pascal@19425
|
753 menuitem "$@"
|
pascal@17635
|
754 }
|
pascal@17635
|
755
|
pascal@17635
|
756 gotposixovlzip()
|
pascal@17635
|
757 {
|
pascal@17635
|
758 [ "$(which zip)" ] && gotposixovl "$1" "$2"
|
pascal@17635
|
759 }
|
pascal@17635
|
760
|
pascal@17635
|
761 xfile()
|
pascal@17635
|
762 {
|
pascal@17924
|
763 [ "$(which $1)" ] && menuitem "$@"
|
pascal@17635
|
764 }
|
pascal@17635
|
765
|
pascal@17635
|
766 cdfile()
|
pascal@17635
|
767 {
|
pascal@17924
|
768 gotcdfile "$1" && menuitem "$@"
|
pascal@17635
|
769 }
|
pascal@17635
|
770
|
pascal@19425
|
771 gottazusb()
|
pascal@19425
|
772 {
|
pascal@19425
|
773 gotcdfile 'rootfs*.gz' && xfile tazusb "$@"
|
pascal@19425
|
774 }
|
pascal@19425
|
775
|
pascal@17659
|
776 isbzImage()
|
pascal@17659
|
777 {
|
pascal@17659
|
778 [ $(get 514 $file 4) -eq 1400005704 ] &&
|
pascal@17659
|
779 [ $(($(get 529 $file 1) & 1)) -eq 1 ]
|
pascal@17659
|
780 }
|
pascal@17659
|
781
|
pascal@17635
|
782 cdfilex()
|
pascal@17635
|
783 {
|
pascal@17924
|
784 gotcdfile "$1" && [ "$(which kexec)" ] && isbzImage && menuitem "$@"
|
pascal@17635
|
785 }
|
pascal@17635
|
786
|
pascal@17635
|
787 cdfilef()
|
pascal@17635
|
788 {
|
pascal@17635
|
789 [ -e /sys/block/fd0 ] && cdfile "$@"
|
pascal@17635
|
790 }
|
pascal@17635
|
791
|
pascal@17635
|
792 cdexe()
|
pascal@17635
|
793 {
|
pascal@17635
|
794 gotcdfile "$1" &&
|
pascal@17635
|
795 [ $(get 0 $file 2>/dev/null || echo 0) -eq 23117 ] &&
|
pascal@17924
|
796 menuitem "$@"
|
pascal@17635
|
797 }
|
pascal@17635
|
798
|
pascal@17635
|
799 misspkg()
|
pascal@17635
|
800 {
|
pascal@19029
|
801 for i in zip kexec-tools posixovl cdrkit cdrkit-isoinfo ; do
|
pascal@17635
|
802 [ -d /var/lib/tazpkg/installed/$i/ ] && continue
|
pascal@17924
|
803 [ "$1" != "install" ] && menuitem "$@" && return
|
pascal@17635
|
804 tazpkg get-install $i
|
pascal@17635
|
805 done
|
pascal@17635
|
806 }
|
pascal@17635
|
807
|
pascal@17635
|
808 missing()
|
pascal@17635
|
809 {
|
pascal@17635
|
810 misspkg install
|
pascal@17635
|
811 }
|
pascal@17635
|
812
|
pascal@17635
|
813 ishybrid()
|
pascal@17635
|
814 {
|
pascal@18670
|
815 [ $(get 510 "$ISO") -eq 43605 ] || return
|
pascal@18670
|
816 C=$((2048*$(get $(((17*2048) + 71)) "$ISO" 4)))
|
pascal@18670
|
817 [ $(get $C "$ISO" 4) -eq 1 ] || return
|
pascal@18670
|
818 [ $(get $(($C+30)) "$ISO" 4) -eq $((0x88AA55)) ] || return
|
pascal@18670
|
819 C=$((2048*$(get $(($C+40)) "$ISO" 4)))
|
pascal@18670
|
820 [ $(get $(($C+64)) "$ISO" 4) -eq 1886961915 ] && menuitem "$@"
|
pascal@17635
|
821 }
|
pascal@17635
|
822
|
pascal@17635
|
823 isiso()
|
pascal@17635
|
824 {
|
pascal@18670
|
825 [ $(get 32769 "$ISO" 4) -eq 808469571 ] && menuitem "$@"
|
pascal@18140
|
826 }
|
pascal@18140
|
827
|
pascal@18140
|
828 hastazboot()
|
pascal@18140
|
829 {
|
pascal@18670
|
830 [ $(get 0 "$ISO") -eq 23117 ] && menuitem "$@"
|
pascal@18034
|
831 }
|
pascal@18034
|
832
|
pascal@18034
|
833 burnable()
|
pascal@18034
|
834 {
|
pascal@19510
|
835 [ "$(sed '/Can wr.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] &&
|
pascal@19510
|
836 menuitem "$@"
|
pascal@18034
|
837 }
|
pascal@18034
|
838
|
pascal@18034
|
839 blankable()
|
pascal@18034
|
840 {
|
pascal@19510
|
841 [ "$(sed '/Can wr.*RW.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] &&
|
pascal@19510
|
842 menuitem "$@"
|
pascal@18034
|
843 }
|
pascal@18034
|
844
|
pascal@18034
|
845 burniso()
|
pascal@18034
|
846 {
|
pascal@18034
|
847 wodim -v speed=$(fgrep "drive speed" /proc/sys/dev/cdrom/info | cut -f3) \
|
pascal@18034
|
848 -eject -multi "$ISO"
|
pascal@18034
|
849 }
|
pascal@18034
|
850
|
pascal@18034
|
851 blankcd()
|
pascal@18034
|
852 {
|
pascal@18034
|
853 wodim -v -blank=fast
|
pascal@17635
|
854 }
|
pascal@17635
|
855
|
pascal@18675
|
856 customsector()
|
pascal@18675
|
857 {
|
pascal@19324
|
858 local c=$(echo $(get 32848 "$ISO" 4))
|
pascal@19324
|
859 hascustomconf $(($c+16)) && echo $(($c+16)) || echo $c
|
pascal@18675
|
860 }
|
pascal@18675
|
861
|
pascal@18675
|
862 hascustomconf()
|
pascal@18675
|
863 {
|
pascal@19324
|
864 [ "$(ddq bs=2k skip=${1:-$(customsector)} if="$ISO" | ddq bs=1 count=6)" \
|
pascal@20892
|
865 = "#!boot" ]
|
pascal@18675
|
866 }
|
pascal@18675
|
867
|
pascal@18675
|
868 gotcustomconf()
|
pascal@18675
|
869 {
|
pascal@18675
|
870 hascustomconf && menuitem "$@"
|
pascal@18675
|
871 }
|
pascal@18675
|
872
|
pascal@19425
|
873 hasflavor()
|
pascal@19425
|
874 {
|
pascal@19425
|
875 [ -x /usr/bin/tazlito ] && [ -s $media/boot/bzImage ] && menuitem "$@"
|
pascal@19425
|
876 }
|
pascal@19425
|
877
|
pascal@17635
|
878 gotisomd5()
|
pascal@17635
|
879 {
|
pascal@17635
|
880 [ "$(which md5sum 2> /dev/null)" ] &&
|
pascal@18670
|
881 [ $(get 0 "$ISO") -eq 23117 ] &&
|
pascal@18670
|
882 [ $(get 18 "$ISO") -ne 0 ] && menuitem "$@"
|
pascal@17635
|
883 }
|
pascal@17635
|
884
|
pascal@18675
|
885 getcustomconf()
|
pascal@18675
|
886 {
|
pascal@18675
|
887 ddq bs=2k skip=$(customsector) if="$ISO" | while read line; do
|
pascal@18675
|
888 case "$line" in
|
pascal@18675
|
889 \#!boot*) ;;
|
pascal@18675
|
890 append=*) echo ${line#append=} > cmdline && ls -l $PWD/cmdline ;;
|
pascal@18675
|
891 initrd:*) cnt=${line#initrd:}
|
pascal@18675
|
892 { ddq bs=512 count=$(($cnt / 512));
|
pascal@18675
|
893 ddq bs=1 count=$(($cnt % 512)); } > initrd &&
|
pascal@18675
|
894 ls -l $PWD/initrd
|
pascal@18675
|
895 break ;;
|
pascal@20771
|
896 *) break ;;
|
pascal@18675
|
897 esac
|
pascal@18675
|
898 done
|
pascal@18675
|
899 [ "$1" ] && return 0
|
pascal@18675
|
900 echo -e "\rPress RETURN to continue."
|
pascal@18675
|
901 read n
|
pascal@18675
|
902 }
|
pascal@18675
|
903
|
pascal@17635
|
904 isomd5()
|
pascal@17635
|
905 {
|
pascal@17635
|
906 dotwait "Checking iso image"
|
pascal@18670
|
907 [ "$(ddq if="$ISO" bs=2k skip=16 \
|
pascal@20892
|
908 count=$(($(get 32848 "$ISO" 4)-16)) | md5sum)" = \
|
pascal@18670
|
909 "$(ddq if="$ISO" bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
|
pascal@17635
|
910 sed 's/ //g') -" ] && echo "OK" || echo "ERROR"
|
pascal@17635
|
911 echo -en "\rChecking iso hybrid boot..."
|
pascal@18671
|
912 n=$(($(get 2 "$ISO")-1+($(get 4 "$ISO")-1)*512))
|
pascal@17635
|
913 if [ $n -lt 40000 -a $n -gt 32768 ]; then
|
pascal@18670
|
914 s=$(get 0 "$ISO" 2 $n | awk '{ i+= $0 } END { print i }')
|
pascal@18670
|
915 [ $(((1+$s+$(get $(($n+1)) "$ISO" 1)) % 65536)) -eq 0 ] &&
|
pascal@17635
|
916 echo "OK" || echo "ERROR"
|
pascal@17635
|
917 fi
|
pascal@18675
|
918 if hascustomconf; then
|
pascal@18672
|
919 echo -en "\rChecking iso custom config..."
|
pascal@18672
|
920 TMP=/tmp/$(basename $0)$$md5
|
pascal@18675
|
921 md5="$(ddq bs=2k skip=$(customsector) if="$ISO" | while read line; do
|
pascal@18670
|
922 case "$line" in
|
pascal@18672
|
923 \#!boot*) echo ${line#*boot } > $TMP ;;
|
pascal@18670
|
924 append=*) echo $line ;;
|
pascal@18670
|
925 initrd:*) echo $line
|
pascal@18675
|
926 cnt=${line#initrd:}
|
pascal@18675
|
927 ddq bs=512 count=$((cnt / 512))
|
pascal@18675
|
928 ddq bs=1 count=$((cnt % 512))
|
pascal@18670
|
929 break ;;
|
pascal@20771
|
930 *) break ;;
|
pascal@18670
|
931 esac
|
pascal@18670
|
932 done | md5sum | cut -c1-32)"
|
pascal@20892
|
933 [ "$md5" = "$(cat $TMP)" ] && echo "OK" || echo "ERROR"
|
pascal@18672
|
934 rm -f $TMP
|
pascal@18670
|
935 fi
|
pascal@17635
|
936 rm -f /tmp/wait
|
pascal@17928
|
937 [ "$1" ] && return 0
|
pascal@17635
|
938 echo -e "\rPress RETURN to continue."
|
pascal@17635
|
939 read n
|
pascal@17635
|
940 }
|
pascal@17635
|
941
|
pascal@17635
|
942 usbdev()
|
pascal@17635
|
943 {
|
pascal@17635
|
944 dotwait "Wait 5 seconds for USB devices"
|
pascal@17635
|
945 sleep 5
|
pascal@17635
|
946 rm -f /tmp/wait
|
pascal@17635
|
947 DEV="$(grep -l 1 /sys/block/*/removable | \
|
pascal@17635
|
948 sed 's|/sys/block/\(.*\)/removable|\1|')"
|
pascal@17635
|
949 grep -qs 1 /sys/block/$DEV/ro && return
|
pascal@17635
|
950 [ "$DEV" ] || return
|
pascal@17635
|
951 cat > /tmp/dialog$$ <<EOT
|
pascal@20771
|
952 $DIALOG --clear --title " Select your USB key " \
|
pascal@17635
|
953 --menu "\nPlease select the USB key according to its known size.\n\n" \
|
pascal@18240
|
954 0 0 0 \
|
pascal@17635
|
955 $(for i in $DEV ; do
|
pascal@17635
|
956 echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2> /dev/null)\" "
|
pascal@17635
|
957 done) \
|
pascal@17635
|
958
|
pascal@17635
|
959 EOT
|
pascal@17635
|
960 exec 3>&1
|
pascal@17635
|
961 device=$(. /tmp/dialog$$ 2>&1 1>&3)
|
pascal@17635
|
962 rm -f /tmp/dialog$$
|
pascal@17635
|
963 retval=$?
|
pascal@17635
|
964 exec 3>&-
|
pascal@17635
|
965 rm -f /tmp/dialog$$
|
pascal@17635
|
966 [ $retval -eq 0 ]
|
pascal@17635
|
967 }
|
pascal@17635
|
968
|
pascal@17635
|
969 tazusbmsg()
|
pascal@17635
|
970 {
|
pascal@17635
|
971 [ "$(which tazusb 2> /dev/null)" ] || return
|
pascal@17635
|
972 echo "You should choose 'USB key read/write installation' to be
|
pascal@17635
|
973 able to save the package updates or your own configuration and data files.\n\n"
|
pascal@17635
|
974 }
|
pascal@17635
|
975
|
pascal@17635
|
976 usbbootkey()
|
pascal@17635
|
977 {
|
pascal@17924
|
978 if [ -b "$1" ]; then
|
pascal@17924
|
979 device=$1
|
pascal@17928
|
980 elif [ "$1" ]; then
|
pascal@17928
|
981 echo "Invalid USB key device"
|
pascal@20771
|
982 return 1
|
pascal@17924
|
983 else
|
pascal@20771
|
984 $DIALOG --clear --title " Create a USB boot key " \
|
pascal@17924
|
985 --yes-label "Continue" --yesno \
|
pascal@17635
|
986 "\nThe USB key will be used like a CD-ROM. You will not be able to write
|
pascal@17635
|
987 any data on the boot partition.\n\n
|
pascal@17635
|
988 An extra FAT32 partition will be created with the remaining free space.\n\n
|
pascal@20771
|
989 $(tazusbmsg)Please plug your USB stick in now.\n" 16 70
|
pascal@17924
|
990 [ $? -eq 0 ] || return
|
pascal@17924
|
991 usbdev || return
|
pascal@17635
|
992
|
pascal@17924
|
993 # perform dd in progress bar
|
pascal@18670
|
994 max=$(($(stat -c %s "$ISO")/2048))
|
pascal@20771
|
995 i=0; ddq if="$ISO" bs=1024k | (
|
pascal@20771
|
996 while ddq bs=1024k count=1 ; do
|
pascal@17924
|
997 i=$(($i + 1))
|
pascal@17924
|
998 [ $i -gt $max ] && break
|
pascal@17924
|
999 echo $((($i*100)/$max)) | dialog --gauge \
|
pascal@17924
|
1000 " The ISO image transfer can be long. Please wait..." \
|
pascal@17924
|
1001 6 70 0 > /dev/tty 2>&1
|
pascal@17924
|
1002 done ) > $device
|
pascal@17924
|
1003 fi
|
pascal@17635
|
1004
|
paul@17671
|
1005 # partition + fat32 format for the remaining space
|
pascal@17860
|
1006 for p in 0 16; do
|
pascal@17860
|
1007 get $((450+$p)) $device 2 12 | xargs echo | {
|
pascal@17860
|
1008 read dx cx ol oh ll lh
|
pascal@17860
|
1009 [ $dx -eq $((0x3F17)) ] || continue
|
pascal@17635
|
1010 cx=$(($cx & 0xFF00))
|
pascal@17635
|
1011 ofs=$(($ll+($lh<<16)))
|
pascal@17635
|
1012 n=$(($(cat /sys/block/${device#/dev/}/size)-$ofs))
|
pascal@17635
|
1013 m=$(($cx+($n/8)))
|
pascal@17635
|
1014 [ $m -gt $((0x3FF00)) ] && m=$((0x3FF00))
|
pascal@17635
|
1015 m=$((($m & 0xFF00)+(($m>>16)<<6)))
|
pascal@17635
|
1016 words2bin 0 $((0x101+$cx)) 0x3F0B $((32+$m)) \
|
pascal@17635
|
1017 $ll $lh $(($n & 0xFFFF)) $(($n >> 16)) | \
|
pascal@17860
|
1018 ddq bs=1 seek=$((462-$p)) of=$device
|
pascal@17635
|
1019 if [ "$(which mkdosfs 2> /dev/null)" ]; then
|
pascal@17635
|
1020 losetup -o $((512*$ofs)) /dev/loop2 $device
|
pascal@17635
|
1021 mkdosfs -n "SLITAZ BOOT" /dev/loop2
|
pascal@17635
|
1022 words2bin $(($ofs & 0xFFFF)) $(($ofs >> 16)) | \
|
pascal@17635
|
1023 ddq bs=1 seek=28 of=/dev/loop2
|
pascal@17860
|
1024 sync
|
pascal@17635
|
1025 losetup -d /dev/loop2
|
pascal@17635
|
1026 fi
|
pascal@17860
|
1027 }
|
pascal@17860
|
1028 done
|
pascal@17635
|
1029 }
|
pascal@17635
|
1030
|
pascal@17635
|
1031 usbkey()
|
pascal@17635
|
1032 {
|
pascal@20771
|
1033 $DIALOG --clear --title " Create a SliTaz USB key " \
|
pascal@17635
|
1034 --yes-label "Continue" --yesno \
|
pascal@17635
|
1035 "\nUnlike a hard drive install, the filesystem is kept in a compressed
|
pascal@17635
|
1036 rootfs.gz. The filesystem is loaded entirely into memory upon boot.
|
pascal@17635
|
1037 This should increase responsiveness, protect the filesystem against
|
pascal@17635
|
1038 accidental corruption and reduce read/writes to the USB drive.
|
pascal@17635
|
1039 Once setup, the tazusb utility can rewrite the root filesystem
|
pascal@20771
|
1040 with any changes you have made since booting up,
|
pascal@17635
|
1041 giving the effective benefits of a hard drive install.\n\n
|
pascal@17635
|
1042 /home is mounted on boot using the UUID of your particular flash drive.
|
pascal@17635
|
1043 Unlike a device name, the UUID has the benefit of never changing from machine
|
pascal@17635
|
1044 to machine.\n\n
|
pascal@20771
|
1045 Please plug your USB stick in now.\n" 19 70
|
pascal@17635
|
1046 [ $? -eq 0 ] || return
|
pascal@17635
|
1047 usbdev || return
|
pascal@17635
|
1048 exec 3>&1
|
pascal@17635
|
1049 format=`$DIALOG --clear \
|
pascal@17635
|
1050 --title " Select the filesystem " \
|
pascal@17635
|
1051 --radiolist "\nPlease select the filesystem type to create.\n\n\
|
pascal@20771
|
1052 The filesystem creation will erase all the data in the USB key." 14 70 4 \
|
pascal@17635
|
1053 "none" "Do not erase the USB key" on \
|
pascal@17635
|
1054 "ext3" "Ext3 journaling filesystem" off \
|
pascal@17635
|
1055 "ext2" "Ext2 filesystem" off \
|
pascal@17635
|
1056 "fat32" "Windows FAT32 filesystem" off \
|
pascal@17635
|
1057 2>&1 1>&3`
|
pascal@17635
|
1058 retval=$?
|
pascal@17635
|
1059 exec 3>&-
|
pascal@17635
|
1060 [ $retval -eq 0 ] || return
|
pascal@17635
|
1061 [ "$format" != "none" ] && tazusb format $device "SliTaz" $format
|
pascal@18670
|
1062 tazusb gen-iso2usb "$ISO" $device
|
pascal@17635
|
1063 }
|
pascal@17635
|
1064
|
pascal@17635
|
1065 dokexec()
|
pascal@17635
|
1066 {
|
pascal@17659
|
1067 kexec -l $file || return
|
pascal@18240
|
1068 quit "kexec -e"
|
pascal@17635
|
1069 }
|
pascal@17635
|
1070
|
pascal@17635
|
1071 runmemtest()
|
pascal@17635
|
1072 {
|
pascal@17635
|
1073 gotcdfile 'memtest*' && dokexec
|
pascal@17635
|
1074 }
|
pascal@17635
|
1075
|
pascal@17635
|
1076 runpxe()
|
pascal@17635
|
1077 {
|
pascal@20762
|
1078 gotcdfile '?pxe*' && dokexec
|
pascal@17635
|
1079 }
|
pascal@17635
|
1080
|
pascal@17931
|
1081 flavdata()
|
pascal@17931
|
1082 {
|
pascal@18670
|
1083 [ $(get 1024 "$ISO") -eq 35615 ] && n=2 || n=$((1+$(get 417 "$ISO" 1)))
|
pascal@19425
|
1084 [ $n -eq 4 ] && n=20
|
pascal@20724
|
1085 [ $(get $(($n*512)) "$ISO") -eq 35615 ] || n=13
|
pascal@19510
|
1086 ddq if="$ISO" bs=512 skip=$n count=20 | zcat 2>/dev/null
|
pascal@17931
|
1087 }
|
pascal@17931
|
1088
|
pascal@17931
|
1089 hasflavinfo()
|
pascal@17931
|
1090 {
|
pascal@20892
|
1091 [ "$(flavdata | ddq bs=1 count=7 | strings)" = \
|
pascal@20724
|
1092 "0707010" ] && menuitem "$@"
|
pascal@17931
|
1093 }
|
pascal@17931
|
1094
|
pascal@17931
|
1095 showfavinfo()
|
pascal@17931
|
1096 {
|
pascal@17931
|
1097 mkdir -p /tmp/data
|
pascal@17931
|
1098 flavdata | ( cd /tmp/data ; cpio -i )
|
pascal@17931
|
1099 file=/tmp/data/info
|
pascal@17931
|
1100 cat /tmp/data/*desc > $file
|
pascal@18627
|
1101 if [ -s /tmp/data/*receipt ]; then
|
pascal@18627
|
1102 echo "=== receipt ==="
|
pascal@18627
|
1103 cat /tmp/data/*receipt
|
pascal@18627
|
1104 fi >> $file
|
pascal@17931
|
1105 for i in /tmp/data/*list* ; do
|
pascal@17931
|
1106 echo "=== extra ${i#*list} files"
|
pascal@17931
|
1107 cat $i
|
pascal@17931
|
1108 done >> $file
|
pascal@17931
|
1109 if [ "$1" ]; then
|
pascal@17931
|
1110 cat $file
|
pascal@17931
|
1111 else
|
pascal@20771
|
1112 $DIALOG --clear --title " Flavor info " \
|
pascal@18240
|
1113 --textbox $file 0 0
|
pascal@17931
|
1114 fi
|
pascal@17931
|
1115 rm -rf /tmp/data
|
pascal@17931
|
1116 }
|
pascal@17931
|
1117
|
pascal@18626
|
1118 flavor()
|
pascal@18626
|
1119 {
|
pascal@18626
|
1120 name="$(flavdata | cpio -t 2> /dev/null | sed 's/.[a-z]*$//;q')"
|
pascal@18626
|
1121 echo "Create ${name:=flavor}.flavor..."
|
pascal@18670
|
1122 tazlito iso2flavor "$ISO" $name
|
pascal@18771
|
1123 ls -l $name.flavor 2> /dev/null && return
|
pascal@18771
|
1124 sleep 5
|
pascal@18771
|
1125 [ "$1" ] && return
|
pascal@18771
|
1126 echo -e "\rPress RETURN to continue."
|
pascal@18771
|
1127 read n
|
pascal@18626
|
1128 }
|
pascal@18626
|
1129
|
pascal@20892
|
1130 if [ "$1" = "--build" ]; then #install-begin
|
pascal@18151
|
1131 uuencode -m - < ifmem.bin | sed -e '/^ifmemcode$/r/dev/stdin' \
|
pascal@18151
|
1132 -e '/^ifmemcode$/d' -i $0
|
pascal@18140
|
1133 uuencode -m - < bootloader.bin | sed -e '/^bootloader$/r/dev/stdin' \
|
pascal@18140
|
1134 -e '/^bootloader$/d' -e '/install-begin$/,/install-end$/d' -i $0
|
pascal@18140
|
1135 exit
|
pascal@18140
|
1136 fi #install-end
|
pascal@18140
|
1137 parse_isolinux()
|
pascal@18140
|
1138 {
|
pascal@18140
|
1139 awk 'BEGIN { IGNORECASE=1 }
|
pascal@18145
|
1140 function multi(n)
|
pascal@18145
|
1141 {
|
pascal@18145
|
1142 auto=$n
|
pascal@18145
|
1143 for (--n; n < NF; n+=2) {
|
pascal@18145
|
1144 s=$n
|
pascal@18145
|
1145 if (s ~ /M$/) s = substr(s,0,length(s)-1)
|
pascal@18145
|
1146 else s /= 1024
|
pascal@18145
|
1147 sizes=int(s) " " sizes
|
pascal@18145
|
1148 }
|
pascal@18145
|
1149 next
|
pascal@18145
|
1150 }
|
pascal@18140
|
1151 {
|
pascal@18140
|
1152 if ($1 == "LABEL") {
|
pascal@18140
|
1153 label=$2
|
pascal@18140
|
1154 if (auto == "") auto=label
|
pascal@18140
|
1155 }
|
pascal@18140
|
1156 if ($1 == "KERNEL" || $1 == "COM32") kernel[label]=$2
|
pascal@18140
|
1157 if ($1 == "INITRD") initrd[label]=$2
|
pascal@18140
|
1158 if ($1 == "APPEND") {
|
pascal@18140
|
1159 i=2
|
pascal@18145
|
1160 if (kernel[label] ~ "ifmem.c32") multi(3)
|
pascal@18140
|
1161 if (kernel[label] ~ "c32box.c32") {
|
pascal@18140
|
1162 if ($2 == "linux") { kernel[label]=$3; i=4 }
|
pascal@18145
|
1163 if ($2 == "ifmem") multi(4)
|
pascal@18140
|
1164 }
|
pascal@18140
|
1165 if (kernel[label] ~ "ifcpu64.c32") { auto=$4; next }
|
pascal@18140
|
1166 while (i <= NF) {
|
pascal@18140
|
1167 if ($i ~ "^initrd=") initrd[label]=substr($i,8)
|
pascal@18140
|
1168 else cmdline[label]=cmdline[label] " " $i
|
pascal@18140
|
1169 i++
|
pascal@18140
|
1170 }
|
pascal@18140
|
1171 }
|
pascal@18140
|
1172 }
|
pascal@18140
|
1173 END {
|
pascal@18140
|
1174 print "KERNEL=\"" kernel[auto] "\""
|
pascal@18140
|
1175 print "INITRD=\"" initrd[auto] "\""
|
pascal@18140
|
1176 print "CMDLINE=\"" substr(cmdline[auto],2) "\""
|
pascal@18145
|
1177 print "SIZES=\"" sizes "\""
|
pascal@18140
|
1178 }'
|
pascal@18140
|
1179 }
|
pascal@18140
|
1180
|
pascal@18140
|
1181 locase()
|
pascal@18140
|
1182 {
|
pascal@18140
|
1183 echo "$1" | tr [A-Z] [a-z]
|
pascal@18140
|
1184 }
|
pascal@18140
|
1185
|
pascal@18151
|
1186 ifmemcode()
|
pascal@18151
|
1187 {
|
pascal@18151
|
1188 uudecode <<EOT
|
pascal@18151
|
1189 ifmemcode
|
pascal@18151
|
1190 EOT
|
pascal@18151
|
1191 }
|
pascal@18151
|
1192
|
pascal@18140
|
1193 floppyset()
|
pascal@18140
|
1194 {
|
pascal@19425
|
1195 gotcdfile 'isolinux.cfg'
|
pascal@19432
|
1196 $0 include $file | parse_isolinux > /tmp/var$$
|
pascal@18140
|
1197 . /tmp/var$$
|
pascal@19425
|
1198 [ -z "$KERNEL" ] && echo "Can't parse isolinux.cfg" && return
|
pascal@18240
|
1199 for i in $media/$KERNEL $(dirname $file)/$KERNEL $media/$(locase $KERNEL) \
|
pascal@18240
|
1200 $(dirname $file)/$(locase $KERNEL); do
|
pascal@19433
|
1201 i="$(ls $i* | sed q)"
|
pascal@19433
|
1202 [ -n "$i" ] && KERNEL=$i && break
|
pascal@18240
|
1203 done
|
pascal@20771
|
1204 rm -f /tmp/var$$
|
pascal@18240
|
1205 [ $(get 514 $KERNEL 4) -eq 1400005704 ] || return
|
pascal@18240
|
1206 n=$(($(get 497 $KERNEL 1)+1))
|
pascal@18240
|
1207 ddq bs=512 count=$n if=$KERNEL of=/tmp/fd$$
|
pascal@18140
|
1208 uudecode <<EOT | ddq of=/tmp/fd$$ conv=notrunc
|
pascal@18140
|
1209 bootloader
|
pascal@18140
|
1210 EOT
|
pascal@18140
|
1211 pos=$(($n*512))
|
pascal@18140
|
1212 if [ -n "$CMDLINE" ]; then
|
pascal@18140
|
1213 echo -n "$CMDLINE" | ddq bs=512 count=1 conv=sync >> /tmp/fd$$
|
pascal@18140
|
1214 bytes2bin $n | ddq conv=notrunc \
|
pascal@18140
|
1215 bs=1 seek=497 count=1 of=/tmp/fd$$
|
pascal@18140
|
1216 words2bin $pos | ddq conv=notrunc \
|
pascal@18140
|
1217 bs=1 seek=34 count=2 of=/tmp/fd$$
|
pascal@18240
|
1218 [ $(get 518 $KERNEL 4) -ge 514 ] &&
|
pascal@18155
|
1219 words2bin 32768 9 | ddq conv=notrunc \
|
pascal@18140
|
1220 bs=1 seek=552 count=4 of=/tmp/fd$$
|
pascal@18140
|
1221 fi
|
pascal@18140
|
1222 syssize=$(echo $(get 500 /tmp/fd$$ 4))
|
pascal@18240
|
1223 ddq bs=512 skip=$n if=$KERNEL | cat - /dev/zero | \
|
pascal@18155
|
1224 ddq bs=512 count=$((($syssize+31)/32)) conv=sync >> /tmp/fd$$
|
pascal@18140
|
1225 base=$(stat -c %s /tmp/fd$$)
|
pascal@18140
|
1226 len=
|
pascal@18140
|
1227 if [ "$INITRD" ]; then
|
pascal@18140
|
1228 l=0
|
pascal@18140
|
1229 for i in ${INITRD//,/ }; do
|
pascal@18240
|
1230 for j in $media/$i $(dirname $KERNEL)/$i $media/$(locase $i) \
|
pascal@18240
|
1231 $(dirname $KERNEL)/$(locase $i); do
|
pascal@19433
|
1232 j="$(ls $j* | sed q)"
|
pascal@19433
|
1233 [ -n "$j" ] && i=$j && break
|
pascal@18240
|
1234 done
|
pascal@18240
|
1235 ddq if=$i >> /tmp/fd$$
|
pascal@18240
|
1236 l=$(($l+$(stat -c %s $i)))
|
pascal@18140
|
1237 r=$((4 - ($l % 4)))
|
pascal@18140
|
1238 if [ $r -ne 4 ]; then
|
pascal@18140
|
1239 ddq if=/dev/zero bs=1 count=$r >> /tmp/fd$$
|
pascal@18140
|
1240 l=$(($l + $r))
|
pascal@18140
|
1241 fi
|
pascal@18143
|
1242 case "$i:$INITRD" in
|
pascal@18143
|
1243 *rootfs.gz:*rootfs.gz,*) continue # loram
|
pascal@18140
|
1244 esac
|
pascal@18140
|
1245 len="$len $l"; l=0
|
pascal@18140
|
1246 done
|
pascal@18143
|
1247 rdadrs=${RDADRS:-$(((($syssize*16)+0x1F0000) & -4096))}
|
pascal@18140
|
1248 words2bin $(($rdadrs & 0xFFFF)) $(($rdadrs >> 16)) | ddq \
|
pascal@18140
|
1249 conv=notrunc bs=1 seek=536 count=4 of=/tmp/fd$$
|
pascal@18140
|
1250 fi
|
pascal@18140
|
1251 n=$(echo $len | wc -w)
|
pascal@18140
|
1252 if [ $((494 - $(get 494 /tmp/fd$$))) -ge $(($n * 4)) ]; then
|
pascal@18140
|
1253 i=$(($(get 494 /tmp/fd$$)))
|
pascal@18140
|
1254 bytes2bin $(($i + ($n*4) - 256)) | ddq bs=1 conv=notrunc \
|
pascal@18140
|
1255 seek=496 count=1 of=/tmp/fd$$
|
pascal@18140
|
1256 else
|
pascal@18140
|
1257 i=$(($pos + 0x1FC - ($n*4)))
|
pascal@18140
|
1258 bytes2bin $(($i % 256)) $((i / 256)) 252 | ddq bs=1 \
|
pascal@18140
|
1259 conv=notrunc seek=494 count=3 of=/tmp/fd$$
|
pascal@18151
|
1260 s=$(($i - 2*$(echo "$SIZES" | wc -w)))
|
pascal@18151
|
1261 p=$(($s - $(ifmemcode | wc -c)))
|
pascal@18151
|
1262 ifmemcode | ddq bs=1 conv=notrunc seek=$p of=/tmp/fd$$
|
pascal@18151
|
1263 words2bin $SIZES | ddq bs=1 conv=notrunc seek=$s of=/tmp/fd$$
|
pascal@18151
|
1264 bytes2bin 154 $(($p%256)) $(($p/256)) 0 144 | \
|
pascal@18151
|
1265 ddq bs=1 conv=notrunc seek=60 of=/tmp/fd$$
|
pascal@18140
|
1266 fi
|
pascal@18140
|
1267 for r in $len ; do
|
pascal@18140
|
1268 words2bin $(($r & 0xFFFF)) $(($r >> 16)) | ddq conv=notrunc \
|
pascal@18140
|
1269 bs=1 seek=$i count=4 of=/tmp/fd$$
|
pascal@18140
|
1270 i=$(($i + 4))
|
pascal@18140
|
1271 done
|
pascal@18140
|
1272 split -b 1440k /tmp/fd$$ fd$$
|
pascal@18140
|
1273 rm -f /tmp/fd$$
|
pascal@18140
|
1274 n=1; i=0; r=0
|
pascal@18140
|
1275 set -- $len
|
pascal@18140
|
1276 ls fd$$* | while read file ; do
|
pascal@18140
|
1277 if [ $i -gt $(($1+$base)) ]; then
|
pascal@18140
|
1278 shift
|
pascal@18140
|
1279 r=$(($r+100)); n=0; i=0; base=0
|
pascal@18140
|
1280 fi
|
pascal@18140
|
1281 ddq of=$file bs=18k seek=80 count=0
|
pascal@18140
|
1282 i=$(($i+1474560))
|
pascal@18140
|
1283 printf "mv %s fd%03d.img\n" $file $(($r+$n))
|
pascal@18140
|
1284 n=$(($n+1))
|
pascal@18140
|
1285 done | sh
|
pascal@19029
|
1286 du -ch $PWD/fd???.img
|
pascal@18140
|
1287 }
|
pascal@18140
|
1288
|
pascal@17635
|
1289 quit()
|
pascal@17635
|
1290 {
|
pascal@18240
|
1291 umount -d $media
|
pascal@18240
|
1292 rmdir $media
|
pascal@18240
|
1293 ${1:-exit}
|
pascal@17635
|
1294 }
|
pascal@17635
|
1295
|
pascal@19008
|
1296 infoiso()
|
pascal@19008
|
1297 {
|
pascal@19008
|
1298 isoinfo -d -i "$ISO" > /tmp/isoinfo$$
|
pascal@19008
|
1299 if [ -x "$(which iso2exe)" ]; then
|
pascal@19008
|
1300 echo "----"
|
pascal@20159
|
1301 blkid "$ISO" | while read args; do
|
pascal@20159
|
1302 set -- $args
|
pascal@20159
|
1303 while [ -n "$2" ]; do
|
pascal@20159
|
1304 case "$2" in
|
pascal@20159
|
1305 *UUID*|PT*) echo $2;;
|
pascal@20159
|
1306 esac
|
pascal@20159
|
1307 shift
|
pascal@20159
|
1308 done
|
pascal@20159
|
1309 done
|
pascal@20159
|
1310 if ! fdisk -l "$ISO" | grep -q 'valid partition'; then
|
pascal@20159
|
1311 fdisk -l "$ISO" | grep heads
|
pascal@20159
|
1312 fdisk -l "$ISO" | sed 's/^ *[^ ]* *//;s/ */ /g;$!d'
|
pascal@20159
|
1313 fi
|
pascal@20159
|
1314 echo "----"
|
pascal@19008
|
1315 iso2exe -l "$ISO"
|
pascal@19008
|
1316 fi >> /tmp/isoinfo$$
|
pascal@19008
|
1317 if [ "$1" ]; then
|
pascal@19008
|
1318 cat /tmp/isoinfo$$
|
pascal@19008
|
1319 else
|
pascal@20771
|
1320 $DIALOG --clear --title " Info ISO " \
|
pascal@19008
|
1321 --textbox /tmp/isoinfo$$ 0 0
|
pascal@19008
|
1322 fi
|
pascal@19008
|
1323 rm -f /tmp/isoinfo$$
|
pascal@19008
|
1324 }
|
pascal@19008
|
1325
|
pascal@18289
|
1326 isotitle()
|
pascal@18289
|
1327 {
|
pascal@18778
|
1328 echo "$(blkid "$ISO" | sed 's/.*LABEL="\([^"]*\).*/\1/') $(stat \
|
pascal@18778
|
1329 -c %y $media/.|sed 's/ .*//') $(basename "$ISO")"
|
pascal@18289
|
1330 }
|
pascal@18289
|
1331
|
pascal@20892
|
1332 if [ "$1" = "include" ]; then
|
pascal@19432
|
1333 [ -s "$2" ] && cd $(dirname "$2") && awk -v exe=$0 \
|
pascal@19432
|
1334 '{ if ($1 == "include") system(exe " include " $2); else print }' <"$2"
|
pascal@19432
|
1335 exit
|
pascal@19432
|
1336 fi
|
pascal@18034
|
1337 ISO="${1:-/dev/null}"
|
pascal@20620
|
1338 [ ${ISO:0:1} != "/" ] && ISO=$(cd $(dirname $ISO); echo $PWD/$(basename $ISO))
|
pascal@17635
|
1339 [ -z "$(isiso 2> /dev/null)" ] && echo "Usage : $0 file.iso" && exit 1
|
pascal@18666
|
1340 media=/tmp/media$$
|
pascal@18240
|
1341 mkdir -p $media
|
pascal@18670
|
1342 mount -o loop,ro "$ISO" $media
|
pascal@17635
|
1343
|
pascal@20892
|
1344 if [ "$2" = "list" ]; then
|
pascal@17928
|
1345 sed '/^\$(.*") \\/!d;s/^\$(\(.*\)").*/\1"/' $0 | while read line; do
|
pascal@17928
|
1346 eval $line
|
pascal@17928
|
1347 echo
|
pascal@17928
|
1348 done | sed '/^$/d;/"usbkey"/d'
|
pascal@17928
|
1349 quit
|
pascal@17928
|
1350 fi
|
pascal@17924
|
1351 if grep -q "^$2()" $0; then
|
pascal@17924
|
1352 exe=$2
|
pascal@17924
|
1353 shift 2
|
pascal@18140
|
1354 if [ -n "$(eval $(grep "\"$exe\"" $0 | sed \
|
pascal@18140
|
1355 '/^\$/!d;s/.(\(.*\)[\t ]*".*"[\t ]*".*/\1/'))" ]; then
|
pascal@18289
|
1356 isotitle
|
pascal@17924
|
1357 grep "\"$exe\"" $0 | sed '/^\$/!d;s/.*"[\t ]*"\(.*\)".*/\1/'
|
pascal@18140
|
1358 echo ----
|
pascal@17924
|
1359 $exe "$@"
|
pascal@17924
|
1360 fi
|
pascal@17924
|
1361 quit
|
pascal@17924
|
1362 fi
|
pascal@17924
|
1363
|
pascal@17635
|
1364 while true; do
|
pascal@17635
|
1365 cat > /tmp/dialog$$ <<EOT
|
pascal@21092
|
1366 $DIALOG --clear --title " $(isotitle) " --menu "" 28 70 30 \
|
pascal@17635
|
1367 $(cdfile 'README*' "readme" "Show the README file") \
|
pascal@18675
|
1368 $(gotcustomconf "getcustomconf" "Get custom config") \
|
pascal@17635
|
1369 $(gotisomd5 "isomd5" "Check the ISO image") \
|
pascal@17635
|
1370 $(cdfile 'md5sum*' "md5" "Check the ISO files") \
|
pascal@17635
|
1371 $(cdfile 'sha*sum*' "sha" "Check the ISO files") \
|
pascal@19008
|
1372 $(xfile isoinfo "infoiso" "ISO image info") \
|
pascal@17635
|
1373 $(cdfilex boot/bzImage "bootiso" "Boot the ISO image") \
|
pascal@18034
|
1374 $(burnable "burniso" "Burn the ISO image") \
|
pascal@18034
|
1375 $(blankable "blankcd" "Blank the CD/DVD") \
|
pascal@17635
|
1376 $(gotposixovl "install" "Hard disk installation (UMSDOS way)") \
|
pascal@17635
|
1377 $(gotposixovl "installtaz" "Hard disk installation (TAZUSB way)") \
|
pascal@17635
|
1378 $(gotposixovlzip "inst2zip" "ZIP installation archive (UMSDOS way)") \
|
pascal@17635
|
1379 $(gotposixovlzip "insttaz2zip" "ZIP installation archive (TAZUSB way)") \
|
pascal@19425
|
1380 $(gottazusb "usbkey" "USB key read/write installation") \
|
pascal@17635
|
1381 $(ishybrid "usbbootkey" "USB boot key (read only)") \
|
paul@17935
|
1382 $(hasflavinfo "showfavinfo" "Show flavor extra info") \
|
pascal@19425
|
1383 $(hasflavor "flavor" "Get flavor file") \
|
pascal@18140
|
1384 $(cdfile isolinux.cfg "floppyset" "Boot floppy set") \
|
pascal@18140
|
1385 $(hastazboot "tazboot" "Get tazboot.exe Linux loader") \
|
pascal@17635
|
1386 $(cdexe boot/bzImage "bzimage" "Get linux DOS/EXE file") \
|
pascal@17635
|
1387 $(cdexe 'memtest*' "memtest" "Get Memtest86 DOS/EXE file") \
|
pascal@17635
|
1388 $(cdfilef 'memtest*' "fdmemtest" "Create a Memtest86 boot floppy") \
|
pascal@17635
|
1389 $(cdfilex 'memtest*' "runmemtest" "Start Memtest86") \
|
pascal@20724
|
1390 $(cdexe '?pxe*' "pxe" "Get SliTaz Web boot DOS/EXE utility") \
|
pascal@20724
|
1391 $(cdfilef '?pxe*' "fdpxe" "Create a SliTaz Web boot floppy") \
|
pascal@20724
|
1392 $(cdfilex '?pxe*' "runpxe" "Start the SliTaz Web boot utility") \
|
pascal@17635
|
1393 $(misspkg "missing" "Install packages to get more options") \
|
pascal@17924
|
1394 $(menuitem "quit" "Quit this utility")
|
pascal@17635
|
1395 EOT
|
pascal@17635
|
1396 exec 3>&1
|
pascal@17635
|
1397 value=$(. /tmp/dialog$$ 2>&1 1>&3)
|
pascal@17635
|
1398 retval=$?
|
pascal@17635
|
1399 exec 3>&-
|
pascal@17635
|
1400 rm -f /tmp/dialog$$
|
pascal@18771
|
1401 [ $retval -eq 0 ] || quit
|
pascal@17635
|
1402 $value
|
pascal@17635
|
1403 done
|