Changeset a3a8ee1 for launchers


Ignore:
Timestamp:
May 1, 2018 2:54:36 AM (3 years ago)
Author:
meeh <meeh@…>
Branches:
master
Children:
2d15f8e1
Parents:
4e5a2d00
Message:

Major update for the OSX Launcher code. Now it will bundle
installer resources with the fat jar (we add an exclusion list later)
which the base directory will be built(or updated if lacking files) upon
startup of the I2P router. This is done by the OSXDeployment class which
is an extension for the DeployProfile? class written for Mac OS X.

Since the app bundle itself should be R/O, we use ~/Library/I2P as base path,
and continue using ~/Library/Application? Support/i2p as config path. The BB
code will have other paths.

Location:
launchers
Files:
5 added
4 edited
1 moved

Legend:

Unmodified
Added
Removed
  • launchers/browserbundle/src/main/scala/net/i2p/RouterLauncherApp.scala

    r4e5a2d00 ra3a8ee1  
    33import java.io.{File, InputStream}
    44
     5import net.i2p.launchers.DeployProfile
    56import net.i2p.router.Router
    67import org.json4s._
  • launchers/build.sbt

    r4e5a2d00 ra3a8ee1  
    2121)
    2222
     23lazy val common = (project in file("common"))
     24  .settings(
     25    commonSettings,
     26    name         := "LauncherCommon"
     27  )
    2328
    2429lazy val browserbundle = (project in file("browserbundle"))
     
    2833    assemblyJarName in assembly := s"${name.value}-${version.value}.jar",
    2934    mainClass in assembly := Some("net.i2p.RouterLauncherApp")
    30   )
     35  ).dependsOn(common)
    3136
    3237lazy val macosx = (project in file("macosx"))
     
    3641    assemblyJarName in assembly := s"${name.value}-${version.value}.jar",
    3742    mainClass in assembly := Some("net.i2p.MacOSXRouterLauncherApp")
    38   )
     43  ).dependsOn(common)
    3944
    4045
    4146lazy val root = (project in file("."))
    42   .aggregate(browserbundle, macosx)
     47  .aggregate(common, browserbundle, macosx)
    4348
    4449scalacOptions in Compile := Seq("-deprecated")
  • launchers/common/src/main/scala/net/i2p/launchers/DeployProfile.scala

    r4e5a2d00 ra3a8ee1  
    1 package net.i2p
     1package net.i2p.launchers
    22
    33import java.io.{File, InputStream}
    4 /**
    5   *
    6   * The purpose of this class is to copy files from the i2p "default config" directory
    7   * and to a "current config" directory relative to the browser bundle.
    8   *
    9   * @author Meeh
    10   * @version 0.0.1
    11   * @since 0.9.35
    12   */
    13 class DeployProfile(confDir: String, baseDir: String) {
    14   import java.nio.file.{Paths, Files}
    15   import java.nio.charset.StandardCharsets
    164
     5
     6object DeployProfile {
    177
    188  /**
     
    2616    */
    2717  def pathJoin(parent:String,child:String): String = new File(new File(parent), child).getPath
     18}
     19
     20/**
     21  *
     22  * The purpose of this class is to copy files from the i2p "default config" directory
     23  * and to a "current config" directory relative to the browser bundle - but this class is
     24  * also used by the OSX launcher since it shares common properties like that the bundle has
     25  * to be read only.
     26  *
     27  * @author Meeh
     28  * @version 0.0.1
     29  * @since 0.9.35
     30  */
     31class DeployProfile(val confDir: String, val baseDir: String) {
     32  import java.nio.file.{Files, Paths}
    2833
    2934  /**
     
    3641  def copyFileResToDisk(fStr: String) = Files.copy(
    3742    getClass.getResource("/".concat(fStr)).getContent.asInstanceOf[InputStream],
    38     Paths.get(pathJoin(confDir, fStr)).normalize()
     43    Paths.get(DeployProfile.pathJoin(confDir, fStr)).normalize()
     44  )
     45
     46
     47  /**
     48    * This function copies resources from the fatjar to the config directory of i2p.
     49    *
     50    * @since 0.9.35
     51    * @param path
     52    * @param is
     53    * @return Unit
     54    */
     55  def copyBaseFileResToDisk(path: String, is: InputStream) = Files.copy(
     56    is,
     57    Paths.get(DeployProfile.pathJoin(baseDir, path)).normalize()
    3958  )
    4059
  • launchers/macosx/build.sbt

    r4e5a2d00 ra3a8ee1  
    1010lazy val bundleBuildPath = file("./output")
    1111
     12lazy val staticFiles = List(
     13  "blocklist.txt",
     14  "clients.config",
     15  "continents.txt",
     16  "countries.txt",
     17  "hosts.txt",
     18  "geoip.txt",
     19  "router.config",
     20  "webapps.config"
     21)
    1222
    1323// Pointing the resources directory to the "installer" directory
     
    3444  paths.map { case (s,p) => p.mkdirs() }
    3545  val dirsToCopy = List("certificates","locale","man")
     46
     47  /**
     48    *
     49    * First of, if "map" is unknown for you - shame on you :p
     50    *
     51    * It's a loop basically where it loops through a list/array
     52    * with the current indexed item as subject.
     53    *
     54    * The code bellow takes the different lists and
     55    * copy all the directories or files from the i2p.i2p build dir,
     56    * and into the bundle so the launcher will know where to find i2p.
     57    *
     58    */
    3659  dirsToCopy.map { d => IO.copyDirectory( new File(resDir, d), new File(paths.get("i2pbaseBunldePath").get, d) ) }
    3760  warsForCopy.map { w => IO.copyFile( new File(i2pBuildDir, w), new File(paths.get("webappsBunldePath").get, w) ) }
     
    5477
    5578
    56 assemblyOption in assembly := (assemblyOption in assembly).value.copy(prependShellScript = Some(defaultShellScript))
     79//assemblyOption in assembly := (assemblyOption in assembly).value.copy(prependShellScript = Some(defaultShellScript))
    5780
    5881assemblyJarName in assembly := s"${name.value}-${version.value}"
  • launchers/macosx/src/main/scala/net/i2p/MacOSXRouterLauncherApp.scala

    r4e5a2d00 ra3a8ee1  
    22
    33import net.i2p.router.Router
     4import net.i2p.launchers.OSXDeployment
    45import java.io.File
    56
     
    3637  val i2pBaseBundleDir = new File(new File("."), "../Resources/i2pbase")
    3738
     39  new OSXDeployment()
     40
    3841  Router.main(args)
    3942}
Note: See TracChangeset for help on using the changeset viewer.