forked from meteor/meteor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-dev-bundle.sh
executable file
·179 lines (145 loc) · 5.78 KB
/
generate-dev-bundle.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
#!/bin/bash
set -e
set -u
# Read the bundle version from the meteor shell script.
BUNDLE_VERSION=$(perl -ne 'print $1 if /BUNDLE_VERSION=(\S+)/' meteor)
if [ -z "$BUNDLE_VERSION" ]; then
echo "BUNDLE_VERSION not found"
exit 1
fi
source "$(dirname $0)/build-dev-bundle-common.sh"
echo CHECKOUT DIR IS "$CHECKOUT_DIR"
echo BUILDING DEV BUNDLE "$BUNDLE_VERSION" IN "$DIR"
# ios-sim is used to run iPhone simulator from the command-line. Doesn't make
# sense to build it for linux.
if [ "$OS" == "osx" ]; then
# the build from source is not going to work on old OS X versions, until we
# upgrade our Mac OS X Jenkins machine, download the precompiled tarball
# which rake # rake is required to build ios-sim
# git clone https://github.com/phonegap/ios-sim.git
# cd ios-sim
# git checkout 2.0.1
# rake build
# which build/Release/ios-sim # check that we have in fact got the binary
# mkdir -p "$DIR/lib/ios-sim"
# cp -r build/Release/* "$DIR/lib/ios-sim/"
# Download the precompiled tarball
# See docs on building the new ios_sim: https://mdg.hackpad.com/Building-ios-sim-tarball-9aHVf0rGcwE
IOS_SIM_URL="http://android-bundle.s3.amazonaws.com/ios-sim.mavericks.xcode6.tgz"
curl "$IOS_SIM_URL" | tar xfz -
mkdir -p "$DIR/lib/ios-sim"
cp -r ios-sim/ios-sim "$DIR/lib/ios-sim"
fi
cd "$DIR"
S3_HOST="s3.amazonaws.com/com.meteor.jenkins"
# Update these values after building the dev-bundle-node Jenkins project.
# Also make sure to update NODE_VERSION in generate-dev-bundle.ps1.
NODE_VERSION=0.10.36
NODE_BUILD_NUMBER=13
NODE_TGZ="node_${PLATFORM}_v${NODE_VERSION}.tar.gz"
if [ -f "${CHECKOUT_DIR}/${NODE_TGZ}" ] ; then
tar zxf "${CHECKOUT_DIR}/${NODE_TGZ}"
else
NODE_URL="https://${S3_HOST}/dev-bundle-node-${NODE_BUILD_NUMBER}/${NODE_TGZ}"
echo "Downloading Node from ${NODE_URL}"
curl "${NODE_URL}" | tar zx
fi
# Update these values after building the dev-bundle-mongo Jenkins project.
# Also make sure to update MONGO_VERSION in generate-dev-bundle.ps1.
MONGO_VERSION=2.6.7
MONGO_BUILD_NUMBER=6
MONGO_TGZ="mongo_${PLATFORM}_v${MONGO_VERSION}.tar.gz"
if [ -f "${CHECKOUT_DIR}/${MONGO_TGZ}" ] ; then
tar zxf "${CHECKOUT_DIR}/${MONGO_TGZ}"
else
MONGO_URL="https://${S3_HOST}/dev-bundle-mongo-${MONGO_BUILD_NUMBER}/${MONGO_TGZ}"
echo "Downloading Mongo from ${MONGO_URL}"
curl "${MONGO_URL}" | tar zx
fi
cd "$DIR/build"
# export path so we use our new node for later builds
export PATH="$DIR/bin:$PATH"
which node
which npm
# When adding new node modules (or any software) to the dev bundle,
# remember to update LICENSE.txt! Also note that we include all the
# packages that these depend on, so watch out for new dependencies when
# you update version numbers.
# First, we install the modules that are dependencies of tools/server/boot.js:
# the modules that users of 'meteor bundle' will also have to install. We save a
# shrinkwrap file with it, too. We do this in a separate place from
# $DIR/server-lib/node_modules originally, because otherwise 'npm shrinkwrap'
# will get confused by the pre-existing modules.
mkdir "${DIR}/build/npm-server-install"
cd "${DIR}/build/npm-server-install"
node "${CHECKOUT_DIR}/scripts/dev-bundle-server-package.js" >package.json
npm install
npm shrinkwrap
mkdir -p "${DIR}/server-lib/node_modules"
# This ignores the stuff in node_modules/.bin, but that's OK.
cp -R node_modules/* "${DIR}/server-lib/node_modules/"
mkdir "${DIR}/etc"
mv package.json npm-shrinkwrap.json "${DIR}/etc/"
# Fibers ships with compiled versions of its C code for a dozen platforms. This
# bloats our dev bundle. Remove all the ones other than our
# architecture. (Expression based on build.js in fibers source.)
shrink_fibers () {
FIBERS_ARCH=$(node -p -e 'process.platform + "-" + process.arch + "-v8-" + /[0-9]+\.[0-9]+/.exec(process.versions.v8)[0]')
mv $FIBERS_ARCH ..
rm -rf *
mv ../$FIBERS_ARCH .
}
cd "$DIR/server-lib/node_modules/fibers/bin"
shrink_fibers
# Now, install the npm modules which are the dependencies of the command-line
# tool.
mkdir "${DIR}/build/npm-tool-install"
cd "${DIR}/build/npm-tool-install"
node "${CHECKOUT_DIR}/scripts/dev-bundle-tool-package.js" >package.json
npm install
# Refactor node modules to top level and remove unnecessary duplicates.
npm dedupe
cp -R node_modules/* "${DIR}/lib/node_modules/"
cd "${DIR}/lib"
# Clean up some bulky stuff.
cd node_modules
# Used to delete bulky subtrees. It's an error (unlike with rm -rf) if they
# don't exist, because that might mean it moved somewhere else and we should
# update the delete line.
delete () {
if [ ! -e "$1" ]; then
echo "Missing (moved?): $1"
exit 1
fi
rm -rf "$1"
}
delete browserstack-webdriver/docs
delete browserstack-webdriver/lib/test
delete sqlite3/deps
delete wordwrap/test
delete moment/min
# dedupe isn't good enough to eliminate 3 copies of esprima, sigh.
find . -path '*/esprima/test' | xargs rm -rf
find . -path '*/esprima-fb/test' | xargs rm -rf
# dedupe isn't good enough to eliminate 4 copies of JSONstream, sigh.
find . -path '*/JSONStream/test/fixtures' | xargs rm -rf
# Not sure why dedupe doesn't lift these to the top.
pushd cordova/node_modules/cordova-lib/node_modules/cordova-js/node_modules/browserify/node_modules
delete crypto-browserify/test
delete umd/node_modules/ruglify/test
popd
cd "$DIR/lib/node_modules/fibers/bin"
shrink_fibers
# Download BrowserStackLocal binary.
BROWSER_STACK_LOCAL_URL="https://browserstack-binaries.s3.amazonaws.com/BrowserStackLocal-07-03-14-$OS-$ARCH.gz"
cd "$DIR/build"
curl -O $BROWSER_STACK_LOCAL_URL
gunzip BrowserStackLocal*
mv BrowserStackLocal* BrowserStackLocal
mv BrowserStackLocal "$DIR/bin/"
echo BUNDLING
cd "$DIR"
echo "${BUNDLE_VERSION}" > .bundle_version.txt
rm -rf build
tar czf "${CHECKOUT_DIR}/dev_bundle_${PLATFORM}_${BUNDLE_VERSION}.tar.gz" .
echo DONE