cookutils rev 557 slitaz-tank
Add custom tazdev. This custom tazdev is needed for my cooker setup to work.
author | Christopher Rogers <slaxemulator@gmail.com> |
---|---|
date | Thu Nov 22 11:00:21 2012 +0000 (2012-11-22) |
parents | 2afacf0c3875 |
children | 3d20efa09240 |
files | Makefile tazdev/tazdev tazdev/tazdev.conf |
line diff
1.1 --- a/Makefile Sun Oct 21 17:09:55 2012 +0000 1.2 +++ b/Makefile Thu Nov 22 11:00:21 2012 +0000 1.3 @@ -19,6 +19,8 @@ 1.4 install -m 0755 -d $(DESTDIR)$(PREFIX)/share/applications 1.5 install -m 0755 -d $(DESTDIR)$(PREFIX)/share/cook/cooktest 1.6 install -m 0755 -d $(DESTDIR)$(PREFIX)/share/doc/cookutils 1.7 + install -m 0755 tazdev/tazdev $(DESTDIR)$(PREFIX)/bin 1.8 + install -m 0755 tazdev/tazdev.conf $(DESTDIR)/etc/slitaz 1.9 install -m 0755 cook $(DESTDIR)$(PREFIX)/bin 1.10 install -m 0755 cooker $(DESTDIR)$(PREFIX)/bin 1.11 install -m 0755 cookiso $(DESTDIR)$(PREFIX)/bin
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/tazdev/tazdev Thu Nov 22 11:00:21 2012 +0000 2.3 @@ -0,0 +1,358 @@ 2.4 +#!/bin/sh 2.5 +# 2.6 +# Tazdev - SliTaz developers and build host tool. System wide config 2.7 +# file is located at: /etc/slitaz/tazdev.conf. Keep the code clear and 2.8 +# well commented please, also: configuration variables are $UPPERCASE 2.9 +# and variables initialized by tazdev itself are $lowerspace 2.10 +# 2.11 +# (c) 2011 SliTaz GNU/Linux - GNU gpl v3 2.12 +# 2.13 +# AUTHORS 2.14 +# Christophe Lincoln <pankso@slitaz.org> 2.15 +# Pascal Bellard <bellard@slitaz.org> 2.16 +# 2.17 +. /lib/libtaz.sh 2.18 + 2.19 +[ -f /etc/slitaz/tazdev.conf ] && . /etc/slitaz/tazdev.conf 2.20 +[ -f tazdev.conf ] && . ./tazdev.conf 2.21 + 2.22 +if [ -z "$SLITAZ" ]; then 2.23 + echo -e "\nNo config file found\n" && exit 1 2.24 +fi 2.25 + 2.26 +usage() 2.27 +{ 2.28 + echo -e "\nSliTaz developers and build host tool\n 2.29 +\033[1mUsage: \033[0m `basename $0` [command] [user] [stable|cooking|undigest|path] 2.30 +\033[1mCommands: \033[0m\n 2.31 + usage Print this short usage and command list 2.32 + projects-stats|-ps Display statistics about your projects 2.33 + chroot|-c Mount virtual fs if needed and chroot into the build env 2.34 + gen-chroot|-gc Generate a chroot using the last cooking base rootfs 2.35 + umount-chroot|-uc Unmount chroot specified on cmdline (--forced to force) 2.36 + clean-chroot Clean a chroot environment (skip root/ and home/) 2.37 + purge Remove obsolete packages and obsolete source tarballs 2.38 + dry-purge Show obsolete packages and obsolete source tarballs 2.39 + push|-p Upload new packages to the main mirror. 2.40 + dry-push|-dp Show what will be uploaded to the mirror. Does nothing 2.41 + pull Download new packages from the main mirror. 2.42 + dry-pull Show what will be downloaded from the mirror. Does nothing 2.43 + pack-flavors Pack all SliTaz Live flavors at once 2.44 + relpkg|-rp Archive and upload new package/project version 2.45 + reliso|-ri Create all main flavors (not loram)\n" 2.46 +} 2.47 + 2.48 +get_version() 2.49 +{ 2.50 + if [ "$2" = "stable" ]; then 2.51 + version=stable 2.52 + slitaz=$STABLE 2.53 + elif [ -n "$2" ]; then 2.54 + # Undigest - custom ? 2.55 + version=$2 2.56 + slitaz=$SLITAZ/$2 2.57 + else 2.58 + version=cooking 2.59 + slitaz=$COOKING 2.60 + fi 2.61 + rootfs=$slitaz/chroot 2.62 + wok=$slitaz/wok 2.63 + SRC=$slitaz/src 2.64 +} 2.65 + 2.66 +check_mirror() 2.67 +{ 2.68 + # ping -c 1 $MIRROR 2.69 + if [ -n "$2" ]; then 2.70 + user=$2 2.71 + else 2.72 + user=$user 2.73 + fi 2.74 + if [ "$2" = "stable" ] || [ "$3" = "stable" ]; then 2.75 + remote=$MIRROR_PKGS/stable/ 2.76 + local=$STABLE/packages/ 2.77 + elif [ "$2" = "undigest" ] || [ "$3" = "undigest" ]; then 2.78 + remote=$MIRROR_PKGS/undigest/ 2.79 + local=$UNDIGEST/packages/ 2.80 + else 2.81 + remote=$MIRROR_PKGS/cooking/ 2.82 + local=$COOKING/packages/ 2.83 + fi 2.84 +} 2.85 + 2.86 +# Bind a directory into the chroot 2.87 +bind_chroot_dir() 2.88 +{ 2.89 + mkdir -p $1 $2 2.90 + mount -o bind $1 $2 2.91 +} 2.92 + 2.93 +# Mount virtual Kernel file systems and chroot but check that nobody 2.94 +# else has done mounts 2.95 +mount_chroot() 2.96 +{ 2.97 + if [ ! -d $rootfs/proc/1 ]; then 2.98 + echo -ne "\nMounting virtual filesystems..." 2.99 + mount -t proc proc $rootfs/proc 2.100 + mount -t sysfs sysfs $rootfs/sys 2.101 + mount -t devpts devpts $rootfs/dev/pts 2.102 + mount -t tmpfs shm $rootfs/dev/shm 2.103 + status 2.104 + fi 2.105 + # Mount source so they can be shared between cooking/stable/undigest. 2.106 + # But do it only if it's a slitaz developement chroot. 2.107 + fs=${rootfs}${slitaz} 2.108 + if [ -d "$slitaz" ]; then 2.109 + for i in src flavors xml wok-hg wok packages incoming cache log live iso; do 2.110 + if [ "$AUFS_MODE" ]; then 2.111 + bind_chroot_dir $slitaz/$i $fs/$i 2.112 + else 2.113 + mkdir -p $slitaz/$i $fs/$i 2.114 + mount -o bind $slitaz/$i $fs/$i 2.115 + fi 2.116 + done 2.117 + [ ! -d ${rootfs}${SLITAZ}/src ] && ln -sf $slitaz/src ${rootfs}${SLITAZ}/src 2.118 + mkdir -p $rootfs/$DB/undigest/incoming 2.119 + echo "$slitaz/packages" > $rootfs/$DB/mirror 2.120 + echo "$slitaz/incoming" > $rootfs/$DB/undigest/incoming/mirror 2.121 + echo "incoming" > $rootfs/$DB/priority 2.122 + fi 2.123 +} 2.124 + 2.125 +# Unmount virtual Kernel file systems on exit and ensure we are the last 2.126 +# user before unmounting ! 2.127 +umount_chroot() 2.128 +{ 2.129 + [ "$1" ] && rootfs=$1 2.130 + fs=${rootfs}${slitaz} 2.131 + echo -ne "\nUnmounting virtual filesystems..." 2.132 + for i in /proc /sys /dev/pts /dev/shm; do 2.133 + umount ${rootfs}$i 2.134 + done 2.135 + for i in src flavors xml wok-hg wok packages incoming cache log live iso; do 2.136 + umount $fs/$i 2.137 + done 2.138 + status && echo "" 2.139 +} 2.140 + 2.141 +# Get the last cooking base rootfs, extract and configure. 2.142 +gen_new_chroot() 2.143 +{ 2.144 + echo -e "\nGenerating new chroot in : $rootfs" 2.145 + separator 2.146 + mkdir -p $rootfs 2.147 + for pkg in $CHROOT_PKGS 2.148 + do 2.149 + tazpkg get-install $pkg --root=$rootfs 2.150 + done 2.151 + echo -n "Creating resolv.conf..." 2.152 + cat /etc/resolv.conf > $rootfs/etc/resolv.conf 2.153 + echo -n "Copying hosts..." 2.154 + cat /etc/hosts > $rootfs/etc/hosts 2.155 + status 2.156 + separator 2.157 + echo -e "Ready to chroot. Use 'tazdev chroot [version|path]'" 2.158 + echo -e "Example: tazdev chroot $rootfs\n" 2.159 +} 2.160 + 2.161 +# Remove obsolate slitaz packages 2.162 +purge_packages() 2.163 +{ 2.164 + arg=$1 2.165 + tmp=/tmp/tazdev.$$ 2.166 + ls $wok | while read pkg; do 2.167 + [ -f $wok/$pkg/taz/*/receipt ] || continue 2.168 + unset EXTRAVERSION PACKAGE VERSION 2.169 + . $wok/$pkg/taz/*/receipt 2.170 + echo $pkg-${VERSION}${EXTRAVERSION}.tazpkg 2.171 + done > $tmp 2.172 + ls $slitaz/packages | while read pkg; do 2.173 + case "$pkg" in 2.174 + *.tazpkg) 2.175 + grep -q ^$pkg$ $tmp && continue 2.176 + echo "Remove pkg: $pkg" 2.177 + if [ "$arg" == "purge" ]; then 2.178 + [ -f $slitaz/packages/$pkg ] && rm -f $slitaz/packages/$pkg 2.179 + fi ;; 2.180 + esac 2.181 + done 2.182 + rm -f $tmp 2.183 +} 2.184 + 2.185 +# Remove obsolete source tarballs 2.186 +purge_sources() 2.187 +{ 2.188 + arg=$1 2.189 + tmp=/tmp/tazdev.$$ 2.190 + ls $wok | while read pkg; do 2.191 + [ -f $wok/$pkg/receipt ] || continue 2.192 + unset TARBALL 2.193 + . $wok/$pkg/receipt 2.194 + [ -n "$TARBALL" ] && echo $TARBALL 2.195 + [ -n "$PATCH" ] && echo $(basename $PATCH) 2.196 + [ -f $SRC/${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma ] && \ 2.197 + echo "${SOURCE:-$PACKAGE}-${KBASEVER:-$VERSION}.tar.lzma" 2.198 + grep SOURCES_REPOSITORY/ $wok/$pkg/receipt | sed \ 2.199 + -e 's|.*SOURCES_REPOSITORY/\([^ ]*\)\( .*\)$|\1|' \ 2.200 + -e 's|.*SOURCES_REPOSITORY/\([^ ]*\)$|\1|' | sort | uniq | \ 2.201 + sed "s|['\"/]||g" | while read file ; do 2.202 + eval echo $file 2> /dev/null 2.203 + done 2.204 + done > $tmp 2.205 + ls $slitaz/src | while read pkg; do 2.206 + grep -q ^$pkg$ $tmp && continue 2.207 + echo "Remove src: $pkg" 2.208 + if [ "$arg" == "purge" ]; then 2.209 + [ -f $slitaz/src/$pkg ] && rm -f $slitaz/src/$pkg 2.210 + fi 2.211 + done 2.212 + rm -f $tmp 2.213 +} 2.214 + 2.215 +case "$1" in 2.216 + projects-stats|-ps) 2.217 + echo -e "\nStatistics for: $PROJECTS\n" 2.218 + echo -n "Project" && echo -ne "\033[24G Size" && echo -ne "\033[38G Revision" 2.219 + echo -ne "\033[48G Version" && echo -e "\033[64G Files" 2.220 + separator 2.221 + cd $PROJECTS 2.222 + for proj in * 2.223 + do 2.224 + rev="" 2.225 + echo -n "$proj" 2.226 + size=`du -sh $proj | awk '{ print $1 }'` 2.227 + echo -ne "\033[24G $size" 2.228 + if [ -d $proj/.hg ]; then 2.229 + cd $proj 2.230 + rev=`hg head --template '{rev}\n'` 2.231 + vers=`hg tags | head -n 2 | tail -n 1 | cut -d " " -f 1` 2.232 + echo -ne "\033[38G $rev" 2.233 + echo -ne "\033[48G $vers" && cd .. 2.234 + fi 2.235 + files=`find $proj -type f | wc -l` 2.236 + echo -e "\033[64G $files" 2.237 + done 2.238 + separator 2.239 + echo "" ;; 2.240 + chroot) 2.241 + # Chroot into a build env. Default to cooking configured in tazdev.conf 2.242 + check_root 2.243 + get_version $@ 2.244 + [ -d "$2" ] && rootfs=$2 2.245 + mount_chroot 2.246 + echo -e "Chrooting to: $rootfs\n" 2.247 + chroot $rootfs /bin/sh --login 2.248 + umount_chroot ;; 2.249 + umount-chroot|-uc) 2.250 + check_root 2.251 + get_version $@ 2.252 + [ "$2" ] && rootfs=$2 2.253 + umount_chroot $rootfs ;; 2.254 + gen-chroot|-gc) 2.255 + check_root 2.256 + # We can use: --rootfs=/path/to/chroot 2.257 + if [ "$rootfs" ]; then 2.258 + continue 2.259 + else 2.260 + get_version $@ 2.261 + fi 2.262 + # Dont break another env. 2.263 + if [ -d $rootfs/bin ]; then 2.264 + echo -e "\nA chroot environment already exists in : $rootfs\n" 2.265 + exit 1 2.266 + fi 2.267 + gen_new_chroot ;; 2.268 + clean-chroot) 2.269 + # Keep root/ and /home they may have a build wok, custom scripts, etc. 2.270 + check_root 2.271 + if [ -z "$2" ]; then 2.272 + echo -e "\nPlease specify the path to the chroot environment to clean.\n" 2.273 + exit 0 2.274 + else 2.275 + rootfs=$2 2.276 + if [ ! -d "$rootfs" ]; then 2.277 + echo -e "\nWarning : $rootfs doesn't exist!\n" 2.278 + exit 1 2.279 + fi 2.280 + fi 2.281 + if [ -d $rootfs/proc/1 ]; then 2.282 + echo -e "\nWarning : $rootfs/proc mounted!\n" 2.283 + exit 1 2.284 + fi 2.285 + cd $rootfs || exit 1 2.286 + echo "" 2.287 + boldify "Cleaning chroot: $rootfs" 2.288 + separator 2.289 + for i in bin dev etc init lib media mnt proc sbin sys tmp usr var run 2.290 + do 2.291 + echo -n "Removing: $i ($(du -sh $i | awk '{ print $1 }'))... " 2.292 + rm -rf $i 2.293 + status 2.294 + done 2.295 + separator && echo "" ;; 2.296 + push|-p) 2.297 + check_mirror $@ 2.298 + rsync -r -t -O -l -v -z --delete \ 2.299 + $local -e ssh $user@$MIRROR:$remote ;; 2.300 + dry-push|-dp) 2.301 + check_mirror $@ 2.302 + rsync -r -t -O -l -v -z --delete --dry-run \ 2.303 + $local -e ssh $user@$MIRROR:$remote ;; 2.304 + pull) 2.305 + check_mirror $@ 2.306 + rsync -r -t -l -v -z --delete \ 2.307 + -e ssh $user@$MIRROR:$remote $local ;; 2.308 + dry-pull) 2.309 + check_mirror $@ 2.310 + rsync -r -t -l -v -z --delete --dry-run \ 2.311 + -e ssh $user@$MIRROR:$remote $local ;; 2.312 + purge|dry-purge) 2.313 + check_root 2.314 + get_version $@ 2.315 + purge_packages $1 2.316 + purge_sources $1 ;; 2.317 + relpkg|-rp) 2.318 + # Release a slitaz sub-project and upload tarball to mirror 2.319 + [ -z "$MIRROR_SOURCES" ] && MIRROR_SOURCES="/var/www/slitaz/mirror/sources" 2.320 + if [ -z $2 ] || [ -z $3 ]; then 2.321 + echo -e "\nUsage: $0 relpkg package version\n" 2.322 + exit 0 2.323 + fi 2.324 + pkg=$2 2.325 + version=$3 2.326 + echo "" && cd $PROJECTS/$pkg 2.327 + 2.328 + # Sanity check 2.329 + if ! grep -q $version$ .hgtags; then 2.330 + echo "Missing Hg tag for version: $version" 2.331 + echo -e "You may want to: hg tag $version && hg push\n" 2.332 + exit 0 2.333 + fi 2.334 + 2.335 + # Archive 2.336 + echo -n "Creating tarball and md5sum for: $pkg-$version... " 2.337 + hg archive -t tgz $pkg-$version.tar.gz 2.338 + md5sum $pkg-$version.tar.gz > $pkg-$version.md5 2.339 + echo "Done" 2.340 + 2.341 + # Upload 2.342 + echo -n "Do you wish to upload tarball to the mirror [N/y] ? " 2.343 + read upload 2.344 + if [ "$upload" = "y" ]; then 2.345 + echo "Uploading to: $MIRROR/sources/${pkg#slitaz-}" 2.346 + scp $pkg-$version.tar.gz $pkg-$version.md5 \ 2.347 + $user@$MIRROR:$MIRROR_SOURCES/${pkg#slitaz-} 2.348 + fi 2.349 + 2.350 + # Update pkg in wok 2.351 + echo -n "Do you wish to update $pkg in wok [N/y] ? " 2.352 + read update 2.353 + if [ "$update" = "y" ]; then 2.354 + cd $PROJECTS/wok 2.355 + sed -i s"/VERSION=.*/VERSION=\"$version\"/" $pkg*/receipt 2.356 + fi ;; 2.357 + usage|*) 2.358 + usage ;; 2.359 +esac 2.360 + 2.361 +exit 0
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/tazdev/tazdev.conf Thu Nov 22 11:00:21 2012 +0000 3.3 @@ -0,0 +1,28 @@ 3.4 +# tazdev.conf: SliTaz Developers tool configuration file. 3.5 +# 3.6 + 3.7 +# Path for the wok, chroot and packages directory of each version. 3.8 +SLITAZ="/home/slitaz" 3.9 +COOKING="$SLITAZ/cooking" 3.10 +STABLE="$SLITAZ/stable" 3.11 +UNDIGEST="$SLITAZ/undigest" 3.12 + 3.13 +DB="/var/lib/tazpkg" 3.14 +INSTALLED="$DB/installed" 3.15 + 3.16 +# Path to all own and copy projects. 3.17 +PROJECTS="$HOME/Projects" 3.18 + 3.19 +# Install chroot with packages. 3.20 +ROOTFS_PKG="yes" 3.21 + 3.22 +# Packages to generate a minimal chroot. 3.23 +CHROOT_PKGS="slitaz-base-files busybox cookutils tazpkg lzma" 3.24 + 3.25 +# Main mirror to push and download (ISO, rootfs. etc). 3.26 +MIRROR="mirror.slitaz.org" 3.27 +MIRROR_PKGS="/var/www/slitaz/mirror/packages" 3.28 +MIRROR_SOURCES="/var/www/slitaz/mirror/sources" 3.29 + 3.30 +# enable aufs mode 3.31 +AUFS_MODE=""