wok 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 e56b92028f72
children 28bf6d31c5b9
files avant-window-navigator/receipt awesome/receipt awstats-hotspot/receipt syslinux/stuff/iso2exe/iso2exe.sh syslinux/stuff/iso2exe/taziso
line diff
     1.1 --- a/avant-window-navigator/receipt	Fri Dec 04 21:09:27 2015 +0100
     1.2 +++ b/avant-window-navigator/receipt	Fri Dec 04 21:23:22 2015 +0100
     1.3 @@ -68,7 +68,6 @@
     1.4  post_install()
     1.5  {
     1.6    # ln missing icons
     1.7 -  # FIXME
     1.8 -    ln -sf $1/usr/share/icons/SliTaz/16x16/actions/go-up.png $1/usr/share/icons/SliTaz/16x16/actions/gtk-sort-ascending.png
     1.9 -    ln -sf $1/usr/share/icons/SliTaz/16x16/actions/go-down.png $1/usr/share/icons/SliTaz/16x16/actions/gtk-sort-descending.png
    1.10 +    ln -sf go-up.png $1/usr/share/icons/SliTaz/16x16/actions/gtk-sort-ascending.png
    1.11 +    ln -sf go-down.png $1/usr/share/icons/SliTaz/16x16/actions/gtk-sort-descending.png
    1.12  }
     2.1 --- a/awesome/receipt	Fri Dec 04 21:09:27 2015 +0100
     2.2 +++ b/awesome/receipt	Fri Dec 04 21:23:22 2015 +0100
     2.3 @@ -48,7 +48,7 @@
     2.4  
     2.5  post_install()
     2.6  {
     2.7 -	res=$(cat $1/etc/slim.conf | grep ^session | sed s/"sessions. *"//)
     2.8 +	res=$(cat "$1/etc/slim.conf" | grep ^session | sed s/"sessions. *"//)
     2.9  	# Adding WM to SLIM available sessions.
    2.10  	if ! echo "$res" | grep -q $PACKAGE; then
    2.11  		sed -i "s/^sessions.*/sessions            ${res},$PACKAGE/" "$1/etc/slim.conf"
     3.1 --- a/awstats-hotspot/receipt	Fri Dec 04 21:09:27 2015 +0100
     3.2 +++ b/awstats-hotspot/receipt	Fri Dec 04 21:23:22 2015 +0100
     3.3 @@ -24,6 +24,7 @@
     3.4  
     3.5  post_remove()
     3.6  {
     3.7 -	# FIXME root
     3.8 -	grep -l loghotspot.sh /etc/awstats/*.conf | xargs rm -f
     3.9 +	cd "$1/"
    3.10 +	grep -l loghotspot.sh etc/awstats/*.conf | xargs rm -f
    3.11 +	cd - > /dev/null
    3.12  }
     4.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh	Fri Dec 04 21:09:27 2015 +0100
     4.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh	Fri Dec 04 21:23:22 2015 +0100
     4.3 @@ -124,6 +124,30 @@
     4.4  		store 26 $(($SIZE/512)) $1 8
     4.5  	fi
     4.6  }
     4.7 +
     4.8 +custom_config_sector()
     4.9 +{
    4.10 +	echo $(($(get 32848 "$1" 4)+16))
    4.11 +}
    4.12 +
    4.13 +extract_custom_config()
    4.14 +{
    4.15 +	ISO="$1"
    4.16 +	header=
    4.17 +	ddq bs=2k skip=$(custom_config_sector "$ISO") if="$ISO" | \
    4.18 +	while read line; do
    4.19 +		case "$line" in
    4.20 +		\#!boot*) header=1 ;;
    4.21 +		append=*) [ "$header" ] &&
    4.22 +			  echo "${line#append=}" > "$ISO.append" &&
    4.23 +			  ls -l "$ISO.append" ;;
    4.24 +		initrd:*) [ "$header" ] &&
    4.25 +			  ddq bs=1 count=${line#initrd:} > "$ISO.initrd" &&
    4.26 +			  ls -l "$ISO.initrd" ;;
    4.27 +		esac
    4.28 +		[ "$header" ] || break
    4.29 +	done
    4.30 +}
    4.31  case "$1" in
    4.32  --build)
    4.33  	shift
    4.34 @@ -259,15 +283,26 @@
    4.35  main()
    4.36  {
    4.37  	[ $(id -u) -ne 0 ] && exec su -c "$0 $@" < /dev/tty
    4.38 -	case "${1/--/-}" in
    4.39 -	-get)	shift
    4.40 -		uudecode | unlzma | tar xOf - $@
    4.41 -		exit ;;
    4.42 -	*)	cat > /dev/null
    4.43 -	esac
    4.44 +	append=
    4.45 +	initrd=
    4.46 +	while [ "$1" ]; do
    4.47 +		case "${1/--/-}" in
    4.48 +		-get)	shift
    4.49 +			uudecode | unlzma | tar xOf - $@
    4.50 +			exit ;;
    4.51 +		-a*)	append="$2" ; shift 2 ;;
    4.52 +		-i*)	initrd="$2" ; shift 2 ;;
    4.53 +		-e*)	extract_custom_config "$2"
    4.54 +			exit ;;
    4.55 +		*)	cat > /dev/null
    4.56 +			break
    4.57 +		esac
    4.58 +	done
    4.59  	
    4.60 -	[ ! -s "$1" ] &&
    4.61 -	echo "usage: $0 image.iso [--undo|\"DOS help message\"]" 1>&2 && exit 1
    4.62 +	[ ! -s "$1" ] && cat 1>&2 <<EOT && exit 1
    4.63 +usage: $0 [--append custom_cmdline ] [ --initrd custom_initramfs ] image.iso [--undo|"DOS help message"]
    4.64 +or: $0 --extract-custom-config image.iso
    4.65 +EOT
    4.66  	case "${2/--/-}" in
    4.67  	-u*|-r*|-w*)
    4.68  	    case "$(get 0 $1)" in
    4.69 @@ -318,6 +353,24 @@
    4.70  		store 18 $(( (-$n -1) % 65536 )) $1
    4.71  	fi
    4.72  	echo " done."
    4.73 +	if [ "$append$initrd" ]; then
    4.74 +		echo -n "Adding custom config... "
    4.75 +		DATA=/tmp/$0$$
    4.76 +		rm -f $DATA > /dev/null
    4.77 +		isosz=$(stat -c %s $ISO)
    4.78 +		[ "$append" ] && echo "append=$append" >> $DATA
    4.79 +		[ -s "$initrd" ] && echo "initrd:$(stat -c %s $initrd)" >> $DATA &&
    4.80 +			cat $initrd >> $DATA
    4.81 +		echo "#!boot $(md5sum $DATA | sed 's/ .*//')" | cat - $DATA | \
    4.82 +		ddq bs=2k seek=$(custom_config_sector $ISO) of=$ISO conv=notrunc
    4.83 +		if [ $(stat -c %s $ISO) -gt $isosz ]; then
    4.84 +			echo "$(($isosz - $(stat -c %s $ISO))) extra bytes."
    4.85 +		else
    4.86 +			echo "$(($isosz - 32768 - 2048*$(get 32848 $ISO 4) 
    4.87 +				 - $(stat -c %s $DATA) - 24)) bytes free."
    4.88 +		fi
    4.89 +		rm -f $DATA > /dev/null
    4.90 +	fi
    4.91  }
    4.92  
    4.93  main $@ <<EOT
     5.1 --- a/syslinux/stuff/iso2exe/taziso	Fri Dec 04 21:09:27 2015 +0100
     5.2 +++ b/syslinux/stuff/iso2exe/taziso	Fri Dec 04 21:23:22 2015 +0100
     5.3 @@ -11,8 +11,8 @@
     5.4  
     5.5  get()
     5.6  {
     5.7 -	od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An $2 2>/dev/null ||
     5.8 -	hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %d\n\"" $2
     5.9 +	od -v -j $1 -N ${4:-${3:-2}} -t u${3:-2} -w${3:-2} -An "$2" 2>/dev/null ||
    5.10 +	hexdump -v -s $1 -n ${4:-${3:-2}} -e "\"\" 1/${3:-2} \" %d\n\"" "$2"
    5.11  }
    5.12  
    5.13  bytes2bin()
    5.14 @@ -32,14 +32,14 @@
    5.15  gettazboot()
    5.16  {
    5.17  	echo "Creating $(basename $1) ..."
    5.18 -	O=$(($(get 64 $ISO) - 0xC0))
    5.19 -	L=$(($(get 20 $ISO) - 0xC0 - $(get 24 $ISO) - $O))
    5.20 +	O=$(($(get 64 "$ISO") - 0xC0))
    5.21 +	L=$(($(get 20 "$ISO") - 0xC0 - $(get 24 "$ISO") - $O))
    5.22  	S=$((32+$L))
    5.23  	P=$((($S+511)/512))
    5.24  	E=$((4096-(32*$P)))
    5.25  	words2bin 0x5A4D $(($S%512)) $P 0 2 $E -1 $((${2:-0}-16)) \
    5.26  			-2 0 256 -16 28 0x6C53 0x5469 0x7A61 > $1
    5.27 -	ddq bs=1 count=$L skip=$(echo $O) if=$ISO >> $1
    5.28 +	ddq bs=1 count=$L skip=$(echo $O) if="$ISO" >> $1
    5.29  }
    5.30  
    5.31  uncpio()
    5.32 @@ -461,10 +461,10 @@
    5.33  and http://xpt.sourceforge.net/techdocs/nix/disk/boot/boot07-GrubForDosInfo/ar01s03.html
    5.34  EOT
    5.35  	( cd $mnt ; echo 'See \slitaz\boot\install.txt to launch SliTaz.' | \
    5.36 -	  zip -zr9 $(basename $ISO .iso).zip slitaz )
    5.37 +	  zip -zr9 $(basename "$ISO" .iso).zip slitaz )
    5.38  	[ "$(which advzip)" ] && advzip -z4 $mnt/*.zip
    5.39  	mv $mnt/*.zip .
    5.40 -	ls -l $PWD/$(basename $ISO .iso).zip
    5.41 +	ls -l $PWD/$(basename "$ISO" .iso).zip
    5.42  	umount $mnt
    5.43  	rm -rf $mnt
    5.44  }
    5.45 @@ -802,22 +802,22 @@
    5.46  
    5.47  ishybrid()
    5.48  {
    5.49 -	[ $(get 510 $ISO) -eq 43605 ] || return
    5.50 -	C=$((2048*$(get $(((17*2048) + 71)) $ISO 4)))
    5.51 -	[ $(get $C $ISO 4) -eq 1 ] || return
    5.52 -	[ $(get $(($C+30)) $ISO 4) -eq $((0x88AA55)) ] || return
    5.53 -	C=$((2048*$(get $(($C+40)) $ISO 4)))
    5.54 -	[ $(get $(($C+64)) $ISO 4) -eq 1886961915 ] && menuitem "$@"
    5.55 +	[ $(get 510 "$ISO") -eq 43605 ] || return
    5.56 +	C=$((2048*$(get $(((17*2048) + 71)) "$ISO" 4)))
    5.57 +	[ $(get $C "$ISO" 4) -eq 1 ] || return
    5.58 +	[ $(get $(($C+30)) "$ISO" 4) -eq $((0x88AA55)) ] || return
    5.59 +	C=$((2048*$(get $(($C+40)) "$ISO" 4)))
    5.60 +	[ $(get $(($C+64)) "$ISO" 4) -eq 1886961915 ] && menuitem "$@"
    5.61  }
    5.62  
    5.63  isiso()
    5.64  {
    5.65 -	[ $(get 32769 $ISO 4) -eq 808469571 ] && menuitem "$@"
    5.66 +	[ $(get 32769 "$ISO" 4) -eq 808469571 ] && menuitem "$@"
    5.67  }
    5.68  
    5.69  hastazboot()
    5.70  {
    5.71 -	[ $(get 0 $ISO) -eq 23117 ] && menuitem "$@"
    5.72 +	[ $(get 0 "$ISO") -eq 23117 ] && menuitem "$@"
    5.73  }
    5.74  
    5.75  burnable()
    5.76 @@ -844,24 +844,40 @@
    5.77  gotisomd5()
    5.78  {
    5.79  	[ "$(which md5sum 2> /dev/null)" ] &&
    5.80 -	[ $(get 0 $ISO) -eq 23117 ] &&
    5.81 -	[ $(get 18 $ISO) -ne 0 ] && menuitem "$@"
    5.82 +	[ $(get 0 "$ISO") -eq 23117 ] &&
    5.83 +	[ $(get 18 "$ISO") -ne 0 ] && menuitem "$@"
    5.84  }
    5.85  
    5.86  isomd5()
    5.87  {
    5.88  	dotwait "Checking iso image"
    5.89 -	[ "$(ddq if=$ISO bs=2k skip=16 \
    5.90 -	     count=$(echo $(get 32848 $ISO 4)) | md5sum)" == \
    5.91 -	  "$(ddq if=$ISO bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
    5.92 +	[ "$(ddq if="$ISO" bs=2k skip=16 \
    5.93 +	     count=$(echo $(get 32848 "$ISO" 4)) | md5sum)" == \
    5.94 +	  "$(ddq if="$ISO" bs=16 count=1 skip=2047 | od -N 16 -t x1 -An | \
    5.95  	     sed 's/ //g')  -" ] && echo "OK" || echo "ERROR"
    5.96  	echo -en "\rChecking iso hybrid boot..."
    5.97 -	n=$(($(get 2 $ISO)-1+($(get 4 $ISO)-1)*512))
    5.98 +	n=$(($(get 2 "$IS"O)-1+($(get 4 "$ISO")-1)*512))
    5.99  	if [ $n -lt 40000 -a $n -gt 32768 ]; then
   5.100 -		s=$(get 0 $ISO 2 $n | awk '{ i+= $0 } END { print i }')
   5.101 -		[ $(((1+$s+$(get $(($n+1)) $ISO 1)) % 65536)) -eq 0 ] &&
   5.102 +		s=$(get 0 "$ISO" 2 $n | awk '{ i+= $0 } END { print i }')
   5.103 +		[ $(((1+$s+$(get $(($n+1)) "$ISO" 1)) % 65536)) -eq 0 ] &&
   5.104  		echo "OK" || echo "ERROR"
   5.105  	fi
   5.106 +	n=$(($(get 32848 "$ISO" 4)+16))
   5.107 +	if [ "$(ddq bs=2k skip=$n if="$ISO" | ddq bs=1 count=6)" == "#!boot" ]; then
   5.108 +		echo -en "\rChecking iso custum boot..."
   5.109 +		md5="$(ddq bs=2k skip=$n if="$ISO" | while read line; do
   5.110 +			case "$line" in
   5.111 +			\#!boot*) echo ${line#*boot } > /tmp/$0$$md5 ;;
   5.112 +			append=*) echo $line ;;
   5.113 +			initrd:*) echo $line
   5.114 +				  ddq bs=1 count=${line#initrd:}
   5.115 +				  break ;;
   5.116 +			*)	  break ;;	  
   5.117 +			esac
   5.118 +		done | md5sum | cut -c1-32)"
   5.119 +		[ "$md5" == "$(cat /tmp/$0$$md5)" ] && echo "OK" || echo "ERROR"
   5.120 +		rm -f /tmp/$0$$md5
   5.121 +	fi
   5.122  	rm -f /tmp/wait
   5.123  	[ "$1" ] && return 0
   5.124  	echo -e "\rPress RETURN to continue."
   5.125 @@ -923,8 +939,8 @@
   5.126  		usbdev || return
   5.127  	
   5.128  		# perform dd in progress bar
   5.129 -		max=$(($(stat -c %s $ISO)/2048))
   5.130 -		i=0; ddq if=$ISO bs=1024k | ( 
   5.131 +		max=$(($(stat -c %s "$ISO")/2048))
   5.132 +		i=0; ddq if="$ISO" bs=1024k | ( 
   5.133  		while ddq bs=1024k count=1 ; do 
   5.134  			i=$(($i + 1))
   5.135  			[ $i -gt $max ] && break
   5.136 @@ -994,7 +1010,7 @@
   5.137  	exec 3>&-
   5.138  	[ $retval -eq 0 ] || return
   5.139  	[ "$format" != "none" ] && tazusb format $device "SliTaz" $format
   5.140 -	tazusb gen-iso2usb $ISO $device
   5.141 +	tazusb gen-iso2usb "$ISO" $device
   5.142  }
   5.143  
   5.144  dokexec()
   5.145 @@ -1015,8 +1031,8 @@
   5.146  
   5.147  flavdata()
   5.148  {
   5.149 -	[ $(get 1024 $ISO) -eq 35615 ] && n=2 || n=$((1+$(get 417 $ISO 1)))
   5.150 -	dd if=$ISO bs=512 skip=$n count=20 2>/dev/null | zcat 2>/dev/null
   5.151 +	[ $(get 1024 "$ISO") -eq 35615 ] && n=2 || n=$((1+$(get 417 "$ISO" 1)))
   5.152 +	dd if="$ISO" bs=512 skip=$n count=20 2>/dev/null | zcat 2>/dev/null
   5.153  }
   5.154  
   5.155  hasflavinfo()
   5.156 @@ -1053,7 +1069,7 @@
   5.157  {
   5.158  	name="$(flavdata | cpio -t 2> /dev/null | sed 's/.[a-z]*$//;q')"
   5.159  	echo "Create ${name:=flavor}.flavor..."
   5.160 -	tazlito iso2flavor $ISO $name
   5.161 +	tazlito iso2flavor "$ISO" $name
   5.162  	ls -l $name.flavor
   5.163  }
   5.164  
   5.165 @@ -1222,15 +1238,15 @@
   5.166  
   5.167  isotitle()
   5.168  {
   5.169 -	echo "$(basename $ISO)  $(stat -c %y $media/.|sed 's/ .*//')  $(blkid \
   5.170 -		$ISO | sed 's/.*LABEL="\([^"]*\).*/\1/')"
   5.171 +	echo "$(basename "$ISO")  $(stat -c %y $media/.|sed 's/ .*//')  $(blkid \
   5.172 +		"$ISO" | sed 's/.*LABEL="\([^"]*\).*/\1/')"
   5.173  }
   5.174  
   5.175  ISO="${1:-/dev/null}"
   5.176  [ -z "$(isiso 2> /dev/null)" ] && echo "Usage : $0 file.iso" && exit 1
   5.177  media=/tmp/media$$
   5.178  mkdir -p $media
   5.179 -mount -o loop,ro $ISO $media
   5.180 +mount -o loop,ro "$ISO" $media
   5.181  
   5.182  if [ "$2" == "list" ]; then
   5.183  	sed '/^\$(.*") \\/!d;s/^\$(\(.*\)").*/\1"/' $0 | while read line; do