Mojo RPM Plugin

Specifying <directory> of a pre-exising system directory results in an RPM which can't be installed due to conflicts

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 2.0-beta-2
  • Component/s: rpm
  • Labels:
    None
  • Environment:
    CentOS release 5 (Final)
  • Number of attachments :
    3

Description

<mapping> currently specifies the destination directory for the files. This directory is always listed as part of the installed files.

This presents a problem when trying to install a startup script for the application:
<mapping>
<directory>/etc/init.d</directory>
[...]
</mapping>

Trying to install the RPM results in the following error:

  1. rpm -Uvh dummy-1.0-1.i386.rpm
    file /etc/init.d from install of dummy-1.0-1 conflicts with file from package chkconfig-1.3.30.1-1

$ rpm -qlvp dummy-1.0-1.i386.rpm
[..]
drwxr-xr-x 2 root root 0 Oct 17 10:50 /etc/init.d
-rwxr-xr-x 1 root root 15060 Oct 17 10:50 /etc/init.d/dummy
[..]

Current workarounds:

  • Use the postinstall script to create the file in /etc/init.d, removing this <mapping> altogether.
    or
  • Use --force during the installation

Issue Links

Activity

Hide
Sönke Nommensen added a comment -

This is because /etc/init.d/ is a link to /etc/rc.d/init.d/, thus a mapping to the latter should work.

Show
Sönke Nommensen added a comment - This is because /etc/init.d/ is a link to /etc/rc.d/init.d/, thus a mapping to the latter should work.
Hide
Shmulik Fishman added a comment -

This does fix the specific conflict on /etc/init.d. Thanks.

However, it does not address the real problem: This directory is always listed as part of the installed files, which means we reset its permissions during installation.

So the question remains:

How do I install files only, without the containing directory?

Show
Shmulik Fishman added a comment - This does fix the specific conflict on /etc/init.d. Thanks. However, it does not address the real problem: This directory is always listed as part of the installed files, which means we reset its permissions during installation. So the question remains: How do I install files only, without the containing directory?
Hide
jh added a comment -

I have the same issue but my /etc/init.d is not a link. So I'm probably stuck to the suggested workaround.

Show
jh added a comment - I have the same issue but my /etc/init.d is not a link. So I'm probably stuck to the suggested workaround.
Hide
jh added a comment -

I went ahead checked out the code and added the possibility to create mappings based on one file. This makes it possible to quickly add one-file mappings and will result in file based lines in the rpm spec.

<mapping>
<directory>/etc/init.d</directory>
<configuration>true</configuration>
<username>root</username>
<groupname>root</groupname>
<sourceFile>${project.build.directory}/mystartupscript</sourceFile>
</mapping>

generates:

%config %dir %attr(-,root,root) /etc/init.d/mystartupscript

I bypassed the sources property because this seemed an easier way. Another option was to add something like a handlePerFile property to generate one line per file in the spec, but this means duplicating the DirectoryArchiver functionality.

Please advise if this patch/solution is not to your liking.

Show
jh added a comment - I went ahead checked out the code and added the possibility to create mappings based on one file. This makes it possible to quickly add one-file mappings and will result in file based lines in the rpm spec. <mapping> <directory>/etc/init.d</directory> <configuration>true</configuration> <username>root</username> <groupname>root</groupname> <sourceFile>${project.build.directory}/mystartupscript</sourceFile> </mapping> generates: %config %dir %attr(-,root,root) /etc/init.d/mystartupscript I bypassed the sources property because this seemed an easier way. Another option was to add something like a handlePerFile property to generate one line per file in the spec, but this means duplicating the DirectoryArchiver functionality. Please advise if this patch/solution is not to your liking.
Hide
Bob Allison added a comment -

Your patch has a lot of "changes" where the change updates a blank line. This makes it difficult to locate the real changes.

Can you create a new patch file with the -b option to ignore these changes?

Show
Bob Allison added a comment - Your patch has a lot of "changes" where the change updates a blank line. This makes it difficult to locate the real changes. Can you create a new patch file with the -b option to ignore these changes?
Hide
jh added a comment -

No problem, I've removed the blanks, the patch should be fine now.

Show
jh added a comment - No problem, I've removed the blanks, the patch should be fine now.
Hide
John Erik Halse added a comment -

Another solution to this bug.

Show
John Erik Halse added a comment - Another solution to this bug.
Hide
John Erik Halse added a comment -

The last comment hit the road a little to early. Here is the whole story:

I have the same problem. It is especially annoying when you want to add a configuration file in /etc and you want your rpm to only handle this single file.

It seems like nothing has happened after jh submitted the patch. In case you want another proposal for how to deal with this, I have made a patch as well rpm-filelist.patch .

The main difference from jh's patch is that mine doesn't alter the configuration format. It checks if the sources for a mapping contains only references to files. If so, it generates one line in the spec for each file. Otherwise it uses the old behavior.

Example:

<mapping>
<directory>/etc/init.d</directory>
<configuration>true</configuration>
<username>root</username>
<groupname>root</groupname>
<sources>
 <source>
  <location>src/etc/somefile</location>
 </source>
 <source>
  <location>src/etc/anotherfile</location>
 </source>
</sources>
</mapping>

generates:

%config %dir %attr(-,root,root) /etc/init.d/somefile
%config %dir %attr(-,root,root) /etc/init.d/anotherfile

With a directory in the sources:

<mapping>
<directory>/etc/init.d</directory>
<configuration>true</configuration>
<username>root</username>
<groupname>root</groupname>
<sources>
 <source>
  <location>src/etc/somefile</location>
 </source>
 <source>
  <location>src/etc/somedirectory</location>
 </source>
</sources>
</mapping>

generates:

%config %dir %attr(-,root,root) /etc/init.d
Show
John Erik Halse added a comment - The last comment hit the road a little to early. Here is the whole story: I have the same problem. It is especially annoying when you want to add a configuration file in /etc and you want your rpm to only handle this single file. It seems like nothing has happened after jh submitted the patch. In case you want another proposal for how to deal with this, I have made a patch as well rpm-filelist.patch . The main difference from jh's patch is that mine doesn't alter the configuration format. It checks if the sources for a mapping contains only references to files. If so, it generates one line in the spec for each file. Otherwise it uses the old behavior. Example:
<mapping>
<directory>/etc/init.d</directory>
<configuration>true</configuration>
<username>root</username>
<groupname>root</groupname>
<sources>
 <source>
  <location>src/etc/somefile</location>
 </source>
 <source>
  <location>src/etc/anotherfile</location>
 </source>
</sources>
</mapping>
generates:
%config %dir %attr(-,root,root) /etc/init.d/somefile
%config %dir %attr(-,root,root) /etc/init.d/anotherfile
With a directory in the sources:
<mapping>
<directory>/etc/init.d</directory>
<configuration>true</configuration>
<username>root</username>
<groupname>root</groupname>
<sources>
 <source>
  <location>src/etc/somefile</location>
 </source>
 <source>
  <location>src/etc/somedirectory</location>
 </source>
</sources>
</mapping>
generates:
%config %dir %attr(-,root,root) /etc/init.d
Hide
Michael Hirsch added a comment -

What I would really like is a way to include or exclude the top directory. It could be something explicit like an <includeDir/> tag, or something implicit like <location>foo/bar</location> means to include the directory in the rpm file list and <location>foo/bar/</location> would mean to include the contents of foo/bar, but not the directory itself. This is similar to the way rsync distinguishes the two cases for it's source directory and it is quite convenient.

Show
Michael Hirsch added a comment - What I would really like is a way to include or exclude the top directory. It could be something explicit like an <includeDir/> tag, or something implicit like <location>foo/bar</location> means to include the directory in the rpm file list and <location>foo/bar/</location> would mean to include the contents of foo/bar, but not the directory itself. This is similar to the way rsync distinguishes the two cases for it's source directory and it is quite convenient.
Hide
Chris Ryan added a comment -

I have a solution based on Michael Hirsch's comment (using includeDir) - http://jira.codehaus.org/browse/MOJO-1125

Under the <mapping> element you can add an optional element: <includeDir>boolean</includeDir>. By default it's true. If false, the directory specified in the mapping is not included.

Show
Chris Ryan added a comment - I have a solution based on Michael Hirsch's comment (using includeDir) - http://jira.codehaus.org/browse/MOJO-1125 Under the <mapping> element you can add an optional element: <includeDir>boolean</includeDir>. By default it's true. If false, the directory specified in the mapping is not included.
Hide
Jens Persson added a comment -

It seems it has to be <includeDirectory> rather than just <includeDir>

Show
Jens Persson added a comment - It seems it has to be <includeDirectory> rather than just <includeDir>
Hide
Chris Ryan added a comment -

Yes, that's correct includeDirectory, not includeDir. Sorry about the mistake.

Show
Chris Ryan added a comment - Yes, that's correct includeDirectory, not includeDir. Sorry about the mistake.
Hide
Carlos Sanchez added a comment -

Fixed in 2.0-beta-2-SNAPSHOT. Thanks

Show
Carlos Sanchez added a comment - Fixed in 2.0-beta-2-SNAPSHOT. Thanks

People

Vote (3)
Watch (3)

Dates

  • Created:
    Updated:
    Resolved: