tazpkg diff stripall.sh @ rev 855
cache: fix working; install: install official conf.files if destination is absent; tazpkg-notify: change icons
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Mon Nov 09 04:54:02 2015 +0200 (2015-11-09) |
parents | |
children | d2e1b7133079 |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/stripall.sh Mon Nov 09 04:54:02 2015 +0200 1.3 @@ -0,0 +1,102 @@ 1.4 +#!/bin/sh 1.5 +# TazPkg - SliTaz Package Manager, hg.slitaz.org/tazpkg 1.6 +# stripall.sh - strip and compact resources in build process 1.7 +# Copyright (C) 2015 SliTaz GNU/Linux - BSD License 1.8 + 1.9 + 1.10 +substitute_icons() { 1.11 + # Customize sed script 1.12 + cp "$sed_script" "$sed_script.do" 1.13 + sed -i "s|@@@|$1|" "$sed_script.do" 1.14 + # Run sed script 1.15 + sh "$sed_script.do" 1.16 + rm "$sed_script.do" 1.17 +} 1.18 + 1.19 + 1.20 +# Make script for substitution 1.21 + sed_script="$(mktemp)" 1.22 + echo -n "sed -i '" > "$sed_script" 1.23 + echo -e "\ 1.24 + add \n admin \n back \n battery 1.25 + brightness \n cancel \n cd \n check 1.26 + clock \n conf \n daemons \n delete 1.27 + detect \n diff \n download \n edit 1.28 + eth \n group \n grub \n hdd 1.29 + help \n history \n info \n install 1.30 + link \n list \n locale \n lock 1.31 + logs \n loopback \n modules \n ok 1.32 + proc \n refresh \n removable \n remove 1.33 + repack \n report \n restart \n run 1.34 + save \n scan \n settings \n start 1.35 + stop \n sync \n tag \n tags 1.36 + tazx \n temperature \n terminal \n text 1.37 + unlink \n unlock \n upgrade \n user 1.38 + view \n wifi \n man \n off 1.39 + on \n opt \n web \n slitaz 1.40 + lvl0 \n lvl1 \n lvl2 \n lvl3 1.41 + lvl4 \n lvl5 \n online \n offline 1.42 + sechi \n secmi \n seclo \n pkg 1.43 + pkgi \n pkgib \n toggle \n chlock 1.44 + calendar \n modem \n cpu \n display 1.45 + msg \n msgerr \n msgwarn \n msgup 1.46 + msgtip \n vpn " | \ 1.47 + while read icon symbol; do 1.48 + echo -n "s|data-icon=\"$icon\"|data-icon=\"$symbol\"|g; " >> "$sed_script" 1.49 + echo -n "s|data_icon=\"$icon\"|data_icon=\"$symbol\"|g; " >> "$sed_script" 1.50 + echo -n "s|repo_icon=\"$icon\"|repo_icon=\"$symbol\"|g; " >> "$sed_script" 1.51 + case $icon in 1.52 + clock) 1.53 + echo -n "s|dataset\.icon==\"$icon\"|dataset.icon==\"$symbol\"|g; " >> "$sed_script";; 1.54 + pkg|pkgi|pkgib) 1.55 + echo -n "s|data-icon=\\\\\"$icon\\\\\"|data-icon=\\\\\"$symbol\\\\\"|g; " >> "$sed_script";; 1.56 + esac 1.57 + echo -n "s|data-img=\"$icon\"|data-img=\"$symbol\"|g; " >> "$sed_script" 1.58 + done 1.59 + echo "' @@@" >> "$sed_script" 1.60 + 1.61 + 1.62 +cd build 1.63 + 1.64 +echo -e "\nStrip shell scripts" 1.65 +for CGI in $(ls | grep -v \.css$ | grep -v \.js$); do 1.66 + echo "Processing $CGI" 1.67 + 1.68 + mv $CGI $CGI.old 1.69 + # Copy initial comment (down to empty line) 1.70 + sed '1,/^$/!d' $CGI.old > $CGI 1.71 + # Remove initial tabs, other comments and empty lines 1.72 + sed 's|^\t*||;/^ *#/d;/^$/d' $CGI.old >> $CGI 1.73 + rm $CGI.old 1.74 + 1.75 + substitute_icons $CGI 1.76 + 1.77 + sed -i 's|" *>|">|g' $CGI 1.78 + sed -i "s|' *)|')|g" $CGI 1.79 + sed -i 's| *;;|;;|g' $CGI 1.80 + 1.81 + chmod a+x $CGI 1.82 + 1.83 +done 1.84 + 1.85 + 1.86 +echo -e "\n\nStrip CSS stylesheets" 1.87 +for CSS in *.css; do 1.88 + echo "Processing $CSS" 1.89 + 1.90 + mv $CSS $CSS.old 1.91 + tr '\n' ' ' < $CSS.old > $CSS 1.92 + rm $CSS.old 1.93 + 1.94 + substitute_icons $CSS 1.95 + 1.96 + 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 1.97 +done 1.98 + 1.99 +mkdir gz 1.100 +cat *.css > gz/pkgs.css 1.101 +gzip -9 gz/pkgs.css 1.102 + 1.103 + 1.104 +rm "$sed_script" 1.105 +echo