Still WIP, but I've added a new sbt plugin named

sbt-native-packager for future rpm/deb/windows and 
maybe even OSX packages. Also, the macosx sbt project 
now has a task named buildAppBundleTask and which will 
produce an I2P.app and copy over needed directories/jars/wars
which later needs to be extracted to an writeable area which
would be i2p base directory in runtime.

The MacOSXRouterLauncherApp contains more information about how 
the executable in the OS X bundle will locate our R/O i2pbase so 
it can copy it to a writable area. The R/O is also to ensure valid
signature on the bundle.

At last, this approach is done casue letting an Mach-O binary load
libjvm.dylib was proved unstable, so MacOSXRouterLauncherApp will 
rather use an JNI module to load the needed glue with the 
Mac OS X system.
This commit is contained in:
meeh
2018-04-24 04:18:21 +00:00
parent 9307b27655
commit 8adf55a568
5 changed files with 53 additions and 7 deletions

View File

@@ -1,4 +1,6 @@
import sbt.Keys._
import sbt._
import Keys._
resolvers ++= Seq(
DefaultMavenRepository,
@@ -11,7 +13,10 @@ resolvers ++= Seq(
lazy val commonSettings = Seq(
organization := "net.i2p",
scalaVersion := "2.11.11", // We have to use Scala 11 as long as we're going to support JRE 1.7
version := "0.1.0-SNAPSHOT"
version := "0.1.0-SNAPSHOT",
maintainer := "Meeh <mikalv@mikalv.net>",
packageSummary := "The Invisible Internet Project",
packageDescription := "Blabla"
)
@@ -26,7 +31,7 @@ lazy val browserbundle = (project in file("browserbundle"))
lazy val macosx = (project in file("macosx"))
.settings(
commonSettings,
name := "RouterLaunchApp",
name := "MacI2PLauncher",
assemblyJarName in assembly := s"${name.value}-${version.value}.jar",
mainClass in assembly := Some("net.i2p.MacOSXRouterLauncherApp")
)
@@ -36,8 +41,6 @@ lazy val root = (project in file("."))
.aggregate(browserbundle, macosx)
fork := true
run / javaOptions += "-Xmx512M"

View File

@@ -1,7 +1,39 @@
import sbtassembly.AssemblyPlugin.defaultShellScript
import sbt._
import Keys._
import sbt.io.IO
import java.io.File
lazy val i2pVersion = "0.9.34"
lazy val buildAppBundleTask = taskKey[Unit](s"Build an Mac OS X bundle for I2P ${i2pVersion}.")
lazy val bundleBuildPath = file("./output")
// Pointing the resources directory to the "installer" directory
resourceDirectory in Compile := baseDirectory.value / ".." / ".." / "installer" / "resources"
lazy val resDir = new File("./../installer/resources")
lazy val i2pBuildDir = new File("./../build")
lazy val warsForCopy = i2pBuildDir.list.filter { f => f.endsWith(".war") }
lazy val jarsForCopy = i2pBuildDir.list.filter { f => f.endsWith(".jar") }
buildAppBundleTask := {
println(s"Building Mac OS X bundle for I2P version ${i2pVersion}.")
bundleBuildPath.mkdir()
val paths = Map[String,File](
"execBundlePath" -> new File(bundleBuildPath, "I2P.app/Contents/MacOS"),
"resBundlePath" -> new File(bundleBuildPath, "I2P.app/Contents/Resources"),
"i2pbaseBunldePath" -> new File(bundleBuildPath, "I2P.app/Contents/Resources/i2pbase"),
"i2pJarsBunldePath" -> new File(bundleBuildPath, "I2P.app/Contents/Resources/i2pbase/lib"),
"webappsBunldePath" -> new File(bundleBuildPath, "I2P.app/Contents/Resources/i2pbase/webapps")
)
paths.map { case (s,p) => p.mkdirs() }
val dirsToCopy = List("certificates","locale","man")
dirsToCopy.map { d => IO.copyDirectory( new File(resDir, d), new File(paths.get("i2pbaseBunldePath").get, d) ) }
warsForCopy.map { w => IO.copyFile( new File(i2pBuildDir, w), new File(paths.get("webappsBunldePath").get, w) ) }
warsForCopy.map { j => IO.copyFile( new File(i2pBuildDir, j), new File(paths.get("i2pJarsBunldePath").get, j) ) }
}
// Unmanaged classpath will be available at compile time
unmanagedClasspath in Compile ++= Seq(
baseDirectory.value / ".." / ".." / "build" / "*.jar",

View File

@@ -1,6 +1,7 @@
package net.i2p
import net.i2p.router.Router
import java.io.File
/**
*
@@ -17,12 +18,22 @@ import net.i2p.router.Router
* var is mutable
*
*
* The i2p base directory in the build should be in a relative path from
* the launcher, which would be ../Resources/i2pbase - this directory would
* need to be copied out to a "writable" area, since we're in a signed "immutable"
* bundle. First this launcher will check if i2pbase is already deployed to a
* writable area, if it's not, it deploys, if the i2pbase directory has an older
* version than the one in the bundle, it upgrades. It does nothing if versions
* matches.
*
*
* @author Meeh
* @version 0.0.1
* @since 0.9.35
*/
object MacOSXRouterLauncherApp extends App {
val i2pBaseBundleDir = new File(new File("."), "../Resources/i2pbase")
Router.main(args)
}

View File

@@ -1 +1 @@
sbt.version=1.1.1
sbt.version=1.1.2

View File

@@ -1,4 +1,4 @@
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.1")
addSbtPlugin("com.oradian.sbt" % "sbt-sh" % "0.3.0")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.4")