File:  [mozdev] / basic / src / build-cookiebutton
Revision 1.4: download - view: text, annotated - select for diffs - revision graph
Thu Nov 5 16:54:27 2009 UTC (7 years, 11 months ago) by basic
Branches: MAIN
CVS tags: cookiebutton_0_9_3, HEAD
remove unused overlay file

#!/bin/sh

pushd chrome || exit

rm cookiebutton.jar
rm cookiestatusbutton.jar
rm cookiecontext.jar

pushd cookiecommon || exit

find ! -type d ! -regex '.*/CVS/.*' ! -regex '.*cookieperm\.js' |sed 'sx^\./xx'| xargs zip -X -D -g -0 ../cookiebutton.jar || exit

popd || exit # cookiecommon

cp cookiebutton.jar cookiestatusbutton.jar || exit
cp cookiebutton.jar cookiecontext.jar || exit

zip -d cookiebutton.jar content/bindings.css || exit

combineJS() {
	echo combining JS files for $2
	sed s/COOKIE_BUTTON_OBJECT/$1/g cookiecommon/content/cookieperm.js > $2/content/cookieperm.js || exit
	cat $2/content/overlay.js >> $2/content/cookieperm.js || exit
}

combineJS cookieButtonObject cookietoolbarbutton
combineJS cookieContextObject cookiecontext
combineJS cookieStatusButtonObject cookiestatusbutton

combineCSS() {
	echo combining CSS files for $1
	echo '@namespace url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");' > $1 || exit
	echo '@namespace xul url("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul");' >> $1 || exit
	cssFiles=($*)
	unset cssFiles[0]
	sed \
		-e 's#@namespace [^ ]* url("http://www\.mozilla\.org/keymaster/gatekeeper/there\.is\.only\.xul");##g' \
		-e 's#@namespace url("http://www\.mozilla\.org/keymaster/gatekeeper/there\.is\.only\.xul");##g' \
		${cssFiles[@]} >> $1 || exit
}

combineCSS cookietoolbarbutton/content/combined.css \
	cookiecommon/content/bindings.css cookietoolbarbutton/content/overlay.css

combineCSS cookietoolbarbutton/skin/combined.css \
	cookietoolbarbutton/skin/overlay-winstripe.css cookietoolbarbutton/skin/overlay-winstripe-small.css \
	cookietoolbarbutton/skin/overlay-pinstripe.css cookietoolbarbutton/skin/overlay-pinstripe-small.css \
	cookiecommon/skin/overlay-menupopup.css

combineCSS cookiecontext/skin/combined.css cookiecontext/skin/overlay.css cookiecommon/skin/overlay-menupopup.css
combineCSS cookiestatusbutton/skin/combined.css cookiestatusbutton/skin/overlay.css cookiecommon/skin/overlay-menupopup.css

pushd cookietoolbarbutton || exit

find ! -type d ! -regex '.*/CVS/.*' |sed 'sx^\./xx'| xargs zip -D -g -0 ../cookiebutton.jar

popd || exit # cookietoolbarbutton

zip -X -D -g -0 cookiebutton.jar license.txt

pushd cookiestatusbutton

find ! -type d ! -regex '.*/CVS/.*' |sed 'sx^\./xx'| xargs zip -D -g -0 ../cookiestatusbutton.jar

popd || exit # cookiestatusbutton

zip -X -D -g -0 cookiestatusbutton.jar license.txt

pushd cookiecontext

find ! -type d ! -regex '.*/CVS/.*' |sed 'sx^\./xx'| xargs zip -D -g -0 ../cookiecontext.jar

popd || exit # cookiecontext

zip -X -D -g -0 cookiecontext.jar license.txt

popd || exit # chrome

mkdir -p staging

repackJAR() {
	pushd staging || exit
	rm -r *
	unzip ../$1 || exit
	find -iname contents.rdf|xargs rm
	find -iname overlay.css|xargs rm
	rm content/overlay.js
	#find -iname '*.js'|xargs -n1 ../compact-js
	#find -iname '*.css'|xargs -n1 ../compact-css
	#find -iname '*.xul'|xargs -n1 ../compact-xml
	#find -iname '*.xml'|xargs -n1 ../compact-xml
	rm ../$1 || exit
	find -type f |sed 'sx^\./xx'| sort |
		awk '{c=split($0,a,/\./);print a[c] " " $0 }' |
		sort  | awk '{print $2}' | xargs zip -D -g -0 ../$1
	popd || exit # staging
}

repackJAR chrome/cookiebutton.jar
repackJAR chrome/cookiecontext.jar
repackJAR chrome/cookiestatusbutton.jar

rm -f cookiebutton.xpi

zip -X -D -0 cookiebutton.xpi chrome/cookiebutton.jar defaults/preferences/cookiebutton.js || exit

rm -f cookiestatusbutton.xpi

zip -X -D -0 cookiestatusbutton.xpi chrome/cookiestatusbutton.jar defaults/preferences/cookiestatusbutton.js || exit

rm -f cookiecontext.xpi

zip -X -D -0 cookiecontext.xpi chrome/cookiecontext.jar defaults/preferences/cookiecontext.js || exit

pushd cookietoolbarbutton || exit

zip -X -D -g -0 ../cookiebutton.xpi * || exit

popd || exit # cookietoolbarbutton


pushd cookiestatusbutton || exit

zip -D -g -0 ../cookiestatusbutton.xpi * || exit

popd || exit # cookietstatusbutton

pushd cookiecontext || exit

zip -D -g -0 ../cookiecontext.xpi * || exit

popd || exit # cookiecontext

compressXPI() {
	pushd staging || exit
	rm -r *
	unzip ../$1
	tmpname1=`mktemp`
	tmpname2=`mktemp`
	echo compressing $1 using zlib
	for ((i=0;i<=9;++i)); do
		find -type f|sed 'sx^\./xx'|xargs zip -q -X -D -g -$i ${tmpname1}.zip
		zipmix ../$1 ${tmpname1}.zip ${tmpname2}.zip || exit
		rm ${tmpname1}.zip || exit
		mv ${tmpname2}.zip ../$1 || exit
	done

	echo compressing $1 using advzip
	for ((i=1;i<=4;++i)); do
		advzip -z$i ../$1
	done
	popd || exit # staging
}

compressXPI cookiebutton.xpi
compressXPI cookiecontext.xpi
compressXPI cookiestatusbutton.xpi

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>