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