tazlito rev 492

stat -m is busybox only (thanks st_user)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Tue May 01 11:04:57 2018 +0200 (3 months ago)
parents 94ef1a590b5d
children f745d3b22418
files tazlito
line diff
     1.1 --- a/tazlito	Sat Mar 17 14:03:04 2018 +0100
     1.2 +++ b/tazlito	Tue May 01 11:04:57 2018 +0200
     1.3 @@ -18,6 +18,8 @@
     1.4  # Force to use Busybox cpio and wget
     1.5  alias cpio='busybox cpio'
     1.6  alias wget='busybox wget'
     1.7 +alias stat='busybox stat'
     1.8 +alias awk='busybox awk'
     1.9  
    1.10  # Tazlito configuration variables to be shorter
    1.11  # and to use words rather than numbers.
    1.12 @@ -259,15 +261,21 @@
    1.13  }
    1.14  
    1.15  
    1.16 +first_block() {
    1.17 +	busybox stat -m "$1" | sed q
    1.18 +}
    1.19 +
    1.20 +
    1.21 +
    1.22  # Force size and location in the 2nd eltorito boot file (/boot/isolinux/efi.img)
    1.23  
    1.24  fix_efi_boot_img_size() {
    1.25 -	i=$((2048*$(stat -m $2/boot/isolinux/boot.cat | sed q)+102))
    1.26 +	i=$((2048*$(first_block $2/boot/isolinux/boot.cat)+102))
    1.27  	set -- $1 $i $3 $i $2
    1.28  	for i in $(seq 0 8 24); do
    1.29  		printf '\\\\x%02X' $((($3 >> $i) & 255))
    1.30  	done | xargs echo -en | dd bs=1 conv=notrunc of=$1 seek=$2 2>/dev/null
    1.31 -	set -- $1 $((2+$4)) $(stat -m $5/boot/isolinux/efi.img | sed q)
    1.32 +	set -- $1 $((2+$4)) $(first_block $5/boot/isolinux/efi.img)
    1.33  	for i in $(seq 0 8 24); do
    1.34  		printf '\\\\x%02X' $((($3 >> $i) & 255))
    1.35  	done | xargs echo -en | dd bs=1 conv=notrunc of=$1 seek=$2 2>/dev/null
    1.36 @@ -304,7 +312,7 @@
    1.37  	# Build file list tree
    1.38  
    1.39  	( cd $2 ; find efi -type f -exec echo \
    1.40 -	  'stat -c "$(stat -m {} | sed q) %s f %n" {}' \; | sh | sort -n ) \
    1.41 +	  'stat -c "$(first_block {}) %s f %n" {}' \; | sh | sort -n ) \
    1.42  		>/tmp/fatfiles$$
    1.43  	n=$(sed 's/ .*//;q' /tmp/fatfiles$$)
    1.44  	( cd $2; find efi ) | awk -v n=$n 'BEGIN { FS="/" }
    1.45 @@ -420,9 +428,9 @@
    1.46  	dd if=/dev/zero bs=512 count=$r of=/tmp/fatbr$$ 2> /dev/null
    1.47  	echo -en '\x55\xAA' | \
    1.48  		dd of=/tmp/fatbr$$ seek=510 bs=1 conv=notrunc 2> /dev/null
    1.49 -	n=$(stat -m $2/boot/isolinux/efi.img | sed q)
    1.50 +	n=$(first_block $2/boot/isolinux/efi.img)
    1.51  	fat="$(printf "%02X %02X" $(($fat%256)) $((($fat>>8)%256)))"
    1.52 -	s=$((($(stat -m $(ls -r $2/boot/rootfs* | sed q) | sed q) - $n)*4))
    1.53 +	s=$((($(first_block "$(ls -r $2/boot/rootfs* | sed q)") - $n)*4))
    1.54  	if [ $s -gt 65535 ]; then
    1.55  		size="00 00"
    1.56  		size32="$(printf "%02X %02X %02X %02X" $(($s%256)) \
    1.57 @@ -566,7 +574,7 @@
    1.58  		sed -i "s|.* $i|$( cd /tmp/mnt$$ ; md5sum $i)|" $2/md5sum
    1.59  	done
    1.60  	dd if=$2/md5sum of=$1 conv=notrunc bs=2k \
    1.61 -	   seek=$(stat -m /tmp/mnt$$/md5sum | sed q) 2> /dev/null
    1.62 +	   seek=$(first_block /tmp/mnt$$/md5sum) 2> /dev/null
    1.63  	umount -d /tmp/mnt$$
    1.64  	rmdir /tmp/mnt$$
    1.65