wok annotate slitaz-dev-tools/stuff/tazdev @ rev 3441
slitaz-dev-tools: add command update-www (up slitaz website repo)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Jun 14 02:45:16 2009 +0200 (2009-06-14) |
parents | 7b0f14e1c0ac |
children | e43fb2292deb |
rev | line source |
---|---|
pankso@3440 | 1 #!/bin/sh |
pankso@3440 | 2 # Tazdev - SliTaz developers and build host tool. |
pankso@3440 | 3 # System wide config file: /etc/slitaz/tazdev.conf |
pankso@3440 | 4 # |
pankso@3440 | 5 # (c) 2009 SliTaz GNU/Linux - GNU gpl v3 |
pankso@3440 | 6 # |
pankso@3440 | 7 # Authors : Christophe Lincoln (Pankso) <pankso@slitaz.org> |
pankso@3440 | 8 # |
pankso@3440 | 9 |
pankso@3440 | 10 if [ -f /etc/slitaz/tazdev.conf ]; then |
pankso@3440 | 11 . /etc/slitaz/tazdev.conf |
pankso@3440 | 12 elif [ -f $PWD/tazdev.conf ]; then |
pankso@3440 | 13 . $PWD/tazdev.conf |
pankso@3440 | 14 else |
pankso@3440 | 15 echo -e "\nNo config file found in /etc/slitaz or the current dir...\n" |
pankso@3440 | 16 exit 0 |
pankso@3440 | 17 fi |
pankso@3440 | 18 |
pankso@3440 | 19 usage() |
pankso@3440 | 20 { |
pankso@3440 | 21 echo -e "\nSliTaz developers and build host tool\n |
pankso@3440 | 22 \033[1mUsage: \033[0m `basename $0` [command] [user] [stable|cooking] |
pankso@3440 | 23 \033[1mCommands: \033[0m\n |
pankso@3441 | 24 usage Print this short usage and command list. |
pankso@3441 | 25 cmplog Log 'tazwok cmp' result. |
pankso@3441 | 26 update-wok Update Hg wok and copy it to the chroot wok. |
pankso@3441 | 27 update-wwww Update SliTaz Website repo. |
pankso@3441 | 28 chroot Mount virtual fs if needed and chroot into the build env. |
pankso@3441 | 29 push Upload new packages to the mirror. |
pankso@3441 | 30 dry-push Show what will be uploaded to the mirror. Do nothing. |
pankso@3441 | 31 pull Download new packages from the mirror. |
pankso@3441 | 32 dry-pull Show what will be downloaded from the mirror. Do nothing.\n" |
pankso@3440 | 33 } |
pankso@3440 | 34 |
pankso@3440 | 35 # Exit if user is not root. |
pankso@3440 | 36 check_root() |
pankso@3440 | 37 { |
pankso@3440 | 38 if test $(id -u) != 0 ; then |
pankso@3440 | 39 echo -e "\nThis program requires being run as root.\n" |
pankso@3440 | 40 exit 0 |
pankso@3440 | 41 fi |
pankso@3440 | 42 } |
pankso@3440 | 43 |
pankso@3440 | 44 check_mirror() |
pankso@3440 | 45 { |
pankso@3440 | 46 # ping -c 1 $MIRROR |
pankso@3440 | 47 if [ -n "$2" ]; then |
pankso@3440 | 48 USER=$2 |
pankso@3440 | 49 else |
pankso@3440 | 50 echo -e "\nPlease specify a user.\n" && exit 0 |
pankso@3440 | 51 fi |
pankso@3440 | 52 if [ "$3" = "stable" ]; then |
pankso@3440 | 53 REMOTE_DIR=$MIRROR_DIR/stable/ |
pankso@3440 | 54 LOCAL_DIR=$STABLE/packages/ |
pankso@3440 | 55 else |
pankso@3440 | 56 REMOTE_DIR=$MIRROR_DIR/cooking/ |
pankso@3440 | 57 LOCAL_DIR=$COOKING/packages/ |
pankso@3440 | 58 fi |
pankso@3440 | 59 } |
pankso@3440 | 60 |
pankso@3440 | 61 case "$1" in |
pankso@3440 | 62 cmplog) |
pankso@3440 | 63 # Log 'tazwok cmp' for the web interface (can be used via a cron job). |
pankso@3440 | 64 check_root |
pankso@3440 | 65 tazwok cmp | grep ^[A-Z] | tee $CMP_LOG |
pankso@3440 | 66 echo "Date: `date`" >> $CMP_LOG ;; |
pankso@3440 | 67 update-wok) |
pankso@3440 | 68 # Update the Hg wok and copy it to the chroot env. Hg wok id |
pankso@3440 | 69 # copied to the chroot wok to avoid messing with build result |
pankso@3440 | 70 # file and so we can aslo modify receipt directly with affecting |
pankso@3440 | 71 # the main Hg. |
pankso@3440 | 72 check_root |
pankso@3440 | 73 if [ "$2" = "stable" ]; then |
pankso@3440 | 74 HG_WOK=$STABLE/wok |
pankso@3440 | 75 CHROOT=$STABLE/chroot |
pankso@3440 | 76 else |
pankso@3440 | 77 HG_WOK=$COOKING/wok |
pankso@3440 | 78 CHROOT_WOK=$COOKING/chroot/home/slitaz |
pankso@3440 | 79 fi |
pankso@3440 | 80 cd $HG_WOK |
pankso@3440 | 81 hg pull && hg update |
pankso@3440 | 82 echo -n "Copying Hg wok to the chroot... " |
pankso@3440 | 83 cp -a $HG_WOK $CHROOT_WOK |
pankso@3440 | 84 echo "Done" ;; |
pankso@3441 | 85 update-www) |
pankso@3441 | 86 # Update website from repo. |
pankso@3441 | 87 echo "" |
pankso@3441 | 88 cd $WEBSITE && hg pull && hg update |
pankso@3441 | 89 echo "" ;; |
pankso@3440 | 90 chroot) |
pankso@3440 | 91 # Chroot into a build env. Default to cookind configured in |
pankso@3440 | 92 # tazdev.conf |
pankso@3440 | 93 check_root |
pankso@3440 | 94 if [ "$1" = "stable" ]; then |
pankso@3440 | 95 ROOTFS=$STABLE/chroot |
pankso@3440 | 96 else |
pankso@3440 | 97 ROOTFS=$COOKING/chroot |
pankso@3440 | 98 [ -n "$1" ] && ROOTFS=$1 |
pankso@3440 | 99 fi |
pankso@3440 | 100 # Mount virtual Kernel file systems and chroot but check that |
pankso@3440 | 101 # nobody else has done mounts |
pankso@3440 | 102 if [ ! -d $ROOTFS/proc/1 ]; then |
pankso@3440 | 103 mount -t proc proc $ROOTFS/proc |
pankso@3440 | 104 mount -t sysfs sysfs $ROOTFS/sys |
pankso@3440 | 105 mount -t devpts devpts $ROOTFS/dev/pts |
pankso@3440 | 106 mount -t tmpfs shm $ROOTFS/dev/shm |
pankso@3440 | 107 fi |
pankso@3440 | 108 echo "Chrooting in $ROOTFS... " |
pankso@3440 | 109 chroot $ROOTFS /bin/sh --login |
pankso@3440 | 110 # Unmount virtual Kernel file systems on exit. and ensure we are the |
pankso@3440 | 111 # last user before unmounting ! |
pankso@3440 | 112 if [ "$(ps | grep $(basename $0) | grep -v grep | wc -l)" == "1" ]; then |
pankso@3440 | 113 umount $ROOTFS/dev/shm |
pankso@3440 | 114 umount $ROOTFS/dev/pts |
pankso@3440 | 115 umount $ROOTFS/sys |
pankso@3440 | 116 umount $ROOTFS/proc |
pankso@3440 | 117 fi |
pankso@3440 | 118 echo "Exiting of $ROOTFS chroot environment... " ;; |
pankso@3440 | 119 push) |
pankso@3440 | 120 check_mirror |
pankso@3440 | 121 rsync -r -t -l -v -z --delete \ |
pankso@3440 | 122 $LOCAL_DIR -e ssh $USER@$HOST:$REMOTE_DIR ;; |
pankso@3440 | 123 dry-push) |
pankso@3440 | 124 check_mirror |
pankso@3440 | 125 rsync -r -t -l -v -z --delete --dry-run \ |
pankso@3440 | 126 $LOCAL_DIR -e ssh $USER@$HOST:$REMOTE_DIR ;; |
pankso@3440 | 127 pull) |
pankso@3440 | 128 check_mirror |
pankso@3440 | 129 rsync -r -t -l -v -z --delete \ |
pankso@3440 | 130 -e ssh $USER@$HOST:$REMOTE_DIR $LOCAL_DIR ;; |
pankso@3440 | 131 dry-pull) |
pankso@3440 | 132 check_mirror |
pankso@3440 | 133 rsync -r -t -l -v -z --delete --dry-run \ |
pankso@3440 | 134 -e ssh $USER@$HOST:$REMOTE_DIR $LOCAL_DIR ;; |
pankso@3440 | 135 usage|*) |
pankso@3440 | 136 usage ;; |
pankso@3440 | 137 esac |
pankso@3440 | 138 |
pankso@3440 | 139 exit 0 |