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

Relocatable rpm symlink fix #685

Merged
merged 2 commits into from
Nov 7, 2015
Merged

Conversation

fsat
Copy link
Collaborator

@fsat fsat commented Nov 2, 2015

When creating relocatable RPM packages, the symlink needs to take into account the relocated file paths.

RPM does not provide out of the box support for this, hence the pull request to manage symlinks as part of %post and %postun scriptlet. This will ensure the symlink will be created and removed as part of post-install and post-uninstall step.

When creating the symlink, both the source path and the symlink itself need to take into account the relocated path.

@fsat fsat force-pushed the relocatable-rpm-symlink-fix branch from 7b6a72d to bc19116 Compare November 2, 2015 01:16
@fsat
Copy link
Collaborator Author

fsat commented Nov 2, 2015

@huntc and @muuki88 - can I get a review please?

@@ -284,6 +284,8 @@ object JavaServerAppPackaging extends AutoPlugin {
Some(script)
}

protected def makePostInstallScript(): Option[String] = ???

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops... I thought I've put that in, I'll put it back.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not implemented? what's missing here?

@huntc
Copy link
Contributor

huntc commented Nov 2, 2015

LGTM

@fsat
Copy link
Collaborator Author

fsat commented Nov 2, 2015

Manual test successfully done on Redhat 7 VM for both relocated and default installation.

Test is done using ConductR rpms:

  • During installation: ensure correct installation path, correct symlink, and application is started successfully.
  • During uninstall: ensure application is stopped successfully, files and symlink cleaned up successfully.

@muuki88 muuki88 added the rpm label Nov 2, 2015
preun.fold("")("\n%preun\n" + _ + "\n\n")

def postunContent(tearDownSymlinkScript: Option[String]): String = {
val scripts = Seq(postun, tearDownSymlinkScript).collect {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this can be a simple flatten, or?

@muuki88
Copy link
Contributor

muuki88 commented Nov 2, 2015

I'm still confused why the relocate command in rpm is necessary as this adds so much complexity. The defaultLinuxInstallationPath can't fix this?

Nevertheless code looks okay. And if the relocate feature isn't used, nothing of these bash-magic will make it into the scriptlets.

@fsat fsat force-pushed the relocatable-rpm-symlink-fix branch from bc19116 to 96ab8d0 Compare November 3, 2015 23:41
@fsat
Copy link
Collaborator Author

fsat commented Nov 4, 2015

@muuki88, unfortunately the defaultLinuxInstallationPath does not fix this. And unfortunately the bash magic will need to be present because the relocation is specified during package install time.

When rpm install is called with relocate option (i.e. rpm -i <path to my package file> --relocate /usr/share=/opt), the defaultLinuxInstallationPath which is /usr/share is now mapped to the new location /opt. Internally RPM will look at the %files list and move all the files listed under /usr/share to /opt.

Before this change, the symlink is created during the build time and registered as part of %files list. Because of this, specifying the --relocate during rpm install will break the symlink.

For example, a symlink from /usr/bin/myapp to /usr/share/myapp/bin/myapp are created when the package is built. If I were to relocate the /usr/share to /opt, the /usr/bin/myapp symlink will still point to /usr/share/myapp/bin/myapp which is no longer valid because all the files are now under /opt.

This change will manage the symlink creation as part of post-install and post-uninstall steps using %post and %postun respectively. The symlink now will point to the correct relocated path. If the package is not relocated (i.e. using the defaultLinuxInstallationPath), the relocateLink function will leave the link as-is.

The additional complexity introduced in the %post and %postun scriptlet is unavoidable because rpm does not provide means to handle symlink relocation out of the box.

Hopefully it explains why this change is done.

@fsat fsat force-pushed the relocatable-rpm-symlink-fix branch from cb915f8 to f8eac6c Compare November 4, 2015 00:17
When creating relocatable RPM packages, the symlink needs to take into account the relocated file paths.

RPM does not provide out of the box support for this, hence the pull request to manage symlinks as part of %post and %postun scriptlet. This will ensure the symlink will be created and removed as part of post-install and post-uninstall step.

When creating the symlink, both the source path and the symlink itself need to take into account the relocated path.
@fsat fsat force-pushed the relocatable-rpm-symlink-fix branch from f8eac6c to e8f49a2 Compare November 4, 2015 01:20
Ensure actor system is shutdown only after the sent message is received by the actor under test as expected in the test
system.shutdown
(router ? "SUCCESS!!").foreach { _ =>
system.shutdown
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@muuki88 - this is not related to the RPM symlink issue, but I have intermittent failure on this test today, and hence the fix.

The failure is originally caused by the race condition where the actor system may be shutdown before the actor under test has the chance to print the expected message.

@fsat
Copy link
Collaborator Author

fsat commented Nov 5, 2015

@muuki88 - if you don't have any further feedback, can you merge this and release another milestone version please?

muuki88 added a commit that referenced this pull request Nov 7, 2015
@muuki88 muuki88 merged commit 43c36c7 into sbt:master Nov 7, 2015
@muuki88
Copy link
Contributor

muuki88 commented Nov 7, 2015

Released in 1.0.5-RC1

@huntc
Copy link
Contributor

huntc commented Nov 7, 2015

Thanks!

@fsat
Copy link
Collaborator Author

fsat commented Nov 8, 2015

Thank you @muuki88!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants