wok-stable diff slitaz-dev-tools/stuff/tazdev @ rev 3440
Add slitaz-dev-tools (tazdev replace all scripts on tank)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Jun 14 02:26:59 2009 +0200 (2009-06-14) |
parents | |
children | 79acaf03301f |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/slitaz-dev-tools/stuff/tazdev Sun Jun 14 02:26:59 2009 +0200 1.3 @@ -0,0 +1,133 @@ 1.4 +#!/bin/sh 1.5 +# Tazdev - SliTaz developers and build host tool. 1.6 +# System wide config file: /etc/slitaz/tazdev.conf 1.7 +# 1.8 +# (c) 2009 SliTaz GNU/Linux - GNU gpl v3 1.9 +# 1.10 +# Authors : Christophe Lincoln (Pankso) <pankso@slitaz.org> 1.11 +# 1.12 + 1.13 +if [ -f /etc/slitaz/tazdev.conf ]; then 1.14 + . /etc/slitaz/tazdev.conf 1.15 +elif [ -f $PWD/tazdev.conf ]; then 1.16 + . $PWD/tazdev.conf 1.17 +else 1.18 + echo -e "\nNo config file found in /etc/slitaz or the current dir...\n" 1.19 + exit 0 1.20 +fi 1.21 + 1.22 +usage() 1.23 +{ 1.24 + echo -e "\nSliTaz developers and build host tool\n 1.25 +\033[1mUsage: \033[0m `basename $0` [command] [user] [stable|cooking] 1.26 +\033[1mCommands: \033[0m\n 1.27 + usage Print this short usage and command list. 1.28 + cmplog Log 'tazwok cmp' result. 1.29 + update-wok Update Hg wok and copy it to the chroot wok. 1.30 + chroot Mount virtual fs if needed and chroot into the build env. 1.31 + push Upload new packages to the mirror. 1.32 + dry-push Show what will be uploaded to the mirror. Do nothing. 1.33 + pull Download new packages from the mirror. 1.34 + dry-pull Show what will be downloaded from the mirror. Do nothing.\n" 1.35 +} 1.36 + 1.37 +# Exit if user is not root. 1.38 +check_root() 1.39 +{ 1.40 + if test $(id -u) != 0 ; then 1.41 + echo -e "\nThis program requires being run as root.\n" 1.42 + exit 0 1.43 + fi 1.44 +} 1.45 + 1.46 +check_mirror() 1.47 +{ 1.48 + # ping -c 1 $MIRROR 1.49 + if [ -n "$2" ]; then 1.50 + USER=$2 1.51 + else 1.52 + echo -e "\nPlease specify a user.\n" && exit 0 1.53 + fi 1.54 + if [ "$3" = "stable" ]; then 1.55 + REMOTE_DIR=$MIRROR_DIR/stable/ 1.56 + LOCAL_DIR=$STABLE/packages/ 1.57 + else 1.58 + REMOTE_DIR=$MIRROR_DIR/cooking/ 1.59 + LOCAL_DIR=$COOKING/packages/ 1.60 + fi 1.61 +} 1.62 + 1.63 +case "$1" in 1.64 + cmplog) 1.65 + # Log 'tazwok cmp' for the web interface (can be used via a cron job). 1.66 + check_root 1.67 + tazwok cmp | grep ^[A-Z] | tee $CMP_LOG 1.68 + echo "Date: `date`" >> $CMP_LOG ;; 1.69 + update-wok) 1.70 + # Update the Hg wok and copy it to the chroot env. Hg wok id 1.71 + # copied to the chroot wok to avoid messing with build result 1.72 + # file and so we can aslo modify receipt directly with affecting 1.73 + # the main Hg. 1.74 + check_root 1.75 + if [ "$2" = "stable" ]; then 1.76 + HG_WOK=$STABLE/wok 1.77 + CHROOT=$STABLE/chroot 1.78 + else 1.79 + HG_WOK=$COOKING/wok 1.80 + CHROOT_WOK=$COOKING/chroot/home/slitaz 1.81 + fi 1.82 + cd $HG_WOK 1.83 + hg pull && hg update 1.84 + echo -n "Copying Hg wok to the chroot... " 1.85 + cp -a $HG_WOK $CHROOT_WOK 1.86 + echo "Done" ;; 1.87 + chroot) 1.88 + # Chroot into a build env. Default to cookind configured in 1.89 + # tazdev.conf 1.90 + check_root 1.91 + if [ "$1" = "stable" ]; then 1.92 + ROOTFS=$STABLE/chroot 1.93 + else 1.94 + ROOTFS=$COOKING/chroot 1.95 + [ -n "$1" ] && ROOTFS=$1 1.96 + fi 1.97 + # Mount virtual Kernel file systems and chroot but check that 1.98 + # nobody else has done mounts 1.99 + if [ ! -d $ROOTFS/proc/1 ]; then 1.100 + mount -t proc proc $ROOTFS/proc 1.101 + mount -t sysfs sysfs $ROOTFS/sys 1.102 + mount -t devpts devpts $ROOTFS/dev/pts 1.103 + mount -t tmpfs shm $ROOTFS/dev/shm 1.104 + fi 1.105 + echo "Chrooting in $ROOTFS... " 1.106 + chroot $ROOTFS /bin/sh --login 1.107 + # Unmount virtual Kernel file systems on exit. and ensure we are the 1.108 + # last user before unmounting ! 1.109 + if [ "$(ps | grep $(basename $0) | grep -v grep | wc -l)" == "1" ]; then 1.110 + umount $ROOTFS/dev/shm 1.111 + umount $ROOTFS/dev/pts 1.112 + umount $ROOTFS/sys 1.113 + umount $ROOTFS/proc 1.114 + fi 1.115 + echo "Exiting of $ROOTFS chroot environment... " ;; 1.116 + push) 1.117 + check_mirror 1.118 + rsync -r -t -l -v -z --delete \ 1.119 + $LOCAL_DIR -e ssh $USER@$HOST:$REMOTE_DIR ;; 1.120 + dry-push) 1.121 + check_mirror 1.122 + rsync -r -t -l -v -z --delete --dry-run \ 1.123 + $LOCAL_DIR -e ssh $USER@$HOST:$REMOTE_DIR ;; 1.124 + pull) 1.125 + check_mirror 1.126 + rsync -r -t -l -v -z --delete \ 1.127 + -e ssh $USER@$HOST:$REMOTE_DIR $LOCAL_DIR ;; 1.128 + dry-pull) 1.129 + check_mirror 1.130 + rsync -r -t -l -v -z --delete --dry-run \ 1.131 + -e ssh $USER@$HOST:$REMOTE_DIR $LOCAL_DIR ;; 1.132 + usage|*) 1.133 + usage ;; 1.134 +esac 1.135 + 1.136 +exit 0