tazlito rev 512

loram: add 64 bits support
author Pascal Bellard <pascal.bellard@slitaz.org>
date Thu Jun 07 10:44:25 2018 +0200 (11 months ago)
parents e11610f472bf
children 368b74f9c467
files tazlito
line diff
     1.1 --- a/tazlito	Tue Jun 05 15:34:05 2018 +0200
     1.2 +++ b/tazlito	Thu Jun 07 10:44:25 2018 +0200
     1.3 @@ -1298,29 +1298,37 @@
     1.4  
     1.5  	[ -s /usr/share/boot/busybox-static ] || install_package busybox-static
     1.6  	need_lib=false
     1.7 -	for i in bin dev run mnt proc tmp sys lib/modules; do
     1.8 +	for i in bin dev run mnt proc tmp sys lib/modules/64; do
     1.9  		mkdir -p $TMP_DIR/initfs/$i
    1.10  	done
    1.11  	ln -s bin $TMP_DIR/initfs/sbin
    1.12  	ln -s .   $TMP_DIR/initfs/usr
    1.13  	for aufs in aufs overlayfs; do
    1.14 -		[ -f /lib/modules/$version/kernel/fs/$aufs/$aufs.ko.?z ] && break
    1.15 -		install_package linux-$aufs $version && break
    1.16 +		for v in $version ; do
    1.17 +			[ -f /lib/modules/$v/kernel/fs/$aufs/$aufs.ko.?z ] && continue
    1.18 +			install_package ${v/*taz/linux}-$aufs $v && continue
    1.19 +		done
    1.20  		install_package $aufs $version && break
    1.21  	done || return 1
    1.22  	[ -s /init ] || install_package slitaz-boot-scripts
    1.23  	cp /init $TMP_DIR/initfs/
    1.24 -	cp /lib/modules/$version/kernel/fs/$aufs/$aufs.ko.?z \
    1.25 -		$TMP_DIR/initfs/lib/modules
    1.26 +	for v in $version ; do
    1.27 +		cp /lib/modules/$v/kernel/fs/$aufs/$aufs.ko.?z \
    1.28 +			$TMP_DIR/initfs/lib/modules/${v/*taz/}
    1.29 +	done
    1.30  	if [ "$1" == 'cdrom' ]; then
    1.31  		sed -i '/mod squashfs/d' $TMP_DIR/initfs/init
    1.32  	else
    1.33  		[ ! -f /usr/sbin/mksquashfs ] && ! install_package squashfs && return 1
    1.34 -		while [ ! -f /lib/modules/$version/kernel/fs/squashfs/squashfs.ko.?z ]; do
    1.35 -			install_package linux-squashfs $version || return 1
    1.36 +		for v in $version ; do
    1.37 +			while [ ! -f /lib/modules/$v/kernel/fs/squashfs/squashfs.ko.?z ]; do
    1.38 +				install_package linux-squashfs $v || return 1
    1.39 +			done
    1.40  		done
    1.41 -		cp /lib/modules/$version/kernel/fs/squashfs/squashfs.ko.?z \
    1.42 -			$TMP_DIR/initfs/lib/modules
    1.43 +		for v in $version ; do
    1.44 +			cp /lib/modules/$v/kernel/fs/squashfs/squashfs.ko.?z \
    1.45 +				$TMP_DIR/initfs/lib/modules/${v/*taz/}
    1.46 +		done
    1.47  		#ls /sbin/unsquashfs /usr/lib/liblzma.so* $INSTALLED/squashfs/* | \
    1.48  		#cpio -o -H newc > $TMP_DIR/initfs/extractfs.cpio
    1.49  	fi
    1.50 @@ -1359,20 +1367,22 @@
    1.51  		done 2>&1 > /dev/null
    1.52  		cd - > /dev/null
    1.53  		cp $TMP_DIR/fs/etc/slitaz-release $TMP_DIR/initfs/etc/
    1.54 -		find $TMP_DIR/fs/lib/modules/*/kernel/drivers/net/ethernet \
    1.55 -				-type f -name '*.ko*' | while read mod; do
    1.56 -			f=$TMP_DIR/initfs/lib/modules/$(basename $mod | sed s/..z$//)
    1.57 -			uncompress $mod > $f
    1.58 -			grep -q alias=pci: $f || rm -f $f
    1.59 -		done
    1.60 -		for i in $TMP_DIR/initfs/lib/modules/*.ko ; do
    1.61 -			f=$(basename $i)..z
    1.62 -			grep -q $f:$ $TMP_DIR/fs/lib/modules/*/modules.dep && continue
    1.63 -			deps="$(grep $f: $TMP_DIR/fs/lib/modules/*/modules.dep | sed 's/.*: //')"
    1.64 -			echo "$deps" | sed 's|kernel/[^ ]*/||g;s/.ko..z//g' > $TMP_DIR/initfs/lib/modules/$(basename $i .ko).dep
    1.65 -			for j in $deps; do
    1.66 -				mod=$(ls $TMP_DIR/fs/lib/modules/*/$j)
    1.67 -				uncompress $mod > $TMP_DIR/initfs/lib/modules/$(basename $j | sed s/..z$//)
    1.68 +		for v in $version ; do
    1.69 +			find $TMP_DIR/fs/lib/modules/$v/kernel/drivers/net/ethernet \
    1.70 +					-type f -name '*.ko*' | while read mod; do
    1.71 +				f=$TMP_DIR/initfs/lib/modules/${v/*taz/}/$(basename $mod | sed s/..z$//)
    1.72 +				uncompress $mod > $f
    1.73 +				grep -q alias=pci: $f || rm -f $f
    1.74 +				done
    1.75 +			for i in $TMP_DIR/initfs/lib/modules/${v/*taz/}/*.ko ; do
    1.76 +				f=$(basename $i)..z
    1.77 +				grep -q $f:$ $TMP_DIR/fs/lib/modules/$v/modules.dep && continue
    1.78 +				deps="$(grep $f: $TMP_DIR/fs/lib/modules/$v/modules.dep | sed 's/.*: //')"
    1.79 +				echo "$deps" | sed 's|kernel/[^ ]*/||g;s/.ko..z//g' > ${i/.ko/}.dep
    1.80 +				for j in $deps; do
    1.81 +					mod=$(ls $TMP_DIR/fs/lib/modules/$v/$j)
    1.82 +					uncompress $mod > $(echo $j | sed s/..z$//)
    1.83 +				done
    1.84  			done
    1.85  		done
    1.86  		longline "Default URLs for /iso/$(cat $TMP_DIR/initfs/etc/slitaz-release)/flavors/slitaz-loram-cdrom.iso /iso/$(cat $TMP_DIR/initfs/etc/slitaz-release)/flavors/slitaz-$(cat $TMP_DIR/initfs/etc/slitaz-release)-loram-cdrom.iso: $urliso"
    1.87 @@ -1398,8 +1408,10 @@
    1.88  		ln $TMP_DIR/initfs/bin/busybox $TMP_DIR/initfs/bin/$i
    1.89  	done
    1.90  	# bootfloppybox will need floppy.ko.?z, /dev/fd0, /dev/tty0
    1.91 -	cp /lib/modules/$version/kernel/drivers/block/floppy.ko.?z \
    1.92 -		$TMP_DIR/initfs/lib/modules 2>/dev/null
    1.93 +	for v in $version ; do
    1.94 +		cp /lib/modules/$v/kernel/drivers/block/floppy.ko.?z \
    1.95 +			$TMP_DIR/initfs/lib/modules/${v/*taz/} 2>/dev/null
    1.96 +	done
    1.97  	for i in /dev/console /dev/null /dev/tty /dev/tty0 /dev/zero \
    1.98  		 /dev/kmem /dev/mem /dev/random /dev/urandom; do
    1.99  		cp -a $i $TMP_DIR/initfs/dev
   1.100 @@ -1440,7 +1452,8 @@
   1.101  [ -n "\$size" ] || size="-o size=90%"
   1.102  
   1.103  mount -t sysfs sysfs /sys
   1.104 -for i in /lib/modules/*.ko ; do
   1.105 +for i in /lib/modules/*/*.ko /lib/modules/*.ko ; do
   1.106 +	[ -s \$i ] && continue
   1.107  	echo -en "Probe \$i           \\r"
   1.108  	for j in \$(grep alias=pci: \$i | sed 's/alias//;s/\*/.*/g'); do
   1.109  		grep -q "\$j" /sys/bus/pci/devices/*/uevent || continue
   1.110 @@ -1501,7 +1514,9 @@
   1.111  if [ ! -d /mnt/.cdrom/\$DIR/etc ]; then
   1.112  branch=
   1.113  lp=1
   1.114 -insmod /lib/modules/squashfs.ko 2> /dev/null
   1.115 +for i in /lib/modules/*/squashfs.ko /lib/modules/squashfs.ko ; do
   1.116 +	[ -s \$i ] && insmod \$i
   1.117 +done 2> /dev/null
   1.118  for i in \${path}boot/rootfs?.* ; do
   1.119  	fs=\${i#*root}
   1.120  	branch=\$branch:/mnt/.\$fs
   1.121 @@ -1513,7 +1528,10 @@
   1.122  fi
   1.123  mkdir -p /mnt/.rw/mnt/.httpfs
   1.124  while read type opt; do
   1.125 -	insmod /lib/modules/\$type.ko && mount -t \$type -o \$opt none /mnt && break
   1.126 +	for i in /lib/modules/*/\$type.ko /lib/modules/\$type.ko ; do
   1.127 +		[ -s \$i ] && insmod \$i &&
   1.128 +		mount -t \$type -o \$opt none /mnt && break 2
   1.129 +	done
   1.130  done <<EOT
   1.131  aufs		br=/mnt/.rw\$branch
   1.132  overlayfs	workdir=/mnt/.wd\${branch/:/,lowerdir=},upperdir=/mnt/.rw
   1.133 @@ -1524,7 +1542,8 @@
   1.134  [ -x /mnt/sbin/init ] && exec /bin/switch_root mnt /sbin/init || sh
   1.135  EOTEOT
   1.136  	chmod +x $TMP_DIR/initfs/init
   1.137 -	for i in $TMP_DIR/initfs/lib/modules/*z ; do
   1.138 +	for i in $TMP_DIR/initfs/lib/modules/*z $TMP_DIR/initfs/lib/modules/*/*z ; do
   1.139 +		[ -s $i ] || continue
   1.140  		unxz $i || gunzip $i || lzma d $i ${i%.gz}
   1.141  		rm -f $i
   1.142  	done 2>/dev/null
   1.143 @@ -1541,19 +1560,22 @@
   1.144  
   1.145  build_loram_rootfs() {
   1.146  	rootfs_sizes=""
   1.147 -	for i in $TMP_DIR/iso/boot/rootfs*; do
   1.148 +	for i in $(ls -r $TMP_DIR/iso/boot/rootfs*); do
   1.149  		mkdir -p $TMP_DIR/fs
   1.150  		cd $TMP_DIR/fs
   1.151  		uncompress $i | cpio -idm
   1.152  		deduplicate
   1.153  		cd - > /dev/null
   1.154 -		rootfs=$TMP_DIR/$(basename $i)
   1.155 +		rootfs=$TMP_DIR/$(basename $i 64)
   1.156 +		[ $rootfs == $TMP_DIR/rootfs.gz ] && rootfs=$TMP_DIR/rootfs0.gz
   1.157  		/usr/sbin/mksquashfs $TMP_DIR/fs $rootfs -comp ${1:-xz -Xbcj x86}
   1.158  		cd $TMP_DIR
   1.159  		rootfs_sizes="$rootfs_sizes $(( $(du -s $TMP_DIR/fs | cut -f1) - $(du -s $rootfs | cut -f1) ))"
   1.160  		( cd $(dirname $rootfs); echo $(basename $rootfs) | cpio -o -H newc ) > $rootfs.cpio
   1.161 +		[ $(ls -a fs | wc -l) -le 2 ] && cpio -o -H newc > $rootfs.cpio < /dev/null
   1.162 +		case "$i" in *64) rootfs=${rootfs}64 ;; esac
   1.163  		rm -f $rootfs
   1.164 -		mv $rootfs.cpio $rootfs
   1.165 +		mv ${rootfs%64}.cpio $rootfs
   1.166  		cd - > /dev/null
   1.167  		rm -rf $TMP_DIR/fs
   1.168  	done
   1.169 @@ -1627,6 +1649,8 @@
   1.170  # Reduce sizes with rootfs gains.
   1.171  
   1.172  update_metaiso_sizes() {
   1.173 +	[ -s $TMP_DIR/loramiso/boot/rootfs0.gz ] &&
   1.174 +		sed -i 's|rootfs.gz|&,/boot/rootfs0.gz|' $TMP_DIR/loramiso/boot/isolinux/*.cfg
   1.175  	for cfg in $(grep -El '(append|ifmem) [0-9]' $TMP_DIR/loramiso/boot/isolinux/*.cfg)
   1.176  	do
   1.177  		local append="$(grep -E '(append|ifmem) [0-9]' $cfg)"