maven-rpm-plugin set folders permission differently from files when mapping

4.7k views Asked by At

How can I set permissions for the folders (i.e. 775) while files need to be set to 664? If folders are set to 664 then users other than the rpm installer (root) will see '?' in place of files' owner/permission and I prefer not to set all files' permissions to 775 too. Structure is similar to this question!

2

There are 2 answers

0
Kiarash Zamanifar On

One solution is to map it twice excluding files in one mapping and exclude folders in the next one. Any better ideas?

<mapping>
    <directory>/opt/bin</directory>
    <filemode>755</filemode>
    <username>myUser</username>
    <groupname>myUser</groupname>
    <sources>
        <source>
            <location>bin</location>
            <excludes>
                <exclude>*.*</exclude>
            </excludes>
        </source>
    <sources>
</mapping>

<mapping>
<directory>/opt/bin</directory>
<filemode>664</filemode>
<username>myUser</username>
<groupname>myUser</groupname>
<directoryIncluded>false</directoryIncluded>
<sources>
    <source>
        <location>bin</location>
    </source>
<sources>
</mapping>
0
bthitman On

I did it by using the <default??> tags. Then if you needed to override a default setting, you could use the <filemode> tag in the <mapping> section (but the <defaultDirmode>, <defaultUsername>, <defaultGroupname> are only applicable to a <mapping> if <filemode>, <username>, and <groupname> are NOT populated). Here's the plugin parameter documentation.

<plugin>
   <groupId>org.codehaus.mojo</groupId>
   <artifactId>rpm-maven-plugin</artifactId>
   <version>2.1.3</version>

   ....

    <configuration>
       ....
       <defaultDirmode>755</defaultDirmode>
       <defaultFilemode>644</defaultFilemode>
       <defaultGroupname>MyGroup</defaultGroupname>
       <defaultUsername>MyUser</defaultUsername>
       ....
    </configuration>
</plugin>