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