Git Product home page Git Product logo

sbt / sbt-native-packager Goto Github PK

View Code? Open in Web Editor NEW
1.6K 52.0 438.0 17.3 MB

sbt Native Packager

Home Page: https://sbt-native-packager.readthedocs.io/en/stable/

License: BSD 2-Clause "Simplified" License

Scala 94.36% Shell 3.68% Makefile 0.01% CSS 0.01% Python 1.59% HTML 0.09% JavaScript 0.02% C 0.01% Roff 0.05% Dockerfile 0.01% Java 0.19%
sbt scala native-packages sbt-docker sbt-plugin docker rpm deb

sbt-native-packager's Introduction

CI Latest version Discord

sbt

sbt is a build tool for Scala, Java, and more.

For general documentation, see https://www.scala-sbt.org/.

sbt 1.x

This is the 1.x series of sbt. The source code of sbt is split across several GitHub repositories, including this one.

  • sbt/io hosts sbt.io module.
  • sbt/librarymanagement hosts sbt.librarymanagement module that wraps Ivy.
  • sbt/zinc hosts Zinc, an incremental compiler for Scala.
  • sbt/sbt, this repository hosts modules that implements the build tool.

Other links

  • Setup: Describes getting started with the latest binary release.
  • FAQ: Explains how to get help and more.
  • sbt/sbt-zero-seven: hosts sbt 0.7.7 and earlier versions

Issues and Pull Requests

Please read CONTRIBUTING carefully before opening a GitHub Issue.

The short version: try searching or asking on StackOverflow.

license

See LICENSE.

sbt-native-packager's People

Contributors

antonini avatar aparkinson avatar artempyanykh avatar dhardy92 avatar dwhjames avatar dwickern avatar eed3si9n avatar ezzarghili avatar fiadliel avatar fsat avatar huntc avatar ivanfrain avatar jan0sch avatar jkutner avatar jroper avatar jsuereth avatar kardapoltsev avatar mhamrah avatar mkurz avatar muuki88 avatar myyk avatar nazoking avatar nequissimus avatar nigredo-tori avatar rfranco avatar scalawilliam avatar sethtisue avatar spigene avatar xuwei-k avatar yanns avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sbt-native-packager's Issues

failed to create symbolic link

I'm using the java_server archetype.

The debian:packageBin task creates a symlink in /usr/bin pointing to the final target file.

This link is invalid when created in the staging directory and becomes valid once installed on the system.

After having run the debian:packageBin task once, it fails on subsequent calls with

ln: failed to create symbolic link `repo-service': File exists

The check at https://github.com/sbt/sbt-native-packager/blob/master/src/main/scala/com/typesafe/sbt/packager/linux/LinuxPackageMapping.scala#L74 is wrong, because File.exists returns false for broken symlinks.

Using "ln -f -s" should fix this.

RPM build fails on Kubuntu 11.04

When attempting to build an RPM release I get the following error output

[error] + umask 022
[error] + cd /home/me/development/project/target/rpm/BUILD
[error] + [ -e /home/me/development/project/target/rpm/buildroot ]
[error] + mv /home/me/development/project/target/rpm/tmp-buildroot/* /home/me/development/project/target/rpm/buildroot
[error] mv: cannot stat `/home/me/development/project/target/rpm/tmp-buildroot/*': No such file or directory

The rpmbuild command used is

Executing rpmbuild with: rpmbuild -bb --buildroot /home/me/development/project/target/rpm/buildroot --define _topdir /home/me/development/project/target/rpm --target noarch-us-Linux project.spec

and the generated spec file is:

Name: Project
Version: 1.0.0
Release: 1
Summary: Provides a capability to run Stuff
License: Ours
Vendor: Us
URL: http://git/gitweb/project.git
Requires: java-1.6.0-openjdk
BuildRoot: /home/me/development/project/target/rpm/buildroot

%description



%install
if [ -e $RPM_BUILD_ROOT ]; then
  mv /home/me/development/project/target/rpm/tmp-buildroot/* $RPM_BUILD_ROOT
else
  mv /home/me/development/project/target/rpm/tmp-buildroot $RPM_BUILD_ROOT
fi

%files
%attr(0644,root,root) /usr/share/lib/project/mylibrary.jar

I have rpm and rpmbuild available on my system.

exec $java_cmd vs simple $java_cmd in bash script

If we'll able to set it in configs (e.g. fork in run) then it'll be possible to use bash script in java_server_application in /etc/init.d/ script to start the app. No the problem is in the pid of java process, which is used in start-stop-daemon.

What do you think about it?
In bash template:

${{exec_cmd}} "$java_cmd" 

And in bash script replacements smth like this:

replacements ++= Seq("exec_cmd" -> (if(fork) "exec" else ""))

Directories in packageMapping

Currently it's not possible just to specify a single dir in packageMapping, one has to recursively go through its contents. The following code does not work as expected:

linuxPackageMappings <+= target map { target =>
  val src = target / "webapp"
  val dest = "/opt/app"
  packageMapping(src -> dest)
}

A way of dealing with it on the client side:

linuxPackageMappings <+= target map { target =>
  val src = target / "webapp"
  val dest = "/opt/app"
  LinuxPackageMapping(
    for {
      path <- (src ***).get
      if !path.isDirectory
    } yield path -> path.toString.replaceFirst(src.toString, dest)
  )
}

It would be nice to have this functionality on the library side for consistent and expected behavior.

Change sourceDirectory and/or stageDirectory in Universal from Settings to Tasks

Some context first :

In my SBT build, I need to repackage a bundle, previously built with sbt-native-packager by another build and published in my Ivy repo, in order to add some files in it.
This means that I need to :

  • Fetch the bundle from the repo
  • Unzip it
  • Use the unzipped bundle as a source directory for sbt-native-packager

The first two steps have to be done in a task, as I can't expect that the bundle has been already fetched when the project loads.

However, this means that sourceDirectory or stagingDirectory in Universal must be tasks, as settings can't depend on tasks...

Would it be possible to change those (or one of those) two settings to tasks ? Looking at the code of UniversalPlugin, it seems that the impact would be minimal.
In my case, changing stagingDirectory to a task would be sufficient : the structure is already there, so the unzipped bundle would be a perfectly fine staging directory.
I can submit a PR if you like :)

Debian postinst/preinst

I've started looking at sbt-native-packager and couldn't figure out how to add a postinst script to my packages. Is it possible to do at the moment?

Thanks in advance!

Duplicate entries in zip

The scriptClasspathOrdering config in JavaAppPackaging.settings adds the projects binary to the config, regardless of whether it's already there or not. The comment there suggests that there is a reason for this. That's ok, but the result is that for zip packaging for example, you end up with the binary packaged twice, and then when you unzip, the Linux unzip command stops on the second entry and prompts you to ask whether you want to overwrite it or not. Either the scriptClasspathOrdering should be fixed, or when it's added to mappings, distinct needs to be called on it.

Linux unfriendly default naming

Hi,

I'm currently working on this issue to integrate the default scripts for play with the sbt-native-packager.

I found out that the UniversalPlugin.scala defines the folder name a bit strange. name-version.

I would prefer normalizedName-version as there are all special characters erased.

Add unit to comment describing memory integer

This is output in my play start script:

-mem set memory options (default: $sbt_mem, which is $(get_mem_opts $sbt_mem))

It would be nice to say "set memory in MB" instead of "set memory options"

rpm and directories

For RPMs its important to specify all of the directories that come along with the package; i.e., /opt/trafficland/project, so proper user:group ownership is created and also for when the RPM is removed the directories which were created during installation are removed as well.

Specifying /opt/trafficland/project/lib/file.jar is not enough, /opt/trafficland/project, /opt/trafficland/project/lib should also be specified.

I can get around this limitation now by using the following hack:

packageMapping(IO.temporaryDirectory / "." -> "/opt/trafficland/project") withUser "tluser" withGroup "tlgroup" withPerms "0755"

(Likewise for each subdirectory, such as lib, bin, conf, etc. the RPM deploys files into.)

Having a cleaner packageDirectory for initially empty directories and specifically to satisfy clean RPMs would be better solution than the hack above.

ZIP file names do not extract correctly if ZIP is created on Windows and unzipped on Linux

When a ZIP is created on a Windows platform which passes in file names created from File.getPath, the directory separators used are Windows backslash. The ZIP entry then creates the filename with these backslashes. Unzipping on a Linux based system unzips these files with the filename including the directory name, ie;
share\doc\api\views\html\commands\index$.html
Is the filename.

Similar to IO.scala in sbt, the file names need to be normalized such that if the separatorChar is '' then they need to be replaced with '/'

Uninformative exception when `head` called on empty list

https://github.com/sbt/sbt-native-packager/blob/master/src/main/scala/com/typesafe/sbt/packager/universal/Archives.scala#L126

I'm not sure what the cause is. We probably want a .headOption.getOrElse(throw)

java.util.NoSuchElementException: next on empty iterator
    at scala.collection.Iterator$$anon$2.next(Iterator.scala:39)
    at scala.collection.Iterator$$anon$2.next(Iterator.scala:37)
    at scala.collection.IndexedSeqLike$Elements.next(IndexedSeqLike.scala:64)
    at scala.collection.IterableLike$class.head(IterableLike.scala:91)
    at scala.collection.mutable.ArrayOps$ofRef.scala$collection$IndexedSeqOptimized$$super$head(ArrayOps.scala:108)
    at scala.collection.IndexedSeqOptimized$class.head(IndexedSeqOptimized.scala:120)
    at scala.collection.mutable.ArrayOps$ofRef.head(ArrayOps.scala:108)
    at com.typesafe.sbt.packager.universal.Archives$$anonfun$makeTarball$1.apply(Archives.scala:126)
    at com.typesafe.sbt.packager.universal.Archives$$anonfun$makeTarball$1.apply(Archives.scala:116)
    at sbt.IO$.withTemporaryDirectory(IO.scala:285)
    at com.typesafe.sbt.packager.universal.Archives$.makeTarball(Archives.scala:116)
    at com.typesafe.sbt.packager.universal.Archives$$anonfun$10.apply(Archives.scala:109)
    at com.typesafe.sbt.packager.universal.Archives$$anonfun$10.apply(Archives.scala:109)
    at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:35)
    at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:34)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
    at sbt.std.Transform$$anon$4.work(System.scala:64)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.Execute.work(Execute.scala:244)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask.run(FutureTask.java:262)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)
[error] (universal:packageZipTarball) java.util.NoSuchElementException: next on empty iterator

Support for BuildArch SPEC configuration

When running rpm:package-bin on OsX the rpmbuild tool seems to be slightly different than when running on a linux (Ubuntu/Centos). This might be due to some configuration error on my OsX rpmbuild of course...
I'm trying to package a "noarch" rpm but on OsX it insists on building a "x86_64" rpm file even though the "noarch" flag is passed to rpmbuild.

[debug] Executing rpmbuild with: rpmbuild -bb --buildroot /Users/peterl/Source/test/target/rpm/buildroot --define _topdir /Users/peterl/Source/test/target/rpm --target noarch-Peter-linux test.spec
[info] Building target platforms: noarch-Peter-linux
[info] Executing(%install): /bin/sh -e /usr/local/var/tmp/rpm-tmp.78161
[error] + umask 022
[error] + cd /Users/peterl/Source/test/target/rpm/BUILD
[error] + /bin/rm -rf /Users/peterl/Source/test/target/rpm/buildroot
[error] + /bin/mkdir -p /Users/peterl/Source/test/target/rpm/buildroot
[error] + '[' -e /Users/peterl/Source/test/target/rpm/buildroot ']'
[error] + mv /Users/peterl/Source/test/target/rpm/tmp-buildroot/etc /Users/peterl/Source/test/target/rpm/tmp-buildroot/usr /Users/peterl/Source/test/target/rpm/buildroot
[info] Processing files: test-0.8-snapshot.x86_64

If I edit the generated SPEC file adding:

BuildArch: noarch

And then running the rpmbuild command I get the correct "noarch".

rpmbuild -bb -v --buildroot /Users/peterl/Source/test/target/rpm/buildroot --define '_topdir /Users/peterl/Source/test/target/rpm' --target noarch target/rpm/SPECS/test.spec

Building target platforms: noarch
Executing(%install): /bin/sh -e /usr/local/var/tmp/rpm-tmp.96006
+ umask 022
+ cd /Users/peterl/Source/test/target/rpm/BUILD
+ /bin/rm -rf /Users/peterl/Source/test/target/rpm/buildroot
+ /bin/mkdir -p /Users/peterl/Source/test/target/rpm/buildroot
+ '[' -e /Users/peterl/Source/test/target/rpm/buildroot ']'
+ mv /Users/peterl/Source/test/target/rpm/tmp-buildroot/peter /Users/peterl/Source/test/target/rpm/buildroot
+ exit 0
Processing files: schematron-service-0.8-snapshot.noarch

Perhaps we could add support for "BuildArch" in RpmMetdata.writeSpec as well?

Specify default memory parameters of java_application BASH script in the build

I downloaded a sample app for the latest version of play
packaged it using debian:packageBin and then installed it in my VM with 512 megs of ram
but when I try to run it I get this

Error occurred during initialization of VM
Could not reserve enough space for object heap

While you can specify -mem to the script to fix this, it'd be nice if the default configuration for memory requirements was configurable.

Specifying a post rpm command breaks java_server

I have a auto generated play app configured for java_server. If I add the following line :

rpmPost := Some("ls")

I get:

play_clean rpm:packageBin
[info] Loading project definition from /web/svc-salesforce/project
[info] Set current project to svc-salesforce (in build file:/web/svc-salesforce/)
[info] Wrote /web/svc-salesforce/target/scala-2.10/svc-salesforce_2.10-0.1.0.pom
[info] Building target platforms: noarch-gilt-Linux
[info] Executing(%install): /bin/sh -e /usr/local/var/tmp/rpm-tmp.43711
[error] + umask 022
[error] + cd /web/svc-salesforce/target/rpm/BUILD
[error] + /bin/rm -rf /web/svc-salesforce/target/rpm/buildroot
[error] + /bin/mkdir -p /web/svc-salesforce/target/rpm/buildroot
[error] + '[' -e /web/svc-salesforce/target/rpm/buildroot ']'
[error] + mv /web/svc-salesforce/target/rpm/tmp-buildroot/usr /web/svc-salesforce/target/rpm/buildroot
[error] + exit 0
[info] Processing files: svc-salesforce-0.1.0-1.x86_64
[error] /bin/bash: --rpm-requires: invalid option
[error] Usage: /bin/bash [GNU long option] [option] ...
[error] /bin/bash [GNU long option] [option] script-file ...
[error] GNU long options:
[error] --debug
[error] --debugger
[error] --dump-po-strings
[error] --dump-strings
[error] --help
[error] --init-file
[error] --login
[error] --noediting
[error] --noprofile
[error] --norc
[error] --posix
[error] --protected
[error] --rcfile
[error] --restricted
[error] --verbose
[error] --version
[error] --wordexp
[error] Shell options:
[error] -irsD or -c command or -O shopt_option (invocation only)
[error] -abefhkmnptuvxBCHP or -o option
[info] Requires(interp): /bin/sh
[info] Requires(post): /bin/sh
[info] Checking for unpackaged file(s): /usr/local/Cellar/rpm/5.4.11/lib/rpm/check-files /web/svc-salesforce/target/rpm/buildroot
[info] Wrote: /web/svc-salesforce/target/rpm/RPMS/x86_64/svc-salesforce-0.1.0-1.x86_64.rpm
[success] Total time: 4 s, completed Nov 15, 2013 5:13:52 PM

Please let me know if you need any additional information.

Primary key duplicated in table 'Shortcut' for Windows builds

Using version 0.6.0 I'm currently receiving the following error when trying to build a Windows MSI installer:

error LGHT0130 : The primary key 'shortcut_85903ec4_f15e_49bb_be96_bfe37a1a794b_Shortcut' is duplicated in table 'Shortcut'. Please remove one of the entries or rename a part of the primary key to avoid the collision.

Looking into the code at https://github.com/sbt/sbt-native-packager/blob/master/src/main/scala/com/typesafe/sbt/packager/windows/WixHelper.scala#L125-L143 it looks like the same id is used for multiple shortcuts.

java.lang.NoClassDefFoundError

Hi there. When I try and execute the bin on *.nix platforms, I get a java.lang.NoClassDefFoundError error. Specifically

Exception in thread "main" java.lang.NoClassDefFoundError: scala/reflect/ClassManifest
        at com.mongodb.casbah.Implicits$$anon$4.asScala(Implicits.scala:73)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at com.mongodb.casbah.MongoClient.apply(MongoClient.scala:216)
        at com.onlysix.preface.retriever$.run(Retriever.scala)
Caused by: java.lang.ClassNotFoundException: scala.reflect.ClassManifest
        at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
        ... 9 more

Everything runs fine with sbt run. Please let me know if any other details would help!

folder mappings

Hi,

What would be the easiest way to add a folder with all files (or betterโ€”pattern-filtered) to this?

mappings in Universal += {
  file("my/local/conffile") -> "conf/my.conf"
}

support multiple main classes in a single module

While it is possible to get native packager to output start scripts for each of a multi-module project, it would be nice if there was an optional way to pass the main class to the bin script, target/universal/stage/bin/<module> -m some.main.Clazz

this might also bring for free a repl without sbt needed? (not sure of the mechanics)
target/universal/stage/bin/<module> -m the.scala.repl.main.Clazz

Possible race condition in zip creation?

I got the following exception when doing a clean dist:

java.io.IOException: This archives contains unclosed entries.
    at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.finish(ZipArchiveOutputStream.java:413)
    at org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream.close(ZipArchiveOutputStream.java:806)
    at com.typesafe.sbt.packager.universal.ZipHelper$.withZipOutput(ZipHelper.scala:94)
    at com.typesafe.sbt.packager.universal.ZipHelper$.archive(ZipHelper.scala:74)
    at com.typesafe.sbt.packager.universal.ZipHelper$.zip(ZipHelper.scala:53)
    at com.typesafe.sbt.packager.universal.Archives$.makeZip(Archives.scala:15)
    at com.typesafe.sbt.packager.universal.UniversalPlugin$$anonfun$com$typesafe$sbt$packager$universal$UniversalPlugin$$makePackageSettingsForConfig$1.apply(UniversalPlugin.scala:31)
    at com.typesafe.sbt.packager.universal.UniversalPlugin$$anonfun$com$typesafe$sbt$packager$universal$UniversalPlugin$$makePackageSettingsForConfig$1.apply(UniversalPlugin.scala:31)
    at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:35)
    at scala.Function3$$anonfun$tupled$1.apply(Function3.scala:34)
    at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
    at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
    at sbt.std.Transform$$anon$4.work(System.scala:64)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
    at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
    at sbt.Execute.work(Execute.scala:244)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
    at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
    at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
    at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
[error] (universal:packageBin) java.io.IOException: This archives contains unclosed entries.

I couldn't reproduce it, so I don't know what to think, maybe a race condition?

How to specify JAVA_OPTS for JavaServer archetype?

Hey there,

I might be missing something in the documentation, but if I wanted to use the java server archetype (which generates its own upstart script), how can I specify custom JAVA_OPTS like my heap sizes? I've currently been using the java application archetype with my own init.d script while I figure this out.

Thanks for the plugin, it's been great for generating debian packages for deployment!

Blake

Upstart Script for Linux Distros

Provide a default upstart script to start you packaged application from linux distributions. See #38

I will provide a pull request for this ticket.

Need to be able to specify what user and group the RPM installs files

Need the ability to specify which user and group the files get when they are installed. Currently we hard code the file user and group to root:root in GenericPackageSettings.scala

Seq(
packageMappingWithRename((binaries ++ directories):*) withUser "root" withGroup "root" withPerms "0755",
packageMappingWithRename(compressedManPages:).gzipped withUser "root" withGroup "root" withPerms "0644",
packageMappingWithRename(configFiles:
) withConfig() withUser "root" withGroup "root" withPerms "0644",
packageMappingWithRename(remaining:
*) withUser "root" withGroup "root" withPerms "0644"
)

rpmVendor value with comma

Having a rpmVendor String with a comma will execute %install two times. The second time will fail because the mv command has already moved the file from tmp-buildroot.

To reproduce, use

object Packaging {
  val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ Seq(

    ...

    rpmVendor := "2013, The Vendor",

    ...
  )
}

and run rpm:package-bin.

Confilict with sbtscalariform

Using together sbt-native-packager used with scalariform in a build.sbt file lead to confilict:

build.sbt:5: error: reference to settings is ambiguous;
it is imported twice in the same scope by
import _root_.com.typesafe.packager.PackagerPlugin._
and import _root_.com.typesafe.sbtscalariform.ScalariformPlugin._
settings(com.typesafe.packager.PackagerPlugin.packagerSettings:_*)
^
[error] Type error in expression
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?

build.sbt:

import scalariform.formatter.preferences._

seq(scalariformSettings: _*)

settings(com.typesafe.packager.PackagerPlugin.packagerSettings:_*)

name := "myapp"

version := "0.0.1"

scalaVersion := "2.9.2"

resolvers ++= Seq(
  DefaultMavenRepository,
  "sonatype.release" at "http://oss.sonatype.org/content/repositories/releases",
  "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/"
)

ScalariformKeys.preferences := FormattingPreferences().
  setPreference(FormatXml, false)

project/build.properties:

sbt.version=0.11.3

project/plugins.sbt

resolvers += Classpaths.typesafeResolver

resolvers += Classpaths.typesafeSnapshots

resolvers += Resolver.url("sbt-plugin-releases",
  new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)

addSbtPlugin("com.typesafe.sbtscalariform" % "sbtscalariform" % "0.4.0")

addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.3")

Readme / Usage typo

Hi Josh,
first of all thanks for your packaging plugin.
I started using it today by trying out the code you put in the readme under 'usage'. Being an Scala/SBT newbe it took me half a day to figure out why it was not working.
Problem is, 'archetypes.java_application' should be packageArchetype.java_application'.
But anyway... on the way of finding out I really learned a lot about SBT.
Cheers,
Peter

BashTemplate - problem resolving relative symlinks on the bash file (not the directory)

Hi,

play-2.2 integrates now the sbt-native-packager plugin. However the [https://github.com/sbt/sbt-native-packager/blob/master/src/main/resources/com/typesafe/sbt/packager/archetypes/bash-template](start script) in a debian package doesn't work, when it's not called within in /usr/share/<appname>/bin folder.

The problem with the bash script seems to be that realpath() cannot handle the relative symlink correctly.

/usr/bin/<appname> -> ../share/<appname>/bin/<appname>

h4. steps to reproduce

play new play-script-test
cd play-script-test

Follow ingbuild.sbt

import com.typesafe.sbt.packager.Keys._

name := "play-script-test"

version := "1.0"

libraryDependencies ++= Seq(
  jdbc,
  anorm,
  cache
)     

play.Project.playScalaSettings

maintainer in Debian := "John Doe <[email protected]>"

packageSummary in Linux := "My custom package summary"

packageDescription := "My longer package description"

Than run

play clean dist debian:packageBin
sudo dpkg -i target/play-script-test-1.0.deb
# open new console
play-script-test

when I run ./<app> from /usr/share/<app>/bin everything works. On every other path it fails, as it cannot find the /usr/share/<app>/lib aka the lib_dir.

JAVA_OPTS ignored

usage() for the bash script says it uses JAVA_OPTS, but I only see java_opts in there.

Creating a "Tested On" Wiki/Doc page

To keep track of system-configurations that are already tested, we should create a wiki page for this. This could look like

System Version Type Comments #
Ubuntu 13.10 64bit - โœ”

Clarify about "Java Server Application" in README

I've read the section "Java Server Application" in README, but I still don't know how to tell sbt-native-packager to start my Java app at boot time.

Is this feature finished, or currently it's just a planned feature?

get_mem_opts interferes with java_opts

Set java_opts='-Xmx=256m' and you get "Error occurred during initialization of VM; Incompatible minimum and maximum heap sizes specified"

On heroku, JAVA_OPTS are provided to match the size of the VM you're deployed on, so the JAVA_OPTS need to win.

Suggest that get_mem_opts gives up if any are set manually, or something like that.

Packaging fails for RPM & DEB if there is a space in the directory path

Both the rpm:package-bin and debian:package-bin targets fail if the project is located at a path that has a space in the filename.

Output from debian:package-bin for a project located in /home/me/a/path with/spaces/project

chmod: cannot access `/home/me/a/path': No such file or directory
chmod: cannot access `with/spaces/project/target/project-1.0.0-SNAPSHOT': No such file or directory
chmod: cannot access `/home/me/a/path: No such file or directory
chmod: cannot access `with/spaces/project/target/project-1.0.0-SNAPSHOT/DEBIAN': No such file or directory

Output from `rpm:package-bin for the same project

[info] Loading project definition from /home/me/a/path with/spaces/project
[info] Set current project to project (in build file:/home/me/a/path%20with/spaces/project/)
[info] Building target platforms: noarch-Us-Linux
[info] Building for target noarch-Us-Linux
[info] Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.jlFbsx
[info] 
[info] 
[info] RPM build errors:
[error] + umask 022
[error] + cd /home/me/a/path with/spaces/project/target/rpm/BUILD
[error] + [ -e /home/me/a/path with/spaces/project/target/rpm/buildroot ]
[error] [: 1: /home/me/a/path: unexpected operator
[error] + mv /home/me/a/path with/spaces/project/target/rpm/tmp-buildroot /home/me/a/path         with/spaces/project/target/rpm/buildroot
[error] mv: target `with/spaces/project/target/rpm/buildroot' is not a directory
[error] error: Bad exit status from /var/tmp/rpm-tmp.jlFbsx (%install)
[error]     Bad exit status from /var/tmp/rpm-tmp.jlFbsx (%install)
[error] {file:/home/me/a/path%20with/spaces/project/}default-fe4988/rpm:package-bin: Unable to run rpmbuild, check     output for details.

Provide docs how to use the plugin with multi-project projects

Hi, Josh. I try to use this plugin with multi-project setup described in your book "SBT in Action" (btw, I can't skip dots at the end of the lines like in the book - it doesn't compile).

My build.sbt:

import dependencies._
import common._

packageArchetype.java_application

name := "CoolProject"

lazy val common = (
  DefProject("common").
  settings(libraryDependencies ++= commonDependencies)
)

lazy val backend = (
  DefProject("backend").
  dependsOn(common).
  settings(libraryDependencies ++= backendDependencies)
)

lazy val frontend = (
  DefProject("frontend").
  dependsOn(backend).
  settings(libraryDependencies ++= frontendDependencies)
)

common.scala:

import sbt._
import Keys._

object common {
  val commonSettings = Seq(
    organization := "com.example",
    organizationName := "AwesomeOrg",
    version := "0.1-SNAPSHOT",

    scalaVersion := "2.10.3",
    scalacOptions ++= Seq("-feature", "-unchecked", "-encoding", "utf8"),

    resolvers ++= Seq(
      "Typesafe repository" at "http://repo.typesafe.com/typesafe/releases/"
    )
  )

  def DefProject(name: String): Project = {
    Project(name, file(name)).
    settings(commonSettings: _*)
  }
}

and dependencies.scala:

import sbt._

object dependencies {
  // versions
  val scalaARMVersion = "1.3"

  val jodaTimeVersion = "2.3"
  val jodaConvertVersion = "1.2"

  val apachePOIVersion = "3.9"

  val reactiveMongoVersion = "0.9"

  val scalaTestVersion = "1.9.1"
  val scalaCheckVersion = "1.10.1"

  // libraries
  val scalaARM = "com.jsuereth" %% "scala-arm" % scalaARMVersion

  val jodaTime = "joda-time" % "joda-time" % jodaTimeVersion
  val jodaConvert = "org.joda" % "joda-convert" % jodaConvertVersion

  val apachePOI = "org.apache.poi" % "poi-scratchpad" % apachePOIVersion

  val reactiveMongo = "org.reactivemongo" %% "reactivemongo" % reactiveMongoVersion

  val scalaTest = "org.scalatest" %% "scalatest" % scalaTestVersion
  val scalaCheck = "org.scalacheck" %% "scalacheck" % scalaCheckVersion

  // projects
  val commonDependencies = Seq(
    scalaTest % "test", scalaCheck % "test"
  )

  val backendDependencies = commonDependencies ++ Seq(
    scalaARM,

    jodaTime, jodaConvert,

    apachePOI,

    reactiveMongo
  )

  val frontendDependencies = commonDependencies ++ Seq(
  )
}

But when I invoke 'stage' from the root I don't get my sub-projects and their dependencies. I just want to include all my sub-projects. Can you provide some documentation describing this plugin usage in such a common scenario? Thank you so much for your book and this plugin!

Windows MSI + Play 2.2.0 : `CNDL0027 : The Shortcut/@Name attribute's value, '\application.conf', is not a valid long name because it contains illegal characters`

Trying to build MSI package from sample play 2.2 application forms we get this error :

[info] [...] play\play-2.2.0\samples\java\forms\target\windows\forms.wix(1173) : error CNDL0027 : The Shortcut/@Name attribute's value, '\application.conf', is not a valid long name because it contains illegal characters.  Legal long names contain no more than 260 characters and must contain at least one non-period character.  Any character except for the follow may be used: \ ? | > < : / * ".
java.lang.RuntimeException: Unable to run WIX compilation to wixobj...
        at scala.sys.package$.error(package.scala:27)
        at com.typesafe.sbt.packager.windows.WindowsPlugin$$anonfun$windowsSettings$14.apply(WindowsPlugin.scala:81)
        at com.typesafe.sbt.packager.windows.WindowsPlugin$$anonfun$windowsSettings$14.apply(WindowsPlugin.scala:69)
        at scala.Function7$$anonfun$tupled$1.apply(Function7.scala:35)
        at scala.Function7$$anonfun$tupled$1.apply(Function7.scala:34)
        at scala.Function1$$anonfun$compose$1.apply(Function1.scala:47)
        at sbt.$tilde$greater$$anonfun$$u2219$1.apply(TypeFunctions.scala:42)
        at sbt.std.Transform$$anon$4.work(System.scala:64)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
        at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
        at sbt.Execute.work(Execute.scala:244)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
        at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
        at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
        at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
        at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
        at java.util.concurrent.FutureTask.run(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
        at java.lang.Thread.run(Unknown Source)
[error] (windows:packageBin) Unable to run WIX compilation to wixobj...
[error] Total time: 1 s, completed Sep 24, 2013 5:40:27 PM

It looks like plugin generate wrong wix file. In my case :

<Component Id="shortcut_3dd9158d_540a_4728_b759_11203f352fdc1702832501xxxxxxxxx" Guid="1f4b2895-5d8b-46da-9736-a27cf7c4eccb">
    <Shortcut Id="shortcut_3dd9158d_540a_4728_b759_11203f352fdc1702832501xxxxxxxxx_SC" Name="\application.conf" Description="Edit configuration file: \application.conf" Target="[INSTALLDIR]\conf\\application.conf" WorkingDirectory="INSTALLDIR"/>
    <RemoveFolder Id="ApplicationProgramsFolderRemove" Directory="ApplicationProgramsFolder" On="uninstall"/>
    <RegistryValue Root="HKCU" Key="Software\Company\forms" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>

See Name="\application.conf"

Not sure if it's a bug on play-sbt side or an issue with the sbt-native-packager plugin.

Don't know SBT enough to properly investigate but it seems that it's related to PlayScalaSettings:

https://github.com/playframework/playframework/blob/2.2.0/framework/src/sbt-plugin/src/main/scala/play/Project.scala#L49

Would be great if you can confirm if it's a bug on you side or on the play-sbt side?

Original discussion here : https://groups.google.com/forum/#!topic/play-framework/cMzBuei9C2M

Thank you,

Specify location where RPM installs files

Need to be able to specify where the RPM puts the files it installs. We need to remove the hard coded /usr/share in GenericPackageSettings

object GenericPackageSettings {
val installLocation = "/usr/share"
}

Start command too long on some platforms with big classpaths

UPDATE: For those who have stumbled across this and want to know what the answer is, read here:

http://www.scala-sbt.org/sbt-native-packager/recipes/longclasspath.html

The generated start script is too long on some platforms (Windows) when the classpath is too big.

There are two ways we could go about solving this:

  1. Make it a config option as to whether classpath ordering is maintained, when it's set to false, then use JDK wildcard expansion for the classpath.
  2. Implement a loader that will load the classpath specification from a text file, and create a new classloader from that.

Original issue raised here: playframework/playframework#2025

rpm and [error] logging

When running rpm:package-bin, some output is logged on [error] for some reason. Example:

[info] Building for target noarch-vendor-Linux
[info] Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.48357
[error] + umask 022
[error] + cd /vagrant_data/foo/target/rpm/BUILD
[error] + LANG=C

When I execute the script manually the output looks like:

[root@centos58 foo]# sh -e /var/tmp/rpm-tmp.38734
+ umask 022
+ cd /vagrant_data/strand/target/rpm/BUILD
+ LANG=C
+ export LANG

The problem with the [error] logging is that this will fail some build (CI) servers which use the logs to determine if a build has failed (i.e. Bamboo).

Template Directories for Debian package

Play generates its logfiles by default under {application.dir}/logs/application.log which messes up the debian uninstall process as the installation directory is not empty.

Maven jdeb solves this by providing a template datatype.

<data>
   <type>template</type>
   <paths>
       <path>/etc/${artifactId}</path>
       <path>/var/lib/${artifactId}</path>
       <path>/var/log/${artifactId}</path>
       <path>/var/run/${artifactId}</path>
   </paths>
</data>

It would be nice to add this to the linuxPackageMapping options. The API could look like

linuxPackageMapping ++= (packageMappingTemplate(
    "/var/log/" + name,
    "/etc/" + name,
) withPermission("0755")

Dependency with classifier not included

I have a dependency on the Stanford CoreNLP library, which has a 'models' jar that contains resources necessary to use the library. The dependency setting looks like:

libraryDependencies ++= Seq(                                                                                                                                                                                         
  "edu.stanford.nlp" % "stanford-corenlp" % "3.3.0",                                                                                                                                                                 
  "edu.stanford.nlp" % "stanford-corenlp" % "3.3.0" classifier "models"                                                                                                                                              
)

I can't figure out how to get the sbt-native-packager to include both jars in the stage/lib directory and the classpath, even though sbt is downloading both jars. Is this a known limitation of the plugin, or am I missing something? Is there some way to manually tell the plugin to include the second jar in the distribution?

Is this related to #67?

Unable to generate deb file in play 2.2-RC2

Hello,

Play! framework 2.2.x comes with the native packager bundled in. I generated a new project and tried to generate a deb but my efforts were futile. The command fails saying the description field has a blank line. Please see the image below for the full error.
screen shot 2013-09-18 at 00 07 50

I added a couple of description fields but sbt complained that the key couldn't be found. Error in image below.
screen shot 2013-09-18 at 20 44 56

I fixed this by explicitly importing com.typesafe.sbt.packager.Keys._. This solved the second problem - keys were now valid. However, I still was unable to generate the deb package ๐Ÿ˜ฆ.

My build.sbt can be found here.

I posted this on the play mailing list but I was told to try here.

I'll really appreciate any help I can get on this.

Cheers,
Fayi

bash start script fails with java_cmd: readonly variable

We have a PlayFramework that I'm trying to package using sbt clean universal:package-zip-tarball. This generates a tgz file. When I unpack it and run -h it says that I can pass JAVA_HOME as the command line argument

-java-home <path>         alternate JAVA_HOME

but this doesn't work:

$ /opt/IDEC-1.0-SNAPSHOT/bin/idec -java-home /usr/lib/jvm/java-7-oracle
line 201: java_cmd: readonly variable

In bash.template line 255

declare -r java_cmd=$(get_java_cmd)

and on the last line it calls run() which calls proccess_args and on line 166 java_cmdis redefined

 -java-home) require_arg path "$1" "$2" && java_cmd="$2/bin/java" && shift 2 ;;

I can see that as part of revision 69c3bd5b53b6a7a3e7ecbd4b02e5248be917d040 when the main bash script was moved from JavaAppBashScript.scala to bash.template it changed

declare java_cmd=java

to the current

declare -r java_cmd=$(get_java_cmd)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.