forked from Woundorf/foxreplace
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·100 lines (83 loc) · 2.68 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash
# build.sh -- builds JAR and XPI files for mozilla extensions
# by Nickolay Ponomarev <[email protected]>
# (original version based on Nathan Yergler's build script)
# Most recent version is at <http://kb.mozillazine.org/Bash_build_script>
# This script assumes the following directory structure:
# ./
# chrome.manifest (optional - for newer extensions)
# install.rdf
# (other files listed in $ROOT_FILES)
#
# content/ |
# locale/ |} these can be named arbitrary and listed in $CHROME_PROVIDERS
# skin/ |
#
# defaults/ |
# components/ |} these must be listed in $ROOT_DIRS in order to be packaged
# ... |
#
# It uses a temporary directory ./build when building; don't use that!
# Script's output is:
# ./$APP_NAME.xpi
# ./files -- the list of packaged files
#
# Note: It modifies chrome.manifest when packaging so that it points to
# chrome/$APP_NAME.jar!/*
#
# default configuration file is ./config_build.sh, unless another file is
# specified in command-line. Available config variables:
APP_NAME= # short-name, jar and xpi files name. Must be lowercase with no spaces
CLEAN_UP= # delete the jar / "files" when done? (1/0)
ROOT_FILES= # put these files in root of xpi (space separated list of leaf filenames)
ROOT_DIRS= # ...and these directories (space separated list)
BEFORE_BUILD= # run this before building (bash command)
AFTER_BUILD= # ...and this after the build (bash command)
if [ -z $1 ]; then
. ./config_build.sh
else
. $1
fi
if [ -z $APP_NAME ]; then
echo "You need to create build config file first!"
echo "Read comments at the beginning of this script for more info."
exit;
fi
ROOT_DIR=`pwd`
TMP_DIR=build
EXCLUDED_EXTENSIONS_PATTERN=`echo $EXCLUDED_EXTENSIONS | sed s/[[:alnum:]_][[:alnum:]_]*/-e\ \\\\\\\\.\&$/g`
#uncomment to debug
#set -x
# remove any left-over files from previous build
rm -f $APP_NAME.xpi files
rm -rf $TMP_DIR
$BEFORE_BUILD
mkdir $TMP_DIR
# prepare components and defaults
echo "Copying various files to $TMP_DIR folder..."
for DIR in $ROOT_DIRS; do
mkdir $TMP_DIR/$DIR
FILES="`find $DIR -type f -print | grep -v -e \~ $EXCLUDED_EXTENSIONS_PATTERN`"
echo $FILES >> files
cp --verbose --parents $FILES $TMP_DIR
done
# Copy other files to the root of future XPI.
for ROOT_FILE in $ROOT_FILES; do
cp --verbose $ROOT_FILE $TMP_DIR
if [ -f $ROOT_FILE ]; then
echo $ROOT_FILE >> files
fi
done
cd $TMP_DIR
# generate the XPI file
echo "Generating $APP_NAME.xpi..."
zip -r ../$APP_NAME.xpi *
cd "$ROOT_DIR"
echo "Cleanup..."
if [ $CLEAN_UP != 0 ]; then
# remove the working files
rm ./files
rm -rf $TMP_DIR
fi
echo "Done!"
$AFTER_BUILD