slitaz-pizza view web/pizza.cgi @ rev 119

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