wok-next view slitaz-dev-tools/stuff/tazdev @ rev 3444

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