tazpkg view stripall.sh @ rev 940

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