2010-05-05

Slitaz -- firefox


Env: slitaz-3.0.iso
langpack: Traditional Chinese (zh-TW) Language Pack
[http://releases.mozilla.org/pub/mozilla.org/firefox/releases/latest-3.5/linux-i686/xpi/zh-TW.xpi]

root@slitaz:~# file /tmp/zh-TW.xpi
/tmp/zh-TW.xpi: Zip archive data, at least v2.0 to extract
root@slitaz:~# unzip -l /tmp/zh-TW.xpi
Archive: /tmp/zh-TW.xpi
Length Date Time Name
-------- ---- ---- ----
876 03-15-10 09:10 install.rdf
467859 03-15-10 09:10 chrome/zh-TW.jar
1363 03-15-10 09:10 chrome.manifest
-------- -------
470098 3 files
root@slitaz:~#
root@slitaz:~# ls -lR /usr/lib/firefox-3.5.7/extensions/langpack-zh-TW@firefox.mo
zilla.org/
/usr/lib/firefox-3.5.7/extensions/langpack-zh-TW@firefox.mozilla.org/:
drwxr-xr-x 2 root root 60 May 5 19:43 chrome
-rw-r--r-- 1 root root 1363 Mar 15 09:10 chrome.manifest
-rw-r--r-- 1 root root 876 Mar 15 09:10 install.rdf

/usr/lib/firefox-3.5.7/extensions/langpack-zh-TW@firefox.mozilla.org/chrome:
-rw-r--r-- 1 root root 467859 Mar 15 09:10 zh-TW.jar
root@slitaz:~#

root@slitaz:~# cat /etc/firefox/pref/firefox-l10n.js
//@line 36 "/home/slitaz/wok/firefox/firefox-3.5.7/browser/locales/en-US/firefox-l10n.js"

//@line 38 "/home/slitaz/wok/firefox/firefox-3.5.7/browser/locales/en-US/firefox-l10n.js"

pref("general.useragent.locale", "zh-TW");

root@slitaz:~# cat /var/lib/tazpkg/installed/firefox/receipt
# SliTaz package receipt.

PACKAGE="firefox"
VERSION="3.5.7"
CATEGORY="network"
SHORT_DESC="User friendly, secure and fast web browser."
MAINTAINER="pankso@slitaz.org"
DEPENDS="gtk+ sqlite dbus dbus-glib glib jpeg xorg-libX11 xorg-libXdamage alsa-lib xorg-libXt libfirefox"
BUILD_DEPENDS="xorg-dev gtk+-dev zip libIDL coreutils findutils xorg-libXft-dev \
dbus-dev dbus-glib-dev alsa-lib-dev"
TARBALL="$PACKAGE-$VERSION.source.tar.bz2"
WEB_SITE="http://www.mozilla.org/"
WGET_URL="http://releases.mozilla.org/pub/mozilla.org/firefox/releases/$VERSION/source/$TARBALL"
CONFIG_FILES="/etc/firefox"
TAGS="browser"

# Rules to configure and make the package.
#
# A long compile time... dont forget to build libidl before and check the
# .mozconfig file from the stuff and the stuff/README document.
#
compile_rules()
{
# Move the mozilla source tree to $PACKAGE-$VERSION to keep variables
# and to have a nice clean.
mv mozilla-* $PACKAGE-$VERSION 2>/dev/null
cp -a stuff/firefox.mozconfig $src/.mozconfig
cd $src
sed -i 's/xtype/type/' toolkit/mozapps/installer/packager.mk
./configure $CONFIGURE_ARGS &&
make &&
make DESTDIR=$PWD/_pkg install
}

# Rules to gen a SliTaz package suitable for Tazpkg.
genpkg_rules()
{
mkdir -p $fs/usr/lib/$PACKAGE-$VERSION $fs/usr/share $fs/etc
cp -a $_pkg/usr/bin $fs/usr
cp -a $_pkg/usr/lib/$PACKAGE-$VERSION $fs/usr/lib

# Home page, bookmarks file and branding.
cp -a stuff/browserconfig.properties $fs/usr/lib/$PACKAGE-$VERSION
cp -a stuff/bookmarks.html \
$fs/usr/lib/$PACKAGE-$VERSION/defaults/profile
cp -a stuff/firefox-branding.js \
$fs/usr/lib/$PACKAGE-$VERSION/defaults/pref/

# User preference.
cp -a stuff/prefs.js $fs/usr/lib/$PACKAGE-$VERSION/defaults/profile
cp -a stuff/userChrome.css \
$fs/usr/lib/$PACKAGE-$VERSION/defaults/profile/chrome

# Move default config to /etc/firefox (/usr maybe read-only)
for i in defaults browserconfig.properties ; do
mv -f $fs/usr/lib/$PACKAGE-$VERSION/$i $fs/etc/$PACKAGE
done
ln -s /etc/$PACKAGE/browserconfig.properties $fs/usr/lib/$PACKAGE-$VERSION
ln -s /etc/$PACKAGE $fs/usr/lib/$PACKAGE-$VERSION/defaults

# EULA is accepted by SliTaz project.
sed -i s:'pref("browser.EULA.3.accepted", false);':'pref("browser.EULA.3.accepted", true);': \
$fs/etc/firefox/pref/firefox.js

# Locale fr
tar xjf stuff/langpack-fr@firefox.mozilla.org.tar.bz2 \
-C $fs/usr/lib/$PACKAGE-$VERSION/extensions

#sed -i "s/maxVersion>3.0../maxVersion>$VERSION/" \
# $fs/usr/lib/$PACKAGE-$VERSION/extensions/langpack*/install.rdf

# Search Plugin (by: oddball)
cp -a stuff/searchplugins $fs/usr/lib/firefox-$VERSION/
chown -R root.root $fs

# Remove unnecessary files.
rm -rf $fs/usr/lib/$PACKAGE-$VERSION/dictionaries/*
rm -rf $fs/usr/lib/$PACKAGE-$VERSION/icons
# split firefox libs
rm -rf $fs/usr/lib/$PACKAGE-$VERSION/*.so
#retain big firefox libs
cp $_pkg/usr/lib/$PACKAGE-$VERSION/libxul.so \
$_pkg/usr/lib/$PACKAGE-$VERSION/libmozjs.so \
$fs/usr/lib/$PACKAGE-$VERSION

}

# Pre - Post install command to set default locale.
pre_install()
{
local root
root=$1
# Get old plugins
mkdir /tmp/firefox-plugins-$$
cp -a $root/usr/lib/firefox-*/plugins/* /tmp/firefox-plugins-$$ 2> /dev/null
# Remove old libs and configs
rm -rf $root/usr/lib/firefox-*/plugins
rm -rf $root/usr/lib/firefox-*/dictionaries
rm -rf $root/etc/firefox
}
post_install()
{
local root
root=$1
if grep -q "fr_*" $root/etc/locale.conf 2>/dev/null; then
sed -i 's/en-US/fr/' \
$root/etc/firefox/pref/firefox-l10n.js

fi
for i in /tmp/firefox-plugins-$$/* ; do
[ -e $i ] || continue
[ -e /usr/lib/firefox-*/plugins/$(basename $i) ] && continue
cp -a $i /usr/lib/firefox-*/plugins/
done
rm -rf /tmp/firefox-plugins-$$
}
.