~ubuntu-branches/debian/sid/zeroinstall-injector/sid

« back to all changes in this revision

Viewing changes to 0alias

  • Committer: Package Import Robot
  • Author(s): Thomas Leonard
  • Date: 2012-02-12 15:19:54 UTC
  • mfrom: (1.1.28)
  • Revision ID: package-import@ubuntu.com-20120212151954-u5nef8c1381klr43
Tags: 1.6-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
from optparse import OptionParser
20
20
 
21
21
from zeroinstall.injector import reader, model
22
 
from zeroinstall import support, alias, helpers
 
22
from zeroinstall import support, alias, helpers, _
23
23
from zeroinstall.support import basedir
24
24
 
25
25
def export(name, value):
30
30
        return "export %s=%s" % (name, value)
31
31
 
32
32
def find_path(paths):
33
 
        """Find the first writable path in : separated list."""
 
33
        """Find the first writable path in the list,
 
34
        skipping /bin, /sbin and everything under /usr except /usr/local/bin"""
34
35
        for path in paths:
35
 
                if os.path.realpath(path).startswith(basedir.xdg_cache_home):
 
36
                if path.startswith('/usr/') and not path.startswith('/usr/local/bin'):
 
37
                        # (/usr/local/bin is OK if we're running as root)
 
38
                        pass
 
39
                elif path.startswith('/bin') or path.startswith('/sbin'):
 
40
                        pass
 
41
                elif os.path.realpath(path).startswith(basedir.xdg_cache_home):
36
42
                        pass # print "Skipping cache", first_path
37
43
                elif not os.access(path, os.W_OK):
38
44
                        pass # print "No access", first_path
208
214
        sys.exit(1)
209
215
 
210
216
try:
 
217
        if not options.user_path:
 
218
                if alias_prog == '0launch':
 
219
                        raise model.SafeException(_('Refusing to create an alias named "0launch" (to avoid an infinite loop)'))
 
220
 
211
221
        interface = model.Interface(interface_uri)
212
222
        if not reader.update_from_cache(interface):
213
223
                print("Interface '%s' not currently in cache. Fetching..." % interface_uri, file=sys.stderr)