#! /bin/sh
ORG_NAME="Gnuzilla"
ORG_DOMAIN="gnuzilla.gnu.org"

rm -fv ./mailnews/addrbook/src/nsAbOSXDirectory.o
rm -fv ./mailnews/addrbook/src/nsAbOSXCard.o
rm -fv ./mailnews/addrbook/src/nsAbOSXDirFactory.o
rm -fv ./mailnews/addrbook/src/nsAbOSXUtils.o

rm -rfv  ./plugin/oji/JEP

rm -fv ./build/wince/shunt/build/shunt.vcb
rm -fv ./build/wince/shunt/build/shunt.vco
rm -fv './directory/c-sdk/ldap/examples/macintosh/asearch (2i).68k.u'
rm -fv './directory/c-sdk/ldap/examples/macintosh/asearch (4i).68k.u'
rm -fv './directory/c-sdk/ldap/examples/macintosh/asearch PPC.u'
rm -fv ./directory/c-sdk/ldap/libraries/macintosh/LDAPClient.mcp
rm -fv ./modules/oji/tests/script/killer.exe
rm -fv ./modules/plugin/samples/default/mac/NullPlugin.rsrc
rm -fv './modules/plugin/tools/sdk/samples/basic/mac/Basic Plugin.mcp'
rm -fv ./modules/plugin/tools/sdk/samples/basic/mac/Basic.rsrc
rm -fv './modules/plugin/tools/sdk/samples/scriptable/mac/Scriptable Plugin.mcp'
rm -fv './modules/plugin/tools/sdk/samples/scriptable/mac/Scriptable PluginIDL.mcp'
rm -fv ./modules/plugin/tools/sdk/samples/scriptable/mac/Scriptable.rsrc
rm -fv ./toolkit/mozapps/update/src/updater/macbuild/Contents/Resources/English.lproj/MainMenu.nib/keyedobjects.nib
rm -fv ./toolkit/mozapps/update/src/updater/macbuild/Contents/PkgInfo
rm -fv ./extensions/manticore/resources/manticore.psd
rm -fv ./extensions/universalchardet/doc/UniversalCharsetDetection.doc
rm -fv ./config/bin2rc.exe
rm -fv ./config/makedep.exe
rm -fv ./config/mangle.exe
rm -fv ./config/mantomak.exe
rm -fv ./embedding/browser/activex/src/pluginhostctrl/cab/redist/ATL.DLL
rm -fv ./embedding/browser/activex/tests/vbrowse/browser.frx
rm -fv ./embedding/browser/activex/tests/vbrowse/frmToolBar.frx
rm -fv ./embedding/browser/cocoa/res/English.lproj/alert.nib/objects.nib
rm -fv ./embedding/browser/powerplant/resources/cfmAlias.rsrc
rm -fv ./embedding/browser/powerplant/resources/cfmAliasDebug.rsrc
rm -fv ./embedding/minimo/mozconfig
rm -fv ./embedding/qa/testembed/testembed.aps
rm -fv ./embedding/tests/MSDotNETCSEmbed/MSDotNETCSEmbed.suo
rm -fv ./embedding/tests/cocoaEmbed/res/English.lproj/MainMenu.nib/objects.nib
rm -fv ./embedding/wrappers/DotNETEmbed/DotNETEmbed.snk
rm -fv ./intl/unicharutil/tools/data/case.dat
rm -fv ./intl/unicharutil/tools/data/cmbcl.dat
rm -fv ./intl/unicharutil/tools/data/ctype.dat
rm -fv ./intl/unicharutil/tools/data/decomp.dat
rm -fv ./intl/unicharutil/tools/data/num.dat
rm -fv ./js/src/fdlibm/fdlibm.mdp
rm -fv ./js/src/js.mdp
rm -fv ./js/src/liveconnect/jsj_nodl.c
rm -fv ./plugin/oji/JEP/MRJPlugin.plugin/Contents/MacOS/MRJPlugin
rm -fv ./plugin/oji/JEP/MRJPlugin.plugin/Contents/MacOS/MRJPlugin.jar
rm -fv ./plugin/oji/JEP/MRJPlugin.plugin/Contents/Resources/MRJPlugin.rsrc
rm -fv ./plugin/oji/JEP/JavaEmbeddingPlugin.bundle/Contents/MacOS/JavaEmbeddingPlugin
rm -fv ./plugin/oji/JEP/JavaEmbeddingPlugin.bundle/Contents/Resources/Java/JavaEmbeddingPlugin.jar
rm -fv ./plugin/oji/MRJ/plugin/Resources/Dialogs.rsrc
rm -fv ./plugin/oji/MRJ/plugin/Resources/Strings.rsrc
rm -fv ./plugin/oji/MRJ/plugin/Resources/Version.rsrc
rm -fv ./plugin/oji/MRJ/plugin/MRJPlugin.jar
rm -fv ./plugin/oji/MRJ/plugin/netscape.plugin.jar
rm -fv ./plugin/oji/MRJ/plugin/Source/JMURLConnection
rm -fv ./plugin/oji/MRJ/testing/ConsoleApplet/ConsoleApplet.mcp
rm -fv ./plugin/oji/MRJ/testing/JSApplet/JSApplet.mcp
rm -fv ./plugin/oji/MRJ/testing/SwingApplet/TestApplet.mcp
rm -fv ./plugin/oji/MRJ/testing/TrivialApplet/MyApplet.mcp
rm -fv ./plugin/oji/MRJCarbon/MRJSDK/JavaFrameworks/JavaEmbeddingLib
rm -fv ./plugin/oji/MRJCarbon/plugin/MRJPlugin.jar
rm -fv ./plugin/oji/MRJCarbon/plugin/Resources/Dialogs.rsrc
rm -fv ./plugin/oji/MRJCarbon/plugin/Resources/Strings.rsrc
rm -fv ./plugin/oji/MRJCarbon/plugin/Resources/Version.rsrc
rm -fv ./xpcom/reflect/xptcall/tests/eVC4/XPTCInvoke_Testing.cpp
rm -fv ./xpcom/tests/StringFactoringTests/StringTest.mcp
rm -fv ./xpcom/typelib/xpidl/macplugin/compiler.rsrc
rm -fv ./xpcom/typelib/xpidl/macplugin/linker.rsrc
rm -fv ./xpcom/typelib/xpidl/macplugin/panel.rsrc
rm -fv ./xpcom/typelib/xpidl/macplugin/version.rsrc
rm -fv ./xpinstall/packager/mac/ASEncoder/build/ASEncoder.mcp
rm -fv ./xpinstall/packager/mac/ASEncoder/rsrc/ASEncoder.rsrc
rm -fv ./xpinstall/packager/mac/ASEncoder/src/ASEncoderUsage.script
rm -fv ./xpinstall/test/pre_checkin.xpi
rm -fv ./xpinstall/wizard/libxpnet/GUSI/lib/GUSI_Core.PPC.Lib
rm -fv ./xpinstall/wizard/libxpnet/GUSI/lib/GUSI_ForeignThreads.PPC.Lib
rm -fv ./xpinstall/wizard/libxpnet/GUSI/lib/GUSI_MPW.PPC.Lib
rm -fv ./xpinstall/wizard/libxpnet/GUSI/lib/GUSI_MSL.PPC.Lib
rm -fv ./xpinstall/wizard/libxpnet/GUSI/lib/GUSI_SIOUX.PPC.Lib
rm -fv ./xpinstall/wizard/libxpnet/GUSI/lib/GUSI_Sfio.PPC.Lib
rm -fv ./xpinstall/wizard/mac/rsrc/MIWCommon.rsrc
rm -fv ./xpinstall/wizard/mac/rsrc/Mozilla.rsrc
rm -fv ./xpinstall/wizard/os2/setuprsc/box_ch_d.bmp
rm -fv ./xpinstall/wizard/os2/setuprsc/box_chec.bmp
rm -fv ./xpinstall/wizard/os2/setuprsc/box_unch.bmp
rm -fv ./xpinstall/wizard/unix/src2/logo.xpm
rm -fv ./gfx/cairo/libpixman/src/pixman-vc71.lib
rm -fv ./gfx/src/mac/printerplugin/Resources/English.lproj/Localizable.strings
rm -fv ./gfx/src/mac/nsMacGFX.rsrc
rm -fv ./layout/doc/SpaceMgr_BlockReflSt_OD.sda
rm -fv ./layout/doc/object_diagram_template.sda
rm -fv ./layout/html/tests/block/bugs/RealSnow.jar
rm -fv ./webshell/tests/viewer/mac/cfmAlias.rsrc
rm -fv ./webshell/tests/viewer/mac/cfmAliasDebug.rsrc
rm -fv ./webshell/tests/viewer/mac/viewer.ppob
rm -fv ./webshell/tests/viewer/mac/viewer.rsrc
rm -fv ./webshell/tests/viewer/mac/viewercarb.rsrc
rm -fv ./webshell/tests/viewer/viewer-beos.rsrc
rm -fv ./xpfe/bootstrap/appleevents/nsAppleEvents.rsrc
rm -fv ./xpfe/bootstrap/apprunner-beos.rsrc
rm -fv ./mailnews/mapi/old/tests/mapitest/mapitest.ncb
rm -fv ./mailnews/mapi/old/tests/mapitest/mapitest.opt


# also we need to remove any copyrighted image files from the mozilla
# src  suite,  not replaced by the branding process. This includes
# theme throbbers depending on how you handle that and windows icons,
# app icons, windows splash etc

rm -fv ./xpfe/bootstrap/splash.bmp
rm -fv ./xpfe/bootstrap/mozilla.ico
rm -fv ./xpfe/bootstrap/mozos2.ico
rm -fv ./browser/app/mozicon128.png
rm -fv ./browser/app/mozicon16.xpm
rm -fv ./browser/app/mozicon50.xpm

# I'm not sure about the os2 as I can't see them
rm -fv ./xpfe/bootstrap/icons/os2/mozilla.ico

rm -fv ./xpinstall/wizard/windows/setuprsc/bitmap1.bmp
rm -fv ./xpinstall/wizard/windows/setuprsc/downloadLogo.bmp
rm -fv ./xpinstall/wizard/windows/setuprsc/turbo-systray.bmp

rm -fv ./xpinstall/wizard/os2/nsinstall/stubinstall.ico
rm -fv ./xpinstall/wizard/os2/setuprsc/downloadLogo.bmp
rm -fv ./xpinstall/wizard/os2/setuprsc/bitmap1.bmp

rm -fv ./suite/branding/icons/gtk/seamonkey.png

# remove the throbbers as they are branded

rm -fv ./themes/classic/communicator/brand/throbber-single.gif
rm -fv ./themes/classic/communicator/brand/throbber16-single.gif
rm -fv ./themes/classic/communicator/brand/throbber-anim.gif
rm -fv ./themes/classic/communicator/brand/throbber16-anim.gif

rm -fv ./themes/modern/communicator/brand/throbber-single.gif
rm -fv ./themes/modern/communicator/brand/throbber16-single.gif
rm -fv ./themes/modern/communicator/brand/throbber-anim.gif
rm -fv ./themes/modern/communicator/brand/throbber16-anim.gif

rm -fv ./xpfe/bootstrap/splash.xpm
rm -fv ./themes/classic/communicator/icons/turbo-systray.gif
rm -fv ./themes/modern/communicator/icons/turbo-systray.gif


rm -fvr other-licenses/{7zstub,branding,nsis}
rm -fv README/mozilla/README.os2

rm -fv netwerk/protocol/ftp/doc/rfc959.txt
rm -fv directory/c-sdk/ldap/docs/draft-ietf-ldapext-ldap-c-api-05.txt
rm -fv calendar/sunbird/app/sunbird.ico
rm -fv calendar/sunbird/app/default.xpm

rm -rfv browser/branding/nightly
#rm -rfv browser/branding/unofficial



rm -fv ./themes/classic/communicator/brand/throbber-anim.gif
rm -fv ./themes/classic/communicator/brand/throbber16-anim.gif

rm -fv ./themes/modern/communicator/brand/throbber-single.gif
rm -fv ./themes/modern/communicator/brand/throbber16-single.gif
rm -fv ./themes/modern/communicator/brand/throbber-anim.gif
rm -fv ./themes/modern/communicator/brand/throbber16-anim.gif

rm -fv ./xpfe/bootstrap/splash.xpm
rm -fv ./themes/classic/communicator/icons/turbo-systray.gif
rm -fv ./themes/modern/communicator/icons/turbo-systray.gif

rm -fv README/mozilla/README.os2

rm -fv netwerk/protocol/ftp/doc/rfc959.txt
rm -fv directory/c-sdk/ldap/docs/draft-ietf-ldapext-ldap-c-api-05.txt
rm -fv calendar/sunbird/app/sunbird.ico
rm -fv calendar/sunbird/app/default.xpm

rm -rfv browser/branding/nightly

#remove CVS directories
find -iname CVS -type d | xargs rm -rvf

patch -p0 < locales-strings.patch || exit 1
patch -p0 < nullplugin.patch  || exit 1
patch -p0 < canvas_notify.patch || exit 1

rm -fv browser/branding/unofficial/wizHeader.bmp
rm -fv browser/branding/unofficial/wizHeaderRTL.bmp
rm -fv browser/branding/unofficial/wizWatermark.bmp
rm -fv browser/branding/unofficial/firefox.ico

cp -v browser/branding/unofficial/locales/en-US/aboutDialog.dtd browser/locales/en-US/chrome/browser/
cp -v browser/branding/unofficial/locales/en-US/credits.dtd browser/locales/en-US/chrome/browser/
cp -v browser/branding/unofficial/content/credits.xhtml browser/base/content/


convert browser/branding/unofficial/content/default.png -resize 16x16 browser/branding/unofficial/default16.png
convert browser/branding/unofficial/content/default.png -resize 32x32 browser/branding/unofficial/default32.png
convert browser/branding/unofficial/content/default.png -resize 48x48 browser/branding/unofficial/default48.png

convert browser/branding/unofficial/content/default.png -resize 16x16 browser/branding/unofficial/mozicon16.xpm
convert browser/branding/unofficial/content/default.png -resize 48x48 browser/branding/unofficial/mozicon50.xpm
convert browser/branding/unofficial/content/default.png -resize 128x128 browser/branding/unofficial/mozicon128.png

convert browser/branding/unofficial/content/default.png -resize 48x48 browser/branding/unofficial/content/icon48.png
convert browser/branding/unofficial/content/default.png -resize 64x64 browser/branding/unofficial/content/icon64.png

cp  ./browser/branding/unofficial/run-icecat.sh ./build/unix/
perl -pi -e"s/run-mozilla\.sh/run-icecat.sh/g" build/unix/Makefile.in browser/installer/package-manifest.in \
    browser/installer/removed-files.in toolkit/mozapps/installer/packager.mk js/src/config/config.mk config/config.mk

# Fetch the privacy extension.
(cd ./browser/branding/unofficial/extensions
svn co svn://svn.savannah.gnu.org/gnuzilla/trunk/privacy_ext
(cd privacy_ext; zip ../privacy_ext.xpi $(find -type f \! -wholename '*.svn*'))
rm -rf privacy_ext)


# Change the usage string of --help.
sed -i -e"s|Usage: firefox| Usage: icecat|" browser/components/nsBrowserContentHandler.js

find -name Makefile.in -exec sed -i -e "s|-777|-755|g" \{\} \;
