Issue Details (XML | Word | Printable)

Key: MRPM-14
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Carlos Sanchez
Reporter: Shmulik Fishman
Votes: 3
Watchers: 3
Operations

If you were logged in you would be able to see more operations.
Mojo RPM Plugin

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

Created: 17/Oct/07 04:37 AM   Updated: Thursday 07:23 AM
Component/s: rpm
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments: 1. Text File rpm-filelist.patch (2 kB)
2. Text File rpm-single-sourcefile-v2.patch (3 kB)
3. Text File rpm-single-sourcefile.patch (23 kB)

Environment: CentOS release 5 (Final)
Issue Links:
Duplicate
 
Supercedes
 


 Description  « Hide
<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


 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Sönke Nommensen added a comment - 17/Oct/07 06:30 AM
This is because /etc/init.d/ is a link to /etc/rc.d/init.d/, thus a mapping to the latter should work.

Shmulik Fishman added a comment - 17/Oct/07 07:17 AM
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?


jh added a comment - 23/Nov/07 02:50 AM
I have the same issue but my /etc/init.d is not a link. So I'm probably stuck to the suggested workaround.

jh added a comment - 23/Nov/07 04:17 AM
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.


Bob Allison added a comment - 23/Nov/07 06:03 AM
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?


jh added a comment - 26/Nov/07 01:22 AM
No problem, I've removed the blanks, the patch should be fine now.

John Erik Halse added a comment - 27/Feb/08 06:47 AM
Another solution to this bug.

John Erik Halse added a comment - 27/Feb/08 06:49 AM
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

Michael Hirsch added a comment - 26/Mar/08 11:03 PM
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.

Chris Ryan added a comment - 18/May/08 07:48 PM
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.


Jens Persson added a comment - 17/Nov/08 05:45 AM
It seems it has to be <includeDirectory> rather than just <includeDir>

Chris Ryan added a comment - 17/Nov/08 06:27 AM
Yes, that's correct includeDirectory, not includeDir. Sorry about the mistake.

Carlos Sanchez added a comment - 02/Jan/09 11:47 AM
Fixed in 2.0-beta-2-SNAPSHOT. Thanks