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