tazpkg rev 786
pkgs.cgi: info: show receipt, show package icon, add tool to improving packages by the community effort (unfinished).
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Sat Apr 18 16:25:03 2015 +0300 (2015-04-18) |
parents | 0fc40a0f873f |
children | 2d836243f5e2 d749c4f90a06 |
files | modules/tazpkg-find-depends tazpanel/pkgs.cgi tazpanel/pkgs.css |
line diff
1.1 --- a/modules/tazpkg-find-depends Mon Apr 13 11:53:19 2015 +0300 1.2 +++ b/modules/tazpkg-find-depends Sat Apr 18 16:25:03 2015 +0300 1.3 @@ -11,7 +11,7 @@ 1.4 1.5 is_elf() 1.6 { 1.7 - [ "$(dd if=$1 bs=1 skip=1 count=3 2> /dev/null)" = "ELF" ] 1.8 + [ `dd if=$1 bs=1 skip=1 count=3 2>/dev/null` == 'ELF' ] 1.9 } 1.10 1.11 1.12 @@ -19,7 +19,7 @@ 1.13 1.14 ldd() 1.15 { 1.16 - LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2> /dev/null 1.17 + LD_TRACE_LOADED_OBJECTS=1 /lib/ld*.so $1 2>/dev/null 1.18 } 1.19 1.20 1.21 @@ -30,7 +30,7 @@ 1.22 DEFAULT_DEPENDS="glibc-base gcc-lib-base" 1.23 1.24 [ -n "$TMPLOCALSTATE" ] || TMPLOCALSTATE=$PKGS_DB 1.25 - [ -f $TMPLOCALSTATE/files.list.lzma ] || tazpkg recharge > /dev/null 1.26 + [ -f $TMPLOCALSTATE/files.list.lzma ] || tazpkg recharge >/dev/null 1.27 for i in $TMPLOCALSTATE/files.list.lzma \ 1.28 $TMPLOCALSTATE/undigest/*/files.list.lzma ; do 1.29 [ -f $i ] && lzma d $i -so >> $TMP_DIR/files.list 1.30 @@ -47,7 +47,7 @@ 1.31 1.32 for lib in $(ldd $chkfile | sed '/=>/!d;s/ =>.*//') ; do 1.33 case " $libs_found " in 1.34 - *\ $lib\ *) continue 1.35 + *\ $lib\ *) continue 1.36 esac 1.37 libs_found="$libs_found $lib" 1.38 case "$lib" in 1.39 @@ -74,7 +74,7 @@ 1.40 1.41 spc="" 1.42 [ -s $TMP_DIR/depends ] && 1.43 - sort < $TMP_DIR/depends 2> /dev/null | uniq | \ 1.44 + sort < $TMP_DIR/depends 2>/dev/null | uniq | \ 1.45 while read file; do 1.46 echo -n "$spc$file" 1.47 spc=" "
2.1 --- a/tazpanel/pkgs.cgi Mon Apr 13 11:53:19 2015 +0300 2.2 +++ b/tazpanel/pkgs.cgi Sat Apr 18 16:25:03 2015 +0300 2.3 @@ -9,7 +9,6 @@ 2.4 # (C) 2011-2015 SliTaz GNU/Linux - BSD License 2.5 # 2.6 2.7 -. /lib/libtaz.sh 2.8 . lib/libtazpanel 2.9 2.10 . /etc/slitaz/slitaz.conf 2.11 @@ -52,10 +51,10 @@ 2.12 esac 2.13 2.14 2.15 -header 2.16 2.17 - 2.18 +# 2.19 # AJAX commands 2.20 +# 2.21 2.22 case " $(GET) " in 2.23 2.24 @@ -65,6 +64,7 @@ 2.25 pkg=$(GET pkg) 2.26 cd $PKGS_DB 2.27 2.28 + header 2.29 if [ -d $INSTALLED/$pkg ]; then 2.30 files="$(wc -l < $INSTALLED/$pkg/files.list)" 2.31 cat <<EOT 2.32 @@ -90,12 +90,59 @@ 2.33 grep -q "^$pkg$" $PKGS_DB/blocked-packages.list && class='pkgib' 2.34 fi 2.35 2.36 + header 2.37 echo -n "<a data-icon=\"$class\" href=\"?info=${pkg//+/%2B}\">$pkg</a>" 2.38 exit 0 ;; 2.39 2.40 + *\ app_img\ * ) 2.41 + # Show application image 2.42 + pkg=$(GET app_img) 2.43 + current_user="$(who | cut -d' ' -f1)" 2.44 + if [ -n "$current_user" ]; then 2.45 + current_user_home="$(awk -F: -vu=$current_user '{if($1==u) print $6}' /etc/passwd)" 2.46 + current_icon_theme="/usr/share/icons/$(grep gtk-icon-theme-name $current_user_home/.gtkrc-2.0 | cut -d'"' -f2)" 2.47 + default_pkg_icon="$(find -L $current_icon_theme -type f -path '*48*' -name 'package-x-generic.png' | head -n1)" 2.48 + pkg_icon="$(find -L $current_icon_theme -type f -path '*48*' -name "$pkg.png" | head -n1)" 2.49 + if [ -z "$pkg_icon" ]; then 2.50 + pkg_icon="$(find -L /usr/share/pixmaps -type f -name "$pkg.png" | head -n1)" 2.51 + fi 2.52 + 2.53 + header "Content-Type: image/png" 2.54 + cat "${pkg_icon:-$default_pkg_icon}" 2.55 + else 2.56 + default_pkg_icon="$(find -L /usr/share/icons -type f -name 'package-x-generic.png' | sort | tail -n1)" 2.57 + fi 2.58 + exit 0 ;; 2.59 + 2.60 + *\ show_receipt\ * ) 2.61 + # Show package receipt 2.62 + pkg=$(GET show_receipt) 2.63 + if [ -d "$INSTALLED/$pkg" ]; then 2.64 + # Redirects to the receipt view 2.65 + header "HTTP/1.1 301 Moved Permanently" "Location: index.cgi?file=$INSTALLED/$pkg/receipt" 2.66 + exit 0 2.67 + else 2.68 + temp_receipt=$(mktemp -d) 2.69 + wget -O $temp_receipt/receipt -T 5 http://hg.slitaz.org/wok/raw-file/tip/$pkg/receipt 2.70 + if [ -e "$temp_receipt" ]; then 2.71 + # Redirects to the receipt view 2.72 + header "HTTP/1.1 301 Moved Permanently" "Location: index.cgi?file=$temp_receipt/receipt" 2.73 + exit 0 2.74 + else 2.75 + header; xhtml_header 2.76 + msg err "$(_ 'Receipt for package %s unavailable' $pkg)" 2.77 + xhtml_footer 2.78 + exit 0 2.79 + fi 2.80 + fi 2.81 + ;; 2.82 + 2.83 esac 2.84 2.85 2.86 +header 2.87 + 2.88 + 2.89 # xHTML 5 header with special side bar for categories. 2.90 TITLE=$(TEXTDOMAIN='tazpkg'; _ 'TazPanel - Packages') 2.91 xhtml_header | sed 's/id="content"/id="content-sidebar"/' 2.92 @@ -854,6 +901,8 @@ 2.93 </form> 2.94 </header> 2.95 2.96 +<table class="wide summary"> 2.97 + <tr><td id="appImg"><img src="pkgs.cgi?app_img=$PACKAGE"/></td><td> 2.98 <table class="wide zebra summary" id="infoTable"> 2.99 <tbody> 2.100 <tr><td><b>$(_ 'Name')</b></td><td>$PACKAGE</td></tr> 2.101 @@ -869,6 +918,12 @@ 2.102 $(show_info_links "$SUGGESTED" "$(_ 'Suggested')" 'info') 2.103 </tbody> 2.104 </table> 2.105 +</td></tr></table> 2.106 + 2.107 + <footer> 2.108 + <a data-icon="text" href="?show_receipt=$pkg">$(_ 'View receipt')</a> 2.109 + <a data-icon="slitaz" href="?improve=$pkg">$(_ 'Improve package')</a> 2.110 + </footer> 2.111 </section> 2.112 <span id="ajaxStatus" style="display:none"></span> 2.113 2.114 @@ -1335,7 +1390,156 @@ 2.115 ;; 2.116 2.117 2.118 - *) 2.119 + *\ improve\ *) 2.120 + # 2.121 + # Improving packages by the community effort 2.122 + # 2.123 + search_form; sidebar 2.124 + msg warn 'Under construction!<br/>It is only imitation of working' 2.125 + 2.126 + pkg=$(GET improve) 2.127 + user=$(POST user); type=$(POST type); text="$(POST text)" 2.128 + login=$(POST login); password=$(POST password) 2.129 + 2.130 + login_c=$(COOKIE login); password_c=$(COOKIE password) 2.131 + mail_hash=$(COOKIE mail_hash); user_name=$(COOKIE user_name) 2.132 + 2.133 + n=$'\n' 2.134 + 2.135 + if [ -n "$login" ]; then 2.136 + # Get mail hash and user Name from bugs.slitaz.org 2.137 + page="$(busybox wget --post-data "auth=${login}&pass=${password}&id=" \ 2.138 + -O- "http://bugs.slitaz.org/bugs.cgi?user=${login}")" 2.139 + # Parse page and get: 2.140 + mail_hash="$(echo "$page" | fgrep '<h2>' | cut -d/ -f5 | cut -c 1-32)" 2.141 + user_name="$(echo "$page" | fgrep '<h2>' | cut -d'>' -f3 | cut -d'<' -f1)" 2.142 + 2.143 + # Put variables to the session Cookies (they clean in browser close) 2.144 + cat <<EOT 2.145 +<script type="text/javascript"> 2.146 + document.cookie = "login=$login"; 2.147 + document.cookie = "password=$password"; 2.148 + document.cookie = "mail_hash=$mail_hash"; 2.149 + document.cookie = "user_name=$user_name"; 2.150 +</script> 2.151 +EOT 2.152 + login_c="$login"; password_c="$password" 2.153 + fi 2.154 + 2.155 + if [ -z "$login_c" ]; then 2.156 + cat <<EOT 2.157 +<section> 2.158 + <div>$(_ 'Please log in using your TazBug account.')</div> 2.159 + <form method="post"> 2.160 + <input type="hidden" name="improve" value="$pkg"/> 2.161 + <table> 2.162 + <tr><td>$(_ 'Login:')</td> 2.163 + <td><input type="text" name="login"/></td></tr> 2.164 + <tr><td>$(_ 'Password:')</td> 2.165 + <td><input type="password" name="password"/></td></tr> 2.166 + <tr><td colspan="2"> 2.167 + <button type="submit" data-icon="user">$(_ 'Log in')</button></td></tr> 2.168 + </table> 2.169 + </form> 2.170 + <footer> 2.171 + <a href="http://bugs.slitaz.org/bugs.cgi?signup&online" target="_blank">$(_ 'Create new account')</a> 2.172 + </footer> 2.173 +</section> 2.174 +EOT 2.175 + xhtml_footer; exit 0 2.176 + fi 2.177 + 2.178 + 2.179 + # Get receipt variables, show Install/Remove buttons 2.180 + if [ -d $INSTALLED/$pkg ]; then 2.181 + . $INSTALLED/$pkg/receipt 2.182 + else 2.183 + cd $PKGS_DB 2.184 + eval "$(awk -F$'\t' -vp=$pkg ' 2.185 + $1==p{ 2.186 + printf "VERSION=\"%s\"; SHORT_DESC=\"%s\"; TAGS=\"%s\"; ", $2, $4, $6 2.187 + }' packages.info undigest/*/packages.info)" 2.188 + fi 2.189 + 2.190 + RECEIPT="$(wget -O - http://hg.slitaz.org/wok/raw-file/tip/$pkg/receipt | htmlize)" 2.191 + DESCRIPTION="$(wget -O - http://hg.slitaz.org/wok/raw-file/tip/$pkg/description.txt | htmlize)" 2.192 + DESCRIPTION="$(separator)$n${DESCRIPTION:-(empty)}$n$(separator)" 2.193 + 2.194 + if [ -z "$type" ]; then 2.195 + cat <<EOT 2.196 +<section> 2.197 + <header> 2.198 + $(_ 'Improve package "%s"' $pkg) 2.199 + <form><button name="info" value="$pkg" data-icon="back">$(_ 'Back')</button></form> 2.200 + </header> 2.201 + 2.202 + <div style="display:none"> 2.203 + <span id="newVersion">Current version: $VERSION${n}New version: $VERSION${n}Link to announce: http://</span> 2.204 + <span id="improveShortDesc">Short description (English):$n$SHORT_DESC</span> 2.205 + <span id="translateShortDesc">Short description (English):$n$SHORT_DESC$n${n}Language: $LANG${n}Short description:$n$SHORT_DESC</span> 2.206 + <span id="improveDesc">Description (English):$n$DESCRIPTION</span> 2.207 + <span id="translateDesc">Language: $LANG${n}Description:$n$DESCRIPTION</span> 2.208 + <span id="improveCategory">Old category: $CATEGORY${n}New category: $CATEGORY</span> 2.209 + <span id="improveTags">Tags: $TAGS</span> 2.210 + <span id="addIcon">Link to application icon (48x48px): http://</span> 2.211 + <span id="addScreenshot">Link to application screenshot: http://</span> 2.212 + <span id="improveReceipt">$RECEIPT</span> 2.213 + <span id="improveOther"></span> 2.214 + </div> 2.215 + 2.216 + <form method="post" class="wide"> 2.217 + 2.218 + <table class="wide"> 2.219 + <tr><td style="vertical-align:bottom"> 2.220 + <input type="hidden" name="improve" value="$pkg"/> 2.221 + <input type="hidden" name="user" value="$login_c"/> 2.222 + $(_ 'How can you help:')<br/> 2.223 + <select name='type' id="improveType" onchange="improveAction()"> 2.224 + <option value=''>$(_ 'Please select an action') 2.225 + <option value='newVersion'>$(_ 'Report new version') 2.226 + <option value='improveShortDesc'>$(_ 'Improve short description') 2.227 + <option value='translateShortDesc'>$(_ 'Translate short description') 2.228 + <option value='improveDesc'>$(_ 'Add or improve description') 2.229 + <option value='translateDesc'>$(_ 'Translate description') 2.230 + <option value='improveCategory'>$(_ 'Improve category') 2.231 + <option value='improveTags'>$(_ 'Add or improve tags') 2.232 + <option value='addIcon'>$(_ 'Add application icon') 2.233 + <option value='addScreenshot'>$(_ 'Add application screenshot') 2.234 + <option value='improveReceipt'>$(_ 'Improve receipt') 2.235 + <option value='improveOther'>$(_ 'Other') 2.236 + </select> 2.237 + </td> 2.238 + <td id="user_info">$user_name 2.239 + <img src="http://www.gravatar.com/avatar/$mail_hash?s=48&d=identicon" 2.240 + style="border-radius: 0.3rem"/> 2.241 + </td></tr> 2.242 + </table> 2.243 + 2.244 + <textarea name="text" id="improveText" style="width:100%; resize: vertical; min-height:10rem"></textarea> 2.245 + <button type="submit" data-icon="slitaz">$(_ 'Send')</button> 2.246 + </form> 2.247 +</section> 2.248 +EOT 2.249 + else 2.250 + cat <<EOT 2.251 +<section> 2.252 + <header> 2.253 + $(_ 'Thank you!') 2.254 + <form><button name="info" value="$pkg" data-icon="back">$(_ 'Back')</button></form> 2.255 + </header> 2.256 +<div>The following information was sent to SliTaz developers:</div> 2.257 +<pre class="scroll"><b>User:</b> $user 2.258 +<b>Type:</b> $type 2.259 +<b>Package:</b> $pkg 2.260 +<b>Message:</b> 2.261 +$(echo "$text" | htmlize)</pre> 2.262 +</section> 2.263 +EOT 2.264 + fi 2.265 + ;; 2.266 + 2.267 + 2.268 + *) 2.269 # 2.270 # Default to summary 2.271 #
3.1 --- a/tazpanel/pkgs.css Mon Apr 13 11:53:19 2015 +0300 3.2 +++ b/tazpanel/pkgs.css Sat Apr 18 16:25:03 2015 +0300 3.3 @@ -160,3 +160,19 @@ 3.4 3.5 /* Disable too much borders */ 3.6 section .hborders thead tr { border-top: none; border-bottom: 1pt solid #DDD; } 3.7 + 3.8 + 3.9 +#appImg { vertical-align: top; width: 48px; padding: 0; margin: 0; } 3.10 +#appImg img { height: 48px !important; width: 48px !important; } 3.11 + 3.12 + 3.13 +#user_info { 3.14 + float: right; 3.15 + padding: 0.2rem; margin: 0.2rem; 3.16 + font-size: 1rem; 3.17 + vertical-align: bottom; 3.18 +} 3.19 +#user_info img { 3.20 + padding: 0; margin: 0; 3.21 + vertical-align: bottom; 3.22 +}