tazpkg view stripall.sh @ rev 840
Add a bunch of modules with new-style support of 'root' (not all commands are modules yet); strip and compress resources.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Fri Aug 28 16:10:34 2015 +0300 (2015-08-28) |
parents | |
children | d2e1b7133079 |
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|data-icon=\"$icon\"|data-icon=\"$symbol\"|g; " >> "$sed_script"
46 echo -n "s|data_icon=\"$icon\"|data_icon=\"$symbol\"|g; " >> "$sed_script"
47 echo -n "s|repo_icon=\"$icon\"|repo_icon=\"$symbol\"|g; " >> "$sed_script"
48 case $icon in
49 clock)
50 echo -n "s|dataset\.icon==\"$icon\"|dataset.icon==\"$symbol\"|g; " >> "$sed_script";;
51 pkg|pkgi|pkgib)
52 echo -n "s|data-icon=\\\\\"$icon\\\\\"|data-icon=\\\\\"$symbol\\\\\"|g; " >> "$sed_script";;
53 esac
54 echo -n "s|data-img=\"$icon\"|data-img=\"$symbol\"|g; " >> "$sed_script"
55 done
56 echo "' @@@" >> "$sed_script"
59 cd build
61 echo -e "\nStrip shell scripts"
62 for CGI in $(ls | grep -v \.css$ | grep -v \.js$); do
63 echo "Processing $CGI"
65 mv $CGI $CGI.old
66 # Copy initial comment (down to empty line)
67 sed '1,/^$/!d' $CGI.old > $CGI
68 # Remove initial tabs, other comments and empty lines
69 sed 's|^\t*||;/^ *#/d;/^$/d' $CGI.old >> $CGI
70 rm $CGI.old
72 substitute_icons $CGI
74 sed -i 's|" *>|">|g' $CGI
75 sed -i "s|' *)|')|g" $CGI
76 sed -i 's| *;;|;;|g' $CGI
78 chmod a+x $CGI
80 done
83 echo -e "\n\nStrip CSS stylesheets"
84 for CSS in *.css; do
85 echo "Processing $CSS"
87 mv $CSS $CSS.old
88 tr '\n' ' ' < $CSS.old > $CSS
89 rm $CSS.old
91 substitute_icons $CSS
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
94 done
96 mkdir gz
97 cat *.css > gz/pkgs.css
98 gzip -9 gz/pkgs.css
101 rm "$sed_script"
102 echo