slitaz-pizza view pizza-bot @ rev 63

Tiny typo
author Paul Issott <paul@slitaz.org>
date Fri Jul 27 19:44:01 2012 +0100 (2012-07-27)
parents 8ef7eec5250e
children a623eba88ed3
line source
1 #!/bin/sh
2 #
3 # SliTaz Pizza chroot cmdline utility. This tool is designed to be run
4 # by cron and automatically build flavors in the queue. We build one ISO
5 # at once so we don't use too many resources.
6 #
7 # Copyright (C) 2012 SliTaz GNU/Linux - GNU gpl v2
8 # Authors : Christophe Lincoln <pankso@slitaz.org>
9 #
11 . /etc/slitaz/pizza-bot.conf
13 # Pizza DB files.
14 pizza="/home/slitaz"
15 cache="$pizza/cache"
16 queue="$pizza/queue"
17 activity="$cache/activity"
18 public="$pizza/public"
19 builds="$cache/builds"
20 lockfile="/var/lock/pizza.lock"
21 feeds="$pizza/xml"
23 # Log activities, we want first letter capitalized.
24 log() {
25 grep ^[A-Z] | \
26 sed s"#^[A-Z]\([^']*\)#$(date '+%Y-%m-%d %H:%M') : \0#" >> $activity
27 }
29 # Clean exit.
30 quit() {
31 rm -f $lockfile
32 exit 0
33 }
35 # Create a XML feed for freshly built flavor.
36 gen_rss() {
37 pubdate=$(date "+%a, %d %b %Y %X")
38 cat > $feeds/slitaz-$ID.xml << EOT
39 <item>
40 <title>$FLAVOR $VERSION</title>
41 <link>${PIZZA_URL}?id=$ID</link>
42 <guid>slitaz-$ID</guid>
43 <pubDate>$pubdate</pubDate>
44 <description>$SHORT_DESC</description>
45 </item>
46 EOT
47 }
49 # Mail body.
50 mail_body() {
51 md5=$(cat $public/slitaz-$ID/$FLAVOR.md5 | awk '{print $1}')
52 cat << EOT
53 From: SliTaz Pizza <pizza@$MAIL_DOMAIN>
54 To: $MAINTAINER
55 Date: $(date '+%a, %d %b %Y %H:%M:%S %z')
56 Subject: Flavor ISO is built
57 Content-Type: text/plain; charset=utf-8
58 Content-Transfer-Encoding: 8bit
60 Hi,
62 Your custom SliTaz GNU/Linux system is ready to download! It will be
63 hosted as long as we can but with absolutely no warranty in time.
65 Get $FLAVOR ISO and files at: ${PIZZA_URL}?id=$ID
67 ISO size: $ISO_SIZE
68 MD5 sum: $md5
70 If you wish a long time hosting service please get in touch via our
71 professional platform at http://slitaz.pro
73 Visit http://www.slitaz.org for latest news about the project and
74 get community support on SliTaz Forum http://forum.slitaz.org
76 Sent by the SliTaz Pizza Mailer
78 EOT
79 }
81 # Run as daemon by default.
82 case "$1" in
83 usage)
84 echo "Usage: $(basename $0) [lock|unlock]" ;;
85 lock)
86 echo $$ > $lockfile ;;
87 unlock)
88 rm -f $lockfile ;;
89 *)
90 [ -f "$lockfile" ] && echo "Pizza is locked" && exit 0
91 trap 'rm -f $command && exit 1' INT TERM
92 echo $$ > $lockfile
93 name=$(ls -rt $queue | head -n 1)
94 log="$public/$name/distro.log"
95 work="$pizza/flavors"
96 [ ! "$name" ] && echo "Empty build queue" && quit
97 . $queue/$name/receipt
99 [ -z "$ID" -o -z "$FLAVOR" ] && echo "$name not valid" && quit
101 [ -d /proc/1 ] || mount -t proc /proc /proc
102 #tazpkg setup-mirror /home/slitaz/packages
103 tazpkg recharge
105 echo "Build started for flavor: <a href='?id=$ID'>$ID</a> ($FLAVOR)" | log
106 echo -e "Build started : $(date '+%Y-%m-%d %H:%M')\n" | tee -a $log
108 rm -rf $work && mkdir -p $work && cd $work
109 mv $queue/$name $FLAVOR
110 chown -R root.root $FLAVOR
111 tazlito pack-flavor $FLAVOR | tee -a $log
112 tazlito get-flavor $FLAVOR | tee -a $log
113 mv $FLAVOR.flavor $public/$name
114 sed -i s"/^ISO_NAME=.*/ISO_NAME=\"$FLAVOR\"/" tazlito.conf
115 yes '' | tazlito gen-distro 2>&1 | tee -a $log
117 # Create an XML feed
118 gen_rss
120 # We want a public packages list md5sum file and move ISO so users
121 # can download it. Keep original pkgs list and build a complete one.
122 cp -f $FLAVOR/packages.list $public/$name
123 cd $pizza/distro
124 pkgsinst="$public/$name/installed.list"
125 rm -f $pkgsinst && touch $pkgsinst
126 for pkg in $(ls -1 rootfs/var/lib/tazpkg/installed)
127 do
128 . rootfs/var/lib/tazpkg/installed/$pkg/receipt
129 echo "$PACKAGE | $VERSION | $SHORT_DESC" >> $pkgsinst
130 done
131 echo "ISO_SIZE=\"$(du -sh $FLAVOR.iso | awk '{print $1}')\"" >> \
132 $public/$name/receipt
133 echo "ROOTFS_SIZE=\"$(du -sh rootfs | awk '{print $1}')\"" >> \
134 $public/$name/receipt
135 md5sum $FLAVOR.iso > $public/$name/$FLAVOR.md5
136 mv $FLAVOR.iso $public/$name
137 chown -R www.www $public/$name
139 # Send mail if enabled.
140 if [ "$MAIL_DOMAIN" ]; then
141 . $public/$name/receipt
142 echo "Sending mail to: $MAINTAINER"
143 mail_body | /usr/sbin/sendmail $MAINTAINER
144 fi
146 # Count builds
147 count=$(cat $builds)
148 count=$(($count + 1))
149 echo "$count" > $builds
150 rm -f $lockfile ;;
151 esac
152 exit 0