summaryrefslogtreecommitdiff
blob: a7fa7dc4d67a5a2a0dc07b18a857cc591bd80444 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
diff -ur zeroinstall-orig/0launch-gui/properties.py zeroinstall/0launch-gui/properties.py
--- zeroinstall-orig/0launch-gui/properties.py	2007-04-08 04:50:32.000000000 -0600
+++ zeroinstall/0launch-gui/properties.py	2007-05-07 09:48:41.000000000 -0600
@@ -263,7 +263,13 @@
 		model, miter = sel.get_selected()
 		if not miter: return	# build in progress
 		iface = model[miter][Feeds.URI]
-		self.remove_feed_button.set_sensitive(iface != self.interface.uri)
+		# Only enable removing user_override feeds
+		enable_remove = False
+		for x in self.interface.feeds:
+			if x.uri == iface:
+				if x.user_override:
+					enable_remove = True
+		self.remove_feed_button.set_sensitive( enable_remove )
 		self.description.set_details(iface_cache.get_interface(iface))
 	
 	def updated(self):
diff -ur zeroinstall-orig/injector/model.py zeroinstall/injector/model.py
--- zeroinstall-orig/injector/model.py	2007-04-06 13:22:30.000000000 -0600
+++ zeroinstall/injector/model.py	2007-05-07 09:48:41.000000000 -0600
@@ -70,6 +70,7 @@
 developer = Stability(10, 'developer', 'Work-in-progress - bugs likely')
 testing = Stability(20, 'testing', 'Stability unknown - please test!')
 stable = Stability(30, 'stable', 'Tested - no serious problems found')
+packaged = Stability(35, 'packaged', 'Supplied by the local package manager')
 preferred = Stability(40, 'preferred', 'Best of all - must be set manually')
 
 class Restriction(object):
diff -ur zeroinstall-orig/injector/reader.py zeroinstall/injector/reader.py
--- zeroinstall-orig/injector/reader.py	2007-04-07 02:47:20.000000000 -0600
+++ zeroinstall/injector/reader.py	2007-05-07 12:33:27.000000000 -0600
@@ -41,7 +41,7 @@
 					    before = parse_version(e.getAttribute('before'))))
 
 def update_from_cache(interface):
-	"""Read a cached interface and any user overrides.
+	"""Read a cached interface and any local feeds or user overrides.
 	@param interface: the interface object to update
 	@type interface: L{model.Interface}
 	@return: True if cached version and user overrides loaded OK.
@@ -61,7 +61,11 @@
 			debug("Loading cached information for %s from %s", interface, cached)
 			update(interface, cached)
 
-	update_user_overrides(interface)
+	if update_local_feeds(interface):
+		cached = True
+
+	if update_user_overrides(interface):
+		cached = True
 
 	# Special case: add our fall-back local copy of the injector as a feed
 	if interface.uri == injector_gui_uri:
@@ -70,6 +74,49 @@
 
 	return bool(cached)
 
+def update_local_feeds(interface):
+	"""Update an interface with system-supplied local feeds.
+	@param interface: the interface object to update
+	@type interface: L{model.Interface}
+	@return: True if a local feed was loaded.
+	@rtype: bool"""
+	debug( "update_local_feeds for %s" % escape(interface.uri) )
+	path = basedir.load_first_config(config_site, 'local_feeds',
+			escape(interface.uri))
+
+	if not path:
+		return False
+
+	debug( "Adding system-supplied local_feed from '%s'" % path )
+
+	# Ensure the local feed matches the specified interface
+	root = qdom.parse(file(path))
+	if root.getAttribute('uri') != interface.uri:
+		match = False
+		for item in root.childNodes:
+			if item.uri != XMLNS_IFACE: continue
+			if item.name == 'feed-for':
+				if interface.uri == item.getAttribute('interface'):
+					match = True
+					break
+		if not match:
+			raise InvalidInterface('Local feed does not match specified interface')
+
+	realpath = path
+	linkcount = 0
+	while os.path.islink(realpath):
+		# Add the "real" location, not the link
+		oldpath = realpath
+		realpath = os.readlink(oldpath)
+		if not realpath.startswith('/'):
+			realpath = os.path.join(os.path.dirname(oldpath), realpath)
+		linkcount += 1
+		if linkcount > 100:
+			raise InvalidInterface('Local feed symlink more than 100 levels deep, skipping')
+	interface.feeds.append(Feed(realpath, None, False))
+
+	return True
+
 def update_user_overrides(interface):
 	"""Update an interface with user-supplied information.
 	@param interface: the interface object to update
@@ -77,7 +124,7 @@
 	user = basedir.load_first_config(config_site, config_prog,
 					   'user_overrides', escape(interface.uri))
 	if not user:
-		return
+		return False
 
 	root = qdom.parse(file(user))
 
@@ -113,6 +160,7 @@
 			if not feed_src:
 				raise InvalidInterface('Missing "src" attribute in <feed>')
 			interface.feeds.append(Feed(feed_src, item.getAttribute('arch'), True))
+	return True
 
 def check_readable(interface_uri, source):
 	"""Test whether an interface file is valid.