Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
muuki88 opened this issue Sep 21, 2013 · 6 comments

Comments

@muuki88
Copy link
Contributor

muuki88 commented Sep 21, 2013

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.

@muuki88
Copy link
Contributor Author

muuki88 commented Sep 23, 2013

I found the setting where it's done, which is rather uncool.

https://github.com/sbt/sbt-native-packager/blob/master/src/main/scala/com/typesafe/sbt/packager/debian/DebianPlugin.scala#L115

The setting should be absolute by default as relative symlink resolution is rather complicated.

@jsuereth
Copy link
Member

The reason it's relative is actually because I had issues getting the debian file to generate correctly with absolute symlinks. I'm more than happy to take a patch on this. I'm looking into it now.

@muuki88
Copy link
Contributor Author

muuki88 commented Sep 23, 2013

Nice. Maybe the symbolic-link logic should be done with: JavaNIO http://docs.oracle.com/javase/tutorial/essential/io/links.html

@jsuereth
Copy link
Member

I'd love to, except (unfortunately) we're still supporting JDK6. Literally HALF off this code would disappaer/be easier with JDK7, but we're stuck for now.

@muuki88
Copy link
Contributor Author

muuki88 commented Sep 27, 2013

# walking up from /usr/share/your-app/bin/your-app to /usr/share/your-app
declare -r app_home=$(dirname $(dirname $(readlink -f $0)))
# TODO - Check whether this is ok in cygwin...
declare -r lib_dir=$app_home/lib

not really nice, but it works. However this isn't tested with cygwin.

@jsuereth
Copy link
Member

Ok, I have a bit more robust fix that retains the current mechanism (which we should try to retain the current realpath, as it fixes a few issues that cropped up on odd systems).

Thanks for the patch idea though. Helped me isolate the underlying problem.

havocp added a commit that referenced this issue Sep 27, 2013
Fixes #39 - Unable to follow symlinks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants