| 10 |
10 |
errcho "$@"
|
| 11 |
11 |
fi
|
| 12 |
12 |
|
| 13 |
|
errcho "usage: $0 [OPTION]... BROWSER"
|
| 14 |
|
errcho
|
| 15 |
|
errcho "the -- preceding long forms is optional"
|
| 16 |
|
errcho "browsers:"
|
| 17 |
|
errcho " -C, chromium: build for Chromium and derivatives"
|
| 18 |
|
errcho " -M, mozilla: build for Firefox and derivatives"
|
| 19 |
|
errcho "options:"
|
| 20 |
|
errcho " -b, build [LOC]: set file/directory to use for building"
|
| 21 |
|
errcho " -f, force: delete the build directory if it exists"
|
| 22 |
|
errcho " instead of throwing an error."
|
| 23 |
|
errcho " -h, help: print usage information and exit"
|
| 24 |
|
errcho " -o, output [LOC]: set output file/directory"
|
| 25 |
|
errcho " -z, zip_ext: pack the extension as a file"
|
| 26 |
|
errcho " -7, 7zip: use the '7z' command instead of 'zip'"
|
|
13 |
echo "usage: $0 [OPTION]... BROWSER"
|
|
14 |
echo
|
|
15 |
echo "long options can be provided either in the form"
|
|
16 |
echo "'[OPTION](=[VALUE])' or '--[OPTION] (VALUE)'."
|
|
17 |
echo "browsers:"
|
|
18 |
echo " -C, chromium: build for Chromium and derivatives"
|
|
19 |
echo " -M, mozilla: build for Firefox and derivatives"
|
|
20 |
echo "options:"
|
|
21 |
echo " -b, build=[LOC]: set file/directory to use for building"
|
|
22 |
echo " -h, help: print usage information and exit"
|
|
23 |
echo " -o, output=[LOC]: set output file/directory"
|
|
24 |
echo " -s, safe: don't delete existing directories;"
|
|
25 |
echo " throw an error instead."
|
|
26 |
echo " -z, zip: pack the extension as a file"
|
|
27 |
echo
|
|
28 |
echo "environment variables (optional)"
|
|
29 |
echo " HAKETILO_ZIP: command to use for generating ZIP files"
|
|
30 |
echo " HAKETILO_CHROMIUM: command to user to invoke Chromium"
|
| 27 |
31 |
|
| 28 |
32 |
exit $EXIT_STATUS
|
| 29 |
33 |
}
|
| ... | ... | |
| 33 |
37 |
BROWSER=''
|
| 34 |
38 |
BUILDDIR=''
|
| 35 |
39 |
MAKEZIP=0
|
| 36 |
|
FORCE=0
|
| 37 |
|
ZIP_COMMAND='zip -r'
|
|
40 |
FORCE=1
|
| 38 |
41 |
|
| 39 |
42 |
while [ "x$1" != x ]; do
|
| 40 |
43 |
case "$1" in
|
| 41 |
|
-C | chromium | --chromium) BROWSER=chromium;;
|
| 42 |
|
-M | mozilla | --mozilla) BROWSER=mozilla;;
|
| 43 |
|
-b | output | --build) BUILDDIR="$2"
|
| 44 |
|
shift;;
|
| 45 |
|
-f | force | --force) FORCE=1;;
|
| 46 |
|
-h | help | --help) print_usage;;
|
| 47 |
|
-o | output | --output) OUTPUT="$2"
|
| 48 |
|
shift;;
|
| 49 |
|
-z | zip_ext | --zip_ext) MAKEZIP=1;;
|
| 50 |
|
-7 | 7zip | --7zip) ZIP_COMMAND='7z a';;
|
| 51 |
|
*) print_usage 2 Unrecognized option "'$1'.";;
|
|
44 |
-C | --chromium | chromium) BROWSER=chromium;;
|
|
45 |
-M | --mozilla | mozilla) BROWSER=mozilla;;
|
|
46 |
-b | --build) BUILDDIR="$2"; shift;;
|
|
47 |
build=*) BUILDDIR="$(echo "$1" | cut -c 7-)";;
|
|
48 |
-h | --help | help) print_usage;;
|
|
49 |
-o | --output) OUTPUT="$2"; shift;;
|
|
50 |
output=*) OUTPUT="$(echo "$1" | cut -c 8-)";;
|
|
51 |
-s | --safe | safe) FORCE=0;;
|
|
52 |
-z | --zip | zip_ext) MAKEZIP=1;;
|
|
53 |
*) print_usage 2 Unrecognized option "'$1'.";;
|
| 52 |
54 |
esac
|
| 53 |
55 |
shift
|
| 54 |
56 |
done
|
| ... | ... | |
| 57 |
59 |
print_usage 1 No browser was specified.
|
| 58 |
60 |
fi
|
| 59 |
61 |
|
| 60 |
|
BUILDDIR="${BUILDDIR:-build_$BROWSER}"
|
|
62 |
|
|
63 |
if [ $MAKEZIP = 1 ]; then
|
|
64 |
BUILDDIR="${BUILDDIR:-build_$BROWSER}"
|
|
65 |
|
|
66 |
if [ "x$OUTPUT" = x ]; then
|
|
67 |
case $BROWSER in
|
|
68 |
chromium) OUTPUT=build.crx;;
|
|
69 |
mozilla) OUTPUT=build.xpi;;
|
|
70 |
esac
|
|
71 |
fi
|
|
72 |
else
|
|
73 |
if [ "x$BUILDDIR" = x ]; then
|
|
74 |
BUILDDIR="${OUTPUT:-build_$BROWSER}"
|
|
75 |
fi
|
|
76 |
|
|
77 |
OUTPUT="${OUTPUT:-$BUILDDIR}"
|
|
78 |
fi
|
|
79 |
|
| 61 |
80 |
if [ -e "$BUILDDIR" ]; then
|
| 62 |
81 |
if [ $FORCE = 0 ]; then
|
| 63 |
82 |
errcho "Build directory '$BUILDDIR' exists."
|
| ... | ... | |
| 67 |
86 |
fi
|
| 68 |
87 |
fi
|
| 69 |
88 |
|
| 70 |
|
if [ "x$OUTPUT" = x ]; then
|
| 71 |
|
case "$MAKEZIP$BROWSER" in
|
| 72 |
|
0*) OUTPUT=build_$BROWSER;;
|
| 73 |
|
1chromium) OUTPUT=build.crx;;
|
| 74 |
|
1mozilla) OUTPUT=build.xpi;;
|
| 75 |
|
esac
|
| 76 |
|
fi
|
| 77 |
|
|
| 78 |
89 |
if [ -e "$OUTPUT" ]; then
|
| 79 |
|
errcho "Output location '$OUTPUT' exists."
|
| 80 |
|
exit 3
|
|
90 |
if [ $FORCE = 0 ]; then
|
|
91 |
errcho "Output location '$OUTPUT' exists."
|
|
92 |
exit 3
|
|
93 |
else
|
|
94 |
rm -rf "$BUILDDIR"
|
|
95 |
fi
|
| 81 |
96 |
fi
|
| 82 |
97 |
|
| 83 |
98 |
mkdir "$BUILDDIR"
|
Normalize CLI options
Use saner defaults and (where suitable) environment variables