Repository navigation
Expand file tree
/
Copy pathbuild.sh
More file actions
executable file
·102 lines (88 loc) · 2.44 KB
/
Copy pathbuild.sh
File metadata and controls
executable file
·102 lines (88 loc) · 2.44 KB
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
101
102
#!/usr/bin/env bash
ME=$0
PROJECT_SRC_DIR=$(cd $(dirname "$ME") && pwd)
BUILD_DIR="$PWD/.build"
VERSION=
# Display Usage
function help() {
cat <<EOS
usage: ${ME} [options]
Build and package the find+ extension.
example:
${ME} -v 1.4.4 -o find/buildpath
options:
-v, --version New extension version number
-o, --output Alternate build directory. Default '.build' in the current working directory
-h, --help Show help and exit
EOS
exit 2
}
function parseargs() {
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-v|--version)
VERSION=$2
shift
shift
;;
-o|--output)
case $2 in
/*) BUILD_DIR="$2" ;;
*) BUILD_DIR="$PWD/$2" ;;
esac
shift
shift
;;
-h|--help)
help
;;
*)
echo "Error: Unknown option $key"
help
;;
esac
done
}
parseargs "$@"
# Check if version number is set
if [ -z "$VERSION" ]; then
echo "Error: missing version number."
help
fi
# Check if zip is installed
if ! command -v zip >/dev/null; then
echo "Error: missing 'zip' utility."
exit 2
fi
# Create build directory structure
echo "$ME: Creating the build directory structure under $BUILD_DIR..."
rm -rf "$BUILD_DIR"
mkdir --parents --verbose "$BUILD_DIR/chr"
mkdir --parents --verbose "$BUILD_DIR/moz"
# Copy project src to build directory
echo "$ME: Copying project source files to build directory..."
for file in "$PROJECT_SRC_DIR/"*
do
[[ $file = $BUILD_DIR ]] && continue
cp -r "$file" "$BUILD_DIR/chr"
cp -r "$file" "$BUILD_DIR/moz"
done
# Update manifest version numbers
echo "$ME: Updating version number in manifest to $VERSION..."
sed -i "s/\"version\": \"1\"/\"version\": \"$VERSION\"/" "$BUILD_DIR/chr/manifest.json"
sed -i "s/\"version\": \"1\"/\"version\": \"$VERSION\"/" "$BUILD_DIR/moz/manifest_firefox.json"
# Package extension for chrome
echo "$ME: Packaging extension for Chrome..."
(
cd "$BUILD_DIR/chr" &&
rm -f "manifest_firefox.json" &&
zip -r "$BUILD_DIR/find-chrome.zip" . ;
)
# Package extension for firefox
echo "$ME: Packaging extension for Firefox..."
(
cd "$BUILD_DIR/moz" &&
mv "manifest_firefox.json" "manifest.json" &&
zip -r "$BUILD_DIR/find-firefox.zip" . ;
)