Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 240728 - [touchpoint] chmod touchpoint action not working correctly
Summary: [touchpoint] chmod touchpoint action not working correctly
Status: RESOLVED FIXED
Alias: None
Product: Equinox
Classification: Eclipse Project
Component: p2 (show other bugs)
Version: 3.4   Edit
Hardware: PC Linux
: P3 major (vote)
Target Milestone: 3.5 M6   Edit
Assignee: Simon Kaegi CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-14 16:53 EDT by Ryan Mising name CLA
Modified: 2009-03-05 10:01 EST (History)
5 users (show)

See Also:


Attachments
Implentation and Updated test (5.84 KB, patch)
2009-02-26 19:38 EST, Henrik Lindberg CLA
simon_kaegi: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ryan Mising name CLA 2008-07-14 16:53:06 EDT
I am trying to use the chmod touchpoint action on the install phase for my
plug-in, and I can't get it to work quite right.  It works fine for
something simple like changing the permissions of one file:

<instruction key='install'>
chmod(targetDir:${installFolder}/path/to/file,targetFile:myFile,permissions:+x);
</instruction>

But when I try to recursively set permissions on a directory, like I would
with "chmod -R +x myDirectory/", it does not work:

<instruction key='install'>
chmod(targetDir:${installFolder}/path/to/parentDirectory,targetFile:myDirectory,permissions:-R
+x);
</instruction>

I have also tried putting the "-R +x" in double quotes and single quotes,
nothing works.  I have also tried specifying * for targetFile just to see
if that would work, and that doesn't even seem to work.
Comment 1 Ryan Mising name CLA 2008-07-14 17:02:40 EDT
Hoping to find a workaround, I tried specifying the directory as targetDir, and then specifying **/* as targetFile, and that doesn't work either.
Comment 2 Ryan Mising name CLA 2008-07-14 18:15:21 EDT
From a cursory glance at the code in ChmodAction, and from some experimentation...I don't think this can work right unless you add an "options" parameter to chmod so that -R can be specified separate from the "permissions".  

This won't work at all (which was expected):

String[] cmd = {"chmod", "-R +x", "/path/to/directory"};
Runtime.getRuntime().exec(cmd);

It's gotta be:

String[] cmd = {"chmod", "-R", "+x", "/path/to/directory"};
Runtime.getRuntime().exec(cmd);

As an aside, using getRuntime().exec() with chmod doesn't seem to like being given * as a file...like this:

String[] cmd = {"chmod", "+x", "/path/to/directory/*"};
Runtime.getRuntime().exec(cmd);

Even though it works perfectly fine from a terminal.  
Comment 3 Andrew Niefer CLA 2008-07-15 10:40:06 EDT
I believe '*' is usually expanded by the shell, for it to work here the action would need to expand it itself.

As an aside, #exec(String[]) was chosen instead of #exec(String) to avoid issues with spaces in the path.  Though it does make it impossible to play with the arguments like "-R +x".
Comment 4 Pascal Rapicault CLA 2008-12-22 20:57:03 EST
See also bug #240728.
Comment 5 DJ Houghton CLA 2009-02-20 13:25:39 EST
Henrik, please talk to Simon to co-ordinate this. Thanks.
Comment 6 Henrik Lindberg CLA 2009-02-20 20:02:33 EST
(In reply to comment #5)
> Henrik, please talk to Simon to co-ordinate this. Thanks.
> 
Sure, I can fix this. Will supply a patch that adds support for options (space separated). But will not add support for "*" .
Comment 7 Henrik Lindberg CLA 2009-02-26 19:38:03 EST
Created attachment 126931 [details]
Implentation and Updated test

This patch implements an extra parameter to the chmod action that makes it possible to pass additional flags to the command. This is done in the new parameter "options" - as an example

options=-R -H,permissions=+x

One refactoring needs to be done after applying this patch - the "options" string is defined in the ChmodAction class, and it should be moved to ActionConstants. Hope this is ok.
Comment 8 Henrik Lindberg CLA 2009-02-26 19:41:40 EST
(In reply to comment #7)
> 
> options=-R -H,permissions=+x
> 
Should have written:
<instruction key='install'>
chmod(targetDir:${installFolder}/path/to/file,targetFile:myDir,options:-R -H,permissions:+x);
</instruction>

As you can see, options allows multiple options separated by space. And, "options" is naturally "optional" :)
Comment 9 Henrik Lindberg CLA 2009-02-26 19:44:18 EST
Assigning it back to inbox so a committer can apply the patch.
Comment 10 Simon Kaegi CLA 2009-03-03 11:32:05 EST
Fixed in HEAD.
Thanks Henrik.
Comment 11 Henrik Lindberg CLA 2009-03-04 07:46:52 EST
I updated the wiki page to describe the "options" parameter. http://wiki.eclipse.org/Equinox/p2/Engine/Touchpoint_Instructions#Native_Touchpoint_Actions