Search code examples
scalasbtsbt-native-packager

config directory when using sbt-native-packager


I'd like to ask about reasoning behind the fact, that the sbt-native-packager plugin creates a symlink /etc/ -> /usr/share//conf (instead of really putting files there and somehow specifying in the app where to look for them)?

In particular how does it influence update/uninstall+install process? Are the configs somehow preserved (for example for debian with java_server architecture setting)?


Solution

  • I'd like to ask about reasoning behind the fact, that the sbt-native-packager plugin creates a symlink /etc/ -> /usr/share//conf

    Keeping everything in one place. You have your application directory which contains everything and then you just link from the OS-specific folders to the according directories in your application folder.

    Are the configs somehow preserved

    Yes indeed. You can try it out with a simple play application. Add this to your build.sbt

    mappings in Universal <+= (packageBin in Compile, baseDirectory ) map { (_, base) =>
         val conf = base / "conf" / "application.conf"
         conf -> "conf/application.conf"
    } 
    

    This will map your application.conf in the conf folder. When you build a debian package with

    debian:packageBin
    

    you can see in target/-/DEBIAN/conffiles an entry

    /usr/share/<app-name>/conf/application.conf
    

    An apt-get remove your-app won't remove this file, only a purge