-
Notifications
You must be signed in to change notification settings - Fork 30
/
find-meteor-dev-bundle.sh
executable file
·61 lines (50 loc) · 2.57 KB
/
find-meteor-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
#! /bin/bash
#
# Sandstorm - Personal Cloud Sandbox
# Copyright (c) 2014 Sandstorm Development Group, Inc. and contributors
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script attempts to find Meteor's "dev bundle", which contains the node
# and mongo binaries and headers, so that we can borrow them rather than making
# users install them separately.
#
# Currently this script is not quite right. It tries to find the most-recent
# bundle, but we should probably take the bundle matching the Meteor version
# that Sandstorm is currently using. Moreover, it appears that this script's
# technique sometimes ends up with an *older* bundle than the most-recent, I
# guess because Meteor is sometimes lazy about updating the main `meteor`
# command's symlink. I have not yet deciphered enough about the Meteor
# warehouse's layout to figure out how to map directly from a version to a
# dev bundle.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
METEOR_WAREHOUSE_DIR="${METEOR_WAREHOUSE_DIR:-$HOME/.meteor}"
echo -n "Finding meteor-tool installation (can take a few seconds)..." >&2
# If we run the meteor tool outside of `app`, it might try to update itself. Inside `app`, it
# sees the meteor version we're using and sticks to that.
cd "$SCRIPT_DIR/app"
METEOR_RELEASE=$(<.meteor/release)
if [ "$METEOR_RELEASE" = "[email protected]" ]; then
# Some time after 1.0.2, the output format of `meteor show` changed and the --ejson flag was
# added. But as of this writing we're still at 1.0.2, so parse the old output format.
TOOL_VERSION=$(meteor show "$METEOR_RELEASE" | grep -o 'meteor-tool@[0-9a-zA-Z_.-]*')
else
# TODO(cleanup): It would be nice to use a real JSON parser here, but I don't particularly want
# to depend on one, nor do I want to depend on Node being installed.
TOOL_VERSION=$(meteor show --ejson $METEOR_RELEASE | grep '^ *"tool":' |
sed -re 's/^.*"(meteor-tool@[^"]*)".*$/\1/g')
fi
TOOLDIR=$(echo $TOOL_VERSION | tr @ /)
echo " $TOOL_VERSION" >&2
readlink -f $METEOR_WAREHOUSE_DIR/packages/$TOOLDIR/mt-os.linux.x86_64/dev_bundle