Skip to content

Commit ac6791b

Browse files
committed
Add sandstorm dir with pkgdeg
1 parent aa82527 commit ac6791b

7 files changed

Lines changed: 198 additions & 1 deletion

File tree

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
.meteor
2-
.sandstorm
32
Vagrantfile
43
build

.sandstorm/build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Make meteor bundle
5+
6+
METEOR_WAREHOUSE_DIR="${METEOR_WAREHOUSE_DIR:-$HOME/.meteor}"
7+
METEOR_DEV_BUNDLE=$(dirname $(readlink -f "$METEOR_WAREHOUSE_DIR/meteor"))/dev_bundle
8+
9+
cd /opt/app
10+
meteor build --directory /home/vagrant/
11+
(cd /home/vagrant/bundle/programs/server && "$METEOR_DEV_BUNDLE/bin/npm" install)
12+
13+
# Copy our launcher script into the bundle so the grain can start up.
14+
mkdir -p /home/vagrant/bundle/opt/app/.sandstorm/
15+
cp /opt/app/.sandstorm/launcher.sh /home/vagrant/bundle/opt/app/.sandstorm/

.sandstorm/global-setup.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
echo localhost > /etc/hostname
4+
hostname localhost
5+
curl https://install.sandstorm.io/ > /host-dot-sandstorm/caches/install.sh
6+
SANDSTORM_CURRENT_VERSION=$(curl -fs "https://install.sandstorm.io/dev?from=0&type=install")
7+
SANDSTORM_PACKAGE="sandstorm-$SANDSTORM_CURRENT_VERSION.tar.xz"
8+
if [[ ! -f /host-dot-sandstorm/caches/$SANDSTORM_PACKAGE ]] ; then
9+
curl --output "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE.partial" "https://dl.sandstorm.io/$SANDSTORM_PACKAGE"
10+
mv "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE.partial" "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE"
11+
fi
12+
bash /host-dot-sandstorm/caches/install.sh -d -e "/host-dot-sandstorm/caches/$SANDSTORM_PACKAGE"
13+
modprobe ip_tables
14+
# Make the vagrant user part of the sandstorm group so that commands like
15+
# `spk dev` work.
16+
usermod -a -G 'sandstorm' 'vagrant'
17+
# Bind to all addresses, so the vagrant port-forward works.
18+
sudo sed --in-place='' \
19+
--expression='s/^BIND_IP=.*/BIND_IP=0.0.0.0/' \
20+
/opt/sandstorm/sandstorm.conf
21+
# TODO: update sandstorm installer script to ask about dev accounts, and
22+
# specify a value for this option in the default config?
23+
if ! grep --quiet --no-messages ALLOW_DEV_ACCOUNTS=true /opt/sandstorm/sandstorm.conf ; then
24+
echo "ALLOW_DEV_ACCOUNTS=true" | sudo tee -a /opt/sandstorm/sandstorm.conf
25+
sudo service sandstorm restart
26+
fi
27+
# Enable apt-cacher-ng proxy to make things faster if one appears to be running on the gateway IP
28+
GATEWAY_IP=$(ip route | grep ^default | cut -d ' ' -f 3)
29+
if nc -z "$GATEWAY_IP" 3142 ; then
30+
echo "Acquire::http::Proxy \"http://$GATEWAY_IP:3142\";" > /etc/apt/apt.conf.d/80httpproxy
31+
fi

.sandstorm/launcher.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
exec node /start.js -p 8000

.sandstorm/sandstorm-pkgdef.capnp

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
@0xb0c9c98147bea6cf;
2+
3+
using Spk = import "/sandstorm/package.capnp";
4+
# This imports:
5+
# $SANDSTORM_HOME/latest/usr/include/sandstorm/package.capnp
6+
# Check out that file to see the full, documented package definition format.
7+
8+
const pkgdef :Spk.PackageDefinition = (
9+
# The package definition. Note that the spk tool looks specifically for the
10+
# "pkgdef" constant.
11+
12+
id = "n4n49dkfyskmhcmg5h0mfzk4kjvce2jcs8ravr7y7uw9xs2pzghh",
13+
# Your app ID is actually its public key. The private key was placed in
14+
# your keyring. All updates must be signed with the same key.
15+
16+
manifest = (
17+
# This manifest is included in your app package to tell Sandstorm
18+
# about your app.
19+
20+
appTitle = (defaultText = "TextEditor"),
21+
22+
appVersion = 0, # Increment this for every release.
23+
24+
appMarketingVersion = (defaultText = "0.0.1"),
25+
# Human-readable representation of appVersion. Should match the way you
26+
# identify versions of your app in documentation and marketing.
27+
28+
actions = [
29+
# Define your "new document" handlers here.
30+
( title = (defaultText = "New Document"),
31+
command = .myCommand
32+
# The command to run when starting for the first time. (".myCommand"
33+
# is just a constant defined at the bottom of the file.)
34+
)
35+
],
36+
37+
continueCommand = .myCommand,
38+
# This is the command called to start your app back up after it has been
39+
# shut down for inactivity. Here we're using the same command as for
40+
# starting a new instance, but you could use different commands for each
41+
# case.
42+
43+
44+
metadata = (
45+
icons = (
46+
appGrid = (svg = embed "../app/icon.svg"),
47+
grain = (svg = embed "../app/icon.svg"),
48+
market = (svg = embed "../app/icon.svg"),
49+
marketBig = (svg = embed "../app/icon.svg"),
50+
),
51+
52+
website = "https://github.com/rchrd2/texteditor",
53+
codeUrl = "https://github.com/rchrd2/texteditor",
54+
license = (openSource = mit),
55+
categories = [office, productivity],
56+
57+
author = (
58+
contactEmail = "me@rchrd.net",
59+
pgpSignature = embed "../app/pgp-signature",
60+
upstreamAuthor = "Richard Caceres",
61+
),
62+
pgpKeyring = embed "../app/pgp-keyring",
63+
64+
description = (defaultText = embed "../app/description.md"),
65+
shortDescription = (defaultText = "Plain text editor"),
66+
67+
screenshots = [
68+
(width = 797, height = 627, png = embed "../app/screenshot-01.png"),
69+
(width = 797, height = 627, png = embed "../app/screenshot-02.png"),
70+
(width = 797, height = 627, png = embed "../app/screenshot-03.png")
71+
],
72+
73+
changeLog = (defaultText = embed "../CHANGELOG.md"),
74+
),
75+
76+
),
77+
78+
sourceMap = (
79+
# The following directories will be copied into your package.
80+
searchPath = [
81+
( sourcePath = "/home/vagrant/bundle" ),
82+
( sourcePath = "/opt/meteor-spk/meteor-spk.deps" )
83+
]
84+
),
85+
86+
alwaysInclude = [ "." ]
87+
# This says that we always want to include all files from the source map.
88+
# (An alternative is to automatically detect dependencies by watching what
89+
# the app opens while running in dev mode. To see what that looks like,
90+
# run `spk init` without the -A option.)
91+
);
92+
93+
const myCommand :Spk.Manifest.Command = (
94+
# Here we define the command used to start up your server.
95+
argv = ["/sandstorm-http-bridge", "8000", "--", "/opt/app/.sandstorm/launcher.sh"],
96+
environ = [
97+
# Note that this defines the *entire* environment seen by your app.
98+
(key = "PATH", value = "/usr/local/bin:/usr/bin:/bin")
99+
]
100+
);

.sandstorm/setup.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
cd /opt/
5+
6+
PACKAGE=meteor-spk-0.1.7
7+
PACKAGE_FILENAME="$PACKAGE.tar.xz"
8+
CACHE_TARGET="/host-dot-sandstorm/caches/${PACKAGE_FILENAME}"
9+
10+
# Fetch meteor-spk tarball if not cached
11+
if [ ! -f "$CACHE_TARGET" ] ; then
12+
curl https://dl.sandstorm.io/${PACKAGE_FILENAME} > "$CACHE_TARGET"
13+
fi
14+
15+
# Extract to /opt
16+
tar xf "$CACHE_TARGET"
17+
18+
# Create symlink so we can rely on the path /opt/meteor-spk
19+
ln -s "${PACKAGE}" meteor-spk
20+
21+
# Add bash, and its dependencies, so they get mapped into the image.
22+
# Bash runs the launcher script.
23+
cp -a /bin/bash /opt/meteor-spk/meteor-spk.deps/bin/
24+
cp -a /lib/x86_64-linux-gnu/libncurses.so.* /opt/meteor-spk/meteor-spk.deps/lib/x86_64-linux-gnu/
25+
cp -a /lib/x86_64-linux-gnu/libtinfo.so.* /opt/meteor-spk/meteor-spk.deps/lib/x86_64-linux-gnu/
26+
27+
# Unfortunately, Meteor does not explicitly make it easy to cache packages, but
28+
# we know experimentally that the package is mostly directly extractable to a
29+
# user's $HOME/.meteor directory.
30+
METEOR_RELEASE=1.1.0.2
31+
METEOR_PLATFORM=os.linux.x86_64
32+
METEOR_TARBALL_FILENAME="meteor-bootstrap-${METEOR_PLATFORM}.tar.gz"
33+
METEOR_TARBALL_URL="https://d3sqy0vbqsdhku.cloudfront.net/packages-bootstrap/${METEOR_RELEASE}/${METEOR_TARBALL_FILENAME}"
34+
METEOR_CACHE_TARGET="/host-dot-sandstorm/caches/${METEOR_TARBALL_FILENAME}"
35+
36+
# Fetch meteor tarball if not cached
37+
if [ ! -f "$METEOR_CACHE_TARGET" ] ; then
38+
curl "$METEOR_TARBALL_URL" > "${METEOR_CACHE_TARGET}.partial"
39+
mv "${METEOR_CACHE_TARGET}"{.partial,}
40+
fi
41+
42+
# Extract as unprivileged user, which is the usual meteor setup
43+
cd /home/vagrant/
44+
su -c "tar xf '${METEOR_CACHE_TARGET}'" vagrant
45+
# Link into global PATH
46+
ln -s /home/vagrant/.meteor/meteor /usr/bin/meteor
47+

.sandstorm/stack

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
meteor

0 commit comments

Comments
 (0)