# HG changeset patch # User Pascal Bellard # Date 1565455650 -7200 # Node ID 1c40a6bea05c797c8986b275288f13a56a8f1ca5 # Parent c25206bfb95e0ecd945b5f7c334b5d75e323c91d linld/iso2exe: remove non slitaz dos boot diff -r c25206bfb95e -r 1c40a6bea05c linld/stuff/src/TAZBOOT.CPP --- a/linld/stuff/src/TAZBOOT.CPP Sat Aug 10 14:24:44 2019 +0200 +++ b/linld/stuff/src/TAZBOOT.CPP Sat Aug 10 18:47:30 2019 +0200 @@ -67,7 +67,7 @@ { const char *init = " rdinit=/init.exe", *mode="menu"; char c; - static char rootfs[16], fallback[16], isknoppix, noauto; + static char rootfs[16], fallback[16], noauto; unsigned long magic; struct isostate *x=&isostate; @@ -76,20 +76,12 @@ base_himem = memtop() /2; //if (base_himem >= _64m) base_himem = _64m; if (* ((char *) &base_himem +3) >= 4) ((short *)&base_himem)[1] = _64m/_64k; - isoopen("boot") != -1 || - isoopen("live") != -1 || // debian - isoopen("casper") != -1; // ubuntu + isoopen("boot"); if (iso[1] && !strcmp(mode = iso[1], "text")) init = ""; - do { - if ((isoopen(mode) != -1 && ++noauto != 0) || // custom - isoopen("bzImage") != -1 || // SliTaz - isoopen("vmlinuz") != -1 || // misc - (isoopen("linux") != -1 && ++isknoppix != 0)) { - magic = kver2ul(isokernel()); - break; - } - } while (isoopen("isolinux") != -1); // Knoppix + if (isoopen(mode) == -1 || ++noauto == 0) // custom + isoopen("bzImage"); // SliTaz + magic = kver2ul(isokernel()); for (c = 0, x->curdirsize = 0xFFFF; isoreaddir() != -1;) { if (strstr(x->filename, ".gz")) strcpy(fallback, x->filename); @@ -99,7 +91,7 @@ strcpy(rootfs, x->filename); } - strcatb(buf_cmdline,"rw root=/dev/null autologin bootfrom="); + strcatb(buf_cmdline,"autologin bootfrom="); strcat(buf_cmdline,*iso); if (magic < 0x20630) init = ""; // Does not support multiple initramfs @@ -116,15 +108,10 @@ } } else if (magic != 0) { - char *initrdfilename = fallback; static const unsigned long initrddesc = 18L; - if (rootfs[0]) { - initrdfilename = rootfs; - if (rootfs[6] != '.' && isoopen("rootfs.gz") != -1) - addinitrd(); // for loram - } - if (isoopen(initrdfilename) != -1) { + if (isoopen("rootfs.gz") != -1 || + isoopen(rootfs[0] ? rootfs : fallback) != -1) { addinitrd(); } if (*init && isolseek(&initrddesc) != 0) { @@ -141,13 +128,6 @@ strcat(buf_cmdline,(char *)ultoa(magic)); } load_initrds(); - if (isknoppix) { - char *s = *iso; - if (s[1] == ':') - s += 2; - for (; *s; s++) - if (*s == '\\') *s = '/'; - } close(x->fd); boot_kernel(); } diff -r c25206bfb95e -r 1c40a6bea05c linld/stuff/src/pipehole.awk --- a/linld/stuff/src/pipehole.awk Sat Aug 10 14:24:44 2019 +0200 +++ b/linld/stuff/src/pipehole.awk Sat Aug 10 18:47:30 2019 +0200 @@ -202,7 +202,7 @@ } # file == "iso9660.cpp" if (file == "iso9660.cpp" || file == "tazboot.cpp") { if (/do s\+\+; while/) isiso=3 - if (/for \(p = s; \*s && \*s \!=/) isiso=3 + if (/for \(p = s; \*s && \*s \!=/) isiso=3 # tazboot/main if (isiso == 3) { # ISO9660.LST, TAZBOOT.LST sub(/cmp byte ptr \[.i\]/,"sub al") if (/mov byte ptr \[bp-5\],al/) $0=" push ax" @@ -243,11 +243,11 @@ } } # file == "iso9660.cpp" if (/endp/) { xlabel = ""; goto2=0 } - if (/isoopen\(s\+7\)/ && xlabel == "") goto2=1 - if (/_vid_mode,ax/ && xlabel == "") goto2=1 - if (/_initrd_name,si/ && xlabel == "") goto2=1 - if (/_base_himem\+2,/ && xlabel == "@") goto2=1 - if (/DGROUP:_skip_alloc/ && xlabel == "@") goto2=1 + if (/isoopen\(s\+7\)/ && xlabel == "") goto2=1 # tazboot/bootiso + if (/_vid_mode,ax/ && xlabel == "") goto2=1 # tazboot/main + if (/_initrd_name,si/ && xlabel == "") goto2=1 # tazboot/main + if (/_base_himem\+2,/ && xlabel == "@") goto2=1 # tazboot/bootiso tazboot/main + if (/DGROUP:_skip_alloc/ && xlabel == "@") goto2=1 # tazboot/bootiso tazboot/main if (/puts\(cmdline\)/ && xlabel == "@@") goto2=1 if (goto2 == 1 && /jmp/) { # TAZBOOT.LST && LINLD.LST print $NF xlabel "@:" @@ -257,6 +257,29 @@ $0=$0 xlabel if (goto2++ == 1) xlabel=xlabel "@" } + if (file == "tazboot.cpp" && /close\(x/) isotazboot=16 + if (isotazboot == 160) { # TAZBOOT.LST + $0="; " $0 + if (/ret/) isotazboot=0 + } + if (isotazboot == 16) { # TAZBOOT.LST + if (/@.@/) { + isotazboot=160 + next + } + } + if (file == "tazboot.cpp" && /jne @@2/) isotazboot=15 + if (isotazboot == 15) { # TAZBOOT.LST + if (/@.@/) { + print " pop di" + print " pop si" + print " mov sp,bp" + print " pop bp" + print " ret" + next + } + if (/skip_alloc/) isotazboot=0 + } if (/if\(\*s>=/) isotazboot=14 if (isotazboot == 14) { # LINLD.LST if (/jmp/) { @@ -264,24 +287,24 @@ isotazboot=0 } } - if (file == "tazboot.cpp" && /; s \+= 4/) isotazboot=13 + if (file == "tazboot.cpp" && /; s \+= 4/) isotazboot=13 # tazboot/main if (isotazboot == 13) { # TAZBOOT.LST if (/si,4/) $0=" lea bx,[si+4]" if (/bx,si/) next if (/DGROUP:_topmem/ || /set_iso/) isotazboot=0 } - if (file == "tazboot.cpp" && /case 0x652F:/) isotazboot=12 + if (file == "tazboot.cpp" && /case 0x652F:/) isotazboot=12 # tazboot/main if (isotazboot == 12) { # TAZBOOT.LST sub(/si,word/,"bx,word") if (/short/) isotazboot=0 } - if (/return load_kernel/) isotazboot=11 + if (/return load_kernel/) isotazboot=11 # tazboot/isokernel if (isotazboot == 11) { # TAZBOOT.LST sub(/call/,"jmp") if (/ret/ || /pop/) next if (/endp/) isotazboot=0 } - if (/cmdline=s\+=3/ || /magic \!= 0/ || /&root_dev =/) { isotazboot=10; j="" } + if (/cmdline=s\+=3/ || /magic \!= 0/ || /&root_dev =/) { isotazboot=10; j="" } # ,tazboot/bootiso,tazboot/main if (isotazboot == 10) { # TAZBOOT.LST && LINLD.LST if (/je/ || /jne/) { j=$1; next } if (/jmp/) { @@ -290,39 +313,39 @@ isotazboot=0 } } - if (/static const unsigned long initrddesc = 18L/) isotazboot=9 + if (/static const unsigned long initrddesc = 18L/) isotazboot=9 # tazboot/bootiso if (isotazboot == 9) { # TAZBOOT.LST if (/,0/) { split($4,y,",") print " mov bx,offset " y[1] + sub(/DGROUP:.*,/,"[bx],") } - if (/DGROUP:.*\+6,46/) { - sub(/DGROUP:.*\+6,/,"[bx+6],") - isotazboot=0 - } - if (/mov/) $0=" mov si,bx" - sub(/DGROUP:.*,/,"[bx],") + if (/mov/ && $3 == y[1]) next + if (/je/) next + if (/jmp/) sub(/jmp/,"jne") + sub(/ax,offset/,"bx,offset") + if (/bx,ax/) { isotazboot=0; next } } - if (/isoopen\(s\+7\) != -1/) isotazboot=8 + if (/isoopen\(s\+7\) != -1/) isotazboot=8 # tazboot/bootiso if (isotazboot == 8) { # TAZBOOT.LST - if (/ax,si/) next - sub(/ax,ax/,"si,si") + sub(/\[bx/,"[si") + if (/bx,si/) next if (/magic/) isotazboot=0 } - if (/\+\+isknoppix/) isotazboot=7 + if (/isoopen\(\"bzImage\"\)/) isotazboot=7 # tazboot/bootiso if (isotazboot == 7) { # TAZBOOT.LST if (/inc/ || /,al/) next if (/al,byte/) sub (/mov al,/,"inc ") if (/isokernel/) isotazboot=0 } - if (/if \(c\) s\+\+;/) isotazboot=6 + if (/if \(c\) s\+\+;/) isotazboot=6 # tazboot/main if (isotazboot == 6) { # TAZBOOT.LST if (/cmp/) { $0=" cmp al,0" isotazboot=0 } } - if (/static void next_chunk/) isotazboot=5 + if (/static void next_chunk/) isotazboot=5 # tazboot/next_chunk if (isotazboot == 501) { if (/ret/) { print "@1@86:" @@ -350,7 +373,7 @@ } if (/ax,-4/) isotazboot++ } - if (/0x7FF0/) isotazboot=4 + if (/0x7FF0/) isotazboot=4 # tazboot/bootiso if (isotazboot == 4) { # TAZBOOT.LST if (/ax,word ptr/) { print " mov ax,32752" @@ -363,22 +386,21 @@ sub(/,cx/,",ax") if (/@addinitrd\$qv/) isotazboot=0 } - if (/c = x->filename/) isotazboot=3 + if (/c = x->filename/) isotazboot=3 # tazboot/bootiso if (isotazboot == 3) { # TAZBOOT.LST if (/ax,/) $0=" xchg ax,bx" if (/\]$/) next if (/@strcpy\$qpxzct1/) isotazboot=0 } - if (/base_himem = memtop/) isotazboot=2 + if (/base_himem = memtop/) isotazboot=2 # tazboot/bootiso if (isotazboot == 2) { # TAZBOOT.LST - if (/@6@226/ || /mov ax,1/ || /@6@254/ || /xor ax,ax/) next - if (/word ptr \[bx\+2\],0/) { + if (/word ptr \[si\+2\],0/) { print s; hold=0 - print " mov bx,word ptr [bx+2]" + print " mov bx,word ptr [si+2]" $0=" or bx,bx" } if (/\[bp-4\],ax/) sub(/ax/,"bx") - if (/ax,word ptr \[bx\+2\]/ || /bx,ax/) next + if (/ax,word ptr \[si\+2\]/ || /bx,ax/) next if (/_base_himem\+2,dx/) { print " mov bx,offset DGROUP:_base_himem+2" } @@ -387,7 +409,7 @@ sub(/DGROUP:_base_himem\+3,/,"[bx+1],") if (/@strcmp\$qpxzct1/) isotazboot=0 } - if (/static void addinitrd/) isotazboot=100 + if (/static void addinitrd/) isotazboot=100 # tazboot/addinitrd if (isotazboot == 100) { # TAZBOOT.LST if (/cx,ax/) { print " mov si,offset _isostate+8" diff -r c25206bfb95e -r 1c40a6bea05c syslinux/stuff/iso2exe/init --- a/syslinux/stuff/iso2exe/init Sat Aug 10 14:24:44 2019 +0200 +++ b/syslinux/stuff/iso2exe/init Sat Aug 10 18:47:30 2019 +0200 @@ -4,7 +4,7 @@ ddq() { - dd $@ 2> /dev/null + dd $@ 2>/dev/null } get() @@ -41,15 +41,15 @@ while [ "$1" ]; do case "$1" in --title) title=" \x1B[30;47m$2\x1B[37;40m\n" - echo -e $title; shift ;; - --yes-label) label="$2" ; shift ;; + echo -e $title; shift;; + --yes-label) label="$2"; shift;; --textbox) xless "$2" "\nPress RETURN to continue." break;; --gauge) t=" " echo -e "$t$2\n" - while read pct ; do + while read pct; do s=" " s="$s$pct%$s" pct=$((($pct*63)/100)) @@ -66,7 +66,7 @@ ''|Y*|y*|1) return 0;; N*|n*|2|0) return 1;; esac - done ;; + done;; --menu|--radiolist) [ "$1" = "--menu" ] && shft=2 || shft=3 label="" @@ -79,12 +79,12 @@ echo "$((n++)) $2" shift $shft done >> /tmp/data - while ! grep -q "^$n " /tmp/data ; do + while ! grep -q "^$n " /tmp/data; do clear xless /tmp/data echo -en "\n <- Enter the selection number\r" read n - done 2> /dev/null + done 2>/dev/null rm -f /tmp/data [ $n -eq 0 ] && return 1 eval echo -n \$key_$n 1>&2 @@ -98,27 +98,27 @@ { mount -t proc /proc /proc mount -t sysfs /sys /sys - udevd --daemon 2> /dev/null && udevadm trigger && sleep 5 + udevd --daemon 2>/dev/null && udevadm trigger && sleep 5 } umount_proc() { - killall udevd 2> /dev/null - umount /sys/fs/fuse/connections 2> /dev/null + killall udevd 2>/dev/null + umount /sys/fs/fuse/connections 2>/dev/null umount /sys umount /proc } bytes2bin() { - for i in $@ ; do + for i in $@; do printf '\\\\x%02X' $(($i&255)) done | xargs echo -en } words2bin() { - for i in $@ ; do + for i in $@; do printf '\\\\x%02X\\\\x%02X' $(($i&255)) $((($i>>8)&255)) done | xargs echo -en } @@ -146,7 +146,7 @@ getiso() { mkdir -p /media/cdrom - for dev in /sys/block/?d?/?d??* ; do + for dev in /sys/block/?d?/?d??*; do mount /dev/$(basename $dev) /mnt if checkmagic /mnt/$ISO; then mount -o loop,ro /mnt/$ISO /media/cdrom @@ -154,20 +154,22 @@ return 0 fi umount /mnt - done 2> /dev/null + done 2>/dev/null return 1 } uncpio() { - [ -s "$1" ] || return - echo -en "\n Extracting $(basename $1) ..." - case $(get 0 $1) in - *35615) ( zcat || gunzip ) ;; - *14333) unxz ;; - *\ 93) unlzma ;; - *) cat ;; - esac < $1 | ( cd ${2:-/} ; cpio -idmu > /dev/null 2>&1 ) + i=$1 + grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64 + [ -s "$i" ] || return + echo -en "\n Extracting $(basename $i) ..." + case $(get 0 $i) in + *35615) ( zcat || gunzip );; + *14333) unxz;; + *\ 93) unlzma;; + *) cat;; + esac < $i | ( cd ${2:-/}; cpio -idmu > /dev/null 2>&1 ) } dotwait() @@ -191,7 +193,7 @@ PAD=$(($(stat -c %s $1) % 4)) [ $PAD -ne 0 ] && ddq if=/dev/zero bs=1 count=$((4 - $PAD)) >> $1 mkdir -p /tmp/fs/etc /tmp/fs/lib /tmp/fs/home - cp /etc/keymap.conf /etc/locale.conf /tmp/fs/etc 2> /dev/null + cp /etc/keymap.conf /etc/locale.conf /tmp/fs/etc 2>/dev/null cat > /tmp/fs/init1 < /dev/null ; done; sleep 2 -v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2> /dev/null) +for i in /lib/modules/*.ko*; do insmod \$i 2>/dev/null; done; sleep 2 +v=\$(sed '/\\/home=/!d;s|.*/home=\\([^ ]*\\).*|\\1|' /proc/cmdline /cmdline 2>/dev/null) mount / -o remount,rw mkdir /mnt/dos -rm -f /cmdline 2> /dev/null +rm -f /cmdline 2>/dev/null mount / -o remount,ro mnt=/mnt/dos/\${v#*/} dev=\$( (blkid /dev/[sh]d* || blkid) | grep \${v%%/*} | sed 's/:.*//;q') @@ -219,18 +221,18 @@ EOT chmod 755 /tmp/fs/init? cp -a /tmp/fs/* / - ln -s /sqfs/bin/gzip /bin 2> /dev/null - ( cd /tmp/fs ; find * | cpio -o -H newc ) | gzip -9 >> $1 + ln -s /sqfs/bin/gzip /bin 2>/dev/null + ( cd /tmp/fs; find * | cpio -o -H newc ) | gzip -9 >> $1 } mkinitrd() { echo dotwait "Creating $(basename $1) " - for i in bin lib dev proc tmp mnt etc ; do + for i in bin lib dev proc tmp mnt etc; do mkdir -p /tmp/fs/$i done - for i in /dev/console /dev/null /dev/tty /dev/tty[012] /dev/fuse /dev/[hs]d* ; do + for i in /dev/console /dev/null /dev/tty /dev/tty[012] /dev/fuse /dev/[hs]d*; do cp -a $i /tmp/fs$i done for i in /bin/busybox $(which mount.posixovl) $(which blkid); do @@ -238,13 +240,13 @@ sed 's|.*=> \(.*/lib/l[^ ]*\).*|\1|;/^\//!d') /tmp/fs/lib cp $i /tmp/fs/bin done - cp -a /sqfs/lib/ld-* /tmp/fs/lib 2> /dev/null || + cp -a /sqfs/lib/ld-* /tmp/fs/lib 2>/dev/null || cp -a /lib/ld-* /tmp/fs/lib for i in $(busybox | sed '/Current/,$!d'); do [ -e /tmp/fs/bin/${i%,} ] || ln -s busybox /tmp/fs/bin/${i%,} done ln -s /proc/mounts /tmp/fs/etc/mtab - sed 's/ .*//' /proc/modules | while read mod ; do + sed 's/ .*//' /proc/modules | while read mod; do find /lib/modules/ | grep $mod.ko | \ sed 's|.*|cp & /tmp/fs/lib|' | sh done @@ -259,7 +261,7 @@ } mount -t proc /proc /proc -for i in /lib/*.ko* ; do insmod \$i 2> /dev/null ; done; sleep 2 +for i in /lib/*.ko*; do insmod \$i 2>/dev/null; done; sleep 2 arg mount "Mount device" mount \$( (blkid /dev/[sh]d* || blkid) | grep \$val | sed 's/:.*//;q') /mnt arg subroot "Change root to directory" @@ -272,7 +274,7 @@ exec /bin/switch_root /mnt \${LDSO#/mnt/} \$val/usr/sbin/chroot \$val /sbin/init EOT chmod +x /tmp/fs/init - ( cd /tmp/fs ; find * | cpio -o -H newc ) | lzma e $1 -si 2> /dev/null + ( cd /tmp/fs; find * | cpio -o -H newc ) | lzma e $1 -si 2>/dev/null rm -rf /tmp/fs /tmp/wait } @@ -283,7 +285,7 @@ ls_r() { - ls -r $@ 2> /dev/null || ls $@ + ls -r $@ 2>/dev/null || ls $@ } doinstall() @@ -300,7 +302,7 @@ if [ -d /media/cdrom/fs ]; then ( cd /mnt/slitaz/fs; find | cpio -o -H newc ) | gzip -9 else - ls_r /media/cdrom/boot/rootfs*gz | xargs cat + ls_r /media/cdrom/boot/rootfs* | xargs cat fi > /mnt/slitaz/boot/rootfs.gz tazusbinitfs /mnt/slitaz/boot/rootfs.gz initrd=rootfs.gz @@ -308,8 +310,8 @@ else if [ -d /media/cdrom/fs ]; then cp -a /media/cdrom/fs/. /mnt/slitaz - elif is_loram ; then - for i in $(ls_r /media/cdrom/boot/rootfs*gz); do + elif is_loram; then + for i in $(ls_r /media/cdrom/boot/rootfs*); do losetup -o 124 /dev/loop7 $i mount -t squashfs -o ro /dev/loop7 /sqfs/mnt cp -a /sqfs/mnt/. /mnt/slitaz @@ -317,7 +319,7 @@ losetup -d /dev/loop7 done else - for i in $(ls_r /media/cdrom/boot/rootfs*gz); do + for i in $(ls_r /media/cdrom/boot/rootfs*); do uncpio $i /mnt/slitaz done fi @@ -328,14 +330,14 @@ echo -en "\nInstall boot files..." for i in /media/cdrom/boot/bzImage /media/cdrom/boot/*pxe* \ /media/cdrom/boot/isolinux/he* /media/cdrom/boot/isolinux/opt* \ - /media/cdrom/README /media/cdrom/boot/memtest* ; do + /media/cdrom/README /media/cdrom/boot/memtest*; do [ -s $i ] && cp $i /mnt/slitaz/boot done - for i in /mnt/slitaz/boot/memtest /mnt/slitaz/boot/*pxe ; do - [ $(get 0 $i 2> /dev/null || echo 0) -eq 23117 ] && + for i in /mnt/slitaz/boot/memtest /mnt/slitaz/boot/*pxe; do + [ $(get 0 $i 2>/dev/null || echo 0) -eq 23117 ] && mv $i $i.exe done - cp /etc/keymap.conf /etc/locale.conf /mnt/slitaz/etc 2> /dev/null + cp /etc/keymap.conf /etc/locale.conf /mnt/slitaz/etc 2>/dev/null gettazboot /mnt/slitaz/boot/tazboot.exe unix2dos > /mnt/slitaz/boot/tazboot.cmd < /dev/null + cp /tmp/fs/etc/* /etc 2>/dev/null echo "/home=$(getuuid)/slitaz" > /cmdline rm -f /tmp/wait [ -x /init1 ] || return @@ -454,7 +456,7 @@ md5() { dotwait "Checking files" - ( cd /media/cdrom ; ${1:-md5sum -c md5sum*} | sort ) > /tmp/data + ( cd /media/cdrom; ${1:-md5sum -c md5sum*} | sort ) > /tmp/data rm -f /tmp/wait $DIALOG --clear --title " Checked files " --textbox /tmp/data 24 78 rm -f /tmp/data @@ -463,8 +465,8 @@ gotcdfile() { for i in "/media/cdrom/$1" "/media/cdrom/*/$1" \ - "/media/cdrom/*/isolinux/$1" ; do - file=$(ls $i 2> /dev/null | sed q) + "/media/cdrom/*/isolinux/$1"; do + file=$(ls $i 2>/dev/null | sed q) [ -s "$file" ] && break done } @@ -529,7 +531,7 @@ 0 2 2 $(($R%256)) $(($R/256)) 2 64 0 64 11 0xF0 $F 0 \ $G | ddq bs=1 of=/dev/fd0 ddq if=/dev/zero bs=512 count=$((4+$F+$F)) seek=$R of=/dev/fd0 - for i in $R $(($R+$F)) ; do + for i in $R $(($R+$F)); do bytes2bin 0xF0 0xFF 0xFF | ddq bs=512 seek=$i of=/dev/fd0 done echo -n $(basename $1) | ddq bs=1 seek=3 count=8 of=/dev/fd0 @@ -624,13 +626,13 @@ fddata() { [ -e /sys/block/fd0 ] && - [ $(get 26 /mnt/$ISO 1 2> /dev/null || echo 0) -ne 0 ] && + [ $(get 26 /mnt/$ISO 1 2>/dev/null || echo 0) -ne 0 ] && echo -en "\"$1\" \"$2\"" } ishybrid() { - [ $(get 510 $ISO 2> /dev/null || echo 0) -eq 43605 ] || return + [ $(get 510 $ISO 2>/dev/null || echo 0) -eq 43605 ] || return C=$((2048*$(get $(((17*2048) + 71)) /mnt/$ISO 4))) [ $(get $C /mnt/$ISO 4) -eq 1 ] || return [ $(get $(($C+30)) /mnt/$ISO 4) -eq $((0x88AA55)) ] || return @@ -641,13 +643,13 @@ burnable() { - [ "$(sed '/Can wr.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] && + [ "$(sed '/Can wr.*1$/!d' /proc/sys/dev/cdrom/info 2>/dev/null)" ] && [ "$(which wodim)" ] && echo -en "\"$1\" \"$2\"" } blankable() { - [ "$(sed '/Can wr.*RW.*1$/!d' /proc/sys/dev/cdrom/info 2> /dev/null)" ] && + [ "$(sed '/Can wr.*RW.*1$/!d' /proc/sys/dev/cdrom/info 2>/dev/null)" ] && [ "$(which wodim)" ] && echo -en "\"$1\" \"$2\"" } @@ -683,14 +685,14 @@ cd ${1:-/mnt} ddq bs=2k skip=$(customsector) if="/mnt/$ISO" | while read line; do case "$line" in - \#!boot*) ;; - append=*) echo ${line#append=} > cmdline && ls -l cmdline ;; + \#!boot*);; + append=*) echo ${line#append=} > cmdline && ls -l cmdline;; initrd:*) cnt=${line#initrd:} { ddq bs=512 count=$(($cnt / 512)); ddq bs=1 count=$(($cnt % 512)); } > initrd && ls -l initrd - break ;; - *) break ;; + break;; + *) break;; esac done cd - > /dev/null @@ -699,7 +701,7 @@ gotisomd5() { - [ "$(which md5sum 2> /dev/null)" ] && + [ "$(which md5sum 2>/dev/null)" ] && [ $(get 0 /mnt/$ISO) -eq 23117 ] && [ $(get 18 /mnt/$ISO) -ne 0 ] && echo -en "\"$1\" \"$2\"" } @@ -723,14 +725,14 @@ TMP=/tmp/$(basename $0)$$md5 md5="$(ddq bs=2k skip=$(customsector) if=/mnt/$ISO | while read line; do case "$line" in - \#!boot*) echo ${line#*boot } > $TMP ;; - append=*) echo $line ;; + \#!boot*) echo ${line#*boot } > $TMP;; + append=*) echo $line;; initrd:*) echo $line cnt=${line#initrd:} ddq bs=512 count=$((cnt / 512)) ddq bs=1 count=$((cnt % 512)) - break ;; - *) break ;; + break;; + *) break;; esac done | md5sum | cut -c1-32)" [ "$md5" = "$(cat $TMP)" ] && echo "OK" || echo "ERROR" @@ -877,7 +879,7 @@ bytes2bin 154 $(($p%256)) $(($p/256)) 0 144 | \ ddq bs=1 conv=notrunc seek=60 of=/tmp/fd$$ fi - for r in $len ; do + for r in $len; do words2bin $(($r & 0xFFFF)) $(($r >> 16)) | ddq conv=notrunc \ bs=1 seek=$i count=4 of=/tmp/fd$$ i=$(($i + 4)) @@ -886,7 +888,7 @@ rm -f /tmp/fd$$ n=1; i=0; r=0 set -- $len - ls fd$$* | while read file ; do + ls fd$$* | while read file; do if [ $i -gt $(($1+$base)) ]; then shift r=$(($r+100)); n=0; i=0; base=0 @@ -931,8 +933,8 @@ $DIALOG --clear --title " Select your USB key " \ --menu "\nPlease select the USB key according to its known size.\n\n" \ 14 70 4 \ - $(for i in $DEV ; do - echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2> /dev/null)\" " + $(for i in $DEV; do + echo -n "/dev/$i \"$(($(cat /sys/block/$i/size)/2048))MB $(cat /sys/block/$i/device/model 2>/dev/null)\" " done) EOT exec 3>&1 @@ -944,7 +946,7 @@ tazusbmsg() { - [ "$(which tazusb 2> /dev/null)" ] || return + [ "$(which tazusb 2>/dev/null)" ] || return echo "You should choose 'USB key read/write installation' to be able to save the package updates or your own configuration and data files.\n\n" } @@ -963,7 +965,7 @@ ### perform dd in progress bar max=$(($(cat /sys/block/loop0/size)/2048)) i=0; ddq if=/mnt/$ISO bs=1024k | ( - while ddq bs=1024k count=1 ; do + while ddq bs=1024k count=1; do i=$(($i + 1)) [ $i -gt $max ] && break echo $((($i*100)/$max)) | dialog --gauge \ @@ -985,7 +987,7 @@ words2bin 0 $((0x101+$cx)) 0x3F0B $((32+$m)) \ $ll $lh $(($n & 0xFFFF)) $(($n >> 16)) | \ ddq bs=1 seek=$((462-$p)) of=$device - if [ "$(which mkdosfs 2> /dev/null)" ]; then + if [ "$(which mkdosfs 2>/dev/null)" ]; then losetup -o $((512*$ofs)) /dev/loop2 $device mkdosfs -n "SLITAZ BOOT" /dev/loop2 words2bin $(($ofs & 0xFFFF)) $(($ofs >> 16)) | \ @@ -1034,17 +1036,18 @@ mount_loram() { is_loram || return - insmod /lib/modules/squashfs.ko* 2> /dev/null + insmod /lib/modules/squashfs.ko* 2>/dev/null if [ -d /media/cdrom/fs ]; then ln -s /media/cdrom/fs /sqfs else mkdir /sqfs - mount -o loop,ro -t squashfs /rootfs*.gz /sqfs + losetup -o 124 /dev/loop6 $(ls_r /media/cdrom/boot/rootfs?*.* | sed q) + mount -r /dev/loop6 /sqfs fi cp -a /sqfs/dev/fuse /sqfs/dev/tty[12] /sqfs/dev/[hs]d* /dev - ln -s /sqfs/lib/* lib + ln -s /sqfs/lib/* lib 2>/dev/null ln -fs /sqfs/usr /sqfs/var / - mkdir /etc && cp /sqfs/etc/dialogrc /etc 2> /dev/null + mkdir /etc && cp /sqfs/etc/dialogrc /etc 2>/dev/null } umount_loram() @@ -1052,7 +1055,8 @@ is_loram || return rm /var /usr umount -d /sqfs - rmdir /sqfs 2> /dev/null || rm -f /sqfs + rmdir /sqfs 2>/dev/null || rm -f /sqfs + rm -rf /etc } dosync() @@ -1067,6 +1071,7 @@ text() { + uncpio $(ls_r /media/cdrom/boot/rootfs?*.* | sed q) init= cmdline="$(cat /proc/cmdline)" if hascustomconf; then @@ -1078,7 +1083,6 @@ fi dosync sed -i 's/ || exit//' /init - [ -s /etc/inittab ] || rm -rf /etc exec ${init:-/init} $cmdline } @@ -1086,8 +1090,7 @@ { n=0 dotwait "Extract filesystem..." - for i in $(ls_r /media/cdrom/boot/rootfs*gz); do - grep -q ' lm ' /proc/cpuinfo && [ -s ${i}64 ] && i=${i}64 + for i in $(ls_r /media/cdrom/boot/rootfs*); do [ $((n++)) -eq 0 ] || uncpio $i done rm -f /tmp/wait @@ -1141,10 +1144,10 @@ showfavinfo() { mkdir -p /tmp/data - flavdata | ( cd /tmp/data ; cpio -i ) + flavdata | ( cd /tmp/data; cpio -i ) file=/tmp/data/info cat /tmp/data/*desc > $file - for i in /tmp/data/*list* ; do + for i in /tmp/data/*list*; do echo "=== extra ${i#*list} files" cat $i done >> $file @@ -1155,47 +1158,47 @@ flavor() { cd /mnt - name="$(flavdata | cpio -t 2> /dev/null | sed 's/.[a-z]*$//;q')" + name="$(flavdata | cpio -t 2>/dev/null | sed 's/.[a-z]*$//;q')" echo "Create ${name:=flavor}.flavor..." tazlito iso2flavor "/mnt/$ISO" $name - ls -l $name.flavor 2> /dev/null || sleep 5 + ls -l $name.flavor 2>/dev/null || sleep 5 cd - > /dev/null } shell() { trap text 2 - getty -n -l /bin/ash 38400 tty1 2> /dev/null || sh + getty -n -l /bin/ash 38400 tty1 2>/dev/null || sh } BIN=bin/mount.posixovl [ -x /usr/s$BIN ] || mv /bin/mount.posixovl.iso2exe \ -/usr/s$BIN 2> /dev/null || mv /bin/mount.posixovl.iso2exe /$BIN 2> /dev/null +/usr/s$BIN 2>/dev/null || mv /bin/mount.posixovl.iso2exe /$BIN 2>/dev/null mount_proc -for i in /sys/block/*/dev /sys/block/*/*/dev ; do +for i in /sys/block/*/dev /sys/block/*/*/dev; do [ -s "$i" ] || continue n=${i%/dev} n=/dev/${n##*/} [ -e $n ] && continue mknod $n b $(sed 's/:/ /' < $i) -done +done 2>/dev/null ISO="$(getarg bootfrom | sed 's/.://;s|\\|/|g')" -getiso || text 2> /dev/null +getiso 2>/dev/null || text mount_loram case "${ISO##*/}$(getarg mode)" in -*install*|*INSTALL*) install ;; -*live*|*LIVE*) live ;; -*text*|*TEXT*) text ;; +*install*|*INSTALL*) install;; +*live*|*LIVE*) live;; +*text*|*TEXT*) text;; esac -which $DIALOG 2> /dev/null || DIALOG=tinydialog +which $DIALOG 2>/dev/null || DIALOG=tinydialog dmesg > /tmp/dmesg isotitle="$(blkid /mnt/$ISO | sed 's/.*LABEL="\([^"]*\).*/\1/') $(stat \ -c %y /media/cdrom | sed 's/ .*//') $(basename $ISO)" while true; do trap shell 2 - keymap="$(cat /etc/keymap.conf 2> /dev/null)" - locale="$(sed '/^LANG=/!d;s/.*=//' /etc/locale.conf 2> /dev/null)" + keymap="$(cat /etc/keymap.conf 2>/dev/null)" + locale="$(sed '/^LANG=/!d;s/.*=//' /etc/locale.conf 2>/dev/null)" cat > /tmp/dialog <