From a616031ca3be90131161a6823c0cf4102045f70e Mon Sep 17 00:00:00 2001 From: Iulian Dragos Date: Fri, 30 Jun 2017 16:31:28 +0200 Subject: [PATCH 1/9] Read last line of config files without EOL The last line in a configuration file may not have a terminating EOL character. This commit fixes the launcher script to read that line as well. Inspiration: https://stackoverflow.com/questions/10929453/read-a-file-line-by-line-assigning-the-value-to-a-variable --- src/universal/bin/sbt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 8ada3d5f4..6b927348f 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -135,7 +135,8 @@ process_my_args () { } loadConfigFile() { - cat "$1" | sed '/^\#/d' | while read line; do + # Make sure the last line is read even if it doesn't have a terminating \n + cat "$1" | sed '/^\#/d' | while read -r line || [[ -n "$line" ]]; do eval echo $line done } From c487e3166e5decfa2463a1155f216de7de217ee9 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Wed, 26 Jul 2017 14:57:58 +1000 Subject: [PATCH 2/9] Fix java version detection in bash script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `java -version` can include an extra line of output if `_JAVA_OPTTIONS` is set. This commit adds a grep step before sed to harden against this possibility. Before: ``` ⚡ (export _JAVA_OPTIONS=-Dfoo.bar; java -version 2>&1 | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') Picked up _JAVA_OPTIONS: -Dfoo.bar ``` After: ``` ⚡ (export _JAVA_OPTIONS=-Dfoo.bar; java -version 2>&1 | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') 1.8 ``` --- src/universal/bin/sbt-launch-lib.bash | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/universal/bin/sbt-launch-lib.bash b/src/universal/bin/sbt-launch-lib.bash index 59d8af3d6..cd1f6b6ea 100755 --- a/src/universal/bin/sbt-launch-lib.bash +++ b/src/universal/bin/sbt-launch-lib.bash @@ -157,7 +157,7 @@ process_args () { *) addResidual "$1" && shift ;; esac done - + is_function_defined process_my_args && { myargs=("${residual_args[@]}") residual_args=() @@ -165,7 +165,7 @@ process_args () { } ## parses 1.7, 1.8, 9, etc out of java version "1.8.0_91" - java_version=$("$java_cmd" -Xmx512M -version 2>&1 | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') + java_version=$("$java_cmd" -Xmx512M -version 2>&1 | grep ' version "' | sed 's/.*version "\([0-9]*\)\(\.[0-9]*\)\{0,1\}\(.*\)*"/\1\2/; 1q') vlog "[process_args] java_version = '$java_version'" } @@ -265,8 +265,8 @@ run() { ${java_args[@]} \ -jar "$sbt_jar" \ "${sbt_commands[@]}" \ - "${residual_args[@]}" - + "${residual_args[@]}" + exit_code=$? # Clean up the terminal from cygwin hacks. From 38e4fa9b7b536fcc1e03bf2f02c55e461112c497 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 26 Jul 2017 18:00:14 -0400 Subject: [PATCH 3/9] 0.13.16 build id --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index fa874c0da..bed0d58ad 100644 --- a/build.sbt +++ b/build.sbt @@ -87,7 +87,7 @@ val root = (project in file(".")). if (debianBuildId.value == 0) sbtVersionToRelease else sbtVersionToRelease + "." + debianBuildId.value }, - debianBuildId := 3, // 0 + debianBuildId := 0, // 0 // Used to have "openjdk-8-jdk" but that doesn't work on Ubuntu 14.04 https://github.com/sbt/sbt/issues/3105 // before that we had java6-runtime-headless" and that was pulling in JDK9 on Ubuntu 16.04 https://github.com/sbt/sbt/issues/2931 debianPackageDependencies in Debian ++= Seq("bash (>= 3.2)"), @@ -113,7 +113,7 @@ val root = (project in file(".")). }) else stable }, - rpmRelease := "3", + rpmRelease := "0", rpmVendor := "lightbend", rpmUrl := Some("http://github.com/sbt/sbt-launcher-package"), rpmLicense := Some("BSD"), From d6d79bba6c01d64da3fb29fc4cdf149696b497de Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 10 Aug 2017 04:42:57 -0400 Subject: [PATCH 4/9] Fix variable substitution Fixes #173 --- build.sbt | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/build.sbt b/build.sbt index bed0d58ad..663d1a911 100644 --- a/build.sbt +++ b/build.sbt @@ -149,6 +149,27 @@ val root = (project in file(".")). // Universal ZIP download install. packageName in Universal := packageName.value, // needs to be set explicitly due to a bug in native-packager version in Universal := sbtVersionToRelease, + + mappings in Universal := { + val t = (target in Universal).value + val prev = (mappings in Universal).value + prev.toList map { + case (k, "bin/sbt-launch-lib.bash") => + val x = IO.read(k) + IO.write(t / "sbt-launch-lib.bash", x.replaceAllLiterally( + "declare init_sbt_version=_to_be_replaced", + s"""declare init_sbt_version="$sbtVersionToRelease"""")) + (t / "sbt-launch-lib.bash", "bin/sbt-launch-lib.bash") + case (k, "bin/sbt.bat") => + val x = IO.read(k) + IO.write(t / "sbt.bat", x.replaceAllLiterally( + "set INIT_SBT_VERSION=_TO_BE_REPLACED", + s"""set INIT_SBT_VERSION="$sbtVersionToRelease"""")) + (t / "sbt.bat", "bin/sbt.bat") + case (k, v) => (k, v) + } + }, + mappings in Universal ++= { val launchJar = sbtLaunchJar.value val rtExportJar = (packageBin in Compile in java9rtexport).value @@ -162,17 +183,6 @@ val root = (project in file(".")). } else Def.task { Seq[(File, String)]() } }).value, - stage in Universal := { - val old = (stage in Universal).value - val sd = (stagingDirectory in Universal).value - val x = IO.read(sd / "bin" / "sbt-launch-lib.bash") - IO.write(sd / "bin" / "sbt-launch-lib.bash", x.replaceAllLiterally( - "declare init_sbt_version=_to_be_replaced", s"declare init_sbt_version=$sbtVersionToRelease")) - val y = IO.read(sd / "bin" / "sbt.bat") - IO.write(sd / "bin" / "sbt.bat", y.replaceAllLiterally( - "set INIT_SBT_VERSION=_TO_BE_REPLACED", s"set INIT_SBT_VERSION=$sbtVersionToRelease")) - old - }, // Misccelaneous publishing stuff... projectID in Debian := { From 597060b08b0b718fb3a56ecd261a44205ef5cb87 Mon Sep 17 00:00:00 2001 From: eugene yokota Date: Thu, 10 Aug 2017 05:26:03 -0400 Subject: [PATCH 5/9] Fix for building on Windows --- build.sbt | 10 ++++++---- project/plugins.sbt | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/build.sbt b/build.sbt index 663d1a911..22ed2d1d1 100644 --- a/build.sbt +++ b/build.sbt @@ -153,19 +153,21 @@ val root = (project in file(".")). mappings in Universal := { val t = (target in Universal).value val prev = (mappings in Universal).value + val BinBash = "bin" + java.io.File.separator + "sbt-launch-lib.bash" + val BinBat = "bin" + java.io.File.separator + "sbt.bat" prev.toList map { - case (k, "bin/sbt-launch-lib.bash") => + case (k, BinBash) => val x = IO.read(k) IO.write(t / "sbt-launch-lib.bash", x.replaceAllLiterally( "declare init_sbt_version=_to_be_replaced", s"""declare init_sbt_version="$sbtVersionToRelease"""")) - (t / "sbt-launch-lib.bash", "bin/sbt-launch-lib.bash") - case (k, "bin/sbt.bat") => + (t / "sbt-launch-lib.bash", BinBash) + case (k, BinBat) => val x = IO.read(k) IO.write(t / "sbt.bat", x.replaceAllLiterally( "set INIT_SBT_VERSION=_TO_BE_REPLACED", s"""set INIT_SBT_VERSION="$sbtVersionToRelease"""")) - (t / "sbt.bat", "bin/sbt.bat") + (t / "sbt.bat", BinBat) case (k, v) => (k, v) } }, diff --git a/project/plugins.sbt b/project/plugins.sbt index 84b3b6e20..67b671e94 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,4 +1,4 @@ -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.0-M8") +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.0-M9") libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.10" addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0") addSbtPlugin("com.eed3si9n" % "sbt-export-repo" % "0.1.0") From ec086a891a7cc7dc61e099edaf12d43af516db06 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 10 Aug 2017 22:33:19 -0400 Subject: [PATCH 6/9] changelog --- src/debian/changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/debian/changelog b/src/debian/changelog index 835e1fd77..d7947decf 100644 --- a/src/debian/changelog +++ b/src/debian/changelog @@ -1,3 +1,10 @@ +sbt (1.0.0) stable; urgency=low + + * sbt 1.0 uses Scala 2.12 for build definitions and plugins. This also requires JDK 8. + * See http://www.scala-sbt.org/1.x/docs/sbt-1.0-Release-Notes.html for the full list of changes. + + -- Eugene Yokota Fri, 11 Aug 2017 00:00:00 +0000 + sbt (0.13.15) stable; urgency=low * sbt 0.13.15 removes the Maven version range when possible. From 70aceedad7324c1e52954bef1a9b3fed8b8279ee Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 16 Aug 2017 01:08:14 -0400 Subject: [PATCH 7/9] Don't run sbt about as post install. Fixes sbt/sbt#3448 Fixes #176 --- build.sbt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 22ed2d1d1..2a7292432 100644 --- a/build.sbt +++ b/build.sbt @@ -82,12 +82,13 @@ val root = (project in file(".")). if !(link.destination endsWith "sbt-launch.jar") } yield link }, + // DEBIAN SPECIFIC + debianBuildId := 1, version in Debian := { if (debianBuildId.value == 0) sbtVersionToRelease else sbtVersionToRelease + "." + debianBuildId.value }, - debianBuildId := 0, // 0 // Used to have "openjdk-8-jdk" but that doesn't work on Ubuntu 14.04 https://github.com/sbt/sbt/issues/3105 // before that we had java6-runtime-headless" and that was pulling in JDK9 on Ubuntu 16.04 https://github.com/sbt/sbt/issues/2931 debianPackageDependencies in Debian ++= Seq("bash (>= 3.2)"), @@ -100,10 +101,9 @@ val root = (project in file(".")). }, debianChangelog in Debian := { Some(sourceDirectory.value / "debian" / "changelog") }, addPackage(Debian, packageBin in Debian, "deb"), - maintainerScripts in Debian := maintainerScriptsAppend((maintainerScripts in Debian).value)( - Postinst -> s"/usr/share/sbt/bin/sbt about" - ), + // RPM SPECIFIC + rpmRelease := "1", version in Rpm := { val stable0 = (sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty) mkString ".") val stable = if (rpmRelease.value == "0") stable0 @@ -113,7 +113,6 @@ val root = (project in file(".")). }) else stable }, - rpmRelease := "0", rpmVendor := "lightbend", rpmUrl := Some("http://github.com/sbt/sbt-launcher-package"), rpmLicense := Some("BSD"), @@ -123,9 +122,6 @@ val root = (project in file(".")). // https://github.com/elastic/logstash/issues/6275#issuecomment-261359933 rpmRequirements := Seq(), rpmProvides := Seq("sbt"), - maintainerScripts in Rpm := maintainerScriptsAppend((maintainerScripts in Rpm).value)( - RpmConstants.Post -> s"/usr/share/sbt/bin/sbt about" - ), // WINDOWS SPECIFIC windowsBuildId := 0, From 3d194ebdbe75eee8b4abaa53ad1758e1bb808d35 Mon Sep 17 00:00:00 2001 From: Iurii Malchenko Date: Sat, 26 Aug 2017 02:23:26 +0300 Subject: [PATCH 8/9] Use /etc/sbt/sbtopts file if exists. --- src/universal/bin/sbt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/universal/bin/sbt b/src/universal/bin/sbt index 6b927348f..3109a3e2a 100755 --- a/src/universal/bin/sbt +++ b/src/universal/bin/sbt @@ -63,7 +63,8 @@ cygwinpath() { 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="${sbt_home}/conf/sbtopts" +declare -r etc_sbt_opts_file="/etc/sbt/sbtopts" +declare -r dist_sbt_opts_file="${sbt_home}/conf/sbtopts" declare -r win_sbt_opts_file="${sbt_home}/conf/sbtconfig.txt" usage() { @@ -141,6 +142,9 @@ loadConfigFile() { done } +# Here we pull in the default settings configuration. +[[ -f "$dist_sbt_opts_file" ]] && set -- $(loadConfigFile "$dist_sbt_opts_file") "$@" + # Here we pull in the global settings configuration. [[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@" From 9eeb402a1513cde92f33e15197f990b19a4ba011 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Tue, 29 Aug 2017 17:34:24 -0400 Subject: [PATCH 9/9] Reset build number to 0 --- build.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 2a7292432..a0e109a4a 100644 --- a/build.sbt +++ b/build.sbt @@ -84,7 +84,7 @@ val root = (project in file(".")). }, // DEBIAN SPECIFIC - debianBuildId := 1, + debianBuildId := 0, version in Debian := { if (debianBuildId.value == 0) sbtVersionToRelease else sbtVersionToRelease + "." + debianBuildId.value @@ -103,7 +103,7 @@ val root = (project in file(".")). addPackage(Debian, packageBin in Debian, "deb"), // RPM SPECIFIC - rpmRelease := "1", + rpmRelease := "0", version in Rpm := { val stable0 = (sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty) mkString ".") val stable = if (rpmRelease.value == "0") stable0