slitaz-forge annotate pkgs/search.sh @ rev 458

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