slitaz-arm rev 26

Bunch og changes: put all gen files in distro/, improve visual output, handle flavor custom rootfs
author Christophe Lincoln <pankso@slitaz.org>
date Mon Mar 03 13:44:20 2014 +0100 (2014-03-03)
parents 3d67f3150009
children 686faffdd9d0
files sat
line diff
     1.1 --- a/sat	Mon Mar 03 03:48:52 2014 +0100
     1.2 +++ b/sat	Mon Mar 03 13:44:20 2014 +0100
     1.3 @@ -13,10 +13,11 @@
     1.4  [ "$work" ] || work="$(pwd)"
     1.5  [ "$init" ] || init="gz"
     1.6  initramfs="slitaz-arm.$init"
     1.7 -packages=$work/packages
     1.8 -distro=$work/distro
     1.9 -flavors=$work/flavors
    1.10 -cache=$work/cache
    1.11 +packages="$work/packages"
    1.12 +distro="$work/distro"
    1.13 +flavors="$work/flavors"
    1.14 +rootfs="$distro/rootfs"
    1.15 +
    1.16  # http://mirror.slitaz.org/packages/cooking/arm/
    1.17  mirror="http://cook.slitaz.org/cross/arm/packages/"
    1.18  
    1.19 @@ -29,7 +30,7 @@
    1.20  $(boldify "Commands:")
    1.21    gen        Generate a distro cpio/gzip initramfs
    1.22    flavors    List and give info about flavors
    1.23 -  pkgs       Distro packages check and count
    1.24 +  ckpkgs     Distro packages dependencies check
    1.25    clean      Clean up the work directory
    1.26    vdisk      Create a virtual disk to be used by Qemu
    1.27    emu        Emulate the distro with qemu-system-arm
    1.28 @@ -55,12 +56,12 @@
    1.29  	if busybox wget -qs ${mirror%/}/ID 2>/dev/null; then
    1.30  		busybox wget -q ${mirror%/}/ID
    1.31  	else
    1.32 -		gettext "Mirror is unreachable"; false
    1.33 -		status && return 1
    1.34 +		gettext "Mirror is unreachable"; newline
    1.35 +		return 1
    1.36  	fi
    1.37  	if [ "$(cat ID)" == "$(cat ID.bak)" ]; then
    1.38 -		gettext "Mirror is up-to-date"; true
    1.39 -		status && return 1
    1.40 +		gettext "Mirror is up-to-date"; newline
    1.41 +		return 1
    1.42  	fi
    1.43  }
    1.44  
    1.45 @@ -72,54 +73,54 @@
    1.46  	gen)
    1.47  		time=$(date +%s)
    1.48  		check_root
    1.49 -		echo ""
    1.50 -		boldify "Generating SliTaz ARM distro"
    1.51 +		newline && boldify "Generating SliTaz ARM distro"
    1.52  		separator
    1.53 -		rm -rf $distro $initramfs
    1.54 -		mkdir -p $distro $cache
    1.55 +		rm -rf $distro && mkdir -p ${rootfs}
    1.56  		
    1.57  		# Get --flavor= packages lists
    1.58  		if [ "$flavor" ]; then
    1.59  			echo -n "Getting $flavor packages.list..."
    1.60 -			cp -f $flavors/$flavor/packages.list .
    1.61 +			cp -f $flavors/$flavor/packages.list $distro 2>/dev/null
    1.62  			status
    1.63  		fi
    1.64  
    1.65  		# Packages
    1.66 -		rm -f $cache/packages.full
    1.67 -		if [ -f "packages.list" ]; then
    1.68 -			for pkg in $(cat $packages.list)
    1.69 +		rm -f $distro/packages.full
    1.70 +		if [ -f "$distro/packages.list" ]; then
    1.71 +			for pkg in $(cat $distro/packages.list)
    1.72  			do
    1.73  				IFS="|"
    1.74  				grep "^$pkg |" $work/mirror/packages.desc | while read pkg version desc
    1.75  				do
    1.76  					echo ${pkg}-${version}-arm.tazpkg | sed s'/ //'g \
    1.77 -						>> $cache/packages.full
    1.78 +						>> $distro/packages.full
    1.79  				done
    1.80  				unset IFS
    1.81  			done
    1.82  			cd ${work}/mirror
    1.83  		else
    1.84 -			[ ! -d "$packages" ] && \
    1.85 -				echo "Missing packages.list or packages/ directory" && exit 1
    1.86 +			if [ ! -d "$packages" ]; then
    1.87 +				echo "Missing distro/packages.list or packages/ directory"
    1.88 +				echo "" && exit 1
    1.89 +			fi
    1.90  			echo -n "Using packages directory..."
    1.91 -			cd $packages && ls -1 > $cache/packages.full
    1.92 +			cd $packages && ls -1 > $distro/packages.full
    1.93  			status
    1.94  		fi
    1.95  		
    1.96  		# Deps install is not well handled by tazpkg/spk actually.
    1.97  		# So simply install all packages and don't resolve deps.
    1.98 -		for pkg in $(cat $cache/packages.full)
    1.99 +		for pkg in $(cat $distro/packages.full)
   1.100  		do
   1.101  			pkgdir=$(basename $pkg .tazpkg)
   1.102 -			db=$distro/var/lib/tazpkg
   1.103 +			db=${rootfs}/var/lib/tazpkg
   1.104  			echo -n "Installing: $(basename $pkg)"
   1.105  			tazpkg extract $pkg >/dev/null
   1.106  			. $pkgdir/receipt
   1.107  			mkdir -p $db/installed/$PACKAGE
   1.108  			cp $pkgdir/receipt $pkgdir/files.list \
   1.109  				$db/installed/$PACKAGE
   1.110 -			cp -a $pkgdir/fs/* $distro && rm -rf $pkgdir
   1.111 +			cp -a $pkgdir/fs/* $distro/rootfs && rm -rf $pkgdir
   1.112  			md5sum $(basename $pkg) >> $db/installed.md5
   1.113  			status
   1.114  		done
   1.115 @@ -129,32 +130,33 @@
   1.116  			hg=http://hg.slitaz.org
   1.117  			echo -n "Installing: spk ($hg)"
   1.118  			cd $work
   1.119 -			[ -d "spk" ] || hg clone $hg/spk >/dev/null
   1.120 +			[ -d "spk" ] || hg clone $hg/spk >/dev/null 2>/dev/null
   1.121  			cd $work/spk
   1.122  			[ "$noup" ] || hg pull -u >/dev/null
   1.123 -			make DESTDIR=$distro install >/dev/null
   1.124 +			make DESTDIR=${rootfs} install >/dev/null
   1.125  			status
   1.126  		fi
   1.127  
   1.128  		# Move kernel outside the distro
   1.129 -		if [ -d "$distro/boot" ]; then
   1.130 -			cd $work && mv -f $distro/boot/linux-* linux-arm
   1.131 +		if [ -d "$distro/rootfs/boot" ]; then
   1.132 +			mv -f ${rootfs}/boot/linux-* ${distro}/linux-arm
   1.133 +			chmod -x ${distro}/linux-arm
   1.134  		else
   1.135 -			echo -n "Missing: $distro/boot"; false
   1.136 +			echo -n "Missing: ${rootfs}/boot"; false
   1.137  			status && exit 1
   1.138  		fi
   1.139  
   1.140  		# SLITAZ_ARCH
   1.141  		echo -n "Setting SliTaz arch to: arm"
   1.142  		sed -i s"/SLITAZ_ARCH=.*/SLITAZ_ARCH=\"arm\"/" \
   1.143 -			$distro/etc/slitaz/slitaz.conf
   1.144 +			${rootfs}/etc/slitaz/slitaz.conf
   1.145  		status
   1.146  
   1.147  		# Mirror
   1.148 -		echo "$mirror" > $distro/var/lib/tazpkg/mirror
   1.149 +		echo "$mirror" > ${rootfs}/var/lib/tazpkg/mirror
   1.150  
   1.151  		# /init & /run
   1.152 -		cd $distro
   1.153 +		cd ${rootfs}
   1.154  		rm init && ln -s /bin/busybox init
   1.155  		mkdir -p run
   1.156  
   1.157 @@ -162,23 +164,38 @@
   1.158  		. var/lib/tazpkg/installed/linux/receipt
   1.159  		depmod -b . ${VERSION}-slitaz
   1.160  
   1.161 -		# Custom rootfs: make sure all files belong to root.
   1.162 +		# Custom rootfs: make sure all files belong to root
   1.163  		if [ -d "$work/rootfs" ]; then
   1.164 -			echo -n "Copying custom ARM rootfs..."
   1.165 -			tmp=$work/tmp-$$
   1.166 +			echo -n "Copying custom ARM: rootfs"
   1.167 +			tmp=$distro/tmp-$$
   1.168  			mkdir -p $tmp
   1.169  			cp -r $work/rootfs/* $tmp
   1.170 -			if [ "$kmap" ]; then
   1.171 -				cp /etc/keymap.conf $tmp/etc
   1.172 -			fi
   1.173  			chown -R root.root $tmp
   1.174 -			cp -a $tmp/* $distro && rm -rf $tmp
   1.175 +			cp -a $tmp/* ${rootfs} && rm -rf $tmp
   1.176 +			status
   1.177 +		fi
   1.178 +		
   1.179 +		# Custom flavor rootfs
   1.180 +		if [ -d "$flavors/$flavor/rootfs" ]; then
   1.181 +			echo -n "Copying $flavor ARM: rootfs"
   1.182 +			tmp=$distro/tmp-$$
   1.183 +			mkdir -p $tmp
   1.184 +			cp -r $flavors/$flavor/rootfs/* $tmp
   1.185 +			chown -R root.root $tmp
   1.186 +			cp -a $tmp/* ${rootfs} && rm -rf $tmp
   1.187 +			status
   1.188 +		fi
   1.189 +		
   1.190 +		# --kmap
   1.191 +		if [ "$kmap" ]; then
   1.192 +			echo -n "Copying local: /etc/keymap.conf"
   1.193 +			cp -a /etc/keymap.conf ${rootfs}
   1.194  			status
   1.195  		fi
   1.196  
   1.197  		# Rootfs cpio: gzip xz --> /usr/lib/slitaz/liblive.sh ???
   1.198  		echo -n "Compressing initramfs: $initramfs"
   1.199 -		case $initramfs in
   1.200 +		case "$initramfs" in
   1.201  			*.bz2) find . | cpio -o -H newc | bzip2 > ../$initramfs ;;
   1.202  			*.gz) find . | cpio -o -H newc | gzip -9 > ../$initramfs ;;
   1.203  			*.xz) find . | cpio -o -H newc | xz -9 --format=lzma > ../$initramfs ;;
   1.204 @@ -191,28 +208,32 @@
   1.205  		separator
   1.206  		time=$(($(date +%s) - $time))
   1.207  		echo -n "Build time     : " && echo "${time}s"
   1.208 -		echo -n "Initramfs size : " && du -sh $work/$initramfs | awk '{print $1}'
   1.209 -		echo -n "Rootfs size    : " && du -sh $distro | awk '{print $1}'
   1.210 +		echo -n "Initramfs size : " && du -sh $distro/$initramfs | awk '{print $1}'
   1.211 +		echo -n "Rootfs size    : " && du -sh ${rootfs} | awk '{print $1}'
   1.212  		echo -n "Packages       : " && ls $db/installed | wc -l
   1.213 -		separator && echo "" ;;
   1.214 +		separator && newline ;;
   1.215  		
   1.216  	flavors)
   1.217 -		echo ""
   1.218 -		echo -n "Flavor" && indent 16 "Packages"
   1.219 +		newline
   1.220 +		echo -n "$(boldify 'Flavor')" && indent 14 "$(boldify 'Packages')"
   1.221  		separator
   1.222  		for flavor in $(ls $flavors)
   1.223  		do
   1.224  			pkgs=$(cat $flavors/$flavor/packages.list | wc -l)
   1.225 -			echo -n "$flavor" && indent 16 "$pkgs"
   1.226 +			echo -n "$flavor" && indent 14 "$pkgs"
   1.227  		done
   1.228 -		echo "" ;;
   1.229 +		newline ;;
   1.230  	
   1.231 -	pkgs)
   1.232 -		installed="$distro/var/lib/tazpkg/installed"
   1.233 +	ckpkgs)
   1.234 +		installed="${rootfs}/var/lib/tazpkg/installed"
   1.235  		SLITAZ_ARCH="arm"
   1.236  		count=0
   1.237 +		if [ ! -d "$installed" ]; then
   1.238 +			echo "Missing distro rootfs" && exit 1
   1.239 +		fi
   1.240  		echo ""
   1.241 -		echo -n "Package name" && indent 24 "Missing dependencie"
   1.242 +		echo -n "$(boldify 'Package name')"
   1.243 +		indent 24 "$(boldify 'Missing dependencie')"
   1.244  		separator
   1.245  		for pkg in ${installed}/*
   1.246  		do
   1.247 @@ -231,14 +252,16 @@
   1.248  		fi
   1.249  		separator
   1.250  		echo -n "Installed packages: "; colorize 32 $(ls $installed | wc -l)
   1.251 -		echo "" ;;
   1.252 +		newline ;;
   1.253  	
   1.254  	clean)
   1.255  		check_root
   1.256 -		for r in distro cache linux-arm slitaz-arm.*z; do
   1.257 -			echo -n "Cleaning: $r"
   1.258 -			rm -rf $work/$r && status
   1.259 -		done ;;
   1.260 +		echo -n "Cleaning: distro"
   1.261 +		rm -rf $distro && status
   1.262 +		if [ "$spk" ]; then
   1.263 +			echo -n "Cleaning: spk"
   1.264 +			rm -rf $work/spk && status
   1.265 +		fi ;;
   1.266  	
   1.267  	vdisk)
   1.268  		# Lets use and HD in Qemu to store files|packages|whatever
   1.269 @@ -253,17 +276,21 @@
   1.270  		[ -f "vdisk.img" ] && opts="-hda vdisk.img"
   1.271  		qemu-system-arm -m 256 $opts \
   1.272  			-M versatilepb -cpu arm1176 \
   1.273 -			-kernel linux-arm \
   1.274 -			-initrd $initramfs ;;
   1.275 +			-kernel ${distro}/linux-arm \
   1.276 +			-initrd ${distro}/${initramfs} ;;
   1.277  	
   1.278  	mirror)
   1.279  		#
   1.280  		# --> spk-mirror $mirror --sync --dest=/path ???
   1.281  		#
   1.282  		count=0
   1.283 +		newline && boldify "Syncing SliTaz ARM mirror"
   1.284 +		separator
   1.285  		mkdir -p $work/mirror && cd $work/mirror
   1.286 +		
   1.287 +		echo -n "URL: " && colorize 34 "$mirror"
   1.288  		if ! check_mirror_id; then
   1.289 -			exit 0
   1.290 +			newline && exit 0
   1.291  		fi
   1.292  		for list in packages.list packages.desc packages.md5; do
   1.293  			echo -n "Fetching: $list"
   1.294 @@ -294,7 +321,8 @@
   1.295  				status
   1.296  			fi
   1.297  		done
   1.298 -		[ "$count" == 0 ] && status ;;
   1.299 +		[ "$count" == 0 ] && status 
   1.300 +		separator && newline ;;
   1.301  	
   1.302  	*) usage ;;
   1.303  esac