Merge lp:~jamesh/bindwood/conditional-chmod into lp:bindwood

Proposed by James Henstridge
Status: Merged
Approved by: James Henstridge
Approved revision: 37
Merged at revision: 36
Proposed branch: lp:~jamesh/bindwood/conditional-chmod
Merge into: lp:bindwood
Diff against target: 38 lines (+6/-7)
2 files modified
couchdb_env.sh (+1/-1)
modules/desktopcouch.jsm (+5/-6)
To merge this branch: bzr merge lp:~jamesh/bindwood/conditional-chmod
Reviewer Review Type Date Requested Status
Manuel de la Peña (community) Approve
Eric Casteleijn (community) Approve
Review via email: mp+51860@code.launchpad.net

Commit message

Explicitly run couchdb_env.sh under /bin/sh so we don't need to worry about whether it has the execute bit set.

Description of the change

The code to retrieve the desktopcouch environment explicitly sets the executable bit on the couchdb_env.sh file before running it.

This is done because the executable bit may have been lost if Bindwood is installed from an XPI file (which is basically just a zip archive).

Unfortunately, if the package is installed globally on the system then the user won't have the ability to change the file's permissions, and we'll hit an error. This occurs with packaged version of Bindwood in Ubuntu, so they disabled this part of the code.

This branch first checks to see if the script is executable before trying to change the permissions, which should be suitable for both packaged and XPI versions of the extension.

To post a comment you must log in.
Revision history for this message
James Henstridge (jamesh) wrote :

At Stuart's suggestion, I've updated the branch to run "/bin/sh couchdb_env.sh outfile", which gets rid of the need to worry about the permissions on the script.

37. By James Henstridge

Rather than dealing with execute bits, run couchdb_env.sh under /bin/sh
explicitly. This way it doesn't matter what permission bits it has.

Revision history for this message
Eric Casteleijn (thisfred) :
review: Approve
Revision history for this message
Manuel de la Peña (mandel) wrote :

Looks good, remember that couchdb_env.sh will need an equivalent whenever we decide to port the code to an other platform (windows)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'couchdb_env.sh'
2--- couchdb_env.sh 2009-12-16 20:25:10 +0000
3+++ couchdb_env.sh 2011-03-02 09:33:41 +0000
4@@ -1,4 +1,4 @@
5-#!/bin/bash
6+#!/bin/sh
7 # Copyright 2009 Canonical Ltd.
8 #
9 # This program is free software: you can redistribute it and/or modify it
10
11=== modified file 'modules/desktopcouch.jsm'
12--- modules/desktopcouch.jsm 2011-02-17 06:42:46 +0000
13+++ modules/desktopcouch.jsm 2011-03-02 09:33:41 +0000
14@@ -78,19 +78,18 @@
15 tmpfile.initWithPath(tmpdir.path + "/desktopcouch." + Math.random());
16 tmpfile.createUnique(tmpfile.NORMAL_FILE_TYPE, 0600);
17
18- // create an nsILocalFile for the executable
19- var nsifile = Cc["@mozilla.org/file/local;1"]
20+ // create an nsILocalFile for the shell
21+ var shell = Cc["@mozilla.org/file/local;1"]
22 .createInstance(Ci.nsILocalFile);
23- nsifile.initWithPath(couchdb_env_script.path);
24- nsifile.permissions = 0755;
25+ shell.initWithPath("/bin/sh");
26
27 // create an nsIProcess2 to execute this bash script
28 var process = Cc["@mozilla.org/process/util;1"]
29 .createInstance(Ci.nsIProcess2 || Ci.nsIProcess);
30- process.init(nsifile);
31+ process.init(shell);
32
33 // Run the process, passing the tmpfile path
34- var args = [tmpfile.path];
35+ var args = [couchdb_env_script.path, tmpfile.path];
36 process.runAsync(args, args.length, {
37 observe: function(process, finishState, unused_data) {
38 // If the script exists cleanly, we should have a file

Subscribers

People subscribed via source and target branches