cookutils rev 310

Generated XML feed for cooked packages
author Christophe Lincoln <pankso@slitaz.org>
date Wed Mar 14 02:53:06 2012 +0100 (2012-03-14)
parents 5b030078c381
children 20f9b75ec056
files cook cook.conf data/cookutils-doc.desktop data/header.html web/cooker.cgi
line diff
     1.1 --- a/cook	Tue Mar 13 15:11:04 2012 +0100
     1.2 +++ b/cook	Wed Mar 14 02:53:06 2012 +0100
     1.3 @@ -826,6 +826,20 @@
     1.4  	exit $status 
     1.5  }
     1.6  
     1.7 +# Create a XML feed for freshly builded package.
     1.8 +gen_rss() {
     1.9 +	pubdate=$(date "+%a, %d %b %Y %X")
    1.10 +	cat > $FEEDS/$pkg.xml << EOT
    1.11 +	<item>
    1.12 +		<title>$PACKAGE $VERSION${EXTRAVERSION}</title>
    1.13 +		<link>${COOKER_URL}?pkg=$PACKAGE</link>
    1.14 +		<guid>$PACKAGE-$VERSION${EXTRAVERSION}</guid>
    1.15 +		<pubDate>$pubdate</pubDate>
    1.16 +		<description>$SHORT_DESC</description>
    1.17 +	</item>
    1.18 +EOT
    1.19 +}
    1.20 +
    1.21  #
    1.22  # Commands
    1.23  #
    1.24 @@ -1177,6 +1191,9 @@
    1.25  			rm -f $command && exit 1
    1.26  		fi
    1.27  		
    1.28 +		# Create an XML feed
    1.29 +		gen_rss
    1.30 +		
    1.31  		# Time and summary
    1.32  		time=$(($(date +%s) - $time))
    1.33  		summary | tee -a $LOGS/$pkg.log
     2.1 --- a/cook.conf	Tue Mar 13 15:11:04 2012 +0100
     2.2 +++ b/cook.conf	Wed Mar 14 02:53:06 2012 +0100
     2.3 @@ -2,7 +2,7 @@
     2.4  #
     2.5  
     2.6  # SliTaz working directory
     2.7 -SLITAZ="/home/slitaz"
     2.8 +SLITAZ="/home/slitaz/cooking/chroot/home/slitaz"
     2.9  
    2.10  # Directory paths for cookutils DB and files.
    2.11  WOK="$SLITAZ/wok"
    2.12 @@ -10,6 +10,7 @@
    2.13  SRC="$SLITAZ/src"
    2.14  CACHE="$SLITAZ/cache"
    2.15  LOGS="$SLITAZ/log"
    2.16 +FEEDS="$SLITAZ/xml"
    2.17  DATA="/usr/share/cook"
    2.18  
    2.19  # System packages DB.
    2.20 @@ -26,6 +27,9 @@
    2.21  WOK_URL="http://hg.slitaz.org/wok"
    2.22  FLAVORS_URL="http://hg.slitaz.org/flavors"
    2.23  
    2.24 +# Cooker URL for RSS feed link (http://localhost/cooker/cooker.cgi)
    2.25 +COOKER_URL="http://cook.slitaz.org/"
    2.26 +
    2.27  # Translation files to be included in packages.
    2.28  LOCALE=""
    2.29  
     3.1 --- a/data/cookutils-doc.desktop	Tue Mar 13 15:11:04 2012 +0100
     3.2 +++ b/data/cookutils-doc.desktop	Wed Mar 14 02:53:06 2012 +0100
     3.3 @@ -1,5 +1,5 @@
     3.4  [Desktop Entry]
     3.5 -Name=Cookutils documentation
     3.6 +Name=Cookutils Doc
     3.7  Exec=browser file:///usr/share/doc/cookutils/cookutils.html
     3.8  Icon=text-html
     3.9  Type=Application
     4.1 --- a/data/header.html	Tue Mar 13 15:11:04 2012 +0100
     4.2 +++ b/data/header.html	Wed Mar 14 02:53:06 2012 +0100
     4.3 @@ -8,6 +8,10 @@
     4.4  </head>
     4.5  <body>
     4.6  
     4.7 +<div id="network">
     4.8 +	<a href="cooker.cgi?rss">RSS</a>
     4.9 +</div>
    4.10 +
    4.11  <div id="header">
    4.12  	<div id="logo"></div>
    4.13  	<h1><a href="cooker.cgi">SliTaz Cooker</a></h1>
     5.1 --- a/web/cooker.cgi	Tue Mar 13 15:11:04 2012 +0100
     5.2 +++ b/web/cooker.cgi	Wed Mar 14 02:53:06 2012 +0100
     5.3 @@ -29,6 +29,30 @@
     5.4  # Functions
     5.5  #
     5.6  
     5.7 +# RSS feed generator
     5.8 +if [ "$QUERY_STRING" == "rss" ]; then
     5.9 +	pubdate=$(date "+%a, %d %b %Y %X")
    5.10 +	cat << EOT
    5.11 +<?xml version="1.0" encoding="utf-8" ?>
    5.12 +<rss version="2.0">
    5.13 +<channel>
    5.14 +	<title>SliTaz Cooker</title>
    5.15 +	<description>The SliTaz packages cooker feed</description>
    5.16 +	<link>$COOKER_URL</link>
    5.17 +	<lastBuildDate>$pubdate GMT</lastBuildDate>
    5.18 +	<pubDate>$pubdate GMT</pubDate>
    5.19 +EOT
    5.20 +	for rss in $(ls -lt $FEEDS/*.xml | head -n 12)
    5.21 +	do
    5.22 +		cat $rss
    5.23 +	done
    5.24 +	cat << EOT
    5.25 +</channel>
    5.26 +</rss>
    5.27 +EOT
    5.28 +	exit 0
    5.29 +fi
    5.30 +
    5.31  # Put some colors in log and DB files.
    5.32  syntax_highlighter() {
    5.33  	case $1 in