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