tazlito rev 529

move efi.img to /efi/esp.img
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Oct 31 16:26:51 2020 +0000 (2 months ago)
parents fba53d645af2
children 668f2e7befb0
files tazlito
line diff
     1.1 --- a/tazlito	Sun Oct 04 13:26:53 2020 +0000
     1.2 +++ b/tazlito	Sat Oct 31 16:26:51 2020 +0000
     1.3 @@ -34,6 +34,7 @@
     1.4  CACHE_DIR='/var/cache/tazpkg'
     1.5  MIRROR="$LOCALSTATE/mirror"
     1.6  DEFAULT_MIRROR="http://mirror1.slitaz.org/packages/$(cat /etc/slitaz-release)/"
     1.7 +efi_img="efi/esp.img"
     1.8  
     1.9  log='/var/log/tazlito.log'
    1.10  if [ $(id -u) -eq 0 ]; then
    1.11 @@ -269,7 +270,7 @@
    1.12  
    1.13  
    1.14  
    1.15 -# Force size and location in the 2nd eltorito boot file (/boot/isolinux/efi.img)
    1.16 +# Force size and location in the 2nd eltorito boot file (/$efi_img)
    1.17  
    1.18  fix_efi_boot_img_size() {
    1.19  	local n=$3
    1.20 @@ -279,11 +280,11 @@
    1.21  }
    1.22  
    1.23  
    1.24 -# Force the size for the /boot/isolinux/efi.img file
    1.25 +# Force the size for the /$efi_img file
    1.26  
    1.27  fix_efi_img_size() {
    1.28  	local e=$((0x809C))
    1.29 -	for i in BOOT ISOLINUX EFI.IMG ; do
    1.30 +	for i in $(echo ${efi_img//\// } | tr a-z A-Z) ; do
    1.31  		local sz=$(get $(($e+10)) "$2" 4)
    1.32  		e=$(($(get $(($e+2)) "$2" 4) * 2048))
    1.33  		while [ $sz -gt 0 ]; do
    1.34 @@ -300,31 +301,31 @@
    1.35  }
    1.36  
    1.37  
    1.38 -# create /boot/isolinux/efi.img to share EFI files with the iso image
    1.39 +# create /$efi_img to share EFI files with the iso image
    1.40  
    1.41  fixup_uefi_part() {
    1.42 -	[ -s $2/boot/isolinux/efi.img ] || return
    1.43 -	[ -x $2/boot/isolinux/efi.img ] && return
    1.44 -	local n=$(get 19 "$2/boot/isolinux/efi.img")
    1.45 -	[ $n -eq 0 ] && n=$(get 32 "$2/boot/isolinux/efi.img" 4)
    1.46 -	efiblock=$(first_block "$2/boot/isolinux/efi.img")
    1.47 +	[ -s $2/$efi_img ] || return
    1.48 +	[ -x $2/$efi_img ] && return
    1.49 +	local n=$(get 19 "$2/$efi_img")
    1.50 +	[ $n -eq 0 ] && n=$(get 32 "$2/$efi_img" 4)
    1.51 +	efiblock=$(first_block "$2/$efi_img")
    1.52  	fix_efi_img_size $(($n*512)) $1
    1.53  	fix_efi_boot_img_size $1 $2 $n $efiblock
    1.54  	
    1.55  	# Build file list tree
    1.56 -	resv=$(get 14 "$2/boot/isolinux/efi.img")
    1.57 -	if [ $(get 57 "$2/boot/isolinux/efi.img" 1) -ne 49 ]; then
    1.58 +	resv=$(get 14 "$2/$efi_img")
    1.59 +	if [ $(get 57 "$2/$efi_img" 1) -ne 49 ]; then
    1.60  		skiphead=5
    1.61 -		fatsz=$(get 36 "$2/boot/isolinux/efi.img" 4)
    1.62 +		fatsz=$(get 36 "$2/$efi_img" 4)
    1.63  		basecluster=$((($resv+2*$fatsz)/4+$efiblock-2))
    1.64  		dd if=$1 bs=512 skip=$(($efiblock*4)) count=3 \
    1.65  			of=$1 seek=$(($efiblock*4+3)) conv=notrunc
    1.66  	else
    1.67  		skiphead=4
    1.68 -		fatsz=$(get 22 "$2/boot/isolinux/efi.img")
    1.69 +		fatsz=$(get 22 "$2/$efi_img")
    1.70  		basecluster=$((($resv+2*$fatsz)/4+$efiblock-1))
    1.71  	fi 2> /dev/null
    1.72 -	hd "$2/boot/isolinux/efi.img" | awk 'BEGIN { skiphead='$skiphead' }
    1.73 +	hd "$2/$efi_img" | awk 'BEGIN { skiphead='$skiphead' }
    1.74  {
    1.75    if (skiphead!=0) {
    1.76      if ($1=="*") skiphead--
    1.77 @@ -389,8 +390,8 @@
    1.78  	done
    1.79  
    1.80  	# Update fat12 or fat16
    1.81 -	get 57 "$2/boot/isolinux/efi.img"
    1.82 -	dd if="$2/boot/isolinux/efi.img" bs=512 count=$fatsz skip=$resv 2> /dev/null | \
    1.83 +	get 57 "$2/$efi_img"
    1.84 +	dd if="$2/$efi_img" bs=512 count=$fatsz skip=$resv 2> /dev/null | \
    1.85  	od -An -t u1 -w1 -v
    1.86      ) | awk '
    1.87  {
    1.88 @@ -467,8 +468,8 @@
    1.89  
    1.90  alloc_uefi_part() {
    1.91  	local basedir=$(dirname "$1")/..
    1.92 -	if [ -s $basedir/boot/isolinux/efi.img ]; then
    1.93 -		chmod +x $basedir/boot/isolinux/efi.img
    1.94 +	if [ -s $basedir/$efi_img ]; then
    1.95 +		chmod +x $basedir/$efi_img
    1.96  		return
    1.97  	fi
    1.98  	local fclust=$({
    1.99 @@ -546,13 +547,13 @@
   1.100  		size="$(printf "%02X %02X" $(($s%256)) $((($s>>8)%256)) )"
   1.101  		size32="00 00 00 00"
   1.102  	fi
   1.103 -	dd if=/dev/zero bs=512 of=$basedir/boot/isolinux/efi.img \
   1.104 +	dd if=/dev/zero bs=512 of=$basedir/$efi_img \
   1.105  		count=$s 2> /dev/null
   1.106  
   1.107  	# Create boot sector
   1.108  	doslabel="$(echo "SLITAZ BOOT         " | od -v -N 11 -t x1 -w1 -An)"
   1.109  	if [ "$ftype" = "33 32" ]; then
   1.110 -		hexdump -R <<EOT | dd of=$basedir/boot/isolinux/efi.img \
   1.111 +		hexdump -R <<EOT | dd of=$basedir/$efi_img \
   1.112  			conv=notrunc
   1.113  0  eb 58 90 53 6c 69 54 61  7a 00 00 00 02 04 $rsect 00  |
   1.114  0  02 00 00 $size f8 00 00  20 00 40 00 00 00 00 00  |
   1.115 @@ -563,16 +564,16 @@
   1.116  EOT
   1.117  		while read ofs data; do
   1.118  			echo "0 ${data//:/ } |" | hexdump -R | dd conv=notrunc \
   1.119 -			bs=1 seek=$ofs of=$basedir/boot/isolinux/efi.img
   1.120 +			bs=1 seek=$ofs of=$basedir/$efi_img
   1.121  		done <<EOT
   1.122  510	55:aa:52:52:61:41
   1.123  996	72:72:41:61:ff:ff:ff:ff:02
   1.124  1022	55:aa
   1.125  EOT
   1.126  	else
   1.127 -		echo -en '\x55\xAA' | dd of=$basedir/boot/isolinux/efi.img \
   1.128 +		echo -en '\x55\xAA' | dd of=$basedir/$efi_img \
   1.129  			seek=510 bs=1 conv=notrunc
   1.130 -		hexdump -R <<EOT | dd of=$basedir/boot/isolinux/efi.img \
   1.131 +		hexdump -R <<EOT | dd of=$basedir/$efi_img \
   1.132  			conv=notrunc
   1.133  0  eb 3c 90 53 6c 69 54 61  7a 00 00 00 02 04 $rsect 00  |
   1.134  0  02 40 00 $size f8 $fsz   20 00 40 00 00 00 00 00  |
   1.135 @@ -583,32 +584,32 @@
   1.136  	fi 2> /dev/null
   1.137  
   1.138  	# Create fats
   1.139 -	echo "0  $fhead |" | hexdump -R | dd of=$basedir/boot/isolinux/efi.img \
   1.140 +	echo "0  $fhead |" | hexdump -R | dd of=$basedir/$efi_img \
   1.141  		seek=$(($rsect)) bs=512 conv=notrunc 2> /dev/null
   1.142 -	echo "0  $fhead |" | hexdump -R | dd of=$basedir/boot/isolinux/efi.img \
   1.143 +	echo "0  $fhead |" | hexdump -R | dd of=$basedir/$efi_img \
   1.144  		seek=$(($rsect+$fsect)) bs=512 conv=notrunc 2> /dev/null
   1.145  
   1.146  	# Add label
   1.147  	echo "0  $doslabel 08 |" | hexdump -R | \
   1.148 -		dd of=$basedir/boot/isolinux/efi.img bs=512 conv=notrunc \
   1.149 +		dd of=$basedir/$efi_img bs=512 conv=notrunc \
   1.150  		seek=$(($rsect+$fsect+$fsect)) 2> /dev/null
   1.151  
   1.152  	mkdir -p /tmp/mnt$$
   1.153 -	mount -o loop $basedir/boot/isolinux/efi.img /tmp/mnt$$
   1.154 +	mount -o loop $basedir/$efi_img /tmp/mnt$$
   1.155  	( cd $basedir; find efi -type d | cpio -o -H newc ) | \
   1.156  		( cd /tmp/mnt$$ ; cpio -idmu 2> /dev/null )
   1.157  	sync
   1.158 -	dd if=$basedir/boot/isolinux/efi.img of=/tmp/fat$$ \
   1.159 +	dd if=$basedir/$efi_img of=/tmp/fat$$ \
   1.160  		skip=$rsect bs=512 count=$fsect 2> /dev/null
   1.161 -	( cd $basedir; find efi -type f | cpio -o -H newc ) | \
   1.162 +	( cd $basedir; find efi/boot -type f | cpio -o -H newc ) | \
   1.163  		( cd /tmp/mnt$$ ; cpio -idmu 2> /dev/null )
   1.164  	umount /tmp/mnt$$
   1.165 -	cat /tmp/fat$$ /tmp/fat$$ | dd of=$basedir/boot/isolinux/efi.img \
   1.166 +	cat /tmp/fat$$ /tmp/fat$$ | dd of=$basedir/$efi_img \
   1.167  		seek=$rsect bs=512 conv=notrunc 2> /dev/null
   1.168  	rm /tmp/fat$$
   1.169  	rmdir /tmp/mnt$$
   1.170  
   1.171 -	dd count=0 bs=2k of=$basedir/boot/isolinux/efi.img \
   1.172 +	dd count=0 bs=2k of=$basedir/$efi_img \
   1.173  		seek=$count 2> /dev/null
   1.174  }
   1.175  
   1.176 @@ -648,7 +649,7 @@
   1.177  $PWD/boot/isolinux/i18n.cfg
   1.178  $PWD/boot/isolinux/c32box.c32
   1.179  $PWD/boot/isolinux/kbd
   1.180 -$PWD/boot/isolinux/efi.img
   1.181 +$PWD/$efi_img
   1.182  $PWD/boot/bzImage*
   1.183  $PWD/efi/boot/linux.cmdline*
   1.184  $PWD/boot/rootfs*
   1.185 @@ -664,7 +665,7 @@
   1.186  	title 'Generating ISO image'
   1.187  
   1.188  	_ 'Generating %s' "$1"
   1.189 -	uefi="$(cd $2 ; ls boot/isolinux/efi.img 2> /dev/null)"
   1.190 +	uefi="$(cd $2 ; ls $efi_img 2> /dev/null)"
   1.191  	genisoimage -R  -o $1  -hide-rr-moved -sort /tmp/cdsort$$ \
   1.192  		-b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat \
   1.193  		-no-emul-boot   -boot-load-size 4   -boot-info-table \
   1.194 @@ -680,7 +681,7 @@
   1.195  	mount -o loop,ro $1 /tmp/mnt$$
   1.196  	fixup_uefi_part $1 /tmp/mnt$$
   1.197  	for i in boot/isolinux/isolinux.bin boot/isolinux/boot.cat \
   1.198 -		 ${uefi:+boot/isolinux/efi.img} ; do
   1.199 +		 ${uefi:+$efi_img} ; do
   1.200  		sed -i "s|.* $i|$( cd /tmp/mnt$$ ; md5sum $i)|" $2/md5sum
   1.201  	done
   1.202  	dd if=$2/md5sum of=$1 conv=notrunc bs=2k \
   1.203 @@ -1295,9 +1296,9 @@
   1.204  # Remove duplicated files in $1/efi/boot from $1/boot
   1.205  
   1.206  cleanup_efi_boot() {
   1.207 -	[ -s $1/boot/isolinux/efi.img ] &&
   1.208 -	[ ! -x $1/boot/isolinux/efi.img ] &&
   1.209 -	rm -f $1/boot/isolinux/efi.img
   1.210 +	for i in $1/$efi_img $1/boot/isolinux/efi.img ; do
   1.211 +		[ -s $i ] && [ ! -x $i ] && rm -f $i
   1.212 +	done
   1.213  	for i in $1/efi/boot/* ; do
   1.214  		[ -f $i ] || continue
   1.215  		case "$i" in