Search code examples
scalasbtsbt-native-packager

sbt native packager and app writable directory


Using the sbt-native-packager plugin, what's the best approach to have a app-writable directory? In my configuration i use enablePlugins(JavaServerAppPackaging, SystemdPlugin, DebianPlugin, UniversalPlugin) and it all works well except my app needs to write some files for its own functioning, under /usr/share/package-name/ sounds wrong but then i wonder where and how is best to do that, also if i should use debain postinst scripts of try to alter directory permissions from the mappings of the universal pluin.


Solution

  • Adding a new writeable directory in a linux distribution means adding a mapping to the linuxPackageMappings (documentation).

    linuxPackageMappings += packageTemplateMapping(
      s"/opt/${(packageName in Linux).value}"
    )().withUser((daemonUser in Linux).value)
       .withGroup((daemonGroup in Linux).value)
       .withPerms("755")
    

    You can see this with the old sbt syntax in use for the JavaServerApp plugin.

    Note: You should NOT set the /usr/share/<packageName> directory writeable. It contains the executables and config files and should only be modifiable for the root user.

    cheers, Muki