slitaz-pizza annotate web/pizza.cgi @ rev 63

Tiny typo
author Paul Issott <paul@slitaz.org>
date Fri Jul 27 19:44:01 2012 +0100 (2012-07-27)
parents c63cfd9530a0
children f2dd2dcde9e2
rev   line source
pankso@7 1 #!/bin/sh
pankso@7 2 #
paul@9 3 # SliTaz Pizza CGI/web interface - Let's have a pizza :-)
pankso@7 4 # Please KISS, it is important and keep speed in mind. Thanks, Pankso.
pankso@7 5 #
pankso@7 6
pankso@7 7 # Output a RSS feed of latest build isos.
pankso@7 8 if [ "$QUERY_STRING" == "rss" ]; then
pankso@7 9 . /etc/slitaz/pizza.conf
pankso@7 10 pubdate=$(date "+%a, %d %b %Y %X")
pankso@7 11 cat << EOT
pankso@7 12 Content-Type: text/xml
pankso@7 13
pankso@7 14 <?xml version="1.0" encoding="utf-8" ?>
pankso@7 15 <rss version="2.0">
pankso@7 16 <channel>
pankso@7 17 <title>SliTaz Pizza</title>
pankso@7 18 <description>The SliTaz Pizza cooker feed</description>
pankso@7 19 <link>$PIZZA_URL</link>
pankso@7 20 <lastBuildDate>$pubdate GMT</lastBuildDate>
pankso@7 21 <pubDate>$pubdate GMT</pubDate>
pankso@7 22 EOT
pankso@7 23 for rss in $(ls -1t $PIZZA/chroot${SLITAZ}/xml/*.xml | head -n 12)
pankso@7 24 do
pankso@7 25 cat $rss
pankso@7 26 done
pankso@7 27 cat << EOT
pankso@7 28 </channel>
pankso@7 29 </rss>
pankso@7 30 EOT
pankso@7 31 exit 0
pankso@7 32 fi
pankso@7 33
pankso@7 34 # Content negotiation for Gettext
pankso@7 35 IFS=","
pankso@7 36 for lang in $HTTP_ACCEPT_LANGUAGE
pankso@7 37 do
pankso@7 38 lang=${lang%;*} lang=${lang# } lang=${lang%-*}
pankso@7 39 [ -d "$lang" ] && break
pankso@7 40 case "$lang" in
pankso@7 41 en) lang="C" ;;
pankso@7 42 fr) lang="fr_FR" ;;
pankso@7 43 esac
pankso@7 44 done
pankso@7 45 unset IFS
pankso@7 46 export LANG=$lang LC_ALL=$lang
pankso@7 47
pankso@7 48 # Internationalization: $(gettext "")
pankso@7 49 . /usr/bin/gettext.sh
pankso@7 50 TEXTDOMAIN='pizza'
pankso@7 51 export TEXTDOMAIN
pankso@7 52
pankso@7 53 . lib/libpizza
pankso@7 54
pankso@7 55 #
pankso@7 56 # Commands
pankso@7 57 #
pankso@7 58
pankso@7 59 case " $(GET) " in
pankso@7 60 *\ start\ *)
pankso@7 61 #
pankso@7 62 # First step
pankso@7 63 #
pankso@7 64 date=$(date "+%Y%m%d")
pankso@7 65 id=$date-$$
pankso@7 66 cat << EOT
pankso@7 67 <h2>$(gettext "First step")</h2>
pankso@7 68 <p>
paul@9 69 $(gettext "Choose your distribution name and the one you want to use as
paul@9 70 base. We need your mail to notify you when your SliTaz Flavor is built
paul@9 71 and if anything goes wrong.")
pankso@7 72 </p>
pankso@7 73 <form method="get" action="pkgs.cgi" name="pizza" onsubmit="return checkForm();">
pankso@7 74 <table>
pankso@7 75 <tbody>
pankso@7 76 <tr>
pankso@7 77 <td>$(gettext "Flavor name")</td>
pankso@7 78 <td><input type="text" name="flavor" size="40" /></td>
pankso@7 79 </tr>
pankso@7 80 <tr>
pankso@7 81 <td>$(gettext "Short description")</td>
pankso@7 82 <td><input type="text" name="desc" size="40" /></td>
pankso@7 83 </tr>
pankso@7 84 <tr>
pankso@7 85 <td>$(gettext "Email")</td>
pankso@7 86 <td><input type="text" name="mail" size="40" /></td>
pankso@7 87 </tr>
pankso@7 88 <tr>
pankso@7 89 <td>$(gettext "Based on")</td>
pankso@7 90 <td>
pankso@7 91 <select name="skel">
pankso@7 92 <option value="base">
pankso@7 93 Base - $(gettext "Text mode system")</option>
pankso@7 94 <option value="justx">
pankso@7 95 Justx - $(gettext "X without GTK or QT")</option>
pankso@7 96 <option value="gtkonly">
pankso@7 97 Gtkonly - $(gettext "Clean GTK desktop")</option>
pankso@7 98 <option value="core">
pankso@7 99 Core - $(gettext "Default SliTaz desktop")</option>
pankso@7 100 </select>
pankso@7 101 </td>
pankso@7 102 </tr>
pankso@7 103 </tbody>
pankso@7 104 </table>
pankso@7 105 <pre>
pankso@7 106 Uniq ID : $id
pankso@7 107 </pre>
pankso@7 108 <div class="next">
pankso@7 109 <input type="hidden" name="id" value="$id" />
pankso@7 110 <input type="submit" value="$(gettext "Continue")">
pankso@7 111 </div>
pankso@7 112 </form>
pankso@7 113 EOT
pankso@7 114 ;;
pankso@7 115 *\ gen\ *)
pankso@7 116 #
pankso@7 117 # Generate step
pankso@7 118 #
pankso@7 119 id="$(GET id)"
pankso@7 120 . $tmpdir/slitaz-$id/receipt
pankso@7 121 addfiles=$(find $tmpdir/slitaz-$id/addfiles -type f | wc -l)
pankso@7 122 [ "$addfiles" ] || addfiles=0
pankso@7 123 packages=$(cat $tmpdir/slitaz-$id/packages.list | wc -l)
pankso@7 124 cat << EOT
pankso@7 125 <h2>$(gettext "Generate")</h2>
pankso@7 126 <p>
pankso@23 127 $(gettext "Last chance to stop process or start over. Next step will pack
pankso@23 128 your flavor and add it to the build queue. Here you can also add a note to
pankso@23 129 your receipt flavor, this will be displayed on your flavor ID page and
pankso@23 130 can be used to give more info to other users and SliTaz developers.")
pankso@7 131 </p>
pankso@23 132
pankso@7 133 <pre>
pankso@7 134 Uniq ID : $id
pankso@7 135 Flavor : $FLAVOR
pankso@7 136 Short desc : $SHORT_DESC
pankso@7 137 Maintainer : $MAINTAINER
pankso@7 138 Packages : $packages
pankso@7 139 Addfiles : $addfiles
pankso@7 140 </pre>
pankso@7 141 <form method="get" action="./">
pankso@7 142 <div class="box">
pankso@7 143 Note:
pankso@7 144 <input type="text" name="note" style="width: 720px;" />
pankso@7 145 </div>
pankso@7 146 <div class="next">
pankso@7 147 <input type="submit" name="cancel" value="$(gettext "Cancel")">
pankso@7 148 <input type="hidden" name="addfiles" value="$addfiles" />
pankso@7 149 <input type="hidden" name="id" value="$id" />
pankso@7 150 <input type="submit" name="pack" value="$(gettext "Build flavor")">
pankso@7 151 </div>
pankso@7 152 </form>
pankso@7 153 EOT
pankso@7 154 ;;
pankso@7 155 *\ cancel\ *)
pankso@7 156 id="$(GET id)"
pankso@23 157 echo "<p>$(gettext "Removing temporary files for:") $id</p>"
pankso@7 158 [ -d "$tmpdir/slitaz-$id" ] && rm -rf $tmpdir/slitaz-$id/
pankso@7 159 cat << EOT
pankso@7 160 <form method="get" action="./">
pankso@7 161 <input type="submit" name="start" value="$(gettext "Start over")">
pankso@7 162 </form>
pankso@7 163 EOT
pankso@7 164 ;;
pankso@7 165 *\ pack\ *)
pankso@7 166 #
pankso@7 167 # Pack distro step
pankso@7 168 #
pankso@7 169 id="$(GET id)"
pankso@7 170 receipt="$tmpdir/slitaz-$id/receipt"
pankso@7 171 addfiles="$(GET addfiles)"
pankso@7 172 log="$tmpdir/slitaz-$id/distro.log"
pankso@7 173 note="$(GET note)"
pankso@7 174 inqueue=$(ls $queue | wc -l)
pankso@7 175 . $receipt
pankso@7 176 cat << EOT
pankso@7 177 <h2>$(gettext "Packing:") $FLAVOR</h2>
pankso@7 178 <pre>
pankso@7 179 EOT
pankso@7 180 if ! fgrep ADDFILES $receipt; then
pankso@7 181 echo "ADDFILES=\"$addfiles\"" >> $receipt
pankso@7 182 fi
pankso@7 183 if ! fgrep NOTE $receipt; then
pankso@7 184 echo "NOTE=\"$note\"" >> $receipt
pankso@7 185 fi
pankso@7 186
pankso@7 187 # The rootcd README
pankso@7 188 echo -n "Creating SliTaz cdrom README..."
pankso@7 189 date=$(date '+%Y-%m-%d %H:%M')
pankso@7 190 mkdir -p $tmpdir/slitaz-$id/rootcd
pankso@7 191 cp $DATA/README.distro $tmpdir/slitaz-$id/rootcd/README
pankso@7 192 sed -i s"/_DATE_/$date/" $tmpdir/slitaz-$id/rootcd/README
pankso@7 193 status
pankso@7 194
pankso@7 195 echo -n "Creating flavor tarball..."
pankso@7 196 cd $tmpdir && tar cjf $FLAVOR.tar.bz2 slitaz-$id
pankso@7 197 mkdir -p $public/slitaz-$id
pankso@7 198 mv $FLAVOR.tar.bz2 $public/slitaz-$id
pankso@7 199 status
pankso@7 200
pankso@7 201 # Keep a public receipt copy and move everything from tmp to queue.
pankso@7 202 echo "Flavor packed : $(date '+%Y-%m-%d %H:%M')" | tee -a $log
pankso@7 203 echo -n "Moving $id to Pizza build queue..."
pankso@7 204 mv -f $tmpdir/slitaz-$id/distro.log $public/slitaz-$id
pankso@7 205 cp -f $tmpdir/slitaz-$id/receipt $public/slitaz-$id
pankso@7 206 mv $tmpdir/slitaz-$id $queue
pankso@7 207 status
pankso@7 208
pankso@7 209 if [ "$inqueue" == "1" ]; then
pankso@7 210 gettext "Your ISO will be built on next Pizza Bot run"
pankso@7 211 else
paul@63 212 eval_gettext "There are \$inqueue flavors in queue"
pankso@7 213 fi
pankso@7 214 echo ""
pankso@10 215 echo "New flavor added to queue: <a href='?id=$id'>$id</a> ($FLAVOR)" | log
pankso@7 216 cat << EOT
pankso@7 217 </pre>
pankso@7 218 <div>
pankso@7 219 <img src="images/archive.png" alt="[ tarball ]" />
pankso@7 220 $(gettext "Download tarball: ")
pankso@7 221 <a href="public/slitaz-$id/$FLAVOR.tar.bz2">$FLAVOR.tar.bz2</a>
pankso@7 222 - Browse <a href="public/slitaz-$id/">the flavor</a>
pankso@7 223 </div>
pankso@7 224 <div class="next">
pankso@7 225 <form method="get" action="./">
pankso@7 226 <input type="hidden" name="id" value="$id" />
pankso@7 227 <input type="submit" value="$(gettext "Status")">
pankso@7 228 </form>
pankso@7 229 </div>
pankso@7 230 EOT
pankso@7 231 ;;
pankso@7 232 *\ id\ *)
pankso@7 233 #
pankso@7 234 # ID Status page
pankso@7 235 #
pankso@7 236 id="$(GET id)"
pankso@7 237 [ -f "$queue/slitaz-$id/receipt" ] && . $queue/slitaz-$id/receipt
pankso@7 238 [ -f "public/slitaz-$id/receipt" ] && . public/slitaz-$id/receipt
pankso@7 239 log="$public/slitaz-$id/distro.log"
pankso@7 240 if [ ! -d "public/slitaz-$id" ]; then
paul@9 241 echo "Sorry, can't find flavor ID: $id"
pankso@7 242 cat lib/footer.html && exit 0
pankso@7 243 fi
pankso@7 244 if [ -f "$public/slitaz-$id/$FLAVOR.iso" ]; then
pankso@7 245 dir="public/slitaz-$id"
pankso@7 246 list="$dir/packages.list"
pankso@7 247 iso="$dir/$FLAVOR.iso"
pankso@7 248 msg="$(gettext "Download ISO:") <a href='$dir/$FLAVOR.iso'>$FLAVOR.iso</a>
pankso@7 249 [ <a href='$dir/$FLAVOR.md5'>md5</a> ]"
pankso@7 250 else
pankso@7 251 list="$queue/slitaz-$id/packages.list"
pankso@7 252 msg="$(gettext "Flavor is building or still in the build queue")"
pankso@7 253 fi
pankso@7 254 pkgslist=$(cat $list | wc -l)
pankso@7 255 pkgsinst=$(cat $installed | wc -l)
pankso@7 256 [ "$pkgsinst" ] || pkgsinst=0
pankso@7 257 [ "$ISO_SIZE" ] || ISO_SIZE="N/A"
pankso@7 258 [ "$ROOTFS_SIZE" ] || ROOTFS_SIZE="N/A"
pankso@7 259 cat << EOT
pankso@7 260 <h2>$(gettext "Status for:") $FLAVOR</h2>
pankso@14 261 <div>
pankso@14 262 $(get_gravatar $MAINTAINER) $(gettext "Flavor description:") $SHORT_DESC
pankso@14 263 </div>
pankso@7 264 <pre>
pankso@7 265 Uniq ID : $id
pankso@7 266 Flavor : $FLAVOR
pankso@7 267 Packages : $pkgslist in list - $pkgsinst installed
pankso@7 268 Rootfs size : $ROOTFS_SIZE
pankso@7 269 ISO size : $ISO_SIZE
pankso@7 270 </pre>
pankso@7 271
pankso@7 272 <div>
pankso@7 273 <img src="images/iso.png" alt="[ iso ]" /> $(echo $msg)
pankso@7 274 </div>
pankso@7 275 <div>
pankso@7 276 <img src="images/archive.png" alt="[ tarball ]" />
pankso@7 277 $(gettext "Download tarball:")
pankso@7 278 <a href="public/slitaz-$id/$FLAVOR.tar.bz2">$FLAVOR.tar.bz2</a>
pankso@7 279 EOT
pankso@7 280 if [ -f "$public/slitaz-$id/$FLAVOR.flavor" ]; then
pankso@7 281 cat << EOT
pankso@7 282 - Flavor file: <a href="public/slitaz-$id/$FLAVOR.flavor">$FLAVOR.flavor</a>
pankso@7 283 EOT
pankso@7 284 fi
pankso@7 285 cat << EOT
pankso@7 286 - Browse <a href="public/slitaz-$id/">the flavor</a>
pankso@7 287 </div>
pankso@7 288 EOT
pankso@7 289 if [ "$NOTE" ]; then
pankso@7 290 echo "<div class="note">$NOTE</div>"
pankso@7 291 fi
pankso@7 292 if [ -f "$log" ]; then
pankso@7 293 echo '<h2>Distro log</h2>'
pankso@7 294 echo '<pre>'
pankso@7 295 fgrep 'Build time' $log
pankso@7 296 cat $log | highlighter log
pankso@7 297 echo '</pre>'
pankso@7 298 fi ;;
pankso@7 299 *\ help\ *)
pankso@7 300 echo "<h2>$(gettext "Help")</h2>"
pankso@42 301 cat /usr/share/doc/pizza/help.en.html
pankso@40 302 cat /usr/share/doc/pizza/faq.en.html
pankso@43 303 echo '<h3>README</h3>'
pankso@7 304 echo '<pre>'
pankso@7 305 cat /usr/share/doc/pizza/README
pankso@7 306 echo '</pre>' ;;
pankso@7 307 *\ info\ *)
pankso@7 308 # English only :-)
pankso@7 309 if mount | fgrep -q slitaz/public; then
pankso@7 310 mounted="Public is mounted"
pankso@7 311 else
pankso@7 312 mounted="WARRNING: Public is not mounted"
pankso@7 313 fi
pankso@7 314 echo '<h2><img src="images/monitor.png" alt="" />Pizza Info</h2>'
pankso@7 315 echo '<pre>'
pankso@7 316 [ "$mounted" ] && echo "$mounted"
pankso@7 317 echo -n "Public flavors : " && ls -1 public | wc -l
pankso@7 318 echo -n "Public size : " && du -sh public | awk '{print $1}'
pankso@7 319 echo -n "Tmp size : " && du -sh $tmpdir | awk '{print $1}'
pankso@7 320 echo '</pre>' ;;
pankso@16 321 *\ activity\ *)
pankso@16 322 cat << EOT
pankso@16 323 <h2><img src="images/monitor.png" alt="" />$(gettext "Activity")</h2>
pankso@16 324
pankso@16 325 <pre>
pankso@16 326 $(tac $activity | highlighter activity)
pankso@16 327 </pre>
pankso@16 328
pankso@16 329 EOT
pankso@16 330 ;;
pankso@7 331 *)
pankso@7 332 #
pankso@7 333 # Main page
pankso@7 334 #
pankso@7 335 inqueue=$(ls $queue | wc -l)
pankso@7 336 builds=$(cat $builds)
pankso@7 337 pubiso=$(ls -1 public | wc -l)
pankso@7 338 [ "$builds" ] || builds=0
pankso@7 339 cat << EOT
pankso@7 340 <h2>$(gettext "Welcome")</h2>
pankso@16 341 <form method="get" action="./">
pankso@7 342 <p>
pankso@23 343 $(gettext "SliTaz Pizza lets you create your own SliTaz ISO flavor
pankso@23 344 online. The ISO image can be burnt on a cdrom or installed on USB media.
pankso@23 345 Please read the SliTaz Pizza <a href="?help">Help</a> before starting
pankso@23 346 a new flavor.")
pankso@7 347 </p>
pankso@7 348 <pre>
pankso@7 349 Flavors: $inqueue in queue - $builds builds - $pubiso public
pankso@7 350 </pre>
pankso@7 351
pankso@7 352 <div class="start">
pankso@16 353 <input type="submit" name="start" value="$(gettext "Create a new flavor")">
pankso@7 354 </div>
pankso@7 355
pankso@7 356 EOT
pankso@7 357 echo "<h2>$(gettext "Latest builds")</h2>"
pankso@7 358 echo '<pre>'
pankso@19 359 for flavor in $(ls -1t public | head -n 5)
pankso@7 360 do
pankso@7 361 if [ -f "public/$flavor/receipt" ]; then
pankso@7 362 . ./public/$flavor/receipt
pankso@7 363 [ -f "public/$flavor/$FLAVOR.iso" ] && \
pankso@7 364 cat << EOT
pankso@17 365 $(get_gravatar $MAINTAINER 24) <a href="?id=$ID">$VERSION</a> : \
pankso@16 366 <a href="public/$flavor/$FLAVOR.iso">$FLAVOR.iso</a> ($ISO_SIZE)
pankso@7 367 EOT
pankso@7 368 fi
pankso@7 369 done
pankso@16 370 echo '</pre>'
pankso@16 371 cat << EOT
pankso@16 372 <h2>$(gettext "Activity")</h2>
pankso@16 373 <pre>
pankso@16 374 $(tac $activity | head -n 12 | highlighter activity)
pankso@16 375 </pre>
pankso@16 376 <input type="submit" name="activity" value="$(gettext "More activity")">
pankso@16 377 </form>
pankso@16 378 EOT
pankso@16 379 ;;
pankso@7 380 esac
pankso@7 381
pankso@7 382 # HTML footer.
pankso@7 383 cat lib/footer.html
pankso@7 384
pankso@7 385 exit 0