tazpkg annotate stripall.sh @ rev 847

Add 'mkdb' description to 'usage' and English docs. Refresh French translation (thanks Lucas Levrel)
author Aleksej Bobylev <al.bobylev@gmail.com>
date Sat Oct 10 14:52:10 2015 +0300 (2015-10-10)
parents
children d2e1b7133079
rev   line source
al@840 1 #!/bin/sh
al@840 2 # TazPkg - SliTaz Package Manager, hg.slitaz.org/tazpkg
al@840 3 # stripall.sh - strip and compact resources in build process
al@840 4 # Copyright (C) 2015 SliTaz GNU/Linux - BSD License
al@840 5
al@840 6
al@840 7 substitute_icons() {
al@840 8 # Customize sed script
al@840 9 cp "$sed_script" "$sed_script.do"
al@840 10 sed -i "s|@@@|$1|" "$sed_script.do"
al@840 11 # Run sed script
al@840 12 sh "$sed_script.do"
al@840 13 rm "$sed_script.do"
al@840 14 }
al@840 15
al@840 16
al@840 17 # Make script for substitution
al@840 18 sed_script="$(mktemp)"
al@840 19 echo -n "sed -i '" > "$sed_script"
al@840 20 echo -e "\
al@840 21 add  \n admin  \n back  \n battery 
al@840 22 brightness  \n cancel  \n cd  \n check 
al@840 23 clock  \n conf  \n daemons  \n delete 
al@840 24 detect  \n diff  \n download  \n edit 
al@840 25 eth  \n group  \n grub  \n hdd 
al@840 26 help  \n history  \n info  \n install 
al@840 27 link  \n list  \n locale  \n lock 
al@840 28 logs  \n loopback  \n modules  \n ok 
al@840 29 proc  \n refresh  \n removable  \n remove 
al@840 30 repack  \n report  \n restart  \n run 
al@840 31 save  \n scan  \n settings  \n start 
al@840 32 stop  \n sync  \n tag  \n tags 
al@840 33 tazx  \n temperature  \n terminal  \n text 
al@840 34 unlink  \n unlock  \n upgrade  \n user 
al@840 35 view  \n wifi  \n man  \n off 
al@840 36 on  \n opt  \n web  \n slitaz 
al@840 37 lvl0  \n lvl1  \n lvl2  \n lvl3 
al@840 38 lvl4  \n lvl5  \n online  \n offline 
al@840 39 sechi  \n secmi  \n seclo  \n pkg 
al@840 40 pkgi  \n pkgib  \n toggle  \n chlock 
al@840 41 calendar  \n modem  \n cpu  \n display 
al@840 42 msg  \n msgerr  \n msgwarn  \n msgup 
al@840 43 msgtip  \n vpn " | \
al@840 44 while read icon symbol; do
al@840 45 echo -n "s|data-icon=\"$icon\"|data-icon=\"$symbol\"|g; " >> "$sed_script"
al@840 46 echo -n "s|data_icon=\"$icon\"|data_icon=\"$symbol\"|g; " >> "$sed_script"
al@840 47 echo -n "s|repo_icon=\"$icon\"|repo_icon=\"$symbol\"|g; " >> "$sed_script"
al@840 48 case $icon in
al@840 49 clock)
al@840 50 echo -n "s|dataset\.icon==\"$icon\"|dataset.icon==\"$symbol\"|g; " >> "$sed_script";;
al@840 51 pkg|pkgi|pkgib)
al@840 52 echo -n "s|data-icon=\\\\\"$icon\\\\\"|data-icon=\\\\\"$symbol\\\\\"|g; " >> "$sed_script";;
al@840 53 esac
al@840 54 echo -n "s|data-img=\"$icon\"|data-img=\"$symbol\"|g; " >> "$sed_script"
al@840 55 done
al@840 56 echo "' @@@" >> "$sed_script"
al@840 57
al@840 58
al@840 59 cd build
al@840 60
al@840 61 echo -e "\nStrip shell scripts"
al@840 62 for CGI in $(ls | grep -v \.css$ | grep -v \.js$); do
al@840 63 echo "Processing $CGI"
al@840 64
al@840 65 mv $CGI $CGI.old
al@840 66 # Copy initial comment (down to empty line)
al@840 67 sed '1,/^$/!d' $CGI.old > $CGI
al@840 68 # Remove initial tabs, other comments and empty lines
al@840 69 sed 's|^\t*||;/^ *#/d;/^$/d' $CGI.old >> $CGI
al@840 70 rm $CGI.old
al@840 71
al@840 72 substitute_icons $CGI
al@840 73
al@840 74 sed -i 's|" *>|">|g' $CGI
al@840 75 sed -i "s|' *)|')|g" $CGI
al@840 76 sed -i 's| *;;|;;|g' $CGI
al@840 77
al@840 78 chmod a+x $CGI
al@840 79
al@840 80 done
al@840 81
al@840 82
al@840 83 echo -e "\n\nStrip CSS stylesheets"
al@840 84 for CSS in *.css; do
al@840 85 echo "Processing $CSS"
al@840 86
al@840 87 mv $CSS $CSS.old
al@840 88 tr '\n' ' ' < $CSS.old > $CSS
al@840 89 rm $CSS.old
al@840 90
al@840 91 substitute_icons $CSS
al@840 92
al@840 93 sed -i 's|\t| |g; s| *| |g; s|/\*|‹|g; s|\*/|›|g; s|‹[^›][^›]*›||g; s| *| |g; s|^ ||; s| {|{|g; s|{ |{|g; s| *: *|:|g; s| *; *|;|g; s|;}|}|g; s|} |}|g; s| *> *|>|g; s| *, *|,|g; s|000000|000|g; s|CC0000|C00|g; s|00FFFF|0FF|g' $CSS
al@840 94 done
al@840 95
al@840 96 mkdir gz
al@840 97 cat *.css > gz/pkgs.css
al@840 98 gzip -9 gz/pkgs.css
al@840 99
al@840 100
al@840 101 rm "$sed_script"
al@840 102 echo