equal
deleted
inserted
replaced
31 |
31 |
32 class PkgPlan(object): |
32 class PkgPlan(object): |
33 """A package plan takes two package FMRIs and an Image, and produces the |
33 """A package plan takes two package FMRIs and an Image, and produces the |
34 set of actions required to take the Image from the origin FMRI to the |
34 set of actions required to take the Image from the origin FMRI to the |
35 destination FMRI. |
35 destination FMRI. |
36 |
36 |
37 If the destination FMRI is None, the package is removed. |
37 If the destination FMRI is None, the package is removed. |
38 """ |
38 """ |
39 |
39 |
40 def __init__(self, image): |
40 def __init__(self, image): |
41 self.origin_fmri = None |
41 self.origin_fmri = None |
115 if self.origin_fmri: |
115 if self.origin_fmri: |
116 try: |
116 try: |
117 f = file("%s/pkg/%s/filters" % \ |
117 f = file("%s/pkg/%s/filters" % \ |
118 (self.image.imgdir, |
118 (self.image.imgdir, |
119 self.origin_fmri.get_dir_path()), "r") |
119 self.origin_fmri.get_dir_path()), "r") |
120 except OSError, e: |
120 except IOError, e: |
121 if e.errno != errno.ENOENT: |
121 if e.errno != errno.ENOENT: |
122 raise |
122 raise |
123 else: |
123 else: |
124 self.origin_filters = [ |
124 self.origin_filters = [ |
125 (l.strip(), compile( |
125 (l.strip(), compile( |
139 self.actions = self.destination_mfst.difference( |
139 self.actions = self.destination_mfst.difference( |
140 self.origin_mfst) |
140 self.origin_mfst) |
141 |
141 |
142 def preexecute(self): |
142 def preexecute(self): |
143 """Perform actions required prior to installation or removal of a package. |
143 """Perform actions required prior to installation or removal of a package. |
144 |
144 |
145 This method executes each action's preremove() or preinstall() |
145 This method executes each action's preremove() or preinstall() |
146 methods, as well as any package-wide steps that need to be taken |
146 methods, as well as any package-wide steps that need to be taken |
147 at such a time. |
147 at such a time. |
148 """ |
148 """ |
149 flist = None |
149 flist = None |
152 # retrieval step |
152 # retrieval step |
153 if self.destination_fmri == None: |
153 if self.destination_fmri == None: |
154 os.unlink("%s/pkg/%s/installed" % (self.image.imgdir, |
154 os.unlink("%s/pkg/%s/installed" % (self.image.imgdir, |
155 self.origin_fmri.get_dir_path())) |
155 self.origin_fmri.get_dir_path())) |
156 |
156 |
157 os.unlink("%s/pkg/%s/filters" % (self.image.imgdir, |
157 try: |
158 self.origin_fmri.get_dir_path())) |
158 os.unlink("%s/pkg/%s/filters" % ( |
|
159 self.image.imgdir, |
|
160 self.origin_fmri.get_dir_path())) |
|
161 except OSError, e: |
|
162 if e.errno != errno.ENOENT: |
|
163 raise |
159 |
164 |
160 for src, dest in self.actions: |
165 for src, dest in self.actions: |
161 if dest: |
166 if dest: |
162 dest.preinstall(self.image, src) |
167 dest.preinstall(self.image, src) |
163 else: |
168 else: |
191 pass |
196 pass |
192 flist = None |
197 flist = None |
193 |
198 |
194 def execute(self): |
199 def execute(self): |
195 """Perform actions for installation or removal of a package. |
200 """Perform actions for installation or removal of a package. |
196 |
201 |
197 This method executes each action's remove() or install() |
202 This method executes each action's remove() or install() |
198 methods. |
203 methods. |
199 """ |
204 """ |
200 |
205 |
201 # record that we are in an intermediate state |
206 # record that we are in an intermediate state |
217 else: |
222 else: |
218 src.remove(self.image) |
223 src.remove(self.image) |
219 |
224 |
220 def postexecute(self): |
225 def postexecute(self): |
221 """Perform actions required after installation or removal of a package. |
226 """Perform actions required after installation or removal of a package. |
222 |
227 |
223 This method executes each action's postremove() or postinstall() |
228 This method executes each action's postremove() or postinstall() |
224 methods, as well as any package-wide steps that need to be taken |
229 methods, as well as any package-wide steps that need to be taken |
225 at such a time. |
230 at such a time. |
226 """ |
231 """ |
227 # record that package states are consistent |
232 # record that package states are consistent |
236 # XXX should this just go in preexecute? |
241 # XXX should this just go in preexecute? |
237 if self.origin_fmri != None and self.destination_fmri != None: |
242 if self.origin_fmri != None and self.destination_fmri != None: |
238 os.unlink("%s/pkg/%s/installed" % (self.image.imgdir, |
243 os.unlink("%s/pkg/%s/installed" % (self.image.imgdir, |
239 self.origin_fmri.get_dir_path())) |
244 self.origin_fmri.get_dir_path())) |
240 |
245 |
241 os.unlink("%s/pkg/%s/filters" % (self.image.imgdir, |
246 try: |
242 self.origin_fmri.get_dir_path())) |
247 os.unlink("%s/pkg/%s/filters" % ( |
|
248 self.image.imgdir, |
|
249 self.origin_fmri.get_dir_path())) |
|
250 except OSError, e: |
|
251 if e.errno != errno.ENOENT: |
|
252 raise |
243 |
253 |
244 if self.destination_fmri != None: |
254 if self.destination_fmri != None: |
245 file("%s/pkg/%s/installed" % (self.image.imgdir, |
255 file("%s/pkg/%s/installed" % (self.image.imgdir, |
246 self.destination_fmri.get_dir_path()), "w") |
256 self.destination_fmri.get_dir_path()), "w") |
247 |
257 |
258 ]) |
268 ]) |
259 f.close() |
269 f.close() |
260 |
270 |
261 def make_indices(self): |
271 def make_indices(self): |
262 """Create the reverse index databases for a particular package. |
272 """Create the reverse index databases for a particular package. |
263 |
273 |
264 These are the databases mapping packaging object attribute |
274 These are the databases mapping packaging object attribute |
265 values back to their corresponding packages, allowing the |
275 values back to their corresponding packages, allowing the |
266 packaging system to look up a package based on, say, the |
276 packaging system to look up a package based on, say, the |
267 basename of a file that was installed. |
277 basename of a file that was installed. |
268 |
278 |