tazpkg rev 721
pkgs.cgi: rewrite "cat" (simplify and fix bug).
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Tue Dec 23 16:20:16 2014 +0200 (2014-12-23) |
parents | 953cbcb0cd50 |
children | c17a50593335 |
files | tazpanel/pkgs.cgi |
line diff
1.1 --- a/tazpanel/pkgs.cgi Mon Dec 22 05:07:51 2014 +0200 1.2 +++ b/tazpanel/pkgs.cgi Tue Dec 23 16:20:16 2014 +0200 1.3 @@ -387,8 +387,6 @@ 1.4 repo=$(GET repo) 1.5 category=$(GET cat) 1.6 [ "$category" == "cat" ] && category="base-system" 1.7 - #grep_category=$category 1.8 - #[ "$grep_category" == "all" ] && grep_category="*" 1.9 search_form 1.10 sidebar | sed "s/active_$category/active/;s/repo_$repo/active/" 1.11 LOADING_MSG="$(_ 'Listing packages...')" 1.12 @@ -405,12 +403,9 @@ 1.13 <input type="hidden" name="repo" value="$repo" /> 1.14 </div> 1.15 <div class="float-right"> 1.16 - <a class="button" href="$SCRIPT_NAME?recharge"> 1.17 - <img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a> 1.18 - <a class="button" href="$SCRIPT_NAME?up"> 1.19 - <img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a> 1.20 - <a class="button" href='$SCRIPT_NAME?list'> 1.21 - <img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a> 1.22 + <a class="button" href="?recharge"><img src="$IMAGES/recharge.png" />$(_ 'Recharge list')</a> 1.23 + <a class="button" href="?up"><img src="$IMAGES/update.png" />$(_ 'Check upgrades')</a> 1.24 + <a class="button" href="?list"><img src="$IMAGES/tazpkg.png" />$(_ 'My packages')</a> 1.25 </div> 1.26 </div> 1.27 EOT 1.28 @@ -431,29 +426,33 @@ 1.29 $i/extra.list | parse_packages_info 1.30 ;; 1.31 all) 1.32 - # test awk speed (sorry, no i18n_desc, no blocked now) 1.33 - # http://tazpanel:82/pkgs.cgi?cat=all&repo=Any&awk 1.34 - if [ $(GET awk) == "awk" ]; then 1.35 - sort $i/packages.info $i/installed.info | \ 1.36 - awk -F$'\t' ' 1.37 - function outrow(pkg, cls, ver, dsc, web, pkge) { 1.38 - pkge=pkg; gsub(/\+/, "%2B", pkge) 1.39 - printf "<tr><td><input type=\"checkbox\" name=\"pkg\" value=\"%s\"><a class=\"%s\" href=\"?info=%s\">%s</a></td><td>%s</td><td>%s</td><td><a class=\"w\" href=\"%s\"></a></td></tr>", pkg, cls, pkge, pkg, ver, dsc, web } 1.40 - { 1.41 - if ($1==PKG) { 1.42 - outrow($1, "pkgi", $2, $4, $5) 1.43 - INS=$1 1.44 - } else { 1.45 - if (PKG!=INS) { 1.46 - outrow(PKG, "pkg", VER, DSC, WEB) 1.47 - } 1.48 - } 1.49 - PKG=$1; VER=$2; DSC=$4; WEB=$5 1.50 - }' 1.51 - else 1.52 - # old slow method 1.53 - parse_packages_info < $i/packages.info 1.54 - fi 1.55 + { 1.56 + for L in $LANG ${LANG%%_*}; do 1.57 + if [ -e "$PKGS_DB/packages-desc.$L" ]; then 1.58 + sed '/^#/d' $PKGS_DB/packages-desc.$L 1.59 + break 1.60 + fi 1.61 + done 1.62 + 1.63 + [ -e "$i/blocked-packages.list" ] && cat $i/blocked-packages.list 1.64 + 1.65 + sed 's|.*|&\ti|' $i/installed.info 1.66 + 1.67 + cat $i/packages.info 1.68 + } | sort -t$'\t' -k1,1 | awk -F$'\t' ' 1.69 +{ 1.70 + if (PKG && PKG != $1) { 1.71 + if (DSCL) DSC = DSCL 1.72 + printf "<tr><td><input type=\"checkbox\" name=\"pkg\" value=\"%s\"><a class=\"pkg%s%s\" href=\"?info=%s\">%s</a></td><td>%s</td><td>%s</td><td><a href=\"%s\"></a></td></tr>\n", PKG, INS, BLK, gensub(/\+/, "%2B", "g", PKG), PKG, VER, DSC, WEB 1.73 + VER = DSC = WEB = DSCL = INS = BLK = "" 1.74 + } 1.75 + 1.76 + PKG = $1 1.77 + if (NF == 1) { BLK = "b"; next } 1.78 + if (NF == 2) { DSCL = $2; next } 1.79 + if ($9 == "i") { PKG = $1; VER = $2; DSC = $4; WEB = $5; INS = "i"; next} 1.80 + if (! INS) { PKG = $1; VER = $2; DSC = $4; WEB = $5 } 1.81 +}' 1.82 ;; 1.83 *) 1.84 { 1.85 @@ -470,42 +469,22 @@ 1.86 1.87 cat $i/packages.info 1.88 } | sort -t$'\t' -k1,1 | awk -F$'\t' -vc="$category" ' 1.89 -function outrow(pkg, ins, blk, ver, dsc, web, pkge) { 1.90 - pkge=pkg; gsub(/\+/, "%2B", pkge) 1.91 - printf "<tr><td><input type=\"checkbox\" name=\"pkg\" value=\"%s\"><a class=\"pkg%s%s\" href=\"?info=%s\">%s</a></td><td>%s</td><td>%s</td><td><a href=\"%s\"></a></td></tr>\n", pkg, ins, blk, pkge, pkg, ver, dsc, web } 1.92 - 1.93 { 1.94 - if (PKG != "" && PKG != $1) { 1.95 - if (CAT == c) { 1.96 - if (1 in i) { 1.97 - PKG = i[1]; VER = i[2]; DSC = i[4]; WEB = i[5]; 1.98 - } else if (1 in m) { 1.99 - PKG = m[1]; VER = m[2]; DSC = m[4]; WEB = m[5]; 1.100 - } 1.101 - if (DSCL != "") { DSC = DSCL } 1.102 - 1.103 - outrow(PKG, INS, BLK, VER, DSC, WEB) 1.104 + if (PKG && PKG != $1) { 1.105 + if (CAT) { 1.106 + if (DSCL) DSC = DSCL 1.107 + printf "<tr><td><input type=\"checkbox\" name=\"pkg\" value=\"%s\"><a class=\"pkg%s%s\" href=\"?info=%s\">%s</a></td><td>%s</td><td>%s</td><td><a href=\"%s\"></a></td></tr>\n", PKG, INS, BLK, gensub(/\+/, "%2B", "g", PKG), PKG, VER, DSC, WEB 1.108 } 1.109 - 1.110 - VER = ""; DSC = ""; WEB = "" 1.111 - delete m; delete i 1.112 - DSCL = ""; INS = ""; BLK = ""; CAT = "" 1.113 + VER = DSC = WEB = DSCL = INS = BLK = CAT = "" 1.114 } 1.115 1.116 PKG = $1 1.117 - if (NF == 1) { 1.118 - BLK = "b" 1.119 - } else if (NF == 2) { 1.120 - DSCL = $2 1.121 - } else { 1.122 - if ($3 == c) { 1.123 - CAT = c 1.124 - if ($9 == "i") { 1.125 - i[1] = $1; i[2] = $2; i[4] = $4; i[5] = $5; INS = "i" 1.126 - } else { 1.127 - m[1] = $1; m[2] = $2; m[4] = $4; m[5] = $5 1.128 - } 1.129 - } 1.130 + if (NF == 1) { BLK = "b"; next } 1.131 + if (NF == 2) { DSCL = $2; next } 1.132 + if ($3 == c) { 1.133 + CAT = c 1.134 + if ($9 == "i") { PKG = $1; VER = $2; DSC = $4; WEB = $5; INS = "i"; next} 1.135 + if (! INS) { PKG = $1; VER = $2; DSC = $4; WEB = $5 } 1.136 } 1.137 }' 1.138 ;;