wok-current view tazpkg-web/stuff/tazpkg-web @ rev 11570

gnome-desktop: change depends to "GConf gtk+ startup-notification"
author Antoine Bodin <gokhlayeh@slitaz.org>
date Mon Jan 02 23:06:18 2012 +0100 (2012-01-02)
parents 84af4a5de089
children
line source
1 #!/bin/sh
2 # SliTaz Packages Web interface generator: http://pkgs.slitaz.org/
3 #
4 # (C) 2011 SliTaz project - GNU General Public License v3.
5 # Christophe Lincoln <pankso@slitaz.org>
6 #
8 . /etc/slitaz/tazpkg-web.conf
10 RELEASE="$1"
11 PAGES_DIR=$WEB_INTERFACE/$RELEASE
12 DATE=`date +%Y-%m-%d\ \%H:%M:%S`
13 YEAR=`date +%Y`
15 status()
16 {
17 local CHECK=$?
18 echo -en "\033[70G"
19 if [ $CHECK = 0 ]; then
20 echo "Done"
21 else
22 echo "Failed"
23 fi
24 return $CHECK
25 }
27 # Search from option with current version in first so users dont have
28 # to select the correct one.
29 search_form_option()
30 {
31 if [ "$RELEASE" == "stable" ]; then
32 cat << _EOT_
33 <option>stable</option>
34 <option>cooking</option>
35 <option>2.0</option>
36 <option>1.0</option>
37 _EOT_
38 else
39 cat << _EOT_
40 <option>cooking</option>
41 <option>stable</option>
42 <option>2.0</option>
43 <option>1.0</option>
44 _EOT_
45 fi
46 }
48 # xHTML Header.
49 xhtml_header()
50 {
51 cat $LIB_DIR/html/header.html > $PAGES_DIR/$page.html
52 sed -i s/"_RELEASE_"/"$RELEASE"/ $PAGES_DIR/$page.html
53 sed -i s/"_PAGE_"/"$page"/ $PAGES_DIR/$page.html
54 sed -i s/"_DATE_"/"$DATE"/ $PAGES_DIR/$page.html
55 }
57 # xHTML Footer.
58 xhtml_footer()
59 {
60 cat $LIB_DIR/html/footer.html >> $PAGES_DIR/$page.html
61 sed -i s/"_DATE_"/"$DATE"/ $PAGES_DIR/$page.html
62 sed -i s/"_YEAR_"/"$YEAR"/ $PAGES_DIR/$page.html
63 }
65 # Index pages with categories and search form.
66 gen_index_content()
67 {
68 cat >> $PAGES_DIR/$page.html << _EOT_
70 <div class="pkgs-search">
71 <form method="post" action="http://pkgs.slitaz.org/search.cgi">
72 <p>
73 <input type="text" name="query" size="32" />
74 <input type="submit" name="search" value="Search" />
75 </p>
76 <select name="object">
77 <option>Package</option>
78 <option>Desc</option>
79 <option>Tags</option>
80 <option>Receipt</option>
81 <option>Depends</option>
82 <option>BuildDepends</option>
83 <option>File</option>
84 <option>File_list</option>
85 <option>FileOverlap</option>
86 </select>
87 <select name="version">
88 `search_form_option`
89 </select>
90 </form>
91 <p>
92 $packages packages - Database generated on: $DATE
93 </p>
94 </div>
95 _EOT_
96 sed -i s/"_RELEASE_"/"$RELEASE"/ $PAGES_DIR/$page.html
97 }
99 # Packages <h3> and infos in <pre>. Some packages use EXTRAVERSION in
100 # the receipt so keep the value or set it to the kernel version.
101 pkgs_pages_content()
102 {
103 for pkg in $WOK/*
104 do
105 DEPENDS=""
106 DEPENDS_LINKS=""
107 EXTRAVERSION=""
108 . $pkg/receipt
109 packages=$(($packages+1))
110 cat >> $PAGES_DIR/$CATEGORY.html << _EOT_
112 <a name="$PACKAGE"></a>
113 <h3>
114 <a href="tazpkg://mirror.slitaz.org/packages/$RELEASE/$PACKAGE-${VERSION}$EXTRAVERSION.tazpkg">
115 <img src="/pics/tazpkg.png"
116 title="install" alt="install"
117 style="vertical-align: middle; width: 24px; height: 24px;" /></a>
118 $PACKAGE</h3>
119 <pre class="package">
120 Version : $VERSION
121 Short desc : $SHORT_DESC
122 Web site : <a href="$WEB_SITE">$WEB_SITE</a>
123 _EOT_
124 [ -z "$EXTRAVERSION" ] && EXTRAVERSION="_$KERNEL"
125 # Extraversion string or not
126 if [ -f "$PACKAGES_REPOSITORY/$PACKAGE-${VERSION}$EXTRAVERSION.tazpkg" ]; then
127 cat >> $PAGES_DIR/$CATEGORY.html << _EOT_
128 Download : <a href="http://mirror.slitaz.org/packages/$RELEASE/$PACKAGE-${VERSION}$EXTRAVERSION.tazpkg">$PACKAGE-${VERSION}$EXTRAVERSION.tazpkg</a>
129 _EOT_
130 echo '</pre>' >> $PAGES_DIR/$CATEGORY.html
131 else
132 # Check if package exists, could be virtual?
133 [ -f "$PACKAGES_REPOSITORY/$PACKAGE-$VERSION.tazpkg" ] &&
134 cat >> $PAGES_DIR/$CATEGORY.html << _EOT_
135 Download : <a href="http://mirror.slitaz.org/packages/$RELEASE/$PACKAGE-$VERSION.tazpkg">$PACKAGE-$VERSION.tazpkg</a>
136 _EOT_
137 echo '</pre>' >> $PAGES_DIR/$CATEGORY.html
138 fi
139 # Dependencies with link to the package information using
140 # category.html#anchor
141 if [ -n "$DEPENDS" ]; then
142 for dep in $DEPENDS
143 do
144 receipt=$WOK/$dep/receipt
145 if [ -f "$receipt" ]; then
146 cat=`grep CATEGORY $receipt | sed s/CATEGORY=\"// | sed s/\"//`
147 DEPENDS_LINKS=${DEPENDS_LINKS}"<a href=\"$cat.html#$dep\">$dep</a> "
148 fi
149 done
150 cat >> $PAGES_DIR/$CATEGORY.html << _EOT_
151 <p>Depends : $DEPENDS_LINKS</p>
152 _EOT_
153 fi
154 done
155 }
157 # Pages footer
158 pages_footer()
159 {
160 for page in $CATEGORIES
161 do
162 # Gen categories menu/links
163 echo '' >> $PAGES_DIR/$page.html
164 echo '<div class="infobox"><p>' >> $PAGES_DIR/$page.html
165 echo 'Categories' >> $PAGES_DIR/$page.html
166 for i in $CATEGORIES
167 do
168 cat >> $PAGES_DIR/$page.html << _EOF_
169 | <a href="$i.html">$i</a>
170 _EOF_
171 done
172 echo '</p></div>' >> $PAGES_DIR/$page.html
173 xhtml_footer
174 done
175 }
177 # Home page with search form and tag cloud.
178 home_page()
179 {
180 PAGES_DIR=$WEB_INTERFACE
181 page="index"
182 h2="Web interface"
183 RELEASE=""
184 xhtml_header
185 cat $LIB_DIR/html/home.html >> $PAGES_DIR/$page.html
186 xhtml_footer
187 }
189 # Generate all categories pages and release index.
190 gen_all_pages()
191 {
192 # Clean previews files.
193 rm -rf $PAGES_DIR
194 mkdir -p $PAGES_DIR
195 echo -e "\nStarting to build the $RELEASE Web interface... "
196 echo "================================================================================"
197 # Packages pages header, menu and content top at first.
198 echo -n "Generating all page headers..."
199 for page in $CATEGORIES
200 do
201 h2=$page
202 xhtml_header
203 cat $LIB_DIR/html/menu.html >> $PAGES_DIR/$page.html
204 sed -i s/"_RELEASE_"/"$RELEASE"/ $PAGES_DIR/$page.html
205 echo "<h2>Category: $h2</h2>" >> $PAGES_DIR/$page.html
206 done
207 status
208 # Scan the wok and classify packages by category.
209 echo -n "Scanning the wok and generating page contents..."
210 pkgs_pages_content
211 status
212 # Gen all packages pages footer.
213 echo -n "Generating all page footers..."
214 pages_footer
215 status
216 # Stable or Cooking index with categories and home page.
217 echo -n "Generating the main index..."
218 page="index"
219 h2="Categories"
220 xhtml_header
221 cat $LIB_DIR/html/menu.html >> $PAGES_DIR/$page.html
222 gen_index_content
223 xhtml_footer
224 home_page
225 status
226 echo "================================================================================"
227 echo -e "Pages generated: $WEB_INTERFACE\n"
228 }
230 # Prefer the Hg wok in the chroot. On host running Tazbb the wok's
231 # are updated and copied automatically and so more up-to-date.
233 case "$1" in
234 stats)
235 size=`du -sh $WEB_INTERFACE | awk '{ print $1 }'`
236 pages=`find $WEB_INTERFACE -name *.html | wc -l`
237 stable=`find $WEB_INTERFACE/stable -name *.html | wc -l`
238 cooking=`find $WEB_INTERFACE/cooking -name *.html | wc -l`
239 cat << _EOT_
241 Tazpkg-web statistics
242 ================================================================================
243 Web interface : $WEB_INTERFACE ($size)
244 xHTML pages : $pages (Stable $stable - Cooking $cooking)
245 Library path : $LIB_DIR
246 Stable path : $STABLE
247 Cooking path : $COOKING
248 ================================================================================
250 _EOT_
251 ;;
252 check)
253 RELEASE=$2
254 [ -z "$RELEASE" ] && RELEASE=cooking
255 echo -e "\nChecking: $WEB_INTERFACE/$RELEASE\n"
256 for page in `cd $WEB_INTERFACE/$RELEASE && ls *.html`
257 do
258 if ! echo "$CATEGORIES index" | grep -qw ${page%.html}; then
259 echo "Wrong category: ${page%.html}"
260 fi
261 done && echo "" ;;
262 stable)
263 PACKAGES_REPOSITORY=$STABLE/packages
264 if [ -d $STABLE/chroot/home/slitaz/hg/wok ]; then
265 WOK=$STABLE/chroot/home/slitaz/hg/wok
266 else
267 WOK=$STABLE/wok
268 fi
269 KERNEL=`cat $WOK/linux/receipt | grep ^VERSION= | cut -d '"' -f 2`
270 gen_all_pages ;;
271 cooking)
272 PACKAGES_REPOSITORY=$COOKING/packages
273 if [ -d $COOKING/chroot/home/slitaz/hg/wok ]; then
274 WOK=$COOKING/chroot/home/slitaz/hg/wok
275 else
276 WOK=$COOKING/wok
277 fi
278 KERNEL=`cat $WOK/linux/receipt | grep ^VERSION= | cut -d '"' -f 2`
279 gen_all_pages ;;
280 *|usage)
281 cat << _EOT_
283 Tazpkg-web - SliTaz Packages Web interface generator.
284 Usage: `basename $0` [slitaz-release|stats|check]
286 _EOT_
287 ;;
288 esac
290 exit 0