Skip to content

Commit

Permalink
Update install.sh to default to multi-file on OS X [artifacts]
Browse files Browse the repository at this point in the history
- Default to downloading release at `sgr-osx-x86_64.tgz`
when on OS X. This downloads a tarball of the multi-file
executable creatd with `pyinstaller --onedir`, which means
a directory that includes the `sgr` executable and its
dependencies. This performs better than executables generated
with `--onefile` on OS X.
- Allow overriding and reverting to previous behavior (i.e.,
downloading the single-file executable which is still addressable
at `sgr-osx-x86_64` in the release bundle) with `FORCE_ONEFILE` flag
- Unzip the package to `~/.splitgraph/pkg/sgr` (overwrite if exists),
then symlink `~/.splitgraph/sgr -> ~/.splitgraph/pkg/sgr/sgr`, in
order to keep compatibility with existing scripts
- Note: The self-upgrade (`sgr upgrade`) code might still need
to be changed.
  • Loading branch information
milesrichardson committed Mar 17, 2022
1 parent a705fd9 commit a8ddd1e
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,15 @@ _get_binary_name() {
if [ "$os" == Linux ]; then
BINARY="sgr-linux-x86_64"
elif [ "$os" == Darwin ]; then
BINARY="sgr-osx-x86_64"
if [ -n "$FORCE_ONEFILE" ] ; then
echo "Forcing --onefile installation on OS X because \$FORCE_ONEFILE is set."
BINARY="sgr-osx-x86_64"
else
# OS X has bad single-file executable support (pyinstaller --onefile), so we default to --onedir variant
echo "Installing optimized package for OS X (built with pyinstaller --onedir instead of --onefile)"
echo "To force install single-file executable (not recommended), set FORCE_ONEFILE=1"
BINARY="sgr-osx-x86_64.tgz"
fi
else
_die "This installation method only supported on Linux/OSX. Please see https://www.splitgraph.com/docs/installation/ for other installation methods."
fi
Expand All @@ -81,8 +89,30 @@ _install_binary () {
if [ "$BINARY" == "sgr-osx-x86_64.tgz" ] ; then
echo "Installing the compressed sgr binary and deps from $URL into $INSTALL_DIR"
echo "Installing sgr binary and deps into $INSTALL_DIR/pkg"

if [ -d "$INSTALL_DIR/pkg/sgr" ] ; then
echo "Removing existing $INSTALL_DIR/pkg/sgr"
rm -rf "$INSTALL_DIR/pkg/sgr"
fi

mkdir -p "$INSTALL_DIR/pkg/sgr"

curl -fsL "$URL" > "$INSTALL_DIR/pkg/sgr/sgr.tgz"

echo "Extract sgr binary and deps into $INSTALL_DIR/pkg/sgr (necessary on MacOS)"
(cd "$INSTALL_DIR"/pkg/sgr && tar xfz sgr.tgz && rm sgr.tgz)
echo "Main sgr binary is at $INSTALL_DIR/pkg/sgr/sgr"
echo "Link $INSTALL_DIR/sgr -> $INSTALL_DIR/pkg/sgr/sgr"
ln -fs "$INSTALL_DIR"/pkg/sgr/sgr "$INSTALL_DIR"/sgr
else
echo "Installing the sgr binary from $URL into $INSTALL_DIR"
mkdir -p "$INSTALL_DIR"
curl -fsL "$URL" > "$INSTALL_DIR/sgr"
chmod +x "$INSTALL_DIR/sgr"
fi

"$INSTALL_DIR/sgr" --version && echo "sgr binary installed." && echo && return 0
_die "Installation apparently failed. got non-zero exit code from: $INSTALL_DIR/sgr --version"
}

_setup_engine() {
Expand Down

0 comments on commit a8ddd1e

Please sign in to comment.