Permalink
Browse files

sm-installer

  • Loading branch information...
1 parent 5c3814e commit 785ac7eaa1b120a3643d53f06124e12e09554e65 @mpapis mpapis committed Apr 25, 2012
Showing with 102 additions and 28 deletions.
  1. +75 −0 bin/sm-installer
  2. +3 −3 core/install/shell/functions
  3. +24 −25 install
View
@@ -0,0 +1,75 @@
+#!/usr/bin/env sh
+
+platform=` uname -i 2>/dev/null || uname -s `
+
+case $platform in
+ (Darwin|i386|x86_64)
+ true
+ ;;
+ (*)
+ echo "Unsupported platform: $platform."
+ exit 1
+ ;;
+esac
+
+params=()
+while test $# -gt 0
+do
+ case "${1:-}" in
+ (--from)
+ sm_owner=${2:-}
+ shift 2
+ ;;
+ (--path)
+ sm_path=${2:-}
+ shift 2
+ ;;
+ (*)
+ params+=( "$1" )
+ shift
+ ;;
+ esac
+done
+
+if test -z "${sm_curl_command:-}"
+then
+ if builtin command -v curl >/dev/null
+ then sm_curl_command=curl
+ else
+ echo "Could not find curl, please install and try again."
+ exit 2
+ fi
+fi
+
+if test -z "${sm_tar_command:-}"
+then
+ if builtin command -v gtar >/dev/null
+ then sm_tar_command=gtar
+ elif builtin command -v tar >/dev/null
+ then sm_tar_command=tar
+ else
+ echo "Could not find tar, please install and try again."
+ exit 3
+ fi
+fi
+
+if test -z "${sm_path:-}"
+then
+ if test ${UID:-0} -eq 0
+ then sm_path=/opt/sm
+ else sm_path="${HOME:-}/.sm"
+ fi
+fi
+true sm_owner:${sm_owner:=sm}:
+
+rm -rf "${sm_path}/src/${sm_owner}-sm"
+mkdir -p "${sm_path}/archives" "${sm_path}/bin" "${sm_path}/src/${sm_owner}-sm"
+
+${sm_curl_command} https://smf.sh/zsh/$platform/zsh -o "${sm_path}/bin/sm-zsh"
+chmod +x "${sm_path}/bin/sm-zsh"
+${sm_curl_command} -L https://github.com/${sm_owner}/sm/tarball/master -o "${sm_path}/archives/${sm_owner}-sm.tar.gz"
+builtin cd "${sm_path}/src/${sm_owner}-sm"
+${sm_tar_command} xzf "${sm_path}/archives/${sm_owner}-sm.tar.gz"
+mv ${sm_owner}-sm-*/* .
+rm -rf ${sm_owner}-sm-*
+"${sm_path}/bin/sm-zsh" ./install --zsh "${sm_path}/bin/sm-zsh" "${params[@]}"
@@ -191,12 +191,12 @@ make_binaries_executable()
set_binaries_shell()
{
typeset _binary
- for _binary in sm smp
+ for _binary in local bin/sm bin/smp
do
file replace \
regex "^#!.*$" \
- with "#!/usr/bin/env zsh" \
- in "${install_path}/bin/${_binary}"
+ with "#!${sm_shell:-/usr/bin/env zsh}" \
+ in "${install_path}/${_binary}"
done
}
View
49 install
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env zsh
extension_args=()
@@ -10,49 +10,46 @@ fi
while (( $# ))
do
- token="$1" && shift
- case "$token" in
+ case "$1" in
(--trace|trace)
extension_args+=("--trace=all")
+ shift
;;
(--verbose=*)
extension_args+=("--verbose")
+ shift
;;
(--prefix=*)
- prefix_path="${token/*\=}"
+ prefix_path="${1/*\=}"
+ shift
;;
- (shell)
- case "$1" in
- (bash|zsh)
- export sm_shell="$1"
- shift
- ;;
- (*)
- echo "Shell '$1' is not allowed; Shell must be one of {bash,zsh}"
- ;;
- esac
+ (--zsh|--shell)
+ export sm_shell="$2"
+ shift 2
;;
(--prefix|prefix)
- prefix_path="$1"
- if ! shift
+ prefix_path="$2"
+ if ! shift 2
then
echo "ERROR: A prefix path must be followed by keyword 'prefix'."
exit 1
fi
;;
(DESTROOT=)
- DESTROOT="${token/*\=}"
+ DESTROOT="${1/*\=}"
+ shift
;;
(DESTROOT)
- DESTROOT="$1"
- if ! shift
+ DESTROOT="$2"
+ if ! shift 2
then
echo "ERROR: A DESTROOT path must be followed by keyword 'DESTROOT'."
exit 1
fi
;;
(*)
- extension_args+=("$token")
+ extension_args+=("$1")
+ shift
;;
esac
done
@@ -72,15 +69,17 @@ then
fi
# set BDSM basic paths
+export sm_path install_path archives_path scm_path src_path sets_user_path DESTROOT
install_path="${sm_path}" # Path to install everything to.
archives_path="${sm_path}/archives"
scm_path="${sm_path}/scm"
src_path="${sm_path}/src"
sets_user_path="${sm_path}/sets"
exts_user_path="${sm_path}/exts"
-export sm_path install_path archives_path scm_path src_path \
- sets_user_path DESTROOT
-
-exec "${PWD}/local" --call=install/install_sm "${extension_args[@]}"
-
+if [[ -n "${sm_shell:-}" ]]
+then
+ exec "${sm_shell}" "${PWD}/local" --call=install/install_sm "${extension_args[@]}"
+else
+ exec "${PWD}/local" --call=install/install_sm "${extension_args[@]}"
+fi

0 comments on commit 785ac7e

Please sign in to comment.