author | Shawn Walker <shawn.walker@oracle.com> |
Fri, 11 Mar 2011 10:43:38 -0800 | |
changeset 2254 | ab6a2324f73a |
parent 2205 | 53d0be594162 |
child 2274 | 1c8cd2ff57d3 |
permissions | -rw-r--r-- |
1516
8c950a3b4171
10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents:
1507
diff
changeset
|
1 |
#!/usr/bin/python |
49
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
2 |
# |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
4 |
# |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
8 |
# |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
13 |
# |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
19 |
# |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
21 |
# |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
22 |
|
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
23 |
# |
2192
906bafc90a02
17702 file install can fail when original_name and preserve set and old file exists
Shawn Walker <shawn.walker@oracle.com>
parents:
2089
diff
changeset
|
24 |
# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. |
49
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
25 |
# |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
26 |
|
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
27 |
"""module describing a file packaging object |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
28 |
|
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
29 |
This module contains the FileAction class, which represents a file-type |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
30 |
packaging object.""" |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
31 |
|
51
d04d55e16d0b
Simplify the action API and add real support for client-side installation
Danek Duvall <danek.duvall@sun.com>
parents:
49
diff
changeset
|
32 |
import os |
d04d55e16d0b
Simplify the action API and add real support for client-side installation
Danek Duvall <danek.duvall@sun.com>
parents:
49
diff
changeset
|
33 |
import errno |
383
08762e4dac3c
1068 cleanup pylint errors caused by portable package
Tom Mueller <Tom.Mueller@sun.com>
parents:
360
diff
changeset
|
34 |
import tempfile |
621
6c144915eed1
551 IPS should handle socket errors
johansen <johansen@sun.com>
parents:
605
diff
changeset
|
35 |
import stat |
49
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
36 |
import generic |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
339
diff
changeset
|
37 |
import pkg.misc as misc |
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
281
diff
changeset
|
38 |
import pkg.portable as portable |
879
3e4622a4c074
2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
873
diff
changeset
|
39 |
import pkg.client.api_errors as api_errors |
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
907
diff
changeset
|
40 |
import pkg.actions |
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
281
diff
changeset
|
41 |
try: |
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
281
diff
changeset
|
42 |
import pkg.elf as elf |
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
281
diff
changeset
|
43 |
haveelf = True |
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
281
diff
changeset
|
44 |
except ImportError: |
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
281
diff
changeset
|
45 |
haveelf = False |
49
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
46 |
|
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
47 |
class FileAction(generic.Action): |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
48 |
"""Class representing a file-type packaging object.""" |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
49 |
|
1846
37cc4d517320
15386 action fromstr could pool attribute names to reduce memory usage
Shawn Walker <shawn.walker@oracle.com>
parents:
1842
diff
changeset
|
50 |
__slots__ = ["hash", "replace_required"] |
37cc4d517320
15386 action fromstr could pool attribute names to reduce memory usage
Shawn Walker <shawn.walker@oracle.com>
parents:
1842
diff
changeset
|
51 |
|
51
d04d55e16d0b
Simplify the action API and add real support for client-side installation
Danek Duvall <danek.duvall@sun.com>
parents:
49
diff
changeset
|
52 |
name = "file" |
72
9deed41412b3
Support for proper package upgrade.
Danek Duvall <danek.duvall@sun.com>
parents:
66
diff
changeset
|
53 |
key_attr = "path" |
2205
53d0be594162
3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents:
2200
diff
changeset
|
54 |
unique_attrs = "path", "mode", "owner", "group" |
53d0be594162
3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents:
2200
diff
changeset
|
55 |
globally_identical = True |
53d0be594162
3822 image plans should prevent conflicting actions from being installed
Danek Duvall <danek.duvall@oracle.com>
parents:
2200
diff
changeset
|
56 |
namespace_group = "path" |
51
d04d55e16d0b
Simplify the action API and add real support for client-side installation
Danek Duvall <danek.duvall@sun.com>
parents:
49
diff
changeset
|
57 |
|
2026
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1859
diff
changeset
|
58 |
has_payload = True |
d1b30615bc99
9196 pkg(5) should have support for cryptographic manifest signatures
Brock Pytlik <bpytlik@sun.com>
parents:
1859
diff
changeset
|
59 |
|
49
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
60 |
def __init__(self, data=None, **attrs): |
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
61 |
generic.Action.__init__(self, data, **attrs) |
51
d04d55e16d0b
Simplify the action API and add real support for client-side installation
Danek Duvall <danek.duvall@sun.com>
parents:
49
diff
changeset
|
62 |
self.hash = "NOHASH" |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
63 |
self.replace_required = False |
49
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
64 |
|
481
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
65 |
# this check is only needed on Windows |
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
66 |
if portable.ostype == "windows": |
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
67 |
def preinstall(self, pkgplan, orig): |
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
68 |
"""If the file exists, check if it is in use.""" |
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
69 |
if not orig: |
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
70 |
return |
879
3e4622a4c074
2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
873
diff
changeset
|
71 |
path = os.path.normpath( |
3e4622a4c074
2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
873
diff
changeset
|
72 |
os.path.join(pkgplan.image.get_root(), |
3e4622a4c074
2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
873
diff
changeset
|
73 |
orig.attrs["path"])) |
481
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
74 |
if os.path.isfile(path) and self.in_use(path): |
879
3e4622a4c074
2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
873
diff
changeset
|
75 |
raise api_errors.FileInUseException, path |
3e4622a4c074
2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
873
diff
changeset
|
76 |
|
3e4622a4c074
2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
873
diff
changeset
|
77 |
def preremove(self, pkgplan): |
3e4622a4c074
2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
873
diff
changeset
|
78 |
path = os.path.normpath( |
3e4622a4c074
2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
873
diff
changeset
|
79 |
os.path.join(pkgplan.image.get_root(), |
3e4622a4c074
2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
873
diff
changeset
|
80 |
self.attrs["path"])) |
3e4622a4c074
2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
873
diff
changeset
|
81 |
if os.path.isfile(path) and self.in_use(path): |
3e4622a4c074
2747 make per-package progress output work on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
873
diff
changeset
|
82 |
raise api_errors.FileInUseException, path |
481
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
83 |
|
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
84 |
def in_use(self, path): |
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
85 |
"""Determine if a file is in use (locked) by trying |
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
86 |
to rename the file to itself.""" |
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
87 |
try: |
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
88 |
os.rename(path, path) |
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
89 |
except OSError, err: |
552
9dcfb25a9c7e
3187 unicode image path causes traceback within image.make_install_plan
Tom Mueller <Tom.Mueller@sun.com>
parents:
489
diff
changeset
|
90 |
if err.errno != errno.EACCES: |
481
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
91 |
raise |
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
92 |
return True |
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
93 |
return False |
9fa0541013b3
2402 pkg unable to remove executable file that is in use on Windows
Tom Mueller <Tom.Mueller@sun.com>
parents:
462
diff
changeset
|
94 |
|
136 | 95 |
def install(self, pkgplan, orig): |
49
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
96 |
"""Client-side method that installs a file.""" |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
97 |
|
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
98 |
mode = None |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
99 |
try: |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
100 |
mode = int(self.attrs.get("mode", None), 8) |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
101 |
except (TypeError, ValueError): |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
102 |
# Mode isn't valid, so let validate raise a more |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
103 |
# informative error. |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
104 |
self.validate(fmri=pkgplan.destination_fmri) |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
105 |
|
1784
e69b4aa1a6b5
791 stack trace when installing directory or file with missing mandatory attributes
Shawn Walker <srw@sun.com>
parents:
1778
diff
changeset
|
106 |
owner, group = self.get_fsobj_uid_gid(pkgplan, |
e69b4aa1a6b5
791 stack trace when installing directory or file with missing mandatory attributes
Shawn Walker <srw@sun.com>
parents:
1778
diff
changeset
|
107 |
pkgplan.destination_fmri) |
51
d04d55e16d0b
Simplify the action API and add real support for client-side installation
Danek Duvall <danek.duvall@sun.com>
parents:
49
diff
changeset
|
108 |
|
72
9deed41412b3
Support for proper package upgrade.
Danek Duvall <danek.duvall@sun.com>
parents:
66
diff
changeset
|
109 |
final_path = os.path.normpath(os.path.sep.join( |
1784
e69b4aa1a6b5
791 stack trace when installing directory or file with missing mandatory attributes
Shawn Walker <srw@sun.com>
parents:
1778
diff
changeset
|
110 |
(pkgplan.image.get_root(), self.attrs["path"]))) |
51
d04d55e16d0b
Simplify the action API and add real support for client-side installation
Danek Duvall <danek.duvall@sun.com>
parents:
49
diff
changeset
|
111 |
|
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
112 |
# Don't allow installation through symlinks. |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
113 |
self.fsobj_checkpath(pkgplan, final_path) |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
114 |
|
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
289
diff
changeset
|
115 |
if not os.path.exists(os.path.dirname(final_path)): |
1507
b956ea23d3a6
11735 pkg history data files should not be executable
Richard Lowe <richlowe@richlowe.net>
parents:
1407
diff
changeset
|
116 |
self.makedirs(os.path.dirname(final_path), |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
117 |
mode=misc.PKG_DIR_MODE, |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
118 |
fmri=pkgplan.destination_fmri) |
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
281
diff
changeset
|
119 |
|
443
5ffa5b7dac9c
2589 pyc files generate lots of verify chaff
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
409
diff
changeset
|
120 |
# XXX If we're upgrading, do we need to preserve file perms from |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
121 |
# existing file? |
462
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
122 |
|
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
123 |
# check if we have a save_file active; if so, simulate file |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
124 |
# being already present rather than installed from scratch |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
125 |
|
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
126 |
if "save_file" in self.attrs: |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
127 |
orig = self.restore_file(pkgplan.image) |
51
d04d55e16d0b
Simplify the action API and add real support for client-side installation
Danek Duvall <danek.duvall@sun.com>
parents:
49
diff
changeset
|
128 |
|
1767
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
129 |
# See if we need to preserve the file, and if so, set that up. |
125
8b66970ab314
Add preserve attribute to file action
Danek Duvall <danek.duvall@sun.com>
parents:
121
diff
changeset
|
130 |
# |
8b66970ab314
Add preserve attribute to file action
Danek Duvall <danek.duvall@sun.com>
parents:
121
diff
changeset
|
131 |
# XXX What happens when we transition from preserve to |
8b66970ab314
Add preserve attribute to file action
Danek Duvall <danek.duvall@sun.com>
parents:
121
diff
changeset
|
132 |
# non-preserve or vice versa? Do we want to treat a preserve |
8b66970ab314
Add preserve attribute to file action
Danek Duvall <danek.duvall@sun.com>
parents:
121
diff
changeset
|
133 |
# attribute as turning the action into a critical action? |
1767
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
134 |
# |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
135 |
# XXX We should save the originally installed file. It can be |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
136 |
# used as an ancestor for a three-way merge, for example. Where |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
137 |
# should it be stored? |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
138 |
pres_type = self.__check_preserve(orig, pkgplan) |
1832
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1784
diff
changeset
|
139 |
do_content = True |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1784
diff
changeset
|
140 |
if pres_type == True or (pres_type and |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1784
diff
changeset
|
141 |
pkgplan.origin_fmri == pkgplan.destination_fmri): |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1784
diff
changeset
|
142 |
# File is marked to be preserved and exists so don't |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1784
diff
changeset
|
143 |
# reinstall content. |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1784
diff
changeset
|
144 |
do_content = False |
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
145 |
elif pres_type == "renameold.update": |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
146 |
old_path = final_path + ".update" |
1767
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
147 |
elif pres_type == "renameold": |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
148 |
old_path = final_path + ".old" |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
149 |
elif pres_type == "renamenew": |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
150 |
final_path = final_path + ".new" |
125
8b66970ab314
Add preserve attribute to file action
Danek Duvall <danek.duvall@sun.com>
parents:
121
diff
changeset
|
151 |
|
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
152 |
# If it is a directory (and not empty) then we should |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
153 |
# salvage the contents. |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
154 |
if os.path.exists(final_path) and \ |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
621
diff
changeset
|
155 |
not os.path.islink(final_path) and \ |
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
621
diff
changeset
|
156 |
os.path.isdir(final_path): |
1281
b05bb3f65f58
10394 link action emits cryptic message when target is wrong
Dan Price <dp@eng.sun.com>
parents:
1100
diff
changeset
|
157 |
try: |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
158 |
os.rmdir(final_path) |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
159 |
except OSError, e: |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
160 |
if e.errno == errno.ENOENT: |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
161 |
pass |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
162 |
elif e.errno in (errno.EEXIST, errno.ENOTEMPTY): |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
163 |
pkgplan.image.salvage(final_path) |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
164 |
elif e.errno != errno.EACCES: |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
165 |
# this happens on Windows |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
166 |
raise |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
167 |
|
81
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
168 |
# XXX This needs to be modularized. |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
169 |
# XXX This needs to be controlled by policy. |
1832
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1784
diff
changeset
|
170 |
if do_content and self.needsdata(orig, pkgplan): |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
621
diff
changeset
|
171 |
tfilefd, temp = tempfile.mkstemp(dir=os.path.dirname( |
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
621
diff
changeset
|
172 |
final_path)) |
72
9deed41412b3
Support for proper package upgrade.
Danek Duvall <danek.duvall@sun.com>
parents:
66
diff
changeset
|
173 |
stream = self.data() |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
621
diff
changeset
|
174 |
tfile = os.fdopen(tfilefd, "wb") |
342
5e1f4d8429bf
669 Need method to print package licenses before installation
Danek Duvall <danek.duvall@sun.com>
parents:
339
diff
changeset
|
175 |
shasum = misc.gunzip_from_stream(stream, tfile) |
51
d04d55e16d0b
Simplify the action API and add real support for client-side installation
Danek Duvall <danek.duvall@sun.com>
parents:
49
diff
changeset
|
176 |
|
72
9deed41412b3
Support for proper package upgrade.
Danek Duvall <danek.duvall@sun.com>
parents:
66
diff
changeset
|
177 |
tfile.close() |
9deed41412b3
Support for proper package upgrade.
Danek Duvall <danek.duvall@sun.com>
parents:
66
diff
changeset
|
178 |
stream.close() |
9deed41412b3
Support for proper package upgrade.
Danek Duvall <danek.duvall@sun.com>
parents:
66
diff
changeset
|
179 |
|
9deed41412b3
Support for proper package upgrade.
Danek Duvall <danek.duvall@sun.com>
parents:
66
diff
changeset
|
180 |
# XXX Should throw an exception if shasum doesn't match |
9deed41412b3
Support for proper package upgrade.
Danek Duvall <danek.duvall@sun.com>
parents:
66
diff
changeset
|
181 |
# self.hash |
9deed41412b3
Support for proper package upgrade.
Danek Duvall <danek.duvall@sun.com>
parents:
66
diff
changeset
|
182 |
else: |
9deed41412b3
Support for proper package upgrade.
Danek Duvall <danek.duvall@sun.com>
parents:
66
diff
changeset
|
183 |
temp = final_path |
51
d04d55e16d0b
Simplify the action API and add real support for client-side installation
Danek Duvall <danek.duvall@sun.com>
parents:
49
diff
changeset
|
184 |
|
489
e8346a433595
3084 updating missing files tracebacks when trying to chmod
Danek Duvall <danek.duvall@sun.com>
parents:
481
diff
changeset
|
185 |
try: |
e8346a433595
3084 updating missing files tracebacks when trying to chmod
Danek Duvall <danek.duvall@sun.com>
parents:
481
diff
changeset
|
186 |
os.chmod(temp, mode) |
e8346a433595
3084 updating missing files tracebacks when trying to chmod
Danek Duvall <danek.duvall@sun.com>
parents:
481
diff
changeset
|
187 |
except OSError, e: |
e8346a433595
3084 updating missing files tracebacks when trying to chmod
Danek Duvall <danek.duvall@sun.com>
parents:
481
diff
changeset
|
188 |
# If the file didn't exist, assume that's intentional, |
e8346a433595
3084 updating missing files tracebacks when trying to chmod
Danek Duvall <danek.duvall@sun.com>
parents:
481
diff
changeset
|
189 |
# and drive on. |
e8346a433595
3084 updating missing files tracebacks when trying to chmod
Danek Duvall <danek.duvall@sun.com>
parents:
481
diff
changeset
|
190 |
if e.errno != errno.ENOENT: |
e8346a433595
3084 updating missing files tracebacks when trying to chmod
Danek Duvall <danek.duvall@sun.com>
parents:
481
diff
changeset
|
191 |
raise |
e8346a433595
3084 updating missing files tracebacks when trying to chmod
Danek Duvall <danek.duvall@sun.com>
parents:
481
diff
changeset
|
192 |
else: |
e8346a433595
3084 updating missing files tracebacks when trying to chmod
Danek Duvall <danek.duvall@sun.com>
parents:
481
diff
changeset
|
193 |
return |
49
c3a70bdc4527
First cut of actions; make file transfer generic.
Danek Duvall <danek.duvall@sun.com>
parents:
diff
changeset
|
194 |
|
121
9f716d56c0ee
Fix file action upgrade to always reset permissions, as os.rename() doesn't preserve them
Richard Lowe <richlowe@richlowe.net>
parents:
119
diff
changeset
|
195 |
try: |
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
281
diff
changeset
|
196 |
portable.chown(temp, owner, group) |
121
9f716d56c0ee
Fix file action upgrade to always reset permissions, as os.rename() doesn't preserve them
Richard Lowe <richlowe@richlowe.net>
parents:
119
diff
changeset
|
197 |
except OSError, e: |
9f716d56c0ee
Fix file action upgrade to always reset permissions, as os.rename() doesn't preserve them
Richard Lowe <richlowe@richlowe.net>
parents:
119
diff
changeset
|
198 |
if e.errno != errno.EPERM: |
9f716d56c0ee
Fix file action upgrade to always reset permissions, as os.rename() doesn't preserve them
Richard Lowe <richlowe@richlowe.net>
parents:
119
diff
changeset
|
199 |
raise |
72
9deed41412b3
Support for proper package upgrade.
Danek Duvall <danek.duvall@sun.com>
parents:
66
diff
changeset
|
200 |
|
125
8b66970ab314
Add preserve attribute to file action
Danek Duvall <danek.duvall@sun.com>
parents:
121
diff
changeset
|
201 |
# XXX There's a window where final_path doesn't exist, but we |
8b66970ab314
Add preserve attribute to file action
Danek Duvall <danek.duvall@sun.com>
parents:
121
diff
changeset
|
202 |
# probably don't care. |
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
203 |
if do_content and pres_type in ("renameold", |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
204 |
"renameold.update"): |
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
281
diff
changeset
|
205 |
portable.rename(final_path, old_path) |
125
8b66970ab314
Add preserve attribute to file action
Danek Duvall <danek.duvall@sun.com>
parents:
121
diff
changeset
|
206 |
|
72
9deed41412b3
Support for proper package upgrade.
Danek Duvall <danek.duvall@sun.com>
parents:
66
diff
changeset
|
207 |
# This is safe even if temp == final_path. |
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
281
diff
changeset
|
208 |
portable.rename(temp, final_path) |
60
6bd5cd83cfb1
Reverse index database and searching support.
Danek Duvall <danek.duvall@sun.com>
parents:
53
diff
changeset
|
209 |
|
1832
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1784
diff
changeset
|
210 |
# Handle timestamp if specified (and content was installed). |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1784
diff
changeset
|
211 |
if do_content and "timestamp" in self.attrs: |
443
5ffa5b7dac9c
2589 pyc files generate lots of verify chaff
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
409
diff
changeset
|
212 |
t = misc.timestamp_to_time(self.attrs["timestamp"]) |
1330
ef504d0f0e97
10629 timestamp cannot be set on read-only file (Windows)
Tom Mueller <Tom.Mueller@sun.com>
parents:
1281
diff
changeset
|
213 |
try: |
ef504d0f0e97
10629 timestamp cannot be set on read-only file (Windows)
Tom Mueller <Tom.Mueller@sun.com>
parents:
1281
diff
changeset
|
214 |
os.utime(final_path, (t, t)) |
ef504d0f0e97
10629 timestamp cannot be set on read-only file (Windows)
Tom Mueller <Tom.Mueller@sun.com>
parents:
1281
diff
changeset
|
215 |
except OSError, e: |
ef504d0f0e97
10629 timestamp cannot be set on read-only file (Windows)
Tom Mueller <Tom.Mueller@sun.com>
parents:
1281
diff
changeset
|
216 |
if e.errno != errno.EACCES: |
ef504d0f0e97
10629 timestamp cannot be set on read-only file (Windows)
Tom Mueller <Tom.Mueller@sun.com>
parents:
1281
diff
changeset
|
217 |
raise |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
218 |
|
1507
b956ea23d3a6
11735 pkg history data files should not be executable
Richard Lowe <richlowe@richlowe.net>
parents:
1407
diff
changeset
|
219 |
# On Windows, the time cannot be changed on a |
1330
ef504d0f0e97
10629 timestamp cannot be set on read-only file (Windows)
Tom Mueller <Tom.Mueller@sun.com>
parents:
1281
diff
changeset
|
220 |
# read-only file |
1507
b956ea23d3a6
11735 pkg history data files should not be executable
Richard Lowe <richlowe@richlowe.net>
parents:
1407
diff
changeset
|
221 |
os.chmod(final_path, stat.S_IRUSR|stat.S_IWUSR) |
1330
ef504d0f0e97
10629 timestamp cannot be set on read-only file (Windows)
Tom Mueller <Tom.Mueller@sun.com>
parents:
1281
diff
changeset
|
222 |
os.utime(final_path, (t, t)) |
ef504d0f0e97
10629 timestamp cannot be set on read-only file (Windows)
Tom Mueller <Tom.Mueller@sun.com>
parents:
1281
diff
changeset
|
223 |
os.chmod(final_path, mode) |
316
d6ba58c63264
1039 circular dependency in packages is detected at install-time
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
307
diff
changeset
|
224 |
|
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
222
diff
changeset
|
225 |
def verify(self, img, **args): |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
226 |
"""Returns a tuple of lists of the form (errors, warnings, |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
227 |
info). The error list will be empty if the action has been |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
228 |
correctly installed in the given image. |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
229 |
|
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
230 |
In detail, this verifies that the file is present, and if |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
231 |
the preserve attribute is not present, that the hashes |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
232 |
and other attributes of the file match.""" |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
233 |
|
222
12006bf2a260
4 We need to be able to verify that package(s) is/are correctly installed
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
173
diff
changeset
|
234 |
path = os.path.normpath(os.path.sep.join( |
1281
b05bb3f65f58
10394 link action emits cryptic message when target is wrong
Dan Price <dp@eng.sun.com>
parents:
1100
diff
changeset
|
235 |
(img.get_root(), self.attrs["path"]))) |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
236 |
|
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
237 |
lstat, errors, warnings, info, abort = \ |
1281
b05bb3f65f58
10394 link action emits cryptic message when target is wrong
Dan Price <dp@eng.sun.com>
parents:
1100
diff
changeset
|
238 |
self.verify_fsobj_common(img, stat.S_IFREG) |
b05bb3f65f58
10394 link action emits cryptic message when target is wrong
Dan Price <dp@eng.sun.com>
parents:
1100
diff
changeset
|
239 |
if lstat: |
b05bb3f65f58
10394 link action emits cryptic message when target is wrong
Dan Price <dp@eng.sun.com>
parents:
1100
diff
changeset
|
240 |
if not stat.S_ISREG(lstat.st_mode): |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
241 |
self.replace_required = True |
222
12006bf2a260
4 We need to be able to verify that package(s) is/are correctly installed
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
173
diff
changeset
|
242 |
|
1281
b05bb3f65f58
10394 link action emits cryptic message when target is wrong
Dan Price <dp@eng.sun.com>
parents:
1100
diff
changeset
|
243 |
if abort: |
b05bb3f65f58
10394 link action emits cryptic message when target is wrong
Dan Price <dp@eng.sun.com>
parents:
1100
diff
changeset
|
244 |
assert errors |
2200
155eda704b2f
16279 Need a way to revert certain editable files to a as-installed state
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2192
diff
changeset
|
245 |
self.replace_required = True |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
246 |
return errors, warnings, info |
222
12006bf2a260
4 We need to be able to verify that package(s) is/are correctly installed
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
173
diff
changeset
|
247 |
|
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
248 |
if path.lower().endswith("/bobcat") and args["verbose"] == True: |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
249 |
# Returned as a purely informational (untranslated) |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
250 |
# message so that no client should interpret it as a |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
251 |
# reason to fail verification. |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
252 |
info.append("Warning: package may contain bobcat! " |
332
c4547bf88d96
Slight enhancement to file action verification.
Danek Duvall <danek.duvall@sun.com>
parents:
316
diff
changeset
|
253 |
"(http://xkcd.com/325/)") |
c4547bf88d96
Slight enhancement to file action verification.
Danek Duvall <danek.duvall@sun.com>
parents:
316
diff
changeset
|
254 |
|
1832
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1784
diff
changeset
|
255 |
if "preserve" not in self.attrs and \ |
df15686547e4
6795 pkg fix should fix file modes for some preserved files
Shawn Walker <shawn.walker@oracle.com>
parents:
1784
diff
changeset
|
256 |
"timestamp" in self.attrs and lstat.st_mtime != \ |
443
5ffa5b7dac9c
2589 pyc files generate lots of verify chaff
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
409
diff
changeset
|
257 |
misc.timestamp_to_time(self.attrs["timestamp"]): |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
258 |
errors.append(_("Timestamp: %(found)s should be " |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
259 |
"%(expected)s") % { |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
260 |
"found": misc.time_to_timestamp(lstat.st_mtime), |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
261 |
"expected": self.attrs["timestamp"] }) |
1281
b05bb3f65f58
10394 link action emits cryptic message when target is wrong
Dan Price <dp@eng.sun.com>
parents:
1100
diff
changeset
|
262 |
|
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
289
diff
changeset
|
263 |
# avoid checking pkg.size if elfhash present; |
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
289
diff
changeset
|
264 |
# different size files may have the same elfhash |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
222
diff
changeset
|
265 |
if "preserve" not in self.attrs and \ |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
222
diff
changeset
|
266 |
"pkg.size" in self.attrs and \ |
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
289
diff
changeset
|
267 |
"elfhash" not in self.attrs and \ |
1281
b05bb3f65f58
10394 link action emits cryptic message when target is wrong
Dan Price <dp@eng.sun.com>
parents:
1100
diff
changeset
|
268 |
lstat.st_size != int(self.attrs["pkg.size"]): |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
269 |
errors.append(_("Size: %(found)d bytes should be " |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
270 |
"%(expected)d") % { "found": lstat.st_size, |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
271 |
"expected": int(self.attrs["pkg.size"]) }) |
222
12006bf2a260
4 We need to be able to verify that package(s) is/are correctly installed
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
173
diff
changeset
|
272 |
|
447
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
273 |
if "preserve" in self.attrs: |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
274 |
return errors, warnings, info |
447
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
275 |
|
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
276 |
if args["forever"] != True: |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
277 |
return errors, warnings, info |
447
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
278 |
|
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
279 |
# |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
280 |
# Check file contents |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
281 |
# |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
282 |
try: |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
283 |
elfhash = None |
907
35e990d0c13a
7127 elf hash verification problems with new elf hashing
Danek Duvall <danek.duvall@sun.com>
parents:
879
diff
changeset
|
284 |
elferror = None |
447
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
285 |
if "elfhash" in self.attrs and haveelf: |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
286 |
# |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
287 |
# It's possible for the elf module to |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
288 |
# throw while computing the hash, |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
289 |
# especially if the file is badly |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
290 |
# corrupted or truncated. |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
291 |
# |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
292 |
try: |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
293 |
elfhash = elf.get_dynamic(path)["hash"] |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
294 |
except RuntimeError, e: |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
295 |
errors.append("Elfhash: %s" % e) |
222
12006bf2a260
4 We need to be able to verify that package(s) is/are correctly installed
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
173
diff
changeset
|
296 |
|
1281
b05bb3f65f58
10394 link action emits cryptic message when target is wrong
Dan Price <dp@eng.sun.com>
parents:
1100
diff
changeset
|
297 |
if elfhash is not None and \ |
b05bb3f65f58
10394 link action emits cryptic message when target is wrong
Dan Price <dp@eng.sun.com>
parents:
1100
diff
changeset
|
298 |
elfhash != self.attrs["elfhash"]: |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
299 |
elferror = _("Elfhash: %(found)s " |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
300 |
"should be %(expected)s") % { |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
301 |
"found": elfhash, |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
302 |
"expected": self.attrs["elfhash"] } |
447
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
303 |
|
907
35e990d0c13a
7127 elf hash verification problems with new elf hashing
Danek Duvall <danek.duvall@sun.com>
parents:
879
diff
changeset
|
304 |
# If we failed to compute the content hash, or the |
35e990d0c13a
7127 elf hash verification problems with new elf hashing
Danek Duvall <danek.duvall@sun.com>
parents:
879
diff
changeset
|
305 |
# content hash failed to verify, try the file hash. |
35e990d0c13a
7127 elf hash verification problems with new elf hashing
Danek Duvall <danek.duvall@sun.com>
parents:
879
diff
changeset
|
306 |
# If the content hash fails to match but the file hash |
35e990d0c13a
7127 elf hash verification problems with new elf hashing
Danek Duvall <danek.duvall@sun.com>
parents:
879
diff
changeset
|
307 |
# matches, it indicates that the content hash algorithm |
35e990d0c13a
7127 elf hash verification problems with new elf hashing
Danek Duvall <danek.duvall@sun.com>
parents:
879
diff
changeset
|
308 |
# changed, since obviously the file hash is a superset |
35e990d0c13a
7127 elf hash verification problems with new elf hashing
Danek Duvall <danek.duvall@sun.com>
parents:
879
diff
changeset
|
309 |
# of the content hash. |
35e990d0c13a
7127 elf hash verification problems with new elf hashing
Danek Duvall <danek.duvall@sun.com>
parents:
879
diff
changeset
|
310 |
if elfhash is None or elferror: |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
621
diff
changeset
|
311 |
hashvalue, data = misc.get_data_digest(path) |
447
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
312 |
if hashvalue != self.hash: |
907
35e990d0c13a
7127 elf hash verification problems with new elf hashing
Danek Duvall <danek.duvall@sun.com>
parents:
879
diff
changeset
|
313 |
# Prefer the content hash error message. |
35e990d0c13a
7127 elf hash verification problems with new elf hashing
Danek Duvall <danek.duvall@sun.com>
parents:
879
diff
changeset
|
314 |
if elferror: |
35e990d0c13a
7127 elf hash verification problems with new elf hashing
Danek Duvall <danek.duvall@sun.com>
parents:
879
diff
changeset
|
315 |
errors.append(elferror) |
35e990d0c13a
7127 elf hash verification problems with new elf hashing
Danek Duvall <danek.duvall@sun.com>
parents:
879
diff
changeset
|
316 |
else: |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
317 |
errors.append(_("Hash: " |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
318 |
"%(found)s should be " |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
319 |
"%(expected)s") % { |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
320 |
"found": hashvalue, |
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
321 |
"expected": self.hash }) |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
322 |
self.replace_required = True |
447
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
323 |
except EnvironmentError, e: |
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
324 |
if e.errno == errno.EACCES: |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
325 |
errors.append(_("Skipping: Permission Denied")) |
447
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
326 |
else: |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
327 |
errors.append(_("Unexpected Error: %s") % e) |
447
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
328 |
except Exception, e: |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
329 |
errors.append(_("Unexpected Exception: %s") % e) |
447
b7f27ea377b6
2784 verify not bombproofed against exploding elf module
Dan Price <dp@eng.sun.com>
parents:
443
diff
changeset
|
330 |
|
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
331 |
return errors, warnings, info |
222
12006bf2a260
4 We need to be able to verify that package(s) is/are correctly installed
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
173
diff
changeset
|
332 |
|
1767
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
333 |
def __check_preserve(self, orig, pkgplan): |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
334 |
"""Return the type of preservation needed for this action. |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
335 |
|
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
336 |
Returns None if preservation is not defined by the action. |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
337 |
Returns False if it is, but no preservation is necessary. |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
338 |
Returns True for the normal preservation form. Returns one of |
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
339 |
the strings 'renameold', 'renameold.update', or 'renamenew' |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
340 |
for each of the respective forms of preservation. |
1767
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
341 |
""" |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
342 |
|
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
343 |
if not "preserve" in self.attrs: |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
344 |
return None |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
345 |
|
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
346 |
final_path = os.path.normpath(os.path.sep.join( |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
347 |
(pkgplan.image.get_root(), self.attrs["path"]))) |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
348 |
|
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
349 |
pres_type = False |
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
350 |
# If action has been marked with a preserve attribute, the |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
351 |
# hash of the preserved file has changed between versions, |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
352 |
# and the package being installed is older than the package |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
353 |
# that was installed, and the version on disk is different |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
354 |
# than the installed package's original version, then preserve |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
355 |
# the installed file by renaming it. |
2192
906bafc90a02
17702 file install can fail when original_name and preserve set and old file exists
Shawn Walker <shawn.walker@oracle.com>
parents:
2089
diff
changeset
|
356 |
# |
906bafc90a02
17702 file install can fail when original_name and preserve set and old file exists
Shawn Walker <shawn.walker@oracle.com>
parents:
2089
diff
changeset
|
357 |
# If pkgplan.origin_fmri isn't set, but there is an orig action, |
906bafc90a02
17702 file install can fail when original_name and preserve set and old file exists
Shawn Walker <shawn.walker@oracle.com>
parents:
2089
diff
changeset
|
358 |
# then this file is moving between packages and it can't be |
906bafc90a02
17702 file install can fail when original_name and preserve set and old file exists
Shawn Walker <shawn.walker@oracle.com>
parents:
2089
diff
changeset
|
359 |
# a downgrade since that isn't allowed across rename or obsolete |
906bafc90a02
17702 file install can fail when original_name and preserve set and old file exists
Shawn Walker <shawn.walker@oracle.com>
parents:
2089
diff
changeset
|
360 |
# boundaries. |
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
361 |
if orig and pkgplan.destination_fmri and \ |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
362 |
self.hash != orig.hash and \ |
2192
906bafc90a02
17702 file install can fail when original_name and preserve set and old file exists
Shawn Walker <shawn.walker@oracle.com>
parents:
2089
diff
changeset
|
363 |
pkgplan.origin_fmri and \ |
2089
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
364 |
pkgplan.destination_fmri.version < pkgplan.origin_fmri.version: |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
365 |
# Installed, preserved file is for a package newer than |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
366 |
# what will be installed. So check if the version on |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
367 |
# disk is different than what was originally delivered, |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
368 |
# and if so, preserve it. |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
369 |
if os.path.isfile(final_path): |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
370 |
ihash, cdata = misc.get_data_digest(final_path) |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
371 |
if ihash != orig.hash: |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
372 |
# .old is intentionally avoided here to |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
373 |
# avoid accidental collisions with the |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
374 |
# normal install process. |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
375 |
return "renameold.update" |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
376 |
return False |
c8b9d6341530
2775 pkg should provide a way to downgrade (reinstall) packages
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
377 |
|
1767
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
378 |
# If the action has been marked with a preserve attribute, and |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
379 |
# the file exists and has a content hash different from what the |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
380 |
# system expected it to be, then we preserve the original file |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
381 |
# in some way, depending on the value of preserve. |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
382 |
if os.path.isfile(final_path): |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
383 |
chash, cdata = misc.get_data_digest(final_path) |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
384 |
|
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
385 |
if not orig or chash != orig.hash: |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
386 |
pres_type = self.attrs["preserve"] |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
387 |
if pres_type in ("renameold", "renamenew"): |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
388 |
return pres_type |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
389 |
else: |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
390 |
return True |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
391 |
return pres_type |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
392 |
|
125
8b66970ab314
Add preserve attribute to file action
Danek Duvall <danek.duvall@sun.com>
parents:
121
diff
changeset
|
393 |
# If we're not upgrading, or the file contents have changed, |
8b66970ab314
Add preserve attribute to file action
Danek Duvall <danek.duvall@sun.com>
parents:
121
diff
changeset
|
394 |
# retrieve the file and write it to a temporary location. |
8b66970ab314
Add preserve attribute to file action
Danek Duvall <danek.duvall@sun.com>
parents:
121
diff
changeset
|
395 |
# For ELF files, only write the new file if the elfhash changed. |
1767
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
396 |
def needsdata(self, orig, pkgplan): |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
397 |
if self.replace_required: |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
552
diff
changeset
|
398 |
return True |
873
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
621
diff
changeset
|
399 |
bothelf = orig and "elfhash" in orig.attrs and \ |
b95d76c53b5e
2691 ability to publish packages to local disk repository
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
621
diff
changeset
|
400 |
"elfhash" in self.attrs |
119
537d69114be4
Implement bundled file downloads using filelist
johansen <johansen@sun.com>
parents:
81
diff
changeset
|
401 |
if not orig or \ |
359
e9d44298b6a5
1618 Files with matching elf hashes shouldn't be downloaded even if file hashes don't match
Danek Duvall <danek.duvall@sun.com>
parents:
342
diff
changeset
|
402 |
(orig.hash != self.hash and (not bothelf or |
e9d44298b6a5
1618 Files with matching elf hashes shouldn't be downloaded even if file hashes don't match
Danek Duvall <danek.duvall@sun.com>
parents:
342
diff
changeset
|
403 |
orig.attrs["elfhash"] != self.attrs["elfhash"])): |
119
537d69114be4
Implement bundled file downloads using filelist
johansen <johansen@sun.com>
parents:
81
diff
changeset
|
404 |
return True |
1778
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
405 |
elif orig: |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
406 |
# It's possible that the file content hasn't changed |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
407 |
# for an upgrade case, but the file is missing. This |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
408 |
# ensures that for cases where the mode or some other |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
409 |
# attribute of the file has changed that the file will |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
410 |
# be installed. |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
411 |
path = os.path.normpath(os.path.sep.join( |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
412 |
(pkgplan.image.get_root(), self.attrs["path"]))) |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
413 |
if not os.path.isfile(path): |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
414 |
return True |
119
537d69114be4
Implement bundled file downloads using filelist
johansen <johansen@sun.com>
parents:
81
diff
changeset
|
415 |
|
1767
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
416 |
if self.__check_preserve(orig, pkgplan): |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
417 |
return True |
e8a100940a12
14570 file install logic discommoded by excessive cleverness if preserve=rename*
Danek Duvall <danek.duvall@sun.com>
parents:
1755
diff
changeset
|
418 |
|
119
537d69114be4
Implement bundled file downloads using filelist
johansen <johansen@sun.com>
parents:
81
diff
changeset
|
419 |
return False |
1281
b05bb3f65f58
10394 link action emits cryptic message when target is wrong
Dan Price <dp@eng.sun.com>
parents:
1100
diff
changeset
|
420 |
|
136 | 421 |
def remove(self, pkgplan): |
66 | 422 |
path = os.path.normpath(os.path.sep.join( |
136 | 423 |
(pkgplan.image.get_root(), self.attrs["path"]))) |
66 | 424 |
|
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
425 |
# Are we supposed to save this file to restore it elsewhere |
462
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
426 |
# or in another pkg? |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
427 |
if "save_file" in self.attrs: |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
428 |
self.save_file(pkgplan.image, path) |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
429 |
|
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
222
diff
changeset
|
430 |
try: |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
431 |
# Make file writable so it can be deleted. |
621
6c144915eed1
551 IPS should handle socket errors
johansen <johansen@sun.com>
parents:
605
diff
changeset
|
432 |
os.chmod(path, stat.S_IWRITE|stat.S_IREAD) |
1685
51f832187af7
3005 some pkg verify errors should be warnings or informational messages
Shawn Walker <srw@sun.com>
parents:
1516
diff
changeset
|
433 |
except OSError, e: |
1859
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
434 |
if e.errno == errno.ENOENT: |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
435 |
# Already gone; don't care. |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
436 |
return |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
437 |
raise |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
438 |
|
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
439 |
# Attempt to remove the file. |
6e6e866921e7
529 client can traceback with EBUSY during action removal
Shawn Walker <shawn.walker@oracle.com>
parents:
1846
diff
changeset
|
440 |
self.remove_fsobj(pkgplan, path) |
222
12006bf2a260
4 We need to be able to verify that package(s) is/are correctly installed
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
173
diff
changeset
|
441 |
|
81
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
442 |
def different(self, other): |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
443 |
# Override the generic different() method to ignore the file |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
444 |
# hash for ELF files and compare the ELF hash instead. |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
445 |
# XXX This should be modularized and controlled by policy. |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
446 |
|
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
447 |
# One of these isn't an ELF file, so call the generic method |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
448 |
if "elfhash" not in self.attrs or "elfhash" not in other.attrs: |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
449 |
return generic.Action.different(self, other) |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
450 |
|
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
451 |
sset = set(self.attrs.keys()) |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
452 |
oset = set(other.attrs.keys()) |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
453 |
if sset.symmetric_difference(oset): |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
454 |
return True |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
455 |
|
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
456 |
for a in self.attrs: |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
457 |
if self.attrs[a] != other.attrs[a]: |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
458 |
return True |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
459 |
|
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
460 |
return False |
9e0ba665ce7c
Upgrade ELF files only if the ELF hash is different.
Danek Duvall <danek.duvall@sun.com>
parents:
72
diff
changeset
|
461 |
|
144
ce619e0b453f
Fix unscalable search indexing
Danek Duvall <danek.duvall@sun.com>
parents:
140
diff
changeset
|
462 |
def generate_indices(self): |
1100
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
941
diff
changeset
|
463 |
"""Generates the indices needed by the search dictionary. See |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
941
diff
changeset
|
464 |
generic.py for a more detailed explanation.""" |
22a8b08d460a
7364 documentation and code comments needed for fix for 6175
Brock Pytlik <bpytlik@sun.com>
parents:
941
diff
changeset
|
465 |
|
941
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
907
diff
changeset
|
466 |
return [ |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
907
diff
changeset
|
467 |
("file", "content", self.hash, self.hash), |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
907
diff
changeset
|
468 |
("file", "basename", os.path.basename(self.attrs["path"]), |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
907
diff
changeset
|
469 |
None), |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
907
diff
changeset
|
470 |
("file", "path", os.path.sep + self.attrs["path"], None) |
e7bff46da54e
6175 search needs to be moved to version 1
Brock Pytlik <bpytlik@sun.com>
parents:
907
diff
changeset
|
471 |
] |
462
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
472 |
|
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
473 |
def save_file(self, image, full_path): |
1778
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
474 |
"""Save a file for later installation (in same process |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
475 |
invocation, if it exists).""" |
462
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
476 |
|
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
477 |
saved_name = image.temporary_file() |
1778
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
478 |
try: |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
479 |
misc.copyfile(full_path, saved_name) |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
480 |
except OSError, err: |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
481 |
if err.errno != errno.ENOENT: |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
482 |
raise |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
483 |
|
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
484 |
# If the file doesn't exist, it can't be saved, so |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
485 |
# be certain consumers of this information know there |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
486 |
# isn't an original to restore. |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
487 |
saved_name = None |
1281
b05bb3f65f58
10394 link action emits cryptic message when target is wrong
Dan Price <dp@eng.sun.com>
parents:
1100
diff
changeset
|
488 |
|
1842
b71de8f65cc8
15176 imageplan keeps solver cache and catalog data too long
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
489 |
ip = image.imageplan |
b71de8f65cc8
15176 imageplan keeps solver cache and catalog data too long
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
490 |
ip.saved_files[self.attrs["save_file"]] = (self, saved_name) |
462
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
491 |
|
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
492 |
def restore_file(self, image): |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
493 |
"""restore a previously saved file; return cached action """ |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
494 |
|
1842
b71de8f65cc8
15176 imageplan keeps solver cache and catalog data too long
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
495 |
ip = image.imageplan |
b71de8f65cc8
15176 imageplan keeps solver cache and catalog data too long
Shawn Walker <shawn.walker@oracle.com>
parents:
1832
diff
changeset
|
496 |
orig, saved_name = ip.saved_files[self.attrs["save_file"]] |
1778
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
497 |
if saved_name is None: |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
498 |
# Nothing to restore; original file is missing. |
694fd825a62a
14702 file action removal fails if file is missing and original_name is set
Shawn Walker <srw@sun.com>
parents:
1767
diff
changeset
|
499 |
return |
462
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
500 |
|
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
501 |
path = self.attrs["path"] |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
502 |
|
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
503 |
full_path = os.path.normpath(os.path.sep.join( |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
504 |
(image.get_root(), path))) |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
505 |
|
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
506 |
assert(not os.path.exists(full_path)) |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
507 |
|
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
508 |
misc.copyfile(saved_name, full_path) |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
509 |
os.unlink(saved_name) |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
510 |
|
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
447
diff
changeset
|
511 |
return orig |
1755
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
512 |
|
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
513 |
def validate(self, fmri=None): |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
514 |
"""Performs additional validation of action attributes that |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
515 |
for performance or other reasons cannot or should not be done |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
516 |
during Action object creation. An ActionError exception (or |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
517 |
subclass of) will be raised if any attributes are not valid. |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
518 |
This is primarily intended for use during publication or during |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
519 |
error handling to provide additional diagonostics. |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
520 |
|
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
521 |
'fmri' is an optional package FMRI (object or string) indicating |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
522 |
what package contained this action.""" |
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
523 |
|
8e1ed1373f93
9123 client traceback during install for bad file mode
Shawn Walker <srw@sun.com>
parents:
1713
diff
changeset
|
524 |
return self.validate_fsobj_common(fmri=fmri) |