wok-6.x rev 24227

syslinux: add apple partitions (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Jan 01 10:31:50 2022 +0000 (2022-01-01)
parents 4ec86b9eafba
children 4e9f81882cd3
files perl-file-rsyncp/receipt syslinux/stuff/iso2exe/iso2exe.sh
line diff
     1.1 --- a/perl-file-rsyncp/receipt	Fri Dec 31 17:52:39 2021 +0100
     1.2 +++ b/perl-file-rsyncp/receipt	Sat Jan 01 10:31:50 2022 +0000
     1.3 @@ -16,6 +16,12 @@
     1.4  DEPENDS="perl rsync"
     1.5  BUILD_DEPENDS="perl"
     1.6  
     1.7 +current_version()
     1.8 +{
     1.9 +	wget -O - $WEB_SITE 2>/dev/null | \
    1.10 +	sed '/release-name/!d;s|.*-v*||;s|<.*||;q'
    1.11 +}
    1.12 +
    1.13  # Rules to configure and make the package.
    1.14  compile_rules()
    1.15  {
     2.1 --- a/syslinux/stuff/iso2exe/iso2exe.sh	Fri Dec 31 17:52:39 2021 +0100
     2.2 +++ b/syslinux/stuff/iso2exe/iso2exe.sh	Sat Jan 01 10:31:50 2022 +0000
     2.3 @@ -46,10 +46,17 @@
     2.4  	if [ "$2" = "--array" ] || grep -qs rootfs $TMP/mnt/boot/isolinux/isolinux.cfg ; then
     2.5  		$0 --get rootfs.gz > $TMP/rootfs.gz
     2.6  		SIZE=$(wc -c < $TMP/rootfs.gz)
     2.7 -		store 24 $SIZE $1
     2.8 -		OFS=$(( 0x7FF0 - SIZE ))
     2.9 -		printf "Adding rootfs.gz file at %04X (%d bytes) ...\n" $OFS $SIZE
    2.10 -		ddn if=$TMP/rootfs.gz of=$1 bs=1 seek=$OFS
    2.11 +		if [ $(get 2048 $1) -eq 19792 -a $SIZE -lt 1912 ]; then	### Apple partitions
    2.12 +			store 24 $((0 - SIZE)) $1
    2.13 +			OFS2=$(( 0x1000 - SIZE ))
    2.14 +			OFS=$(( 0x7FF0 ))
    2.15 +		else
    2.16 +			store 24 $SIZE $1
    2.17 +			unset OFS2
    2.18 +			OFS=$(( 0x7FF0 - SIZE ))
    2.19 +		fi
    2.20 +		printf "Adding rootfs.gz file at %04X (%d bytes) ...\n" ${OFS2:-$OFS} $SIZE
    2.21 +		ddn if=$TMP/rootfs.gz of=$1 bs=1 seek=${OFS2:-$OFS}
    2.22  	fi
    2.23  	umount $TMP/mnt
    2.24  	rm -rf $TMP
    2.25 @@ -75,26 +82,32 @@
    2.26  {
    2.27  	$0 --get bootiso.bin 2> /dev/null > /tmp/bin$$
    2.28  	SIZE=$($0 --get win32.exe 2> /dev/null | tee /tmp/exe$$ | wc -c)
    2.29 -	n=1536
    2.30 -	cut=$((0x98+$(get 0x94 /tmp/exe$$)))	### end of header
    2.31 +	n=1536; n0=0; n2=0
    2.32 +	cut=$((0x98+$(get 0x94 /tmp/exe$$)))			### end of header
    2.33  	if [ $(get 2048 /tmp/bin$$) -eq 19792 ]; then		### Fix EFI Apple partition
    2.34  		o=$(($(get 584 "$1")*512))
    2.35  		f=$(($(get $((o+0x20)) "$1" 4)/4))
    2.36  		l=$((($(get $((o+0x28)) "$1" 4)+1)/4-f))
    2.37  		store $((0x1008)) $(printf "%08x" $f | sed 's|\(..\)\(..\)\(..\)\(..\)|0x\4\3\2\1|') /tmp/bin$$ 32
    2.38  		store $((0x1054)) $(printf "%08x" $l | sed 's|\(..\)\(..\)\(..\)\(..\)|0x\4\3\2\1|') /tmp/bin$$ 32
    2.39 -		n=4608
    2.40 +		printf "Adding Apple partition at %04X (2560 bytes) ...\n" 2048
    2.41 +		if [ $(get 0x86 /tmp/exe$$) -eq 3 ]; then	### UPX files have 3 sections
    2.42 +			n0=136; n2=2696				### cut header / sections decripttion
    2.43 +		else
    2.44 +			n=4608
    2.45 +		fi
    2.46  	fi
    2.47 -	SIZE=$((SIZE+n))
    2.48 +	SIZE=$((SIZE+n+n2-n0))
    2.49  	printf "Adding WIN32 file at %04X (%d bytes) ...\n" 0 $SIZE
    2.50  	[ -n "$gpt" ] && printf "Adding GPT at %04X (1024 bytes) ...\n" 512
    2.51  	for i in $(seq 396 40 $((356+$(get 0x86 /tmp/exe$$)*40))); do	### 18C 1B4 1DC
    2.52 -		x=$((n + $(get $i /tmp/exe$$)))
    2.53 +		x=$((n + n2 - n0 + $(get $i /tmp/exe$$)))
    2.54  		store $i $x /tmp/exe$$		### section offset
    2.55  	done
    2.56  	store $((0x94)) $((n + cut - 0x98)) /tmp/exe$$
    2.57  	ddn if=/tmp/exe$$ of=$1 bs=1 count=$cut
    2.58 -	ddn if=/tmp/exe$$ of=$1 bs=1 skip=$cut seek=$((n+cut))
    2.59 +	[ $n2 -ne 0 ] && ddn if=/tmp/exe$$ of=$1 bs=1 skip=$cut seek=$((n+cut)) count=$n0
    2.60 +	ddn if=/tmp/exe$$ of=$1 bs=1 skip=$((n0+cut)) seek=$((n+n2+cut))
    2.61  	printf "Adding bootiso head at %04X...\n" 0
    2.62  	store 510 $((0xAA55)) $1
    2.63  	while read adrs sz rem; do
    2.64 @@ -171,7 +184,10 @@
    2.65  	c=$(custom_config_sector "$ISO")
    2.66  	SIZE=0; OFFSET=0
    2.67  	case "$1" in
    2.68 -	win32.exe)	[ $x -eq 2048 ] && x=10752
    2.69 +	win32.exe)	[ $x -eq 2048 ] &&
    2.70 +			x=$((40*$(get 0x86 "$ISO")+\
    2.71 +			     0x98-24+$(get 0x94 "$ISO"))) &&
    2.72 +			x=$(($(get $x "$ISO")+$(get $((x+4)) "$ISO")))
    2.73  			[ $x -eq 1024 ] || SIZE=$x;;
    2.74  	syslinux.mbr)	[ $x -eq 1024 ] || OFFSET=$((x - 512)); SIZE=336;;
    2.75  	flavor.info)	[ $(get 22528 "$ISO") -eq 35615 ] && OFFSET=22528
    2.76 @@ -182,7 +198,8 @@
    2.77  			SIZE=$(ddq bs=512 skip=$((OFFSET/512)) if="$ISO" | gzsize);;
    2.78  	floppy.boot)	SIZE=$(($(get 26 "$ISO" 1)*512))
    2.79  			OFFSET=$(($(get 64 "$ISO") - 0xC0 - SIZE));;
    2.80 -	rootfs.gz)	SIZE=$(get 24 "$ISO"); OFFSET=$((stub - SIZE));;
    2.81 +	rootfs.gz)	SIZE=$(get 24 "$ISO"); OFFSET=$((stub - SIZE))
    2.82 +			[ $SIZE -gt 60000 ] && SIZE=$((0x10000 - SIZE)) && OFFSET=$((0x1000 - SIZE));;
    2.83  	isoboot.com)	OFFSET=$(($(get 64 "$ISO") - 0xC0))
    2.84  			SIZE=$((stub - $(get 24 "$ISO") - OFFSET));;
    2.85  	dosstub)	[ "$dosstub" ] && OFFSET=$stub && SIZE=$((0x7FF0 - OFFSET));;
    2.86 @@ -307,6 +324,7 @@
    2.87  {
    2.88  	start=$(custom_config_sector $1)
    2.89  	cnt=$((512 - (start % 512)))
    2.90 +	[ $(($(stat -c %s $1)/2048 - $start)) -ge $cnt ] &&	### Do not enlarge iso !
    2.91  	[ $cnt -ne 512 ] &&
    2.92  	ddq if=/dev/zero of=$1 bs=2k seek=$start count=$cnt
    2.93  }