slitaz-dev-tools rev 183

tazdev: let use chroot pkgs version and gen chroot handle options: tazdev -gc undigest --clean
author Christophe Lincoln <pankso@slitaz.org>
date Fri Jun 01 18:36:31 2012 +0200 (2012-06-01)
parents c787539dbaed
children dc29dead6d60
files tazdev/tazdev tazdev/tazdev.conf
line diff
     1.1 --- a/tazdev/tazdev	Wed May 09 19:34:56 2012 +0200
     1.2 +++ b/tazdev/tazdev	Fri Jun 01 18:36:31 2012 +0200
     1.3 @@ -16,28 +16,44 @@
     1.4  [ -f /etc/slitaz/tazdev.conf ] && . /etc/slitaz/tazdev.conf
     1.5  [ -f tazdev.conf ] && . ./tazdev.conf
     1.6  
     1.7 -if [ -z "$SLITAZ_HOME" ]; then
     1.8 +if [ ! "$SLITAZ_HOME" ]; then
     1.9  	echo -e "\nNo config file found\n" && exit 1
    1.10  fi
    1.11  
    1.12  usage() {
    1.13 -	echo -e "\nSliTaz developers and build host tool\n
    1.14 -$(boldify "Usage:") $(basename $0) [command] [user|tool] [release|path]
    1.15 +	cat << EOT
    1.16 +
    1.17 +$(boldify "Usage:") $(basename $0) [command] [vers|user|tool] [vers|--opts]
    1.18 +
    1.19 +SliTaz developers and build host tool
    1.20 +
    1.21  $(boldify "Commands:")
    1.22 - usage               Print this short usage and command list
    1.23 - help                Give help on a SliTaz tool or library.
    1.24 - projects-stats|-ps  Display statistics about your projects
    1.25 - chroot|-c           Mount virtual fs if needed and chroot into the build env
    1.26 - gen-chroot|-gc      Generate a chroot using packages from config file
    1.27 - umount-chroot|-uc   Unmount chroot specified on cmdline
    1.28 - clean-chroot        Clean a chroot environment (skip root/ and home/)
    1.29 - purge               Remove obsolete packages and obsolete source tarballs
    1.30 - dry-purge           Show obsolete packages and obsolete source tarballs
    1.31 - push|-p             Upload new packages to the main mirror
    1.32 - dry-push|-dp        Show what will be uploaded to the mirror. Does nothing
    1.33 - pull                Download new packages from the main mirror
    1.34 - dry-pull            Show what will be downloaded from the mirror. Does nothing
    1.35 - relpkg|-rp          Archive and upload new package/project version\n"
    1.36 +  usage               Print this short usage and command list
    1.37 +  help                Give help on a SliTaz tool or library.
    1.38 +  stats|-s           Display statistics about your projects
    1.39 +  chroot|-c           Mount virtual fs and chroot into the build env
    1.40 +  gen-chroot|-gc      Generate a chroot using packages from config file
    1.41 +  umount-chroot|-uc   Unmount chroot specified on cmdline
    1.42 +  clean-chroot|-cc    Clean a chroot environment (skip root/ and home/)
    1.43 +  !purge              Remove obsolete packages and obsolete source tarballs
    1.44 +  !dry-purge          Show obsolete packages and obsolete source tarballs
    1.45 +  push|-p             Upload new packages to the main mirror
    1.46 +  dry-push|-dp        Show what will be uploaded to the mirror. Does nothing
    1.47 +  pull                Download new packages from the main mirror
    1.48 +  dry-pull            Show what will be downloaded from the mirror. Does nothing
    1.49 +  relpkg|-rp          Archive and upload new package/project version
    1.50 +
    1.51 +$(boldify "Options:")
    1.52 +  --rootfs=           Path to the chroot to generate or clean
    1.53 +  --arch=             Specify the architecture type for cross-chroot
    1.54 +  --clean             Clean chroot before generation a new one
    1.55 +
    1.56 +$(boldify "Options:")
    1.57 +  $(basename $0) gen-chroot undigest --clean
    1.58 +  $(basename $0) chroot stable
    1.59 +  $(basename $0) -c --arch=arm
    1.60 +
    1.61 +EOT
    1.62  }
    1.63  
    1.64  get_version() {
    1.65 @@ -47,7 +63,7 @@
    1.66  		slitaz=$SLITAZ_HOME/$2
    1.67  	else
    1.68  		version=cooking
    1.69 -		slitaz=$COOKING
    1.70 +		slitaz=$SLITAZ_HOME/cooking
    1.71  	fi
    1.72  	if [ "$arch" ]; then
    1.73  		rootfs=$slitaz/$arch/chroot
    1.74 @@ -65,13 +81,13 @@
    1.75  	fi
    1.76  	if [ "$2" = "stable" ] || [ "$3" = "stable" ]; then
    1.77  		remote=$MIRROR_PKGS/stable/
    1.78 -		local=$STABLE/packages/
    1.79 +		local=$SLITAZ_HOME/stable/packages/
    1.80  	elif [ "$2" = "undigest" ] || [ "$3" = "undigest" ]; then
    1.81  		remote=$MIRROR_PKGS/undigest/
    1.82 -		local=$UNDIGEST/packages/
    1.83 +		local=$SLITAZ_HOME/undigest/packages/
    1.84  	else
    1.85  		remote=$MIRROR_PKGS/cooking/
    1.86 -		local=$COOKING/packages/
    1.87 +		local=$SLITAZ_HOME/cooking/packages/
    1.88  	fi
    1.89  }
    1.90  
    1.91 @@ -132,19 +148,42 @@
    1.92  	echo -e "\nGenerating new chroot in: $rootfs"
    1.93  	separator
    1.94  	mkdir -p $rootfs
    1.95 +	# We my gen cooking chroot from a stable version or invers
    1.96 +	case "$version" in
    1.97 +		cooking|undigest) url="http://$MIRROR/packages/cooking/" ;;
    1.98 +		stable|4.0) url="http://$MIRROR/packages/stable/" ;;
    1.99 +	esac
   1.100 +	# --mirror=
   1.101 +	[ "$mirror" ] && url="$mirror"
   1.102 +	mpath=/var/lib/tazpkg/mirror
   1.103 +	cp $mpath ${mpath}.tazdev
   1.104 +	echo "$url" > $mpath
   1.105 +	echo -n "Mirror URL: ${url#http://}"
   1.106 +	tazpkg recharge 2>/dev/null 1>/dev/null
   1.107 +	status
   1.108  	for pkg in $CHROOT_PKGS
   1.109  	do
   1.110 -		tazpkg get-install $pkg --root=$rootfs
   1.111 +		echo -n "Installing: $pkg $vers"
   1.112 +		tazpkg -gi $pkg --root=$rootfs 2>/dev/null 1>/dev/null
   1.113 +		status
   1.114  	done
   1.115  	echo -n "Creating resolv.conf..."
   1.116  	cat /etc/resolv.conf > $rootfs/etc/resolv.conf
   1.117  	status
   1.118 +	echo -n "Restoring host packages list..."
   1.119 +	mv -f ${mpath}.tazdev $mpath
   1.120 +	tazpkg recharge 2>/dev/null 1>/dev/null >/dev/null
   1.121 +	status
   1.122  	separator
   1.123 -	echo -e "Ready to chroot. Use 'tazdev chroot [version|path]'"
   1.124 -	echo -e "Example: tazdev chroot $rootfs\n"
   1.125 +	case "$version" in
   1.126 +		cooking) version="" ;;
   1.127 +	esac
   1.128 +	[ "$arch" ] && version="$version --arch=$arch"
   1.129 +	echo -n "Ready to chroot with:"; colorize 34 " tazdev -c $version"
   1.130 +	newline
   1.131  }
   1.132  
   1.133 -# Remove obsolate slitaz packages
   1.134 +# Remove obsolate slitaz packages --> in cooker ???
   1.135  purge_packages() {
   1.136  	arg=$1
   1.137  	tmp=/tmp/tazdev.$$
   1.138 @@ -166,7 +205,8 @@
   1.139  	rm -f $tmp
   1.140  }
   1.141  
   1.142 -# Remove obsolete source tarballs
   1.143 +# Remove obsolete source tarballs --> in cooker ??? but we share $src
   1.144 +# between cooking and stable to we must scan all versions, all arch
   1.145  purge_sources() {
   1.146  	arg=$1
   1.147  	wok=$slitaz/chroot/home/slitaz/wok
   1.148 @@ -193,14 +233,7 @@
   1.149  }
   1.150  
   1.151  case "$1" in
   1.152 -	info)
   1.153 -		get_version $@
   1.154 -		echo ""
   1.155 -		echo "Version: $version"
   1.156 -		[ "$arch" ] && echo "Arch   : $arch"
   1.157 -		echo "Chroot : $rootfs"
   1.158 -		echo "" ;;
   1.159 -	projects-stats|-ps)
   1.160 +	stats|-s)
   1.161  		echo -e "\nStatistics for: $PROJECTS\n"
   1.162  		echo -n "Project" && echo -ne "\033[24G Size" && echo -ne "\033[38G Revision"
   1.163  		echo -ne "\033[48G Version" && echo -e "\033[64G Files"
   1.164 @@ -236,43 +269,42 @@
   1.165  	umount-chroot|-uc)
   1.166  		check_root
   1.167  		get_version $@
   1.168 -		[ "$2" ] && rootfs=$2
   1.169 +		[ -d "$2" ] && rootfs=$2
   1.170  		umount_chroot $rootfs ;;
   1.171  	gen-chroot|-gc)
   1.172  		check_root
   1.173  		# We can use: --rootfs=/path/to/chroot
   1.174 -		if [ "$rootfs" ]; then
   1.175 -			continue
   1.176 -		else
   1.177 +		if [ ! "$rootfs" ]; then
   1.178  			get_version $@
   1.179  		fi
   1.180 +		if [ "$clean" ] || [ "$forced" ]; then
   1.181 +			$0 -cc --rootfs=$rootfs --noline
   1.182 +		fi
   1.183  		# Dont break another env.
   1.184  		if [ -d $rootfs/bin ]; then
   1.185  			echo -e "\nA chroot environment already exists in : $rootfs\n"
   1.186  			exit 1
   1.187  		fi
   1.188  		gen_chroot ;;
   1.189 -	clean-chroot)
   1.190 -		# Keep root/ and /home they may have a build wok, custom scripts, etc.
   1.191 +	clean-chroot|-cc)
   1.192  		check_root
   1.193 -		if [ -z "$2" ]; then
   1.194 -			echo -e "\nPlease specify the path to the chroot environment to clean.\n"
   1.195 -			exit 0
   1.196 -		else
   1.197 -			rootfs=$2
   1.198 -			if [ ! -d "$rootfs" ]; then
   1.199 -				echo -e "\nWarning : $rootfs doesn't exist!\n"
   1.200 -				exit 1
   1.201 -			fi
   1.202 +		# We can use: --rootfs=/path/to/chroot
   1.203 +		if [ ! "$rootfs" ]; then
   1.204 +			get_version $@
   1.205 +		fi
   1.206 +		if [ ! -d "$rootfs" ]; then
   1.207 +			echo -e "\nChroot doesn't exist: $rootfs\n"
   1.208 +			exit 1
   1.209  		fi
   1.210  		if [ -d $rootfs/proc/1 ]; then
   1.211 -			echo -e "\nWarning : $rootfs/proc mounted!\n"
   1.212 +			echo -e "\nWARNING: $rootfs/proc mounted!\n"
   1.213  			exit 1
   1.214  		fi
   1.215  		cd $rootfs || exit 1
   1.216  		echo ""
   1.217  		boldify "Cleaning chroot: $rootfs"
   1.218  		separator
   1.219 +		# Keep root/ and /home they may have a build wok, custom scripts, etc.
   1.220  		for i in boot bin dev etc lib media mnt proc sbin sys tmp usr var run
   1.221  		do
   1.222  			if [ -d "$i" ]; then
   1.223 @@ -281,7 +313,8 @@
   1.224  			fi
   1.225  		done
   1.226  		rm -f init
   1.227 -		separator && echo "" ;;
   1.228 +		separator
   1.229 +		[ "$noline" ] || newline ;;
   1.230  	push|-p)
   1.231  		check_mirror $@
   1.232  		rsync -r -t -O -l -v -z --delete \
     2.1 --- a/tazdev/tazdev.conf	Wed May 09 19:34:56 2012 +0200
     2.2 +++ b/tazdev/tazdev.conf	Fri Jun 01 18:36:31 2012 +0200
     2.3 @@ -1,12 +1,8 @@
     2.4  # tazdev.conf: SliTaz Developers tool configuration file.
     2.5  #
     2.6  
     2.7 -# Path for the wok, chroot and packages directory of each version.
     2.8 -# We we use main slitaz.conf in time.
     2.9 +# We may use main slitaz.conf in time.
    2.10  SLITAZ_HOME="/home/slitaz"
    2.11 -COOKING="$SLITAZ_HOME/cooking"
    2.12 -STABLE="$SLITAZ_HOME/stable"
    2.13 -UNDIGEST="$SLITAZ_HOME/undigest"
    2.14  
    2.15  # Path to all own and copy projects.
    2.16  PROJECTS="$HOME/Projects"