wok-current diff syslinux/stuff/iso2exe/iso2exe.sh @ rev 18670
taziso, iso2exe.sh: add custom config support ; awstat-hotspot, awesome, avant-window-navigator: update pre/post_install
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Fri Dec 04 21:23:22 2015 +0100 (2015-12-04) |
parents | 41c93f510464 |
children | 857cceeac404 |
line diff
1.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh Mon May 18 10:09:16 2015 +0200 1.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh Fri Dec 04 21:23:22 2015 +0100 1.3 @@ -124,6 +124,30 @@ 1.4 store 26 $(($SIZE/512)) $1 8 1.5 fi 1.6 } 1.7 + 1.8 +custom_config_sector() 1.9 +{ 1.10 + echo $(($(get 32848 "$1" 4)+16)) 1.11 +} 1.12 + 1.13 +extract_custom_config() 1.14 +{ 1.15 + ISO="$1" 1.16 + header= 1.17 + ddq bs=2k skip=$(custom_config_sector "$ISO") if="$ISO" | \ 1.18 + while read line; do 1.19 + case "$line" in 1.20 + \#!boot*) header=1 ;; 1.21 + append=*) [ "$header" ] && 1.22 + echo "${line#append=}" > "$ISO.append" && 1.23 + ls -l "$ISO.append" ;; 1.24 + initrd:*) [ "$header" ] && 1.25 + ddq bs=1 count=${line#initrd:} > "$ISO.initrd" && 1.26 + ls -l "$ISO.initrd" ;; 1.27 + esac 1.28 + [ "$header" ] || break 1.29 + done 1.30 +} 1.31 case "$1" in 1.32 --build) 1.33 shift 1.34 @@ -259,15 +283,26 @@ 1.35 main() 1.36 { 1.37 [ $(id -u) -ne 0 ] && exec su -c "$0 $@" < /dev/tty 1.38 - case "${1/--/-}" in 1.39 - -get) shift 1.40 - uudecode | unlzma | tar xOf - $@ 1.41 - exit ;; 1.42 - *) cat > /dev/null 1.43 - esac 1.44 + append= 1.45 + initrd= 1.46 + while [ "$1" ]; do 1.47 + case "${1/--/-}" in 1.48 + -get) shift 1.49 + uudecode | unlzma | tar xOf - $@ 1.50 + exit ;; 1.51 + -a*) append="$2" ; shift 2 ;; 1.52 + -i*) initrd="$2" ; shift 2 ;; 1.53 + -e*) extract_custom_config "$2" 1.54 + exit ;; 1.55 + *) cat > /dev/null 1.56 + break 1.57 + esac 1.58 + done 1.59 1.60 - [ ! -s "$1" ] && 1.61 - echo "usage: $0 image.iso [--undo|\"DOS help message\"]" 1>&2 && exit 1 1.62 + [ ! -s "$1" ] && cat 1>&2 <<EOT && exit 1 1.63 +usage: $0 [--append custom_cmdline ] [ --initrd custom_initramfs ] image.iso [--undo|"DOS help message"] 1.64 +or: $0 --extract-custom-config image.iso 1.65 +EOT 1.66 case "${2/--/-}" in 1.67 -u*|-r*|-w*) 1.68 case "$(get 0 $1)" in 1.69 @@ -318,6 +353,24 @@ 1.70 store 18 $(( (-$n -1) % 65536 )) $1 1.71 fi 1.72 echo " done." 1.73 + if [ "$append$initrd" ]; then 1.74 + echo -n "Adding custom config... " 1.75 + DATA=/tmp/$0$$ 1.76 + rm -f $DATA > /dev/null 1.77 + isosz=$(stat -c %s $ISO) 1.78 + [ "$append" ] && echo "append=$append" >> $DATA 1.79 + [ -s "$initrd" ] && echo "initrd:$(stat -c %s $initrd)" >> $DATA && 1.80 + cat $initrd >> $DATA 1.81 + echo "#!boot $(md5sum $DATA | sed 's/ .*//')" | cat - $DATA | \ 1.82 + ddq bs=2k seek=$(custom_config_sector $ISO) of=$ISO conv=notrunc 1.83 + if [ $(stat -c %s $ISO) -gt $isosz ]; then 1.84 + echo "$(($isosz - $(stat -c %s $ISO))) extra bytes." 1.85 + else 1.86 + echo "$(($isosz - 32768 - 2048*$(get 32848 $ISO 4) 1.87 + - $(stat -c %s $DATA) - 24)) bytes free." 1.88 + fi 1.89 + rm -f $DATA > /dev/null 1.90 + fi 1.91 } 1.92 1.93 main $@ <<EOT