Community
Participate
Working Groups
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.
Hoping to find a workaround, I tried specifying the directory as targetDir, and then specifying **/* as targetFile, and that doesn't work either.
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.
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".
See also bug #240728.
Henrik, please talk to Simon to co-ordinate this. Thanks.
(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 "*" .
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.
(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" :)
Assigning it back to inbox so a committer can apply the patch.
Fixed in HEAD. Thanks Henrik.
I updated the wiki page to describe the "options" parameter. http://wiki.eclipse.org/Equinox/p2/Engine/Touchpoint_Instructions#Native_Touchpoint_Actions