slitaz-forge annotate pkgs/mirror-search.sh @ rev 456

pkgs: add cooker links
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon Feb 17 14:29:16 2014 +0000 (2014-02-17)
parents 9068ce96fee4
children 7442bb8579e9
rev   line source
pascal@316 1 #!/bin/sh
pascal@321 2
pascal@316 3 # Tiny CGI search engine for SliTaz packages on http://pkgs.slitaz.org/
pascal@316 4 # Christophe Lincoln <pankso@slitaz.org>
pascal@321 5 # Pascal Bellard <pascal.bellard@slitaz.org>
pascal@316 6 # Aleksej Bobylev <al.bobylev@gmail.com>
pascal@316 7 #
pascal@316 8
pascal@321 9 renice -n 19 $$
pascal@321 10
pascal@316 11 # Parse query string
pascal@316 12 . /usr/lib/slitaz/httphelper.sh
pascal@316 13
pascal@360 14 case "$HTTP_USER_AGENT" in
pascal@360 15 */[Bb]ot*|*[Bb]ot/*|*spider/*) exec $PWD/Travaux.sh ;;
pascal@360 16 esac
pascal@316 17
pascal@316 18 # User preferred language
pascal@316 19 # parameter $1 have priority; without parameter $1 - browser language only
pascal@316 20 # if we don't support any of user languages (or only en), then return C locale
pascal@316 21 user_lang() {
pascal@316 22 LANG="C"
pascal@316 23 IFS=","
pascal@316 24 for lang in $1 $HTTP_ACCEPT_LANGUAGE
pascal@316 25 do
pascal@316 26 lang=${lang%;*} lang=${lang# } lang=${lang%-*} lang=${lang%_*}
pascal@316 27 case "$lang" in
pascal@316 28 de) LANG="de_DE" ;;
al@376 29 es) LANG="es_AR" ;;
pascal@316 30 fr) LANG="fr_FR" ;;
pascal@316 31 it) LANG="it_IT" ;;
al@376 32 pl) LANG="pl_PL" ;;
pascal@316 33 pt) LANG="pt_BR" ;;
pascal@316 34 ru) LANG="ru_RU" ;;
al@376 35 sv) LANG="sv_SE" ;;
pascal@316 36 zh) LANG="zh_TW" ;;
pascal@316 37 esac
al@376 38 if echo "de en es fr pl pt ru sv zh" | fgrep -q "$lang"; then
pascal@316 39 break
pascal@316 40 fi
pascal@316 41 done
pascal@316 42 unset IFS
pascal@316 43 echo "$LANG"
pascal@316 44 }
pascal@316 45
pascal@316 46 # Short 2-letter lang code from ll_CC
pascal@316 47 ll_lang() {
pascal@316 48 ll_CC="$1"
pascal@316 49 echo ${ll_CC%_*}
pascal@316 50 }
pascal@316 51
pascal@316 52 # Nice URL replacer - to copy url from address bar
pascal@316 53 # TODO: deal with POST method of form submitting
pascal@316 54 nice_url() {
pascal@316 55 # if user submitted a form
pascal@316 56 if [ ! -z $(GET submit) ]; then
pascal@316 57 OBJECT="$(GET object)"
pascal@316 58 SEARCH="$(GET query)"
pascal@316 59 case $OBJECT in
pascal@316 60 Package) NICE="package=$SEARCH";;
pascal@316 61 Desc) NICE="desc=$SEARCH";;
pascal@316 62 Tags) NICE="tags=$SEARCH";;
pascal@331 63 Arch) NICE="arch=$SEARCH";;
pascal@333 64 Bugs) NICE="bugs=$SEARCH";;
pascal@316 65 Receipt) NICE="receipt=$SEARCH";;
pascal@316 66 Depends) NICE="depends=$SEARCH";;
pascal@316 67 BuildDepends) NICE="builddepends=$SEARCH";;
pascal@316 68 File) NICE="file=$SEARCH";;
pascal@316 69 File_list) NICE="filelist=$SEARCH";;
pascal@316 70 FileOverlap) NICE="fileoverlap=$SEARCH";;
pascal@316 71 esac
pascal@316 72 # version, if needed
pascal@316 73 version="$(GET version)"
pascal@316 74 if [ ! -z "$version" -a "$version" != "cooking" ]; then
pascal@316 75 NICE="${NICE}&version=${version:0:1}"
pascal@316 76 fi
pascal@316 77 # lang, if needed
pascal@316 78 query_lang="$(GET lang)"
pascal@316 79 pref_lang="$(user_lang)"
pascal@316 80 browser_lang="$(ll_lang $pref_lang)"
pascal@316 81 if [ ! -z "$query_lang" -a "$query_lang" != "$browser_lang" ]; then
pascal@316 82 NICE="${NICE}&lang=$query_lang"
pascal@316 83 fi
pascal@316 84 # verbose, if needed
pascal@316 85 verboseq="$(GET verbose)"
pascal@316 86 if [ ! -z "$verboseq" -a "$verboseq" != "0" ]; then
pascal@316 87 NICE="${NICE}&verbose=1"
pascal@316 88 fi
pascal@316 89 # redirect
pascal@316 90 # TODO: implement HTTP 301 Redirect
pascal@316 91 cat << EOT
pascal@316 92 Content-type: text/html
pascal@316 93
pascal@316 94 <!DOCTYPE html>
pascal@316 95 <html><head><meta http-equiv="refresh" content="0;url=$SCRIPT_NAME?$NICE" />
pascal@316 96 <title>Redirect</title></head></html>
pascal@316 97 EOT
pascal@316 98 # echo "Location: $SCRIPT_NAME?$NICE"
pascal@316 99 # echo
pascal@316 100 exit 0
pascal@316 101 fi
pascal@316 102 }
pascal@316 103
pascal@316 104 nice_url
pascal@316 105
pascal@316 106
pascal@316 107
pascal@316 108 OBJECT="$(GET object)"
pascal@316 109 SEARCH="$(GET query)"
pascal@316 110 SLITAZ_VERSION="$(GET version)"
pascal@316 111 VERBOSE="$(GET verbose)"
pascal@316 112
pascal@316 113 # Internal variables
pascal@316 114 #DATE=$(date +%Y-%m-%d\ %H:%M:%S)
pascal@316 115
pascal@316 116 # Internationalization
pascal@316 117 . /usr/bin/gettext.sh
pascal@316 118 export TEXTDOMAIN='tazpkg-web'
pascal@316 119
pascal@316 120 SEARCH=""
pascal@316 121 VERBOSE=0
pascal@316 122 for i in $(echo $QUERY_STRING | sed 's/[?&]/ /g'); do
pascal@316 123 # SLITAZ_VERSION=cooking
pascal@316 124 case "$(echo $i | tr [A-Z] [a-z])" in
pascal@316 125 query=*|search=*) [ ${i#*=} == Search ] || SEARCH=${i#*=};;
pascal@316 126 object=*) OBJECT=${i#*=};;
pascal@316 127 verbose=*) VERBOSE=${i#*=};;
pascal@316 128 lang=*) LANG=${i#*=};;
pascal@316 129 file=*) SEARCH=${i#*=}; OBJECT=File;;
pascal@316 130 desc=*) SEARCH=${i#*=}; OBJECT=Desc;;
pascal@316 131 tags=*) SEARCH=${i#*=}; OBJECT=Tags;;
pascal@331 132 arch=*) SEARCH=${i#*=}; OBJECT=Arch;;
pascal@333 133 bugs=*) SEARCH=${i#*=}; OBJECT=Bugs;;
pascal@316 134 receipt=*) SEARCH=${i#*=}; OBJECT=Receipt;;
pascal@316 135 filelist=*) SEARCH=${i#*=}; OBJECT=File_list;;
pascal@316 136 package=*) SEARCH=${i#*=}; OBJECT=Package;;
pascal@316 137 depends=*) SEARCH=${i#*=}; OBJECT=Depends;;
pascal@316 138 builddepends=*) SEARCH=${i#*=}; OBJECT=BuildDepends;;
pascal@316 139 fileoverlap=*) SEARCH=${i#*=}; OBJECT=FileOverlap;;
pascal@316 140 category=*) SEARCH=${i#*=}; OBJECT=Category;;
pascal@316 141 maintainer=*) SEARCH=${i#*=}; OBJECT=Maintainer;;
pascal@370 142 license=*) SEARCH=${i#*=}; OBJECT=License;;
pascal@397 143 version=[1-9]*) i=${i%%.*}; SLITAZ_VERSION=${i#*=}.0;;
pascal@397 144 version=s*|version=4*) SLITAZ_VERSION=stable;;
pascal@397 145 version=b*) SLITAZ_VERSION=backports;;
pascal@316 146 version=u*) SLITAZ_VERSION=undigest;;
pascal@316 147 version=t*) SLITAZ_VERSION=tiny;;
pascal@316 148 esac
pascal@316 149 done
pascal@316 150 [ -z "$SLITAZ_VERSION" ] && SLITAZ_VERSION=cooking
pascal@316 151 #[ -n "$SEARCH" ] && REQUEST_METHOD="POST"
pascal@316 152 #[ "$SEARCH" == "." ] && SEARCH=
pascal@316 153
pascal@316 154
pascal@316 155 # Content negotiation for Gettext
pascal@316 156 LANG=$(user_lang $(GET lang))
pascal@316 157 lang="$(ll_lang $LANG)"
pascal@316 158 export LANG LC_ALL=$LANG
pascal@316 159
pascal@316 160
pascal@316 161 case "$OBJECT" in
pascal@316 162 File) selected_file="selected";;
pascal@316 163 Desc) selected_desc="selected";;
pascal@316 164 Tags) selected_tags="selected";;
pascal@331 165 Arch) selected_arch="selected";;
pascal@333 166 Bugs) selected_bugs="selected";;
pascal@316 167 Receipt) selected_receipt="selected";;
pascal@316 168 File_list) selected_file_list="selected";;
pascal@316 169 Depends) selected_depends="selected";;
pascal@316 170 BuildDepends) selected_build_depends="selected";;
pascal@316 171 FileOverlap) selected_overlap="selected";;
pascal@316 172 esac
pascal@316 173
pascal@316 174 case "$SLITAZ_VERSION" in
pascal@316 175 tiny) selected_tiny="selected";;
pascal@316 176 1.0) selected_1="selected";;
pascal@316 177 2.0) selected_2="selected";;
pascal@316 178 3.0) selected_3="selected";;
pascal@316 179 stable) selected_stable="selected";;
pascal@397 180 backports) selected_undigest="backports";;
pascal@316 181 undigest) selected_undigest="selected";;
pascal@316 182 esac
pascal@316 183
pascal@316 184 # unescape query
pascal@316 185 SEARCH="$(echo $SEARCH | sed 's/%2B/+/g; s/%3A/:/g; s|%2F|/|g')"
pascal@316 186
pascal@316 187 WOK=/home/slitaz/$SLITAZ_VERSION/wok
pascal@316 188 PACKAGES_REPOSITORY=/home/slitaz/$SLITAZ_VERSION/packages
pascal@316 189
pascal@316 190
pascal@316 191 # TODO: header function from httphelper
pascal@316 192 echo "Content-type: text/html"
pascal@316 193 echo
pascal@316 194
pascal@316 195 # Search form
pascal@316 196 # TODO: implement POST method
pascal@316 197 # ... method="post" enctype="multipart/form-data" ...
pascal@316 198 # TODO: add hint 'You are can search for depends loop, if textfield is empty'...
pascal@316 199 # add progress ticker while page is not complete
pascal@316 200 search_form()
pascal@316 201 {
pascal@316 202 cat << _EOT_
pascal@316 203
pascal@316 204 <form id="s_form" method="get" action="$SCRIPT_NAME">
pascal@316 205 <input type="hidden" name="lang" value="$lang" />
pascal@316 206 <select name="object">
pascal@316 207 <option value="Package">$(gettext "Package")</option>
pascal@316 208 <option $selected_desc value="Desc">$(gettext "Description")</option>
pascal@316 209 <option $selected_tags value="Tags">$(gettext "Tags")</option>
pascal@331 210 <!-- option $selected_arch value="Tags">$(gettext "Arch")</option -->
pascal@333 211 <!-- option $selected_bugs value="Bugs">$(gettext "Bugs")</option -->
pascal@316 212 <option $selected_receipt value="Receipt">$(gettext "Receipt")</option>
pascal@316 213 <option $selected_depends value="Depends">$(gettext "Depends")</option>
pascal@316 214 <option $selected_build_depends value="BuildDepends">$(gettext "Build depends")</option>
pascal@316 215 <option $selected_file value="File">$(gettext "File")</option>
pascal@316 216 <option $selected_file_list value="File_list">$(gettext "File list")</option>
pascal@316 217 <option $selected_overlap value="FileOverlap">$(gettext "common files")</option>
pascal@316 218 </select>
pascal@316 219 <input type="text" name="query" id="query" size="20" value="$SEARCH" />
pascal@316 220 <select name="version">
pascal@316 221 <option value="cooking">$(gettext "cooking")</option>
pascal@397 222 <option $selected_backports value="backports">$(gettext backports")</option>
pascal@316 223 <option $selected_stable value="stable">4.0</option>
pascal@316 224 <option $selected_3 value="3.0">3.0</option>
pascal@316 225 <option $selected_2 value="2.0">2.0</option>
pascal@316 226 <option $selected_1 value="1.0">1.0</option>
pascal@316 227 <option $selected_tiny value="tiny">$(gettext "tiny")</option>
pascal@316 228 <option $selected_undigest value="undigest">$(gettext "undigest")</option>
pascal@316 229 </select>
pascal@316 230 <input type="submit" name="submit" value="$(gettext 'Search')" />
pascal@316 231 </form>
pascal@316 232 _EOT_
pascal@316 233 }
pascal@316 234
pascal@316 235 # xHTML5 Header.
pascal@316 236 xhtml_header() {
pascal@316 237 . lib/header.sh
pascal@316 238 }
pascal@316 239
pascal@321 240 cat_files_list()
pascal@321 241 {
pascal@321 242 local tmp=/tmp/files.list.$(basename ${1%/packages})
pascal@321 243 if [ ! -s $tmp -o $1/files.list.lzma -nt $tmp ]; then
pascal@456 244 unlzma < $1/files.list.lzma > $tmp.$$ && mv $tmp.$$ $tmp
pascal@321 245 fi
pascal@321 246 case "$2" in
pascal@321 247 lines) if [ ! -s $tmp.lines -o $tmp -nt $tmp.lines ]; then
pascal@456 248 wc -l < $tmp > $tmp.lines.$$ &&
pascal@321 249 mv $tmp.lines.$$ $tmp.lines
pascal@321 250 fi
pascal@321 251 cat $tmp.lines ;;
pascal@321 252 *) cat $tmp ;;
pascal@321 253 esac
pascal@321 254 }
pascal@321 255
pascal@316 256 # xHTML Footer.
pascal@316 257 # TODO: caching the summary for 5 minutes
pascal@316 258 xhtml_footer() {
pascal@370 259 file=/tmp/footer-$SLITAZ_VERSION
pascal@370 260 [ ! -e $file -o $PACKAGES_REPOSITORY/packages.txt -nt $file ] &&
pascal@370 261 cat > $file.$$ <<EOT && mv -f $file.$$ $file
pascal@370 262 PKGS=$(ls $WOK/ | wc -l)
pascal@370 263 FILES=$(cat_files_list $PACKAGES_REPOSITORY lines)
pascal@370 264 EOT
pascal@370 265 PKGS=$(sed '/PKGS=/!d;s/PKGS=//' $file)
pascal@370 266 FILES=$(sed '/FILES=/!d;s/FILES=//' $file)
pascal@316 267 . lib/footer.sh
pascal@316 268 }
pascal@316 269
pascal@316 270 installed_size()
pascal@316 271 {
pascal@316 272 if [ $VERBOSE -gt 0 ]; then
pascal@316 273 inst=$(grep -A 3 "^$1\$" $PACKAGES_REPOSITORY/packages.txt | grep installed)
pascal@316 274 # size=$(echo $inst | cut -d'(' -f2 | cut -d' ' -f1)
pascal@316 275 echo $inst | sed 's/.*(\(.*\).*/(\1)/'
pascal@316 276 # echo $size
pascal@316 277 # | sed 's/.*(\(.*\) installed.*/(\1) /'
pascal@316 278 fi
pascal@316 279 }
pascal@316 280
pascal@316 281 package_entry()
pascal@316 282 {
pascal@316 283 if [ -s "$(dirname $0)/$SLITAZ_VERSION/$CATEGORY.html" ]; then
pascal@316 284 cat << _EOT_
pascal@316 285 <a href="$SLITAZ_VERSION/$CATEGORY.html#$PACKAGE">$PACKAGE</a> $(installed_size $PACKAGE): $SHORT_DESC
pascal@316 286 _EOT_
pascal@316 287 else
pascal@316 288 PACKAGE_HREF="<u>$PACKAGE</u>"
pascal@316 289 PACKAGE_URL="http://mirror.slitaz.org/packages/$SLITAZ_VERSION/$PACKAGE-$VERSION$EXTRA_VERSION.tazpkg"
pascal@316 290 nslookup mirror.slitaz.org | grep -q 127.0.0.1 &&
pascal@316 291 [ -d /var/www/slitaz/mirror/packages/$SLITAZ_VERSION/$PACKAGE-$VERSION ] &&
pascal@316 292 PACKAGE_URL="http://mirror.slitaz.org/packages/$SLITAZ_VERSION/$PACKAGE-$VERSION" ||
pascal@316 293 PACKAGE_URL="http://mirror.slitaz.org/packages/$SLITAZ_VERSION/$(cd /var/www/slitaz/mirror/packages/$SLITAZ_VERSION ; ls $PACKAGE-$VERSION*.tazpkg)"
pascal@316 294 busybox wget -s $PACKAGE_URL 2> /dev/null &&
pascal@316 295 PACKAGE_HREF="<a href=\"$PACKAGE_URL\">$PACKAGE</a>"
pascal@456 296 case "$SLITAZ_VERSION" in
pascal@456 297 cooking) COOKER="<a href=\"http://cook.slitaz.org/cooker.cgi?pkg=$PACKAGE\">$(gettext "Cooker")</a>";;
pascal@456 298 undigest) COOKER="<a href=\"http://cook.slitaz.org/undigest/cooker.cgi?pkg=$PACKAGE\">$(gettext "Cooker")</a>";;
pascal@456 299 backports) COOKER="<a href=\"http://cook.slitaz.org/backports/cooker.cgi?pkg=$PACKAGE\">$(gettext "Cooker")</a>";;
pascal@456 300 *) COOKER="";;
pascal@456 301 esac
pascal@316 302 cat << _EOT_
pascal@331 303 $PACKAGE_HREF $(installed_size $PACKAGE): $SHORT_DESC \
pascal@360 304 <a href="?receipt=$PACKAGE&amp;version=$SLITAZ_VERSION">$(gettext "Receipt")</a> $COOKER
pascal@316 305 _EOT_
pascal@316 306 fi
pascal@316 307 [ -n "$(GET debug)" ] && cat << _EOT_
pascal@316 308 <pre>
pascal@316 309 PACKAGE=$PACKAGE
pascal@316 310 VERSION=$VERSION
pascal@316 311 EXTRAVERSION=$EXTRAVERSION
pascal@316 312 SLITAZ_VERSION=$SLITAZ_VERSION
pascal@316 313 PACKAGE_URL=$PACKAGE_URL
pascal@316 314 $(cd /var/www/slitaz/mirror/packages/$SLITAZ_VERSION ; ls -l $PACKAGE*)
pascal@316 315 </pre>
pascal@316 316 _EOT_
pascal@316 317 }
pascal@316 318
pascal@316 319 # Show loop in depends/build_depends chains
pascal@316 320 show_loops()
pascal@316 321 {
pascal@316 322 awk '
pascal@316 323 function chkloop(pkg, i, n)
pascal@316 324 {
pascal@316 325 if (n < 8)
pascal@316 326 for (i = 1; i <= split(deps[pkg],curdep," "); i++) {
pascal@316 327 if (curdep[i] == base || chkloop(curdep[i], 0, n+1)) {
pascal@316 328 split(deps[pkg],curdep," ")
pascal@316 329 p = curdep[i] " " p
pascal@316 330 return 1
pascal@316 331 }
pascal@316 332 }
pascal@316 333 return 0
pascal@316 334 }
pascal@316 335 {
pascal@316 336 for (i = 2; i <= NF; i++)
pascal@316 337 deps[$1] = deps[$1] " " $i
pascal@316 338 }
pascal@316 339 END {
pascal@316 340 for (pkg in deps) {
pascal@316 341 base = pkg
pascal@316 342 p = ""
pascal@316 343 if (chkloop(pkg, 0, 0))
pascal@316 344 print pkg " " p
pascal@316 345 #print pkg " : " p "..."
pascal@316 346 }
pascal@316 347 }' | while read line; do
pascal@316 348 set -- $line
pascal@316 349 case " $last " in
pascal@316 350 *\ $1\ *) continue
pascal@316 351 esac
pascal@316 352 last="$line"
pascal@316 353 pkg=$1
pascal@316 354 shift
pascal@316 355 echo "<strong>$pkg </strong>: $@ ..."
pascal@316 356 done
pascal@316 357 }
pascal@316 358
pascal@316 359 # recursive dependencies scan
pascal@316 360 dep_scan()
pascal@316 361 {
pascal@316 362 for i in $1; do
pascal@316 363 case " $ALL_DEPS " in
pascal@316 364 *\ $i\ *) continue;;
pascal@316 365 esac
pascal@316 366 ALL_DEPS="$ALL_DEPS $i"
pascal@316 367 if [ -n "$2" ]; then
pascal@316 368 echo -n "$2"
pascal@316 369 (
pascal@316 370 . $WOK/$i/receipt
pascal@316 371 package_entry
pascal@316 372 )
pascal@316 373 fi
pascal@316 374 [ -f $WOK/$i/receipt ] || continue
pascal@316 375 DEPENDS=""
pascal@316 376 BUILD_DEPENDS=""
pascal@316 377 WANTED=""
pascal@316 378 . $WOK/$i/receipt
pascal@316 379 if [ -n "$3" ]; then
pascal@316 380 [ -n "$BUILD_DEPENDS$WANTED" ] &&
pascal@316 381 dep_scan "$WANTED $BUILD_DEPENDS" "$2 " $3
pascal@316 382 else
pascal@316 383 [ -n "$DEPENDS" ] && dep_scan "$DEPENDS" "$2 "
pascal@316 384 fi
pascal@316 385 done
pascal@316 386 }
pascal@316 387
pascal@316 388 # recursive reverse dependencies scan
pascal@316 389 rdep_scan()
pascal@316 390 {
pascal@316 391 SEARCH=$1
pascal@316 392 case "$SEARCH" in
pascal@316 393 glibc-base|gcc-lib-base)
pascal@316 394 $(gettext " glibc-base and gcc-lib-base are implicit dependencies,
pascal@316 395 <b>every</b> package is supposed to depend on them."); echo
pascal@316 396 return;;
pascal@316 397 esac
pascal@316 398 for i in $WOK/* ; do
pascal@316 399 DEPENDS=""
pascal@316 400 BUILD_DEPENDS=""
pascal@316 401 WANTED=""
pascal@316 402 . $i/receipt
pascal@316 403 if [ -n "$2" ]; then
pascal@316 404 echo "$(basename $i) $(echo $WANTED $BUILD_DEPENDS)"
pascal@316 405 else
pascal@316 406 echo "$(basename $i) $(echo $DEPENDS)"
pascal@316 407 fi
pascal@316 408 done | awk -v search=$SEARCH '
pascal@316 409 function show_deps(deps, all_deps, pkg, space)
pascal@316 410 {
pascal@316 411 if (all_deps[pkg] == 1) return
pascal@316 412 all_deps[pkg] = 1
pascal@316 413 if (space != "") printf "%s%s\n",space,pkg
pascal@316 414 for (i = 1; i <= split(deps[pkg], mydeps, " "); i++) {
pascal@316 415 show_deps(deps, all_deps, mydeps[i],"////" space)
pascal@316 416 }
pascal@316 417 }
pascal@316 418
pascal@316 419 {
pascal@316 420 all_deps[$1] = 0
pascal@316 421 for (i = 2; i <= NF; i++)
pascal@316 422 deps[$i] = deps[$i] " " $1
pascal@316 423 }
pascal@316 424
pascal@316 425 END {
pascal@316 426 show_deps(deps, all_deps, search, "")
pascal@316 427 }
pascal@316 428 ' | while read pkg; do
pascal@316 429 . $WOK/${pkg##*/}/receipt
pascal@316 430 cat << _EOT_
pascal@316 431 $(echo ${pkg%/*} | sed 's|/| |g') $(package_entry)
pascal@316 432 _EOT_
pascal@316 433 done
pascal@316 434 }
pascal@316 435
pascal@316 436 # Check package exists
pascal@316 437 package_exist()
pascal@316 438 {
pascal@316 439 [ -f $WOK/$1/receipt ] && return 0
pascal@316 440 cat << _EOT_
pascal@316 441
pascal@316 442 <h3>$(eval_gettext "No package \$SEARCH")</h3>
pascal@316 443 _EOT_
pascal@316 444 return 1
pascal@316 445 }
pascal@316 446
pascal@316 447 # Display < > &
pascal@316 448 htmlize()
pascal@316 449 {
pascal@316 450 sed -e 's/&/\&amp;/g' -e 's/</\&lt;/g' -e 's/>/\&gt;/g'
pascal@316 451 }
pascal@316 452
pascal@331 453 # Create some clickable links
pascal@331 454 urllink()
pascal@331 455 {
pascal@335 456 local tarball_url
pascal@331 457 sedit=""
pascal@331 458 [ -n "$WEB_SITE" ] && sedit="$sedit -e 's|^WEB_SITE=\"\\(.*\\)\"|WEB_SITE=\"<a href=\"$WEB_SITE\">\\1</a>\"|'"
pascal@338 459 [ -n "$WGET_URL" ] && sedit="$sedit -e 's#^WGET_URL=\"\\(.*\\)\"#WGET_URL=\"<a href=\"${WGET_URL##*|}\">\\1</a>\"#'"
pascal@335 460 [ -n "$CATEGORY" ] && sedit="$sedit -e 's|^CATEGORY=\"\\(.*\\)\"|CATEGORY=\"<a href=\"?category=$CATEGORY\\&amp;version=$SLITAZ_VERSION\">\\1</a>\"|'"
pascal@335 461 [ -n "$WANTED" ] && sedit="$sedit -e 's|^WANTED=\"\\(.*\\)\"|WANTED=\"<a href=\"?receipt=$WANTED\\&amp;version=$SLITAZ_VERSION\">\\1</a>\"|'"
pascal@335 462 [ -n "$BUGS" ] && sedit="$sedit -e 's|^BUGS=\"\\(.*\\)\"|BUGS=\"<a href=\"?bugs=$PACKAGE\\&amp;version=$SLITAZ_VERSION\">\\1</a>\"|'"
pascal@335 463 [ -f $WOK/$PACKAGE/description.txt ] && sedit="$sedit -e 's|^SHORT_DESC=\"\\(.*\\)\"|SHORT_DESC=\"<a href=\"?desc=$PACKAGE\\&amp;version=$SLITAZ_VERSION\">\\1</a>\"|'"
pascal@335 464 tarball_url=sources/packages-$SLITAZ_VERSION/${TARBALL:0:1}/$TARBALL
pascal@335 465 [ -f /var/www/slitaz/mirror/$tarball_url ] || case "$tarball_url" in
pascal@335 466 *.gz) tarball_url=${tarball_url%gz}lzma ;;
pascal@335 467 *.tgz) tarball_url=${tarball_url%tgz}tar.lzma ;;
pascal@335 468 *.bz2) tarball_url=${tarball_url%bz2}lzma ;;
pascal@335 469 esac
pascal@335 470 [ -f /var/www/slitaz/mirror/$tarball_url ] && sedit="$sedit -e 's|^TARBALL=\"\\(.*\\)\"|TARBALL=\"<a href=\"http://mirror.slitaz.org/$tarball_url\">\\1</a>\"|'"
pascal@331 471 if [ -n "$HOST_ARCH" ]; then
pascal@331 472 tmp=""
pascal@331 473 for i in $HOST_ARCH ; do
pascal@335 474 tmp="$tmp <a href=\\\"?arch=$i\\&amp;version=$SLITAZ_VERSION\\\">$i</a>"
pascal@331 475 done
pascal@331 476 sedit="$sedit -e 's|^HOST_ARCH=\".*\"|HOST_ARCH=\"${tmp# }\"|'"
pascal@331 477 fi
pascal@331 478 if [ -n "$TAGS" ]; then
pascal@331 479 tmp=""
pascal@331 480 for i in $TAGS ; do
pascal@335 481 tmp="$tmp <a href=\\\"?tags=$i\\&amp;version=$SLITAZ_VERSION\\\">$i</a>"
pascal@331 482 done
pascal@331 483 sedit="$sedit -e 's|^TAGS=\".*\"|TAGS=\"${tmp# }\"|'"
pascal@331 484 fi
pascal@332 485 if [ -n "$DEPENDS$BUILD_DEPENDS$SUGGESTED" ]; then
pascal@332 486 for i in $(echo $DEPENDS $BUILD_DEPENDS $SUGGESTED) ; do
pascal@335 487 sedit="$sedit -e 's|\\([\" ]\\)$i\\([\" \\]\\)|\\1<a href=\\\"?package=$i\\&amp;version=$SLITAZ_VERSION\\\">$i</a>\\2|'"
pascal@335 488 sedit="$sedit -e 's|\\([\" ]\\)$i\$|\\1<a href=\\\"?package=$i\\&amp;version=$SLITAZ_VERSION\\\">$i</a>|'"
pascal@335 489 sedit="$sedit -e 's|^$i\\([\" \\]\\)|<a href=\\\"?package=$i\\&amp;version=$SLITAZ_VERSION\\\">$i</a>\\1|'"
pascal@335 490 sedit="$sedit -e 's|^$i\$|<a href=\\\"?package=$i\\&amp;version=$SLITAZ_VERSION\\\">$i</a>|'"
pascal@331 491 done
pascal@331 492 fi
pascal@331 493 if [ -n "$CONFIG_FILES" ]; then
pascal@331 494 tmp=""
pascal@331 495 for i in $(echo $CONFIG_FILES) ; do
pascal@335 496 tmp="$tmp <a href=\\\"?file=$i\\&amp;version=$SLITAZ_VERSION\\\">$i</a>"
pascal@331 497 done
pascal@331 498 sedit="$sedit -e 's|^CONFIG_FILES=\".*\"|CONFIG_FILES=\"${tmp# }\"|'"
pascal@331 499 fi
pascal@331 500 if [ -n "$PROVIDE" ]; then
pascal@331 501 tmp=""
pascal@331 502 for i in $(echo $PROVIDE) ; do
pascal@335 503 tmp="$tmp <a href=\\\"?package=${i%:*}\\&amp;version=$SLITAZ_VERSION\\\">$i</a>"
pascal@331 504 done
pascal@331 505 sedit="$sedit -e 's|^PROVIDE=\".*\"|PROVIDE=\"${tmp# }\"|'"
pascal@331 506 fi
pascal@331 507 eval sed $sedit \
pascal@331 508 -e "'s|^MAINTAINER=\".*\"|MAINTAINER=\"<a href=\"?maintainer=$MAINTAINER\">$MAINTAINER</a>\"|'" \
pascal@335 509 -e "'s|^genpkg_rules|<a href=\"?filelist=$PACKAGE\\&amp;version=$SLITAZ_VERSION\">&</a>|'"
pascal@331 510 }
pascal@331 511
pascal@316 512 display_packages_and_files()
pascal@316 513 {
pascal@316 514 last=""
pascal@316 515 while read pkg file; do
pascal@316 516 pkg=${pkg%:}
pascal@316 517 if [ "$pkg" != "$last" ]; then
pascal@316 518 . $WOK/$pkg/receipt
pascal@316 519 package_entry
pascal@316 520 last=$pkg
pascal@316 521 fi
pascal@316 522 echo " $file"
pascal@316 523 done
pascal@316 524 }
pascal@316 525
pascal@316 526 build_cloud_cache()
pascal@316 527 {
pascal@316 528 grep -l ^$1= $WOK/*/receipt | while read file; do
pascal@316 529 eval $1=
pascal@316 530 . $file
pascal@316 531 eval echo \$$1
pascal@316 532 done | sed "$2" | awk '
pascal@316 533 {
pascal@316 534 for (i = 1; $i != ""; i++) {
pascal@316 535 count[$i]++
pascal@316 536 }
pascal@316 537 }
pascal@316 538 END {
pascal@316 539 min=10000
pascal@316 540 max=0
pascal@316 541 for (i in count) {
pascal@316 542 if (count[i] < min) min = count[i]
pascal@316 543 if (count[i] > max) max = count[i]
pascal@316 544 }
pascal@316 545 for (i in count)
pascal@316 546 print count[i] " " int((count[i] - min)*100/(max - min)) " " i
pascal@316 547 }' | sort -k 3
pascal@316 548 }
pascal@316 549
pascal@316 550 display_cloud()
pascal@316 551 {
pascal@316 552 echo "<p>"
pascal@316 553 while read cnt pct item ; do
pascal@360 554 pct=$(((10000 - ((100 - $pct)**2))/100))
pascal@360 555 pct=$(((10000 - ((100 - $pct)**2))/100))
pascal@316 556 cat <<EOT
pascal@316 557 <span style="color:#99f; font-size:9pt; padding-left:5px; padding-right:2px;">\
pascal@316 558 $cnt</span><a href="?$1=$item&amp;version=$SLITAZ_VERSION" style="\
pascal@316 559 font-size:$((8+($pct/10)))pt; font-weight:bold; \
pascal@316 560 color:black; text-decoration:none">$(echo $item | sed 's/-/\&minus;/g')</a>
pascal@316 561 EOT
pascal@327 562 done | tee /dev/stderr | printf "</p><p align=right>$2" $(wc -l)
pascal@316 563 echo "</p>"
pascal@316 564 }
pascal@316 565
pascal@316 566 xhtml_header
pascal@316 567
pascal@316 568 #
pascal@316 569 # Handle GET requests
pascal@316 570 #
pascal@316 571 case " $(GET) " in
pascal@316 572 *\ debug\ *|*\ debug*)
pascal@316 573 cat << EOT
pascal@316 574 <h2>Debug info</h2>
pascal@316 575 <pre>$(httpinfo)</pre>
pascal@316 576 <pre>LANG=$LANG;
pascal@316 577 OBJECT=$OBJECT;
pascal@316 578 SEARCH=$SEARCH;
pascal@316 579 SLITAZ_VERSION=$SLITAZ_VERSION;
pascal@316 580 WOK=$WOK;
pascal@316 581 </pre>
pascal@316 582 EOT
pascal@316 583 #$(xhtml_footer)
pascal@316 584 #EOT
pascal@316 585 # exit 0
pascal@316 586 ;;
pascal@316 587 esac
pascal@316 588
pascal@316 589 # Display search form and result if requested.
pascal@316 590 #xhtml_header
pascal@316 591 echo "<h2>$(gettext 'Search for packages')</h2>"
pascal@316 592 search_form
pascal@316 593
pascal@316 594 case "$OBJECT" in
pascal@316 595
pascal@316 596
pascal@316 597 ### Depends loops; [Reverse] Dependency tree [(SUGGESTED)]
pascal@316 598 Depends)
pascal@316 599 if [ -z "$SEARCH" ]; then
pascal@316 600 cat << _EOT_
pascal@316 601
pascal@316 602 <h3>$(gettext "Depends loops")</h3>
pascal@316 603 <pre>
pascal@316 604 _EOT_
pascal@316 605 for i in $WOK/*/receipt; do
pascal@316 606 PACKAGE=
pascal@316 607 DEPENDS=
pascal@316 608 . $i
pascal@316 609 echo "$PACKAGE $(echo $DEPENDS)"
pascal@316 610 done | show_loops
pascal@316 611 cat << _EOT_
pascal@316 612 </pre>
pascal@316 613 _EOT_
pascal@316 614 elif package_exist $SEARCH ; then
pascal@316 615 cat << _EOT_
pascal@316 616
pascal@316 617 <h3>$(eval_gettext "Dependency tree for: \$SEARCH")</h3>
pascal@316 618 <pre>
pascal@316 619 _EOT_
pascal@316 620 ALL_DEPS=""
pascal@316 621 dep_scan $SEARCH ""
pascal@316 622 SUGGESTED=""
pascal@316 623 . $WOK/$SEARCH/receipt
pascal@316 624 if [ -n "$SUGGESTED" ]; then
pascal@316 625 cat << _EOT_
pascal@316 626 </pre>
pascal@316 627
pascal@316 628 <h3>$(eval_gettext "Dependency tree for: \$SEARCH (SUGGESTED)")</h3>
pascal@316 629 <pre>
pascal@316 630 _EOT_
pascal@316 631 ALL_DEPS=""
pascal@316 632 dep_scan "$SUGGESTED" " "
pascal@316 633 fi
pascal@316 634 cat << _EOT_
pascal@316 635 </pre>
pascal@316 636
pascal@316 637 <h3>$(eval_gettext "Reverse dependency tree for: \$SEARCH")</h3>
pascal@316 638 <pre>
pascal@316 639 _EOT_
pascal@316 640 ALL_DEPS=""
pascal@316 641 rdep_scan $SEARCH
pascal@316 642 cat << _EOT_
pascal@316 643 </pre>
pascal@316 644 _EOT_
pascal@316 645 fi
pascal@316 646 ;;
pascal@316 647
pascal@316 648
pascal@316 649 ### Build depends loops; [Reverse] Build dependency tree
pascal@316 650 BuildDepends)
pascal@316 651 if [ -z "$SEARCH" ]; then
pascal@316 652 cat << _EOT_
pascal@316 653
pascal@316 654 <h3>$(gettext "Build depends loops")</h3>
pascal@316 655 <pre>
pascal@316 656 _EOT_
pascal@316 657 for i in $WOK/*/receipt; do
pascal@316 658 PACKAGE=
pascal@316 659 WANTED=
pascal@316 660 BUILD_DEPENDS=
pascal@316 661 . $i
pascal@316 662 echo "$PACKAGE $WANTED $(echo $BUILD_DEPENDS)"
pascal@316 663 done | show_loops
pascal@316 664 cat << _EOT_
pascal@316 665 </pre>
pascal@316 666 _EOT_
pascal@316 667 elif package_exist $SEARCH ; then
pascal@316 668 cat << _EOT_
pascal@316 669
pascal@316 670 <h3>$(eval_gettext "\$SEARCH needs these packages to be built")</h3>
pascal@316 671 <pre>
pascal@316 672 _EOT_
pascal@316 673 ALL_DEPS=""
pascal@316 674 dep_scan $SEARCH "" build
pascal@316 675 cat << _EOT_
pascal@316 676 </pre>
pascal@316 677
pascal@316 678 <h3>$(eval_gettext "Packages who need \$SEARCH to be built")</h3>
pascal@316 679 <pre>
pascal@316 680 _EOT_
pascal@316 681 ALL_DEPS=""
pascal@316 682 rdep_scan $SEARCH build
pascal@316 683 cat << _EOT_
pascal@316 684 </pre>
pascal@316 685 _EOT_
pascal@316 686 fi
pascal@316 687 ;;
pascal@316 688
pascal@316 689
pascal@316 690 ### Common files
pascal@316 691 FileOverlap)
pascal@317 692 if package_exist $SEARCH; then
pascal@316 693 cat << _EOT_
pascal@316 694
pascal@316 695 <h3>$(eval_gettext "These packages may overload files of \$SEARCH")</h3>
pascal@316 696 <pre>
pascal@316 697 _EOT_
pascal@321 698 ( cat_files_list $PACKAGES_REPOSITORY | grep ^$SEARCH: ;
pascal@321 699 cat_files_list $PACKAGES_REPOSITORY | grep -v ^$SEARCH: ) | awk '
pascal@316 700 BEGIN { pkg=""; last="x" }
pascal@316 701 {
pascal@316 702 if ($2 == "") next
pascal@316 703 if (index($2,last) == 1 && substr($2,1+length(last),1) == "/")
pascal@316 704 delete file[last]
pascal@316 705 last=$2
pascal@316 706 if (pkg == "") pkg=$1
pascal@316 707 if ($1 == pkg) file[$2]=$1
pascal@316 708 else if (file[$2] == pkg) print
pascal@316 709 }
pascal@316 710 ' | display_packages_and_files
pascal@316 711 cat << _EOT_
pascal@316 712 </pre>
pascal@316 713 _EOT_
pascal@316 714 fi
pascal@316 715 ;;
pascal@316 716
pascal@316 717
pascal@316 718 ### File search
pascal@316 719 File)
pascal@316 720 if [ -n "$SEARCH" ]; then
pascal@316 721 cat << _EOT_
pascal@316 722
pascal@316 723 <h3>$(eval_gettext "Result for: \$SEARCH")</h3>
pascal@316 724 <pre>
pascal@316 725 _EOT_
pascal@316 726 last=""
pascal@321 727 cat_files_list $PACKAGES_REPOSITORY \
pascal@316 728 | grep "$SEARCH" | while read pkg file; do
pascal@316 729 echo "$file" | grep -q "$SEARCH" || continue
pascal@316 730 if [ "$last" != "${pkg%:}" ]; then
pascal@316 731 last=${pkg%:}
pascal@316 732 (
pascal@316 733 . $WOK/$last/receipt
pascal@316 734 cat << _EOT_
pascal@316 735
pascal@316 736 <i>$(package_entry)</i>
pascal@316 737 _EOT_
pascal@316 738 )
pascal@316 739 fi
pascal@316 740 echo " $file"
pascal@316 741 done
pascal@316 742 cat << _EOT_
pascal@316 743 </pre>
pascal@316 744 _EOT_
pascal@316 745 fi
pascal@316 746 ;;
pascal@316 747
pascal@316 748
pascal@316 749 ### List of files
pascal@316 750 File_list)
pascal@316 751 if package_exist $SEARCH; then
pascal@316 752 cat << _EOT_
pascal@316 753
pascal@316 754 <h3>$(eval_gettext "Result for: \$SEARCH")</h3>
pascal@316 755 <pre>
pascal@316 756 _EOT_
pascal@316 757 last=""
pascal@321 758 cat_files_list $PACKAGES_REPOSITORY \
pascal@316 759 | grep ^$SEARCH: | sed 's/.*: / /' | sort
pascal@316 760 cat << _EOT_
pascal@316 761 </pre>
pascal@316 762 <pre>
pascal@316 763 _EOT_
pascal@321 764 filenb=$(cat_files_list $PACKAGES_REPOSITORY | grep ^$SEARCH: | wc -l)
pascal@316 765 eval_ngettext "\$filenb file" "\$filenb files" $filenb
pascal@316 766 cat << _EOT_
pascal@316 767 \
pascal@316 768 $(busybox sed -n "/^$SEARCH$/{nnnpq}" $PACKAGES_REPOSITORY/packages.txt)
pascal@316 769 </pre>
pascal@316 770 _EOT_
pascal@316 771 fi
pascal@316 772 ;;
pascal@316 773
pascal@316 774
pascal@316 775 ### Package description
pascal@316 776 Desc)
pascal@331 777 cat << _EOT_
pascal@316 778
pascal@316 779 <h3>$(eval_gettext "Result for: \$SEARCH")</h3>
pascal@316 780 <pre>
pascal@316 781 _EOT_
pascal@331 782 if [ -f $WOK/$SEARCH/description.txt ]; then
pascal@331 783 htmlize < $WOK/$SEARCH/description.txt
pascal@331 784 else
pascal@316 785 last=""
pascal@316 786 grep -i "$SEARCH" $PACKAGES_REPOSITORY/packages.desc | \
pascal@316 787 sort | while read pkg extras ; do
pascal@316 788 . $WOK/$pkg/receipt
pascal@316 789 package_entry
pascal@316 790 done
pascal@331 791 fi
pascal@331 792 cat << _EOT_
pascal@316 793 </pre>
pascal@316 794 _EOT_
pascal@331 795 ;;
pascal@331 796
pascal@331 797
pascal@333 798 ### Bugs
pascal@333 799 Bugs)
pascal@333 800 cat << _EOT_
pascal@333 801
pascal@333 802 <h3>$(eval_gettext "Result for known bugs")</h3>
pascal@333 803 <pre>
pascal@333 804 _EOT_
pascal@333 805 last=""
pascal@333 806 grep ^BUGS= $WOK/*/receipt | \
pascal@333 807 sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
pascal@333 808 BUGS=
pascal@333 809 . $WOK/$pkg/receipt
pascal@333 810 package_entry
pascal@333 811 echo " $BUGS "
pascal@333 812 done
pascal@333 813 cat << _EOT_
pascal@333 814 </pre>
pascal@333 815 _EOT_
pascal@333 816 ;;
pascal@333 817
pascal@333 818
pascal@331 819 ### Arch
pascal@331 820 Arch)
pascal@331 821 cat << _EOT_
pascal@331 822
pascal@331 823 <h3>$(eval_gettext "Result for: \$SEARCH")</h3>
pascal@331 824 <pre>
pascal@331 825 _EOT_
pascal@331 826 last=""
pascal@331 827 grep ^HOST_ARCH= $WOK/*/receipt | grep -i "$SEARCH" | \
pascal@331 828 sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
pascal@331 829 HOST_ARCH=
pascal@331 830 . $WOK/$pkg/receipt
pascal@331 831 echo " $HOST_ARCH " | grep -iq " $SEARCH " &&
pascal@331 832 package_entry
pascal@331 833 done
pascal@331 834 cat << _EOT_
pascal@331 835 </pre>
pascal@331 836 _EOT_
pascal@316 837 ;;
pascal@316 838
pascal@316 839
pascal@316 840 ### Tags
pascal@316 841 Tags)
pascal@316 842 if [ -n "$SEARCH" ]; then
pascal@316 843 cat << _EOT_
pascal@316 844
pascal@316 845 <h3>$(eval_gettext "Result for: \$SEARCH")</h3>
pascal@316 846 <pre>
pascal@316 847 _EOT_
pascal@316 848 last=""
pascal@316 849 grep ^TAGS= $WOK/*/receipt | grep -i "$SEARCH" | \
pascal@316 850 sed "s|$WOK/\(.*\)/receipt:.*|\1|" | sort | while read pkg ; do
pascal@316 851 TAGS=
pascal@316 852 . $WOK/$pkg/receipt
pascal@316 853 echo " $TAGS " | grep -iq " $SEARCH " &&
pascal@316 854 package_entry
pascal@316 855 done
pascal@316 856 cat << _EOT_
pascal@316 857 </pre>
pascal@316 858 _EOT_
pascal@316 859 else
pascal@316 860 # Display clouds
pascal@327 861 while read var arg title fmt filter; do
pascal@316 862 file=/tmp/$arg-$SLITAZ_VERSION
pascal@316 863 echo "<a name=\"$arg\"></a>"
pascal@316 864 echo "<h3>$title</h3>"
pascal@316 865 [ ! -e $file -o \
pascal@316 866 $PACKAGES_REPOSITORY/packages.txt -nt $file ] &&
pascal@316 867 build_cloud_cache $var "$filter" > $file.$$ &&
pascal@370 868 mv -f $file.$$ $file
pascal@327 869 display_cloud $arg "$fmt" < $file 2>&1
pascal@316 870 done << EOT
pascal@327 871 TAGS tags Tag\ cloud %d\ tags.
pascal@327 872 CATEGORY category Category\ cloud %d\ categories.
pascal@370 873 LICENSE license License\ cloud %d\ licenses.
pascal@327 874 MAINTAINER maintainer Maintainer\ cloud %d\ maintainers. s/.*<//;s/.*\ //;s/>//
pascal@316 875 EOT
pascal@316 876 fi
pascal@316 877 ;;
pascal@316 878
pascal@316 879
pascal@316 880 ### Package receipt
pascal@316 881 # TODO: add style highlighting
pascal@316 882 Receipt)
pascal@316 883 package_exist $SEARCH && cat << _EOT_
pascal@316 884
pascal@316 885 <h3>$(eval_gettext "Result for: \$SEARCH")</h3>
pascal@316 886 <pre>
pascal@331 887 $(receipt=$WOK/$SEARCH/taz/*/receipt
pascal@331 888 [ -f $receipt ] || receipt=$WOK/$SEARCH/receipt
pascal@332 889 . /home/slitaz/repos/cookutils/cook.conf
pascal@331 890 . $receipt
pascal@331 891 cat $receipt | htmlize | urllink)
pascal@316 892 </pre>
pascal@316 893 _EOT_
pascal@316 894 ;;
pascal@316 895
pascal@316 896
pascal@316 897 ### Package
pascal@316 898 Package)
pascal@316 899 #WHY# if package_exist $SEARCH; then
pascal@316 900 cat << _EOT_
pascal@316 901
pascal@316 902 <h3>$(eval_gettext "Result for: \$SEARCH")</h3>
pascal@316 903 <pre>
pascal@316 904 _EOT_
pascal@316 905 for pkg in `ls $WOK/ | grep "$SEARCH"`
pascal@316 906 do
pascal@316 907 . $WOK/$pkg/receipt
pascal@316 908 DESC=" <a href=\"?object=Desc&query=$pkg&lang=$lang&version=$SLITAZ_VERSION&submit=go\">$(gettext description)</a>"
pascal@316 909 [ -f $WOK/$pkg/description.txt ] || DESC=""
pascal@316 910 cat << _EOT_
pascal@316 911 $(package_entry)$DESC
pascal@316 912 _EOT_
pascal@316 913 done
pascal@316 914 equiv=$PACKAGES_REPOSITORY/packages.equiv
pascal@456 915 vpkgs="$(cut -d= -f1 < $equiv | grep $SEARCH)"
pascal@316 916 for vpkg in $vpkgs ; do
pascal@316 917 cat << _EOT_
pascal@316 918 </pre>
pascal@316 919
pascal@316 920 <h3>$(eval_gettext "Result for: \$SEARCH (package providing \$vpkg)")</h3>
pascal@316 921 <pre>
pascal@316 922 _EOT_
pascal@316 923 for pkg in $(grep $vpkg= $equiv | sed "s/$vpkg=//"); do
pascal@316 924 . $WOK/${pkg#*:}/receipt
pascal@316 925 package_entry
pascal@316 926 done
pascal@316 927 done
pascal@316 928 cat << _EOT_
pascal@316 929 </pre>
pascal@316 930 _EOT_
pascal@316 931 #WHY# fi
pascal@316 932 ;;
pascal@316 933
pascal@316 934 ### Category
pascal@316 935 Category)
pascal@316 936 cat << _EOT_
pascal@316 937
pascal@316 938 <h3>$(eval_gettext "Result for: \$SEARCH")</h3>
pascal@316 939 <pre>
pascal@316 940 _EOT_
pascal@316 941 for pkg in `ls $WOK/`
pascal@316 942 do
pascal@316 943 CATEGORY=
pascal@316 944 . $WOK/$pkg/receipt
pascal@316 945 DESC=" <a href=\"?object=Desc&query=$pkg&lang=$lang&version=$SLITAZ_VERSION&submit=go\">$(gettext description)</a>"
pascal@316 946 [ -f $WOK/$pkg/description.txt ] || DESC=""
pascal@316 947 [ "$CATEGORY" == "$SEARCH" ] && cat << _EOT_
pascal@316 948 $(package_entry)$DESC
pascal@316 949 _EOT_
pascal@316 950 done
pascal@316 951 ;;
pascal@316 952
pascal@316 953 ### Maintainer
pascal@316 954 Maintainer)
pascal@316 955 cat << _EOT_
pascal@316 956
pascal@316 957 <h3>$(eval_gettext "Result for: \$SEARCH")</h3>
pascal@316 958 <pre>
pascal@316 959 _EOT_
pascal@316 960 for pkg in `ls $WOK/`
pascal@316 961 do
pascal@316 962 MAINTAINER=
pascal@316 963 . $WOK/$pkg/receipt
pascal@316 964 DESC=" <a href=\"?object=Desc&query=$pkg&lang=$lang&version=$SLITAZ_VERSION&submit=go\">$(gettext description)</a>"
pascal@316 965 [ -f $WOK/$pkg/description.txt ] || DESC=""
pascal@316 966 [ "$MAINTAINER" == "$SEARCH" ] && cat << _EOT_
pascal@316 967 $(package_entry)$DESC
pascal@316 968 _EOT_
pascal@316 969 done
pascal@316 970 ;;
pascal@370 971
pascal@370 972 ### License
pascal@370 973 License)
pascal@370 974 cat << _EOT_
pascal@370 975
pascal@370 976 <h3>$(eval_gettext "Result for: \$SEARCH")</h3>
pascal@370 977 <pre>
pascal@370 978 _EOT_
pascal@370 979 for pkg in `ls $WOK/`
pascal@370 980 do
pascal@370 981 LICENSE=
pascal@370 982 . $WOK/$pkg/receipt
pascal@370 983 DESC=" <a href=\"?object=Desc&query=$pkg&lang=$lang&version=$SLITAZ_VERSION&submit=go\">$(gettext description)</a>"
pascal@370 984 [ -f $WOK/$pkg/description.txt ] || DESC=""
pascal@374 985 case " $LICENSE " in
pascal@374 986 *\ $SEARCH\ *) cat << _EOT_
pascal@370 987 $(package_entry)$DESC
pascal@370 988 _EOT_
pascal@374 989 esac
pascal@370 990 done
pascal@370 991 ;;
pascal@316 992 esac
pascal@316 993
pascal@316 994 xhtml_footer
pascal@316 995
pascal@316 996 exit 0