4 if [ -z "$AB_CD" ]; then
5 if [ -z "$1" ]; then AB_CD
=en-US
; else AB_CD
=$1; fi
7 # Set up settings and paths for finding files.
8 if [ -z "$DEBUG" ]; then DEBUG
=0; fi
9 if [ -z "$PERL" ]; then PERL
=perl
; fi
10 if [ -z "$FEDIR" ]; then FEDIR
=$PWD/..
; fi
11 if [ -z "$CONFIGDIR" ]; then CONFIGDIR
=$FEDIR/..
/..
/config
; fi
12 if [ -z "$XPIROOT" ]; then XPIROOT
=$PWD/xpi-tree-
$AB_CD; fi
13 if [ -z "$JARROOT" ]; then JARROOT
=$PWD/jar-tree-
$AB_CD; fi
14 if [ -z "$LOCALEDIR" ]; then LOCALEDIR
=$FEDIR/locales
; fi
15 # the dir containing the actual localisation files
16 # usually this is in l10n/ repository (parallel to mozilla/)
17 # note that toolkit/defines.inc is expected in parallel to extensions/irc there
18 if [ -z "$L10NDIR" ]; then L10NDIR
="$FEDIR/../../../l10n/$AB_CD/extensions/irc"; fi
20 # Display all the settings and paths if we're in debug mode.
21 if [ $DEBUG -ge 1 ]; then
22 echo "\$DEBUG = $DEBUG"
24 echo "\$CONFIGDIR = $CONFIGDIR"
25 echo "\$XPIROOT = $XPIROOT"
26 echo "\$JARROOT = $JARROOT"
27 echo "\$FEDIR = $FEDIR"
28 echo "\$LOCALEDIR = $LOCALEDIR"
29 echo "\$AB_CD = $AB_CD"
30 echo "\$L10NDIR = $L10NDIR"
33 ## Simple function to display all the parameters/arguments to itself.
43 ## Call this with lots of parameters to run a command, log errors, and abort
44 ## if it fails. Supports redirection if '>' and '<' are passed as arguments,
46 ## safeCommand cmd arg1 arg2 '<' input.file '>' output-file
48 ## Note: only a single input and single output redirection is supported.
50 function safeCommand
()
58 if [ "$LASTP" = "<" ]; then
59 if [ -n "$INF" ]; then
60 echo "ERROR: Multiple input files passed to safeCommand()." >&2
64 elif [ "$LASTP" = ">" ]; then
65 if [ -n "$OUTF" ]; then
66 echo "ERROR: Multiple output files passed to safeCommand()." >&2
70 elif [ "$P" = ">" -o "$P" = "<" ]; then
74 CMD_COUNT
=$
((CMD_COUNT
+1))
79 if [ $DEBUG -gt 0 ]; then
81 showParams
"${CMD[@]}"
83 echo 'OUTPUT :' "$OUTF"
86 touch log.stdout log.stderr
87 if [ -z "$INF" -a -z "$OUTF" ]; then
88 "${CMD[@]}" 1>log.stdout
2>log.stderr
89 elif [ -z "$INF" ]; then
90 "${CMD[@]}" 1> "$OUTF" 2>log.stderr
91 elif [ -z "$OUTF" ]; then
92 "${CMD[@]}" < "$INF" 1>log.stdout
2>log.stderr
94 "${CMD[@]}" < "$INF" 1> "$OUTF" 2>log.stderr
98 if [ $DEBUG -gt 0 ]; then
101 if [ "$EC" != "0" ]; then
105 rm -f log.stdout log.stderr
108 rm -f log.stdout log.stderr
113 ## Begin real program ##
116 if [ "$1" = "clean" ]; then
117 echo -n "Cleaning up files"
127 # Check that requested language is in all-locales file (i.e. exists and it
128 # allowed to be used).
129 # FIXME: THIS DOES NOT WORK WITH CYGWIN.
130 grep -sx "$AB_CD" "$LOCALEDIR/all-locales" > /dev
/null
132 echo "ERROR: Language $AB_CD is currently not supported."
135 if [ $DEBUG -ge 1 ]; then echo "Language = $AB_CD"; fi
138 # Check directory setup.
139 if ! [ -d "$FEDIR" ]; then
140 echo "ERROR: Base ChatZilla directory (FEDIR) not found."
143 if ! [ -d "$CONFIGDIR" ]; then
144 echo "ERROR: mozilla/config directory (CONFIGDIR) not found."
147 if ! [ -d "$L10NDIR" ]; then
148 echo "ERROR: Directory with localized files for $AB_CD language (L10NDIR) not found."
153 # Extract version number.
154 VERSION
=`grep "const __cz_version" "$FEDIR/xul/content/static.js" | sed "s|.*\"\([^\"]\{1,\}\)\".*|\1|"`
155 BASE_VERSION
=`echo "$VERSION" | sed "s|\([0-9]\{1,\}\.[0-9]\{1,\}\.[0-9]\{1,\}\).*|\1|"`
157 if [ -z "$VERSION" ]; then
158 echo "ERROR: Unable to get version number."
162 echo "Beginning build of $AB_CD language pack for ChatZilla $VERSION..."
164 # Set up LangPack XPI name using version and language.
165 XPINAME
="chatzilla-$VERSION.$AB_CD.xpi"
167 # Check for an existing XPI file and print a warning.
168 if [ -r "$XPINAME" ]; then
169 echo " WARNING: output XPI will be overwritten."
173 # Check for required directory layouts.
174 echo -n " Checking XPI structure"
176 if ! [ -d "$XPIROOT" ]; then mkdir
-p $XPIROOT; fi
178 if ! [ -d "$XPIROOT/chrome" ]; then mkdir
$XPIROOT/chrome
; fi
181 echo -n " Checking JAR structure"
183 if ! [ -d "$JARROOT" ]; then mkdir
-p $JARROOT; fi
187 # Make Firefox updates.
188 echo -n " Updating Firefox Extension files"
190 # make sure we have all defines we need when preprocessing the install.rdf file
191 # toolkit/defines.inc contains the definition for the locale name we use in the langpack title
192 safeCommand
$PERL "$CONFIGDIR/preprocessor.pl" -DAB_CD=$AB_CD -DCHATZILLA_VERSION=$VERSION -DCHATZILLA_BASE_VERSION=$BASE_VERSION -DINSTALL_EXTENSION_ID=langpack-
$AB_CD@chatzilla.mozilla.org
-I$L10NDIR/..
/..
/toolkit
/defines.inc
-I$L10NDIR/defines.inc
"$LOCALEDIR/generic/install.rdf" '>' "$XPIROOT/install.rdf"
197 # Make Mozilla Suite updates.
198 echo -n " Updating Mozilla Extension files"
200 # make sure we have all defines we need when preprocessing the install.js file
201 # toolkit/defines.inc contains the definition for the locale name we use in the langpack title
202 safeCommand
$PERL "$CONFIGDIR/preprocessor.pl" -DAB_CD=$AB_CD -DCHATZILLA_VERSION=$VERSION -DCHATZILLA_BASE_VERSION=$BASE_VERSION -DINSTALL_EXTENSION_ID=langpack-
$AB_CD@chatzilla.mozilla.org
-I$L10NDIR/..
/..
/toolkit
/defines.inc
-I$L10NDIR/defines.inc
"$LOCALEDIR/generic/install.js" '>' "$XPIROOT/install.js"
208 echo -n " Constructing JAR package"
214 safeCommand
$PERL preprocessor.pl
-DAB_CD="$AB_CD" "$LOCALEDIR/jar.mn" '>' "$LOCALEDIR/jar.mn.pp"
216 safeCommand
$PERL make-jars.pl
-v -z zip -p preprocessor.pl
-s "$LOCALEDIR" -d "$JARROOT" -c "$L10NDIR" -- "-DAB_CD=\"$AB_CD\" -DMOZILLA_LOCALE_VERSION=\"\"" '<' "$LOCALEDIR/jar.mn.pp"
218 safeCommand
rm "$LOCALEDIR/jar.mn.pp"
224 echo -n " Constructing XPI package"
226 safeCommand
cp -v "$JARROOT/chatzilla.jar" "$XPIROOT/chrome/"
228 safeCommand
chmod 664 "$XPIROOT/chrome/chatzilla.jar"
232 safeCommand
zip -vr ..
/$XPINAME .
-i "*" -x "log*"
237 echo "Build of $AB_CD language pack for ChatZilla $VERSION... ALL DONE"