slitaz-dev-tools rev 180

tazdev: handle --arch= for chroot, fixes and clean up
author Christophe Lincoln <pankso@slitaz.org>
date Sat May 05 02:33:39 2012 +0200 (2012-05-05)
parents d852a86d0701
children 227a8a6ba4d7
files tazdev/tazdev tazdev/tazdev.conf
line diff
     1.1 --- a/tazdev/tazdev	Thu May 03 09:54:12 2012 +0200
     1.2 +++ b/tazdev/tazdev	Sat May 05 02:33:39 2012 +0200
     1.3 @@ -20,17 +20,16 @@
     1.4  	echo -e "\nNo config file found\n" && exit 1
     1.5  fi
     1.6  
     1.7 -usage()
     1.8 -{
     1.9 +usage() {
    1.10  	echo -e "\nSliTaz developers and build host tool\n
    1.11  $(boldify "Usage:") $(basename $0) [command] [user|tool] [release|path]
    1.12  $(boldify "Commands:")
    1.13   usage               Print this short usage and command list
    1.14   help                Give help on a SliTaz tool or library.
    1.15   projects-stats|-ps  Display statistics about your projects
    1.16 - chroot              Mount virtual fs if needed and chroot into the build env
    1.17 - gen-chroot|-gs      Generate a chroot using the last cooking base rootfs
    1.18 - umount-chroot|-uc   Unmount chroot specified on cmdline (--forced to force)
    1.19 + chroot|-c           Mount virtual fs if needed and chroot into the build env
    1.20 + gen-chroot|-gc      Generate a chroot using packages from config file
    1.21 + umount-chroot|-uc   Unmount chroot specified on cmdline
    1.22   clean-chroot        Clean a chroot environment (skip root/ and home/)
    1.23   purge               Remove obsolete packages and obsolete source tarballs
    1.24   dry-purge           Show obsolete packages and obsolete source tarballs
    1.25 @@ -38,29 +37,26 @@
    1.26   dry-push|-dp        Show what will be uploaded to the mirror. Does nothing
    1.27   pull                Download new packages from the main mirror
    1.28   dry-pull            Show what will be downloaded from the mirror. Does nothing
    1.29 - pack-flavors        Pack all SliTaz Live flavors at once
    1.30 - relpkg|-rp          Archive and upload new package/project version
    1.31 - reliso|-ri          Create all main flavors (not loram)\n"
    1.32 + relpkg|-rp          Archive and upload new package/project version\n"
    1.33  }
    1.34  
    1.35 -get_version()
    1.36 -{
    1.37 -	if [ "$2" = "stable" ]; then
    1.38 -		version=stable
    1.39 -		slitaz=$STABLE
    1.40 -	elif [ -n "$2" ]; then
    1.41 -		# Undigest - custom ?
    1.42 +get_version() {
    1.43 +	# Stable, undigest or custom.
    1.44 +	if [ "$2" ] && [ ! $(echo $2 | grep "\--*") ]; then
    1.45  		version=$2
    1.46  		slitaz=$SLITAZ_HOME/$2
    1.47  	else
    1.48  		version=cooking
    1.49  		slitaz=$COOKING
    1.50  	fi
    1.51 -	rootfs=$slitaz/chroot
    1.52 +	if [ "$arch" ]; then
    1.53 +		rootfs=$slitaz/$arch/chroot
    1.54 +	else
    1.55 +		rootfs=$slitaz/chroot
    1.56 +	fi
    1.57  }
    1.58  
    1.59 -check_mirror()
    1.60 -{
    1.61 +check_mirror() {
    1.62  	# ping -c 1 $MIRROR
    1.63  	if [ -n "$2" ]; then
    1.64  		user=$2
    1.65 @@ -84,15 +80,6 @@
    1.66  {
    1.67  	mkdir -p $1 $2
    1.68  	mount -o bind $1 $2
    1.69 -
    1.70 -	# Update aufs jail configuration
    1.71 -	# BUGGY
    1.72 -	#if [ "${2#*/home}" != "$2" ] &&
    1.73 -	   #grep -s ^AUFS_MOUNTS= ${2%/home/*}/etc/slitaz/cook.conf &&
    1.74 -	   #! grep -q /home${2#*/home} ${2%/home/*}/etc/slitaz/cook.conf; then
    1.75 -		#sed -i "s|^AUFS_MOUNTS=\"|&/home${2#*/home}|" \
    1.76 -			#${2%/home/*}/etc/slitaz/cook.conf
    1.77 -	#fi
    1.78  }
    1.79  
    1.80  # Mount virtual Kernel file systems and chroot but check that nobody
    1.81 @@ -119,43 +106,31 @@
    1.82  	fi
    1.83  }
    1.84  
    1.85 -# Unmount virtual Kernel file systems on exit and ensure we are the last
    1.86 -# user before unmounting !
    1.87 -umount_chroot()
    1.88 -{
    1.89 -	[ "$1" ] && ROOTF=$1
    1.90 +# Unmount virtual Kernel file systems.
    1.91 +umount_chroot() {
    1.92 +	[ "$1" ] && rootfs=$1
    1.93  	fs=$rootfs/home/slitaz
    1.94  	echo -ne "\nUnmounting virtual filesystems..."
    1.95  	umount $rootfs/dev/shm
    1.96  	umount $rootfs/dev/pts
    1.97  	umount $rootfs/sys
    1.98  	umount $rootfs/proc
    1.99 -	umount $fs/src
   1.100 -	umount $fs/packages
   1.101 +	if mount | fgrep -q $fs/src; then
   1.102 +		umount $fs/src
   1.103 +		umount $fs/packages
   1.104 +	fi
   1.105  	status && echo ""
   1.106 -	#echo -e "\nProcess: $ps\n"
   1.107 -	#ps | grep `basename $0` | grep -v grep
   1.108 -	#echo -e "\nLeaving virtual filesystems unmounted (`pidof tazdev`)...\n"
   1.109  }
   1.110  
   1.111  # Get the last cooking base rootfs, extract and configure.
   1.112 -gen_new_chroot()
   1.113 -{
   1.114 -	echo -e "\nGenerating new chroot in : $rootfs"
   1.115 +gen_chroot() {
   1.116 +	echo -e "\nGenerating new chroot in: $rootfs"
   1.117  	separator
   1.118  	mkdir -p $rootfs
   1.119 -	if [ "$ROOTFS_PKG" == "yes" ]; then
   1.120 -		for pkg in $CHROOT_PKGS
   1.121 -		do
   1.122 -			tazpkg get-install $pkg --root=$rootfs
   1.123 -		done
   1.124 -	elif [ "$ROOTFS_PKG" == "no" ]; then
   1.125 -		cd $rootfs
   1.126 -		wget $DL_URL/boot/cooking/rootfs-base.gz
   1.127 -		echo -n "Extracting the rootfs..."
   1.128 -		lzma d rootfs-base.gz -so | cpio -id
   1.129 -		rm rootfs-base.gz
   1.130 -	fi
   1.131 +	for pkg in $CHROOT_PKGS
   1.132 +	do
   1.133 +		tazpkg get-install $pkg --root=$rootfs
   1.134 +	done
   1.135  	echo -n "Creating resolv.conf..."
   1.136  	cat /etc/resolv.conf > $rootfs/etc/resolv.conf
   1.137  	status
   1.138 @@ -165,39 +140,38 @@
   1.139  }
   1.140  
   1.141  # Remove obsolate slitaz packages
   1.142 -purge_packages()
   1.143 -{
   1.144 +purge_packages() {
   1.145  	arg=$1
   1.146  	tmp=/tmp/tazdev.$$
   1.147 -	ls $BUILD_WOK | while read pkg; do
   1.148 -		[ -f $BUILD_WOK/$pkg/taz/*/receipt ] || continue
   1.149 -		EXTRAversion=""
   1.150 -		. $BUILD_WOK/$pkg/taz/*/receipt
   1.151 -		echo $pkg-$version$EXTRAversion.tazpkg
   1.152 +	ls $wok| while read pkg; do
   1.153 +		[ -f $wok/$pkg/taz/*/receipt ] || continue
   1.154 +		unset VERSION EXTRAVERSION
   1.155 +		. $wok/$pkg/taz/*/receipt
   1.156 +		echo $pkg-${VERSION}$EXTRAVERSION.tazpkg
   1.157  	done > $tmp
   1.158  	ls $slitaz/chroot/home/slitaz/packages | while read pkg; do
   1.159  		case "$pkg" in
   1.160 -		*.tazpkg)
   1.161 -			grep -q ^$pkg$ $tmp && continue
   1.162 -			echo Remove $pkg
   1.163 -			[ "$arg" == "purge" ] &&
   1.164 -			rm -f $slitaz/chroot/home/slitaz/packages/$pkg ;;
   1.165 +			*.tazpkg)
   1.166 +				grep -q ^$pkg$ $tmp && continue
   1.167 +				echo "Removing pkg: $pkg"
   1.168 +				[ "$arg" == "purge" ] &&
   1.169 +				rm -f $slitaz/chroot/home/slitaz/packages/$pkg ;;
   1.170  		esac
   1.171  	done
   1.172  	rm -f $tmp
   1.173  }
   1.174  
   1.175  # Remove obsolete source tarballs
   1.176 -purge_sources()
   1.177 -{
   1.178 +purge_sources() {
   1.179  	arg=$1
   1.180 +	wok=$slitaz/chroot/home/slitaz/wok
   1.181  	tmp=/tmp/tazdev.$$
   1.182 -	ls $BUILD_WOK | while read pkg; do
   1.183 -		[ -f $BUILD_WOK/$pkg/receipt ] || continue
   1.184 +	ls $wok| while read pkg; do
   1.185 +		[ -f $wok/$pkg/receipt ] || continue
   1.186  		TARBALL=""
   1.187 -		. $BUILD_WOK/$pkg/receipt
   1.188 +		. $wok/$pkg/receipt
   1.189  		[ -n "$TARBALL" ] && echo $TARBALL
   1.190 -		grep SOURCES_REPOSITORY/ $BUILD_WOK/$pkg/receipt | sed \
   1.191 +		grep SOURCES_REPOSITORY/ $wok/$pkg/receipt | sed \
   1.192  		-e 's|.*SOURCES_REPOSITORY/\([^ ]*\)\( .*\)$|\1|' \
   1.193  		-e 's|.*SOURCES_REPOSITORY/\([^ ]*\)$|\1|' | sort | uniq | \
   1.194  		sed "s|['\"/]||g" | while read file ; do
   1.195 @@ -206,14 +180,21 @@
   1.196  	done > $tmp
   1.197  	ls $slitaz/chroot/home/slitaz/src | while read pkg; do
   1.198  		grep -q ^$pkg$ $tmp && continue
   1.199 -		echo Remove $pkg
   1.200 +		echo "Removing src: $pkg"
   1.201  		[ "$arg" == "purge" ] &&
   1.202 -		rm -f $slitaz/chroot/home/slitaz/src/$pkg
   1.203 +			rm -f $slitaz/chroot/home/slitaz/src/$pkg
   1.204  	done
   1.205  	rm -f $tmp
   1.206  }
   1.207  
   1.208  case "$1" in
   1.209 +	info)
   1.210 +		get_version $@
   1.211 +		echo ""
   1.212 +		echo "Version: $version"
   1.213 +		[ "$arch" ] && echo "Arch   : $arch"
   1.214 +		echo "Chroot : $rootfs"
   1.215 +		echo "" ;;
   1.216  	projects-stats|-ps)
   1.217  		echo -e "\nStatistics for: $PROJECTS\n"
   1.218  		echo -n "Project" && echo -ne "\033[24G Size" && echo -ne "\033[38G Revision"
   1.219 @@ -238,7 +219,7 @@
   1.220  		done
   1.221  		separator
   1.222  		echo "" ;;
   1.223 -	chroot)
   1.224 +	chroot|-c)
   1.225  		# Chroot into a build env. Default to cooking configured in tazdev.conf
   1.226  		check_root
   1.227  		get_version $@
   1.228 @@ -254,14 +235,18 @@
   1.229  		umount_chroot $rootfs ;;
   1.230  	gen-chroot|-gc)
   1.231  		check_root
   1.232 -		get_version $@
   1.233 -		[ -d "$2" ] && rootfs=$2
   1.234 +		# We can use: --rootfs=/path/to/chroot
   1.235 +		if [ "$rootfs" ]; then
   1.236 +			continue
   1.237 +		else
   1.238 +			get_version $@
   1.239 +		fi
   1.240  		# Dont break another env.
   1.241  		if [ -d $rootfs/bin ]; then
   1.242  			echo -e "\nA chroot environment already exists in : $rootfs\n"
   1.243  			exit 1
   1.244  		fi
   1.245 -		gen_new_chroot ;;
   1.246 +		gen_chroot ;;
   1.247  	clean-chroot)
   1.248  		# Keep root/ and /home they may have a build wok, custom scripts, etc.
   1.249  		check_root
   1.250 @@ -280,13 +265,13 @@
   1.251  			exit 1
   1.252  		fi
   1.253  		cd $rootfs || exit 1
   1.254 -		echo -e "\nCleaning chroot in: $rootfs"
   1.255 +		echo ""
   1.256 +		boldify "Cleaning chroot: $rootfs"
   1.257  		separator
   1.258 -		for i in bin dev etc lib media mnt proc sbin sys tmp usr var
   1.259 +		for i in bin dev etc lib media mnt proc sbin sys tmp usr var run
   1.260  		do
   1.261 -			echo -n "Removing: $i (`du -sh $i | awk '{ print $1 }'`)... "
   1.262 -			rm -rf $i
   1.263 -			status
   1.264 +			echo -n "Removing: $i ($(du -sh $i | awk '{ print $1 }'))... "
   1.265 +			rm -rf $i && status
   1.266  		done
   1.267  		separator && echo "" ;;
   1.268  	push|-p)
   1.269 @@ -352,27 +337,6 @@
   1.270  			sed -i s"/VERSION=.*/VERSION=\"$version\"/" $pkg*/receipt
   1.271  			status
   1.272  		fi ;;
   1.273 -	reliso|-ri)
   1.274 -		# Generate all official images iso at once for a specific version.
   1.275 -		get_version $@
   1.276 -		iso=$slitaz/iso
   1.277 -		mkdir -p $iso
   1.278 -		for flavor in base core gtkonly firefox
   1.279 -		do
   1.280 -			cd $slitaz
   1.281 -			tazlito pack-flavor $flavor
   1.282 -			tazlito get-flavor $flavor
   1.283 -			tazlito gen-distro
   1.284 -			if [ "$flavor" == "core" ]; then
   1.285 -				cp distro/slitaz-$flavor.iso $ISO/slitaz-$version.iso
   1.286 -				cd $ISO && md5sum slitaz-$version.iso > slitaz-$version.md5
   1.287 -			else
   1.288 -				cp distro/slitaz-$flavor.iso $ISO/slitaz-$version-$flavor.iso
   1.289 -				cd $ISO && md5sum slitaz-$version-$flavor.iso slitaz-$version-$flavor.md5
   1.290 -			fi
   1.291 -		done
   1.292 -		# Clean up slitaz working directory.
   1.293 -		rm *.flavor tazlito.conf ;;
   1.294  	help)
   1.295  		[ ! "$2" ] && echo "Missing tool/library name" && exit 0
   1.296  		echo ""
     2.1 --- a/tazdev/tazdev.conf	Thu May 03 09:54:12 2012 +0200
     2.2 +++ b/tazdev/tazdev.conf	Sat May 05 02:33:39 2012 +0200
     2.3 @@ -11,14 +11,10 @@
     2.4  # Path to all own and copy projects.
     2.5  PROJECTS="$HOME/Projects"
     2.6  
     2.7 -# Install chroot with packages.
     2.8 -ROOTFS_PKG="yes"
     2.9 -
    2.10  # Packages to generate a minimal chroot.
    2.11 -CHROOT_PKGS="busybox libtaz cookutils tazpkg slitaz-base-files lzma"
    2.12 +CHROOT_PKGS="slitaz-base-files busybox cookutils tazpkg lzma"
    2.13  
    2.14  # Main mirror to push and download (ISO, rootfs. etc).
    2.15  MIRROR="mirror.slitaz.org"
    2.16 -DL_URL="http://mirror.switch.ch/ftp/mirror/slitaz"
    2.17  MIRROR_PKGS="/var/www/slitaz/mirror/packages"
    2.18  MIRROR_SOURCES="/var/www/slitaz/mirror/sources"