[ 
http://jira.codehaus.org/browse/MUNIX-25?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=179848#action_179848
 ] 

Luis Arias commented on MUNIX-25:
---------------------------------

Ok this does the trick, doesn't look very nice, please review it, I imagine it 
would be better to have a helper method:

=== modified file 
'unix-core/src/main/java/org/codehaus/mojo/unix/core/FsFileCollector.java'
--- unix-core/src/main/java/org/codehaus/mojo/unix/core/FsFileCollector.java    
2009-04-29 19:07:41 +0000
+++ unix-core/src/main/java/org/codehaus/mojo/unix/core/FsFileCollector.java    
2009-06-10 08:11:49 +0000
@@ -119,6 +119,16 @@
                 toFile.getParent().createFolder();
                 toFile.copyFrom( from, Selectors.SELECT_SELF );
                 toFile.getContent().setLastModifiedTime( 
to.lastModified.toDateTime().toDate().getTime() );
+                FileAttributes fileAttributes = to.getFileAttributes();
+                if (fileAttributes.mode.isSome()) {
+                    UnixUtil.chmod(new File(fsRoot.getName().getPath() + 
File.separator + toFile.getName().getPath()), 
fileAttributes.mode.some().toOctalString());
+                }
+                if (fileAttributes.group.isSome()) {
+                    // TODO: chgrp operation
+                }
+                if (fileAttributes.user.isSome()) {
+                    // TODO: chown operation
+                }
                 return Unit.unit();
             }
         };



> Implement setting file attributes on dpkg assembly operations
> -------------------------------------------------------------
>
>                 Key: MUNIX-25
>                 URL: http://jira.codehaus.org/browse/MUNIX-25
>             Project: Maven 2.x Unix Plugin
>          Issue Type: Improvement
>            Reporter: Luis Arias
>
> I would really like to use the maven unix plugin to generate a deb for my 
> project, I recently submitted a patch for some features I need in some form 
> such as setting depends in jira issue MUNIX-24.  I did some work this morning 
> to try and figure out why I was unable to chmod 0755 some executable scripts 
> and realized that setting file attributes is not implemented in either the 
> setAttributes directive or in the copyDirectory directive.  In my attempts to 
> implement the feature while respecting the codebase architecture I ran into 
> some problems that I need guidance with.
> The mechanisms differ between the setAttributes and copyDirectory directives. 
>  In the latter, files are really copied to the staging area when the 
> fileCollector is asked to collect()  in DpkgUnixPackage.packageToFile().  
> However the packageFile() operation in FsFileCollector doesn't exploit the 
> file attribute information in the "to" UnixFsObject.RegularFile parameter.
> I tried to then add some code there to at least do the chmod, even if the 
> user and group information is not taken into account but got stuck because I 
> didn't see how common vfs could support setting file attributes (there is a 
> setAttributes for FileContent but that seems to be something else) and the 
> underlying File instance in FileObject is protected.
> So any ideas on how to proceed ?  I don't really understand the use of vfs 
> for the file collector since as far as I can see the root-xxx staging area is 
> always on the local file system.  I'm thinking the file attributes features 
> where left unimplemented because of some of these architectural issues. 

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to