tazpanel annotate stripall.sh @ rev 638

boot.iso: allow /dev/cdrom
author Pascal Bellard <pascal.bellard@slitaz.org>
date Wed Jan 05 15:14:01 2022 +0000 (2022-01-05)
parents 694b20d6963c
children
rev   line source
al@525 1 #!/bin/sh
al@525 2 # TazPanel - SliTaz Control Panel, hg.slitaz.org/tazpanel
al@525 3 # stripall.sh - strip and compact resources in build process
al@525 4 # Copyright (C) 2015 SliTaz GNU/Linux - BSD License
al@525 5
al@525 6
al@525 7 substitute_icons() {
al@526 8 # Customize sed script
al@526 9 cp "$sed_script" "$sed_script.do"
al@526 10 sed -i "s|@@@|$1|" "$sed_script.do"
al@526 11 # Run sed script
al@526 12 sh "$sed_script.do"
al@526 13 rm "$sed_script.do"
al@526 14 }
al@526 15
al@526 16
al@526 17 # Make script for substitution
al@526 18 sed_script="$(mktemp)"
al@526 19 echo -n "sed -i '" > "$sed_script"
al@525 20 echo -e "\
al@525 21 add  \n admin  \n back  \n battery 
al@525 22 brightness  \n cancel  \n cd  \n check 
al@525 23 clock  \n conf  \n daemons  \n delete 
al@525 24 detect  \n diff  \n download  \n edit 
al@525 25 eth  \n group  \n grub  \n hdd 
al@525 26 help  \n history  \n info  \n install 
al@525 27 link  \n list  \n locale  \n lock 
al@525 28 logs  \n loopback  \n modules  \n ok 
al@525 29 proc  \n refresh  \n removable  \n remove 
al@525 30 repack  \n report  \n restart  \n run 
al@525 31 save  \n scan  \n settings  \n start 
al@525 32 stop  \n sync  \n tag  \n tags 
al@525 33 tazx  \n temperature  \n terminal  \n text 
al@525 34 unlink  \n unlock  \n upgrade  \n user 
al@525 35 view  \n wifi  \n man  \n off 
al@525 36 on  \n opt  \n web  \n slitaz 
al@525 37 lvl0  \n lvl1  \n lvl2  \n lvl3 
al@525 38 lvl4  \n lvl5  \n online  \n offline 
al@525 39 sechi  \n secmi  \n seclo  \n pkg 
al@525 40 pkgi  \n pkgib  \n toggle  \n chlock 
al@525 41 calendar  \n modem  \n cpu  \n display 
al@525 42 msg  \n msgerr  \n msgwarn  \n msgup 
al@556 43 msgtip  \n vpn  \n floppy  \n folder " | \
al@525 44 while read icon symbol; do
al@558 45 echo -n "s|@$icon@|$symbol|g; " >> "$sed_script"
al@525 46 done
al@526 47 echo "' @@@" >> "$sed_script"
al@525 48
al@525 49
al@525 50 cd build
al@525 51
al@525 52 echo -e "\nStrip shell scripts"
al@525 53 for CGI in *.cgi tazpanel libtazpanel bootloader *.html; do
al@526 54 echo "Processing $CGI"
al@525 55
al@558 56 case $CGI in
al@558 57 tazpanel.*.html)
al@558 58 # doc/tazpanel.*.html
al@558 59 substitute_icons $CGI
al@558 60 if [ -n "$(which tidy)" ]; then
al@558 61 tidy -m -q -w 0 -utf8 --show-body-only y --quote-nbsp n $CGI
al@558 62 else
al@558 63 sed -i 's|[ ][ ]*| |g; s|^ ||' $CGI
al@558 64 fi
al@558 65 ;;
al@558 66 *)
al@558 67 mv $CGI $CGI.old
al@558 68 # Copy initial comment (down to empty line)
al@558 69 sed '1,/^$/!d' $CGI.old > $CGI
al@558 70 # Remove initial tabs, other comments and empty lines
al@558 71 sed 's|^[\t ]*||;/^#/d;/^$/d' $CGI.old >> $CGI
al@558 72 rm $CGI.old
al@525 73
al@558 74 substitute_icons $CGI
al@525 75
al@558 76 sed -i 's|" *>|">|g' $CGI
al@558 77 sed -i "s|' *)|')|g" $CGI
al@558 78 sed -i 's| *;;|;;|g' $CGI
al@525 79
al@558 80 chmod a+x $CGI
al@558 81 ;;
al@558 82 esac
al@525 83
al@525 84 done
al@525 85
al@525 86
al@525 87 echo -e "\n\nStrip CSS stylesheets"
al@525 88 for CSS in *.css; do
al@526 89 echo "Processing $CSS"
al@525 90
al@525 91 mv $CSS $CSS.old
al@525 92 tr '\n' ' ' < $CSS.old > $CSS
al@525 93 rm $CSS.old
al@525 94
al@525 95 substitute_icons $CSS
al@525 96
al@525 97 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@525 98 done
al@525 99
al@525 100 mkdir gz
al@525 101 cat *.css > gz/tazpanel.css
al@525 102 gzip -9 gz/tazpanel.css
al@525 103
al@525 104
al@525 105 echo -e "\n\nStrip JS scripts"
al@525 106 for JS in *.js; do
al@525 107 echo -en "\nProcessing $JS"
al@525 108
al@558 109 substitute_icons $JS
al@525 110 sed -i 's|^[\t ]*||; /^$/d; /^\/\//d; /console\./d' $JS
al@525 111
al@525 112 # Try "jsmin"
al@525 113 if [ -n "$(which jsmin)" ]; then
al@525 114 jsmin < $JS > $JS.new
al@525 115 mv -f $JS.new $JS
al@525 116 fi
al@525 117 done
al@525 118
al@525 119 cat *.js > gz/tazpanel.js
al@525 120 gzip -9 gz/tazpanel.js
al@525 121
al@526 122 rm "$sed_script"
al@525 123 echo