From 57dd8bc0ac0fa91031ee8efabe6128e514bccfa4 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 6 Dec 2011 22:37:02 -0500 Subject: [PATCH 1/2] Added a default config file. Added an /etc/sbt/sbtopts file that contains defaults. Added a hook to the sbt script to pull in from /etc. Allowed comments in sbtopts configuration. --- project/debian.scala | 2 +- sbt | 10 ++++++-- src/debian/etc/sbt/sbtopts | 49 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 58 insertions(+), 3 deletions(-) create mode 100644 src/debian/etc/sbt/sbtopts diff --git a/project/debian.scala b/project/debian.scala index cdf449ba9..bc41b93a3 100644 --- a/project/debian.scala +++ b/project/debian.scala @@ -84,7 +84,7 @@ object DebianPkg { final val ControlFileContent = """Section: java Priority: optional Architecture: all -Depends: curl, java2-runtime, bash (>= 2.05a-11) +Depends: curl, java2-runtime, bash, sed Recommends: git Maintainer: Josh Suereth Description: Simple Build Tool diff --git a/sbt b/sbt index 8cf9956a8..794707621 100755 --- a/sbt +++ b/sbt @@ -46,6 +46,7 @@ declare -r default_sbt_opts="-XX:+CMSClassUnloadingEnabled" declare -r default_sbt_mem=1536 declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy" declare -r sbt_opts_file=".sbtopts" +declare -r etc_sbt_opts_file="/etc/sbt/sbtopts" declare -r latest_28="2.8.2" declare -r latest_29="2.9.1" declare -r latest_210="2.10.0-SNAPSHOT" @@ -309,8 +310,13 @@ process_args () } } -# if .sbtopts exists, prepend its contents to $@ so it can be processed by this runner -[[ -f "$sbt_opts_file" ]] && set -- $(cat "$sbt_opts_file") "$@" +loadConfigFile() { + cat "$1" | sed '/^\#/d' +} + +# if sbtopts files exist, prepend their contents to $@ so it can be processed by this runner +[[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@" +[[ -f "$sbt_opts_file" ]] && set -- $(loadConfigFile "$sbt_opts_file") "$@" # process the combined args, then reset "$@" to the residuals process_args "$@" diff --git a/src/debian/etc/sbt/sbtopts b/src/debian/etc/sbt/sbtopts new file mode 100644 index 000000000..8373b437c --- /dev/null +++ b/src/debian/etc/sbt/sbtopts @@ -0,0 +1,49 @@ +# ------------------------------------------------ # +# The SBT Configuration file. # +# ------------------------------------------------ # + + +# Disable ANSI color codes +# +#-no-colors + +# Starts sbt even if the current directory contains no sbt project. +# +-sbt-create + +# Path to global settings/plugins directory (default: ~/.sbt) +# +#-sbt-dir /etc/sbt + +# Path to shared boot directory (default: ~/.sbt/boot in 0.11 series) +# +#-sbt-boot ~/.sbt/boot + +# Path to local Ivy repository (default: ~/.ivy2) +# +#-ivy ~/.ivy2 + +# set memory options +# +#-mem + +# Use local caches for projects, no sharing. +# +#-no-share + +# Put SBT in offline mode. +# +#-offline + +# Sets the SBT version to use. +#-sbt-version 0.11.2 + +# Scala version (default: latest release) +# +#-scala-home +#-scala-version + +# java version (default: java from PATH, currently $(java -version |& grep version)) +# +#-java-home + From 7574d35868d1ccbf76ba7e67eba158d00bd0dd91 Mon Sep 17 00:00:00 2001 From: Josh Suereth Date: Tue, 6 Dec 2011 22:52:07 -0500 Subject: [PATCH 2/2] Moved downloads to user-owned dir. Sbt launch jars are now downloaded to ~/.sbt/.lib to ensure that the location is writeable by the user. This could still be a faulty assumption, but we'll try it anyway. --- sbt | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/sbt b/sbt index 794707621..b17417951 100755 --- a/sbt +++ b/sbt @@ -29,6 +29,10 @@ get_mem_opts () { echo "-Xms${mem}m -Xmx${mem}m -XX:MaxPermSize=${perm}m -XX:ReservedCodeCacheSize=${codecache}m" } +is_owned_by_user () { + [[ "$(stat --printf='%U' $1)" == "$(USER)" ]] && { echo "OK" ; return; } +} + die() { echo "Aborting: $@" exit 1 @@ -52,7 +56,11 @@ declare -r latest_29="2.9.1" declare -r latest_210="2.10.0-SNAPSHOT" declare -r script_path=$(get_script_path "$BASH_SOURCE") -declare -r script_dir="$(dirname $script_path)" +if test -z "$HOME"; then + declare -r script_dir="$(dirname $script_path)" +else + declare -r script_dir="$HOME/.sbt" +fi declare -r script_name="$(basename $script_path)" declare java_cmd=java