tazpkg annotate stripall.sh @ rev 971
modules/get: fix plain mode and cookmode again
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Mon Nov 26 20:27:56 2018 +0200 (2018-11-26) |
parents | a02e36d44d06 |
children |
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@886 | 45 echo -n "s|@$icon@|$symbol|g; " >> "$sed_script" |
al@840 | 46 done |
al@840 | 47 echo "' @@@" >> "$sed_script" |
al@840 | 48 |
al@840 | 49 |
al@840 | 50 cd build |
al@840 | 51 |
al@840 | 52 echo -e "\nStrip shell scripts" |
al@840 | 53 for CGI in $(ls | grep -v \.css$ | grep -v \.js$); do |
al@840 | 54 echo "Processing $CGI" |
al@840 | 55 |
al@886 | 56 case $CGI in |
al@886 | 57 tazpkg.*.html) |
al@886 | 58 # doc/tazpkg.*.html |
al@886 | 59 substitute_icons $CGI |
al@886 | 60 if [ -n "$(which tidy)" ]; then |
al@886 | 61 tidy -m -q -w 0 -utf8 --new-inline-tags x-details --quote-nbsp n \ |
al@886 | 62 --tidy-mark n $CGI |
al@886 | 63 else |
al@886 | 64 sed -i 's|[ ][ ]*| |g; s|^ ||' $CGI |
al@886 | 65 fi |
al@886 | 66 ;; |
al@886 | 67 *) |
al@886 | 68 mv $CGI $CGI.old |
al@886 | 69 # Copy initial comment (down to empty line) |
al@886 | 70 sed '1,/^$/!d' $CGI.old > $CGI |
al@886 | 71 # Remove initial tabs, other comments and empty lines |
al@886 | 72 sed 's|^\t*||;/^ *#/d;/^$/d' $CGI.old >> $CGI |
al@886 | 73 rm $CGI.old |
al@840 | 74 |
al@886 | 75 substitute_icons $CGI |
al@840 | 76 |
al@886 | 77 sed -i 's|" *>|">|g' $CGI |
al@886 | 78 sed -i "s|' *)|')|g" $CGI |
al@886 | 79 sed -i 's| *;;|;;|g' $CGI |
al@840 | 80 |
al@886 | 81 chmod a+x $CGI |
al@886 | 82 ;; |
al@886 | 83 esac |
al@840 | 84 |
al@840 | 85 done |
al@840 | 86 |
al@840 | 87 |
al@840 | 88 echo -e "\n\nStrip CSS stylesheets" |
al@840 | 89 for CSS in *.css; do |
al@840 | 90 echo "Processing $CSS" |
al@840 | 91 |
al@840 | 92 mv $CSS $CSS.old |
al@840 | 93 tr '\n' ' ' < $CSS.old > $CSS |
al@840 | 94 rm $CSS.old |
al@840 | 95 |
al@840 | 96 substitute_icons $CSS |
al@840 | 97 |
al@840 | 98 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 | 99 done |
al@840 | 100 |
al@840 | 101 mkdir gz |
al@840 | 102 cat *.css > gz/pkgs.css |
al@840 | 103 gzip -9 gz/pkgs.css |
al@840 | 104 |
al@840 | 105 |
al@840 | 106 rm "$sed_script" |
al@840 | 107 echo |