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

rpm and directories #92

Closed
cfeduke opened this issue Nov 27, 2013 · 17 comments
Closed

rpm and directories #92

cfeduke opened this issue Nov 27, 2013 · 17 comments

Comments

@cfeduke
Copy link

cfeduke commented Nov 27, 2013

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.

@jsuereth
Copy link
Member

Huh, I thought we had this dir stuff working correctly at one point. In any case, we can clean this up, as we have the info in packageMapping, IIRC.

Also, for the default "magical" RPM generation, we'll be adding in the ability to customize the user/group for the application being bundled (while the symlinks in /usr/bin will be owned by root, as appropriate).

@cfeduke
Copy link
Author

cfeduke commented Nov 27, 2013

I'm guessing by that you mean that if an explicit mapping was created for "/opt/vendor/project/bin/some.jar" then the directories "/opt/vendor", "/opt/vendor/project" and "/opt/vendor/project/bin" would be also automatically created? In general that's convenient, but in some cases an uninstall shouldn't impact, for example "/opt/vendor" because other packages may also be installed there. RPM does the right thing and leaves the directory if its non-empty, but anyone examining the RPM prior to un-installation may be concerned.

@jsuereth
Copy link
Member

jsuereth commented Dec 9, 2013

What I've run into in the past (with RPMs and CentOS 4-5-ish) was that if you claimed a directory in one RPM, you could not install another RPM that also claimed that directory. Is that still an issue, and if so, when was it fixed? I'd like to stay compatible with a reasonable set of versions of RPM.

@cfeduke
Copy link
Author

cfeduke commented Dec 9, 2013

I'm running CentOS 6.4-final on my VM.

I have created three RPMs that claim ownership of /var/log/trafficland - all three packages claim via sbt-native-packager's RPM facility:

%dir %attr(0755,coreservices,coreservices) /var/log/trafficland
%dir %attr(0755,coreservices,coreservices) /var/log/trafficland/%NAME%
...

(where %NAME% is the project name)

The /var/log/{trafficland,trafficland/%NAME%} is created using the IO.temporaryDirectory work around mentioned above.

I can install all three side by side and remove each one with no problems. If there happen to be log files in those directories, RPM does the right thing and leaves them intact. If there are no log files and the last package is removed, RPM does the right thing and also deletes the /var/log/trafficland directory.

I do the same thing for the /opt/trafficland directory and experience similar results. So it seems like RPM is doing the right thing in regards to shared directories and multiple RPM ownership.

@cfeduke
Copy link
Author

cfeduke commented Dec 9, 2013

I will download and test on CentOS 4.0 tonight and see what happens, since I already have the projects setup in order to do so. (I know its really just about rpmbuild version numbers, but I have fears of trying to go backwards with rpmbuild and it seems like having an older CentOS image to test these builds on isn't a bad idea anyway.)

I would hope behavior like this would be consistent across RPM versions. If not then at least RPM does make its directories like mkdir -p so /opt/trafficland/project could just have /opt/trafficland/project owned by the RPM spec and leave /opt/trafficland to stick around after removal.

@jsuereth
Copy link
Member

jsuereth commented Dec 9, 2013

cool. Thanks man!

@muuki88
Copy link
Contributor

muuki88 commented Dec 20, 2013

Maybe this will solve your problem: #107
#6 (directories and packageMapping). You should be able to map complete directories with:

linuxPackageMappings += packageMapping(
   (target.value / "file.jar") -> "/opt/trafficland/project/lib"
) withUser "tluser" withGroup "tlgroup" withPerms "0755" withContents()

This will generate a packageMapping for each directory.

@muuki88
Copy link
Contributor

muuki88 commented Feb 6, 2014

-Tested this approach on Fedora 18 and worked fine. You can specify directory to directory mapping and add withContents() and everything is added accordingly.-

Update

Parent directories are not accordingly created, when you specify only a single file, only and only if you map the complete directory structure:

-target
  - opt
    -trafficland
       - project
          - lib
            - file.jar

then you can do

linuxPackageMappings += packageMapping(
   (target.value / "opt") -> "/opt"
) withUser "tluser" withGroup "tlgroup" withPerms "0755" withContents()

Advantages

This approach has the advantage, that it's very compatible with debian as debian just packages a folder into a debian package.

@muuki88
Copy link
Contributor

muuki88 commented Mar 3, 2014

What is the status on this? Is the withContents() and the MappingsHelper class sufficient enough?

@jsuereth
Copy link
Member

jsuereth commented Mar 3, 2014

from my end, those solve this. I'll mark it as resolved, with the option of opening a new issue with a more refined proposal against withContents and MappingsHelper directly if anyone feels we can do better.

@jsuereth jsuereth closed this as completed Mar 3, 2014
@muuki88
Copy link
Contributor

muuki88 commented Mar 4, 2014

Perfect. I think we could release an 0.7-0-RC1 by now and test the rpm support

@aparkinson
Copy link
Contributor

Do we need to do some more compatibility testing against different RPM distro's? The Test On page is a little light in this area.

FYI I'm currently testing all the recent changes against RHEL 6.2+

@muuki88
Copy link
Contributor

muuki88 commented Mar 4, 2014

Definitely! More tests never hurt :)

@jsuereth
Copy link
Member

jsuereth commented Mar 4, 2014

So, 0.7.0-RC1 or 0.7.0-M4? I can do either. Excited to see @aparkinson's results.

@aparkinson
Copy link
Contributor

You don't have to wait on me as its slow process building RHEL for testing

@muuki88
Copy link
Contributor

muuki88 commented Mar 4, 2014

Can sombebody test on Fedora?
@jsuereth I favor RC1

@jon-shanks
Copy link

I am currently using 0.7.0-rc1 and building a play application java_server, the directory that is created /usr/share/ isn't owned by the user or group created. I have tried adding in the code above in the build.scala as you've mentioned and can't seem to get it to work, this is on centos 6.5

.settings(linuxPackageMappings += packageMapping(
(target.value / "usr/share/application") -> "/usr/share/application"
) withUser "app" withGroup "app" withPerms "0755" withContents()
)

But to no avail, any help would be appreciated.

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

No branches or pull requests

5 participants