author | Shawn Walker <srw@sun.com> |
Tue, 17 Nov 2009 17:06:35 -0600 | |
changeset 1504 | 265a1d6b86bd |
parent 1503 | 78d56b8ee320 |
child 1505 | cc598d70bbbe |
permissions | -rw-r--r-- |
409
713e20963dc2
2314 shebang lines should use minimum python version
Shawn Walker <swalker@opensolaris.org>
parents:
405
diff
changeset
|
1 |
#!/usr/bin/python2.4 |
19 | 2 |
# |
3 |
# CDDL HEADER START |
|
4 |
# |
|
5 |
# The contents of this file are subject to the terms of the |
|
6 |
# Common Development and Distribution License (the "License"). |
|
7 |
# You may not use this file except in compliance with the License. |
|
8 |
# |
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
10 |
# or http://www.opensolaris.org/os/licensing. |
|
11 |
# See the License for the specific language governing permissions |
|
12 |
# and limitations under the License. |
|
13 |
# |
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
|
19 |
# |
|
20 |
# CDDL HEADER END |
|
21 |
# |
|
22 |
||
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
23 |
# |
835
34ec4401dc48
686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents:
834
diff
changeset
|
24 |
# Copyright 2009 Sun Microsystems, Inc. All rights reserved. |
19 | 25 |
# Use is subject to license terms. |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
26 |
# |
19 | 27 |
|
161
e0322fe7842c
Simplify and correct the package matching code.
Danek Duvall <danek.duvall@sun.com>
parents:
157
diff
changeset
|
28 |
import errno |
26 | 29 |
import os |
838
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
30 |
import platform |
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
31 |
import shutil |
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
32 |
import tempfile |
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
33 |
import time |
45
8a3f00dea14f
catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents:
39
diff
changeset
|
34 |
import urllib |
479
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
462
diff
changeset
|
35 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
36 |
from pkg.client import global_settings |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
37 |
logger = global_settings.logger |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
38 |
|
655
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
39 |
import pkg.Uuid25 |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
40 |
import pkg.catalog |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
41 |
import pkg.client.api_errors as api_errors |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
42 |
import pkg.client.constraint as constraint |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
43 |
import pkg.client.history as history |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
44 |
import pkg.client.imageconfig as imageconfig |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
45 |
import pkg.client.imageplan as imageplan |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
46 |
import pkg.client.imagestate as imagestate |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
47 |
import pkg.client.pkgplan as pkgplan |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
48 |
import pkg.client.progress as progress |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
49 |
import pkg.client.publisher as publisher |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
50 |
import pkg.client.transport.transport as transport |
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
302
diff
changeset
|
51 |
import pkg.fmri |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
52 |
import pkg.manifest as manifest |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
53 |
import pkg.misc as misc |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
54 |
import pkg.portable as portable |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
55 |
import pkg.server.catalog |
1231
f7b99e8118d2
9290 need a way to find the file dependencies of a package
Brock Pytlik <bpytlik@sun.com>
parents:
1210
diff
changeset
|
56 |
import pkg.variant as variant |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
57 |
import pkg.version |
104
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
58 |
|
1328
5c3747a4fe0a
9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1288
diff
changeset
|
59 |
from pkg.client.debugvalues import DebugValues |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
60 |
from pkg.client.imagetypes import IMG_USER, IMG_ENTIRE |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
61 |
from pkg.misc import CfgCacheError, EmptyI, EmptyDict |
19 | 62 |
|
26 | 63 |
img_user_prefix = ".org.opensolaris,pkg" |
30 | 64 |
img_root_prefix = "var/pkg" |
26 | 65 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
66 |
IMG_PUB_DIR = "publisher" |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
67 |
|
19 | 68 |
class Image(object): |
69 |
"""An Image object is a directory tree containing the laid-down contents |
|
70 |
of a self-consistent graph of Packages. |
|
71 |
||
72 |
An Image has a root path. |
|
73 |
||
74 |
An Image of type IMG_ENTIRE does not have a parent Image. Other Image |
|
75 |
types must have a parent Image. The external state of the parent Image |
|
76 |
must be accessible from the Image's context, or duplicated within the |
|
77 |
Image (IMG_PARTIAL for zones, for instance). |
|
78 |
||
79 |
The parent of a user Image can be a partial Image. The parent of a |
|
80 |
partial Image must be an entire Image. |
|
81 |
||
82 |
An Image of type IMG_USER stores its external state at self.root + |
|
26 | 83 |
".org.opensolaris,pkg". |
19 | 84 |
|
85 |
An Image of type IMG_ENTIRE or IMG_PARTIAL stores its external state at |
|
86 |
self.root + "/var/pkg". |
|
87 |
||
26 | 88 |
An Image needs to be able to have a different repository set than the |
89 |
system's root Image. |
|
90 |
||
29
f621f1df0849
fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents:
26
diff
changeset
|
91 |
Directory layout |
f621f1df0849
fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents:
26
diff
changeset
|
92 |
|
30 | 93 |
$IROOT/file |
94 |
Directory containing file hashes of installed packages. |
|
95 |
||
96 |
$IROOT/pkg |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
97 |
Directory containing manifests. |
30 | 98 |
|
60
6bd5cd83cfb1
Reverse index database and searching support.
Danek Duvall <danek.duvall@sun.com>
parents:
59
diff
changeset
|
99 |
$IROOT/index |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
100 |
Directory containing search indices. |
60
6bd5cd83cfb1
Reverse index database and searching support.
Danek Duvall <danek.duvall@sun.com>
parents:
59
diff
changeset
|
101 |
|
104
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
102 |
$IROOT/cfg_cache |
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
103 |
File containing image's cached configuration. |
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
104 |
|
418
21621fd99956
2543 eliminate unnecessary stat() calls from gen_installed_pkgs()
Danek Duvall <danek.duvall@sun.com>
parents:
409
diff
changeset
|
105 |
$IROOT/opaque |
104
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
106 |
File containing image's opaque state. |
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
107 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
108 |
$IROOT/publisher |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
109 |
Directory containing publisher metadata. |
418
21621fd99956
2543 eliminate unnecessary stat() calls from gen_installed_pkgs()
Danek Duvall <danek.duvall@sun.com>
parents:
409
diff
changeset
|
110 |
|
397
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
111 |
All of these directories and files other than state are considered |
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
112 |
essential for any image to be complete. To add a new essential file or |
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
113 |
subdirectory, the following steps should be done. |
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
114 |
|
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
115 |
If it's a directory, add it to the image_subdirs list below and it will |
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
116 |
be created automatically. The programmer must fill the directory as |
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
117 |
needed. If a file is added, the programmer is responsible for creating |
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
118 |
that file during image creation at an appropriate place and time. |
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
119 |
|
418
21621fd99956
2543 eliminate unnecessary stat() calls from gen_installed_pkgs()
Danek Duvall <danek.duvall@sun.com>
parents:
409
diff
changeset
|
120 |
If a directory is required to be present in order for an image to be |
21621fd99956
2543 eliminate unnecessary stat() calls from gen_installed_pkgs()
Danek Duvall <danek.duvall@sun.com>
parents:
409
diff
changeset
|
121 |
identifiable as such, it should go into required_subdirs instead. |
21621fd99956
2543 eliminate unnecessary stat() calls from gen_installed_pkgs()
Danek Duvall <danek.duvall@sun.com>
parents:
409
diff
changeset
|
122 |
However, upgrade issues abound; this list should probably not change. |
21621fd99956
2543 eliminate unnecessary stat() calls from gen_installed_pkgs()
Danek Duvall <danek.duvall@sun.com>
parents:
409
diff
changeset
|
123 |
|
397
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
124 |
Once those steps have been carried out, the change should be added |
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
125 |
to the test suite for image corruption (t_pkg_install_corrupt_image.py). |
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
126 |
This will likely also involve a change to |
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
127 |
SingleDepotTestCaseCorruptImage in testutils.py. Each of these files |
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
128 |
outline what must be updated. |
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
129 |
|
19 | 130 |
XXX Root path probably can't be absolute, so that we can combine or |
30 | 131 |
reuse Image contents. |
26 | 132 |
|
133 |
XXX Image file format? Image file manipulation API?""" |
|
134 |
||
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
135 |
# Class constants |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
136 |
IMG_CATALOG_KNOWN = "known" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
137 |
IMG_CATALOG_INSTALLED = "installed" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
138 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
139 |
# Please note that the values of these PKG_STATE constants should not |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
140 |
# be changed as it would invalidate existing catalog data stored in the |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
141 |
# image. This means that if a constant is removed, the values of the |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
142 |
# other constants should not change, etc. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
143 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
144 |
# This is a temporary, private state that is used to indicate that |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
145 |
# a package with state PKG_STATE_INSTALLED was installed from a |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
146 |
# publisher that was preferred at the time of installation. It |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
147 |
# will be obsolete in the near future when publishers are ranked |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
148 |
# instead. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
149 |
__PKG_STATE_PREFERRED = 5 |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
150 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
151 |
# This state indicates that a package is present in a repository |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
152 |
# catalog. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
153 |
PKG_STATE_KNOWN = 0 |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
154 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
155 |
# This is a transitory state used to indicate that a package is no |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
156 |
# longer present in a repository catalog; it is only used to clear |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
157 |
# PKG_STATE_KNOWN. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
158 |
PKG_STATE_UNKNOWN = 1 |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
159 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
160 |
# This state indicates that a package is installed. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
161 |
PKG_STATE_INSTALLED = 2 |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
162 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
163 |
# This is a transitory state used to indicate that a package is no |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
164 |
# longer installed; it is only used to clear PKG_STATE_INSTALLED. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
165 |
PKG_STATE_UNINSTALLED = 3 |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
166 |
PKG_STATE_UPGRADABLE = 4 |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
167 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
168 |
# These states are used to indicate the package's related catalog |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
169 |
# version. This is helpful to consumers of the catalog data so that |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
170 |
# they can be aware of what metadata may not immediately available |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
171 |
# (require manifest retrieval) based on the catalog version. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
172 |
PKG_STATE_V0 = 6 |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
173 |
PKG_STATE_V1 = 7 |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
174 |
|
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
175 |
PKG_STATE_OBSOLETE = 8 |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
176 |
PKG_STATE_RENAMED = 9 |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
177 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
178 |
# Class properties |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
179 |
required_subdirs = [ "file", "pkg" ] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
180 |
image_subdirs = required_subdirs + [ "index", IMG_PUB_DIR, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
181 |
"state/installed", "state/known" ] |
397
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
182 |
|
1370
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
183 |
def __init__(self, root, user_provided_dir=False, progtrack=None, |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
184 |
should_exist=True, imgtype=None, force=False): |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
185 |
if should_exist: |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
186 |
assert(imgtype is None) |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
187 |
assert(not force) |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
188 |
else: |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
189 |
assert(imgtype is not None) |
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
190 |
|
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
191 |
self.__init_catalogs() |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
192 |
self.__upgraded = False |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
193 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
194 |
self.arch_change = False |
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
195 |
self.attrs = { |
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
196 |
"Policy-Require-Optional": False, |
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
197 |
"Policy-Pursue-Latest": True |
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
198 |
} |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
199 |
self.cfg_cache = None |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
200 |
self.constraints = constraint.ConstraintSet() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
201 |
self.dl_cache_dir = None |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
202 |
self.dl_cache_incoming = None |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
203 |
self.history = history.History() |
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
204 |
self.imageplan = None # valid after evaluation succeeds |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
205 |
self.img_prefix = None |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
206 |
self.imgdir = None |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
207 |
self.index_dir = None |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
208 |
self.is_user_cache_dir = False |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
209 |
self.new_variants = {} |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
210 |
self.pkgdir = None |
1370
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
211 |
self.root = root |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
212 |
|
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
213 |
# Transport operations for this image |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
214 |
self.transport = transport.Transport(self) |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
215 |
|
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
216 |
if should_exist: |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
217 |
self.find_root(self.root, user_provided_dir, |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
218 |
progtrack) |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
219 |
else: |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
220 |
if not force and self.image_type(self.root) != None: |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
221 |
raise api_errors.ImageAlreadyExists(self.root) |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
222 |
if not force and os.path.exists(self.root) and \ |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
223 |
len(os.listdir(self.root)) > 0: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
224 |
raise api_errors.CreatingImageInNonEmptyDir( |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
225 |
self.root) |
1370
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
226 |
self.__set_dirs(root=self.root, imgtype=imgtype, |
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
227 |
progtrack=progtrack) |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
228 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
229 |
# a place to keep info about saved_files; needed by file action |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
230 |
self.saved_files = {} |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
231 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
232 |
self.state = imagestate.ImageState(self) |
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
302
diff
changeset
|
233 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
234 |
self.type = None |
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
235 |
|
674
e740c8c3bed1
166 os.makedirs() does not set directory mode
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
664
diff
changeset
|
236 |
# right now we don't explicitly set dir/file modes everywhere; |
e740c8c3bed1
166 os.makedirs() does not set directory mode
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
664
diff
changeset
|
237 |
# set umask to proper value to prevent problems w/ overly |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
238 |
# locked down umask. |
674
e740c8c3bed1
166 os.makedirs() does not set directory mode
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
664
diff
changeset
|
239 |
os.umask(0022) |
e740c8c3bed1
166 os.makedirs() does not set directory mode
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
664
diff
changeset
|
240 |
|
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
241 |
def _check_subdirs(self, sub_d, prefix): |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
242 |
for n in self.required_subdirs: |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
243 |
if not os.path.isdir(os.path.join(sub_d, prefix, n)): |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
244 |
return False |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
245 |
return True |
397
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
246 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
247 |
def __catalog_loaded(self, name): |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
248 |
"""Returns a boolean value indicating whether the named catalog |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
249 |
has already been loaded. This is intended to be used as an |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
250 |
optimization function to determine which catalog to request.""" |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
251 |
|
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
252 |
return name in self.__catalogs |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
253 |
|
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
254 |
def __init_catalogs(self): |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
255 |
"""Initializes default catalog state. Actual data is provided |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
256 |
on demand via get_catalog()""" |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
257 |
|
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
258 |
# This is used to cache image catalogs. |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
259 |
self.__catalogs = {} |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
260 |
|
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
261 |
# This is used to keep track of what packages have been added |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
262 |
# to IMG_CATALOG_KNOWN by set_pkg_state(). |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
263 |
self.__catalog_new_installs = set() |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
264 |
|
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
265 |
def image_type(self, d): |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
266 |
"""Returns the type of image at directory: d; or None""" |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
267 |
rv = None |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
268 |
if os.path.isdir(os.path.join(d, img_user_prefix)) and \ |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
269 |
os.path.isfile(os.path.join(d, img_user_prefix, |
786
a400f8c4d1c0
2340 support authority enable and disable
Tom Mueller <Tom.Mueller@sun.com>
parents:
756
diff
changeset
|
270 |
imageconfig.CFG_FILE)) and \ |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
271 |
self._check_subdirs(d, img_user_prefix): |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
272 |
rv = IMG_USER |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
273 |
elif os.path.isdir(os.path.join(d, img_root_prefix)) \ |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
274 |
and os.path.isfile(os.path.join(d, |
786
a400f8c4d1c0
2340 support authority enable and disable
Tom Mueller <Tom.Mueller@sun.com>
parents:
756
diff
changeset
|
275 |
img_root_prefix, imageconfig.CFG_FILE)) and \ |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
276 |
self._check_subdirs(d, img_root_prefix): |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
277 |
rv = IMG_ENTIRE |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
278 |
return rv |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
279 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
280 |
def find_root(self, d, exact_match=False, progtrack=None): |
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
281 |
# Ascend from the given directory d to find first |
1370
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
282 |
# encountered image. If exact_match is true, if the |
561
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
560
diff
changeset
|
283 |
# image found doesn't match startd, raise an |
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
560
diff
changeset
|
284 |
# ImageNotFoundException. |
1370
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
285 |
|
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
286 |
startd = d |
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
287 |
# eliminate problem if relative path such as "." is passed in |
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
288 |
d = os.path.realpath(d) |
26 | 289 |
while True: |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
290 |
imgtype = self.image_type(d) |
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
291 |
if imgtype == IMG_USER: |
26 | 292 |
# XXX Look at image file to determine filter |
293 |
# tags and repo URIs. |
|
561
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
560
diff
changeset
|
294 |
if exact_match and \ |
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
560
diff
changeset
|
295 |
os.path.realpath(startd) != \ |
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
560
diff
changeset
|
296 |
os.path.realpath(d): |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
297 |
raise api_errors.ImageNotFoundException( |
561
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
560
diff
changeset
|
298 |
exact_match, startd, d) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
299 |
self.__set_dirs(imgtype=imgtype, root=d, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
300 |
progtrack=progtrack) |
59
eef94b0c0694
require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents:
51
diff
changeset
|
301 |
self.attrs["Build-Release"] = "5.11" |
26 | 302 |
return |
582
303fa3b78f93
3588 Ensure that users don't image-create over top of an image
Brad Hall <bhall@eng.sun.com>
parents:
577
diff
changeset
|
303 |
elif imgtype == IMG_ENTIRE: |
26 | 304 |
# XXX Look at image file to determine filter |
305 |
# tags and repo URIs. |
|
306 |
# XXX Look at image file to determine if this |
|
307 |
# image is a partial image. |
|
561
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
560
diff
changeset
|
308 |
if exact_match and \ |
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
560
diff
changeset
|
309 |
os.path.realpath(startd) != \ |
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
560
diff
changeset
|
310 |
os.path.realpath(d): |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
311 |
raise api_errors.ImageNotFoundException( |
561
be1ad23e7704
1651 pkg treats -R <bogus-dir> as "use the image at /"
Brock Pytlik <bpytlik@sun.com>
parents:
560
diff
changeset
|
312 |
exact_match, startd, d) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
313 |
self.__set_dirs(imgtype=imgtype, root=d, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
314 |
progtrack=progtrack) |
59
eef94b0c0694
require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents:
51
diff
changeset
|
315 |
self.attrs["Build-Release"] = "5.11" |
26 | 316 |
return |
317 |
||
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
318 |
# XXX follow symlinks or not? |
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
319 |
oldpath = d |
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
320 |
d = os.path.normpath(os.path.join(d, os.path.pardir)) |
26 | 321 |
|
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
322 |
# Make sure we are making progress and aren't in an |
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
323 |
# infinite loop. |
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
324 |
# |
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
325 |
# (XXX - Need to deal with symlinks here too) |
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
326 |
if d == oldpath: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
327 |
raise api_errors.ImageNotFoundException( |
596
f4519e2a99bc
3704 InventoryException raised if optional dependencies not in catalog
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
583
diff
changeset
|
328 |
exact_match, startd, d) |
26 | 329 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
330 |
def __load_config(self): |
104
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
331 |
"""Load this image's cached configuration from the default |
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
332 |
location.""" |
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
333 |
|
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
334 |
# XXX Incomplete with respect to doc/image.txt description of |
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
335 |
# configuration. |
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
336 |
|
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
337 |
if self.root == None: |
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
338 |
raise RuntimeError, "self.root must be set" |
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
339 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
340 |
ic = imageconfig.ImageConfig(self.root, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
341 |
self._get_publisher_meta_dir()) |
786
a400f8c4d1c0
2340 support authority enable and disable
Tom Mueller <Tom.Mueller@sun.com>
parents:
756
diff
changeset
|
342 |
ic.read(self.imgdir) |
1111
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1107
diff
changeset
|
343 |
self.cfg_cache = ic |
26c3e2407c53
8570 zone installer needs support for ssl certs & keys
Dan Price <dp@eng.sun.com>
parents:
1107
diff
changeset
|
344 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
345 |
for pub in self.gen_publishers(inc_disabled=True): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
346 |
pub.transport = self.transport |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
347 |
|
551 | 348 |
def save_config(self): |
1143
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1141
diff
changeset
|
349 |
# First, create the image directories if they haven't been, so |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1141
diff
changeset
|
350 |
# the cfg_cache can be written. |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1141
diff
changeset
|
351 |
self.mkdirs() |
786
a400f8c4d1c0
2340 support authority enable and disable
Tom Mueller <Tom.Mueller@sun.com>
parents:
756
diff
changeset
|
352 |
self.cfg_cache.write(self.imgdir) |
551 | 353 |
|
104
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
354 |
# XXX mkdirs and set_attrs() need to be combined into a create |
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
355 |
# operation. |
29
f621f1df0849
fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents:
26
diff
changeset
|
356 |
def mkdirs(self): |
397
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
357 |
for sd in self.image_subdirs: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
358 |
if os.path.isdir(os.path.join(self.imgdir, sd)): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
359 |
continue |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
360 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
361 |
try: |
397
617be57c5f2b
777 Image.find_root thinks a repository is an image
Brock Pytlik <bpytlik@sun.com>
parents:
394
diff
changeset
|
362 |
os.makedirs(os.path.join(self.imgdir, sd)) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
363 |
except EnvironmentError, e: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
364 |
if e.errno == errno.EACCES: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
365 |
raise api_errors.PermissionsException( |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
366 |
e.filename) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
367 |
if e.errno == errno.EROFS: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
368 |
raise api_errors.ReadOnlyFileSystemException( |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
369 |
e.filename) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
370 |
raise |
29
f621f1df0849
fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents:
26
diff
changeset
|
371 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
372 |
def __set_dirs(self, imgtype, root, progtrack=None): |
554
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
373 |
self.type = imgtype |
22
379f0f6809ff
pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents:
19
diff
changeset
|
374 |
self.root = root |
379f0f6809ff
pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents:
19
diff
changeset
|
375 |
if self.type == IMG_USER: |
271
ec8a7669bff2
659 package that delivers existing automounter mountpoint fails installation
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
268
diff
changeset
|
376 |
self.img_prefix = img_user_prefix |
22
379f0f6809ff
pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents:
19
diff
changeset
|
377 |
else: |
271
ec8a7669bff2
659 package that delivers existing automounter mountpoint fails installation
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
268
diff
changeset
|
378 |
self.img_prefix = img_root_prefix |
993
7cfbab7739c3
588 directory remove of cwd fails due to EPERM or EINVAL
Danek Duvall <danek.duvall@sun.com>
parents:
988
diff
changeset
|
379 |
|
7cfbab7739c3
588 directory remove of cwd fails due to EPERM or EINVAL
Danek Duvall <danek.duvall@sun.com>
parents:
988
diff
changeset
|
380 |
# Change directory to the root of the image so that we can |
7cfbab7739c3
588 directory remove of cwd fails due to EPERM or EINVAL
Danek Duvall <danek.duvall@sun.com>
parents:
988
diff
changeset
|
381 |
# remove any directories beneath us. If we're changing the |
7cfbab7739c3
588 directory remove of cwd fails due to EPERM or EINVAL
Danek Duvall <danek.duvall@sun.com>
parents:
988
diff
changeset
|
382 |
# image, don't chdir, as we're likely changing to a new BE |
7cfbab7739c3
588 directory remove of cwd fails due to EPERM or EINVAL
Danek Duvall <danek.duvall@sun.com>
parents:
988
diff
changeset
|
383 |
# and want to be able to unmount it later. |
999
04c29b9c97a0
7811 pkg image-create no longer creates image path if it doesn't exist
Danek Duvall <danek.duvall@sun.com>
parents:
996
diff
changeset
|
384 |
if not self.imgdir and os.path.isdir(root): |
993
7cfbab7739c3
588 directory remove of cwd fails due to EPERM or EINVAL
Danek Duvall <danek.duvall@sun.com>
parents:
988
diff
changeset
|
385 |
os.chdir(root) |
7cfbab7739c3
588 directory remove of cwd fails due to EPERM or EINVAL
Danek Duvall <danek.duvall@sun.com>
parents:
988
diff
changeset
|
386 |
|
1133
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1125
diff
changeset
|
387 |
# The specified root may have been a relative path. |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1125
diff
changeset
|
388 |
self.root = os.getcwd() |
2c28e4526a6e
8720 image-create with a non-absolute path can cause strange results
Shawn Walker <srw@sun.com>
parents:
1125
diff
changeset
|
389 |
|
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
390 |
if not os.path.isabs(self.root): |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
391 |
self.root = os.path.abspath(self.root) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
392 |
|
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
393 |
self.imgdir = os.path.join(self.root, self.img_prefix) |
1037
56ff5f4fab83
8050 image-update fails from b110 to b111 at SUNWgnome-system-monitor manifest
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
999
diff
changeset
|
394 |
self.pkgdir = os.path.join(self.imgdir, "pkg") |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
395 |
self.history.root_dir = self.imgdir |
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
396 |
|
554
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
397 |
if "PKG_CACHEDIR" in os.environ: |
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
398 |
self.dl_cache_dir = os.path.normpath( \ |
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
399 |
os.environ["PKG_CACHEDIR"]) |
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
400 |
self.is_user_cache_dir = True |
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
401 |
else: |
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
402 |
self.dl_cache_dir = os.path.normpath( \ |
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
403 |
os.path.join(self.imgdir, "download")) |
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
404 |
self.dl_cache_incoming = os.path.normpath(os.path.join( |
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
405 |
self.dl_cache_dir, "incoming-%d" % os.getpid())) |
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
406 |
|
1503
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
407 |
# Test if we have the permissions to create the cache |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
408 |
# incoming directory in this hiearachy. If not, we'll need to |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
409 |
# move it somewhere else. |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
410 |
try: |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
411 |
os.makedirs(self.dl_cache_incoming) |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
412 |
except EnvironmentError, e: |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
413 |
if e.errno == errno.EACCES or e.errno == errno.EROFS: |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
414 |
self.dl_cache_incoming = tempfile.mkdtemp( |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
415 |
prefix="incoming-%d-" % os.getpid()) |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
416 |
else: |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
417 |
os.removedirs(self.dl_cache_incoming) |
78d56b8ee320
12698 download directory must be accessible to non-privileged users
johansen <johansen@sun.com>
parents:
1463
diff
changeset
|
418 |
|
1358
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
419 |
# Forcibly discard image catalogs so they can be re-loaded |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
420 |
# from the new location if they are already loaded. This |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
421 |
# also prevents scribbling on image state information in |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
422 |
# the wrong location. |
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
423 |
self.__init_catalogs() |
1358
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
424 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
425 |
if not os.path.exists(os.path.join(self.imgdir, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
426 |
imageconfig.CFG_FILE)): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
427 |
# New images inherently use the newest image format. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
428 |
# This must be set *before* creating the Publisher |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
429 |
# object so that the correct meta_root is set. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
430 |
self.__upgraded = True |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
431 |
else: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
432 |
self.__upgraded = not os.path.exists(os.path.join( |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
433 |
self.imgdir, "catalog")) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
434 |
self.__load_config() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
435 |
self.__check_image(progtrack=progtrack) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
436 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
437 |
def __check_image(self, progtrack=None): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
438 |
"""This does some basic sanity checks on the image structure |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
439 |
and attempts to correct any errors it finds.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
440 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
441 |
if not self.__upgraded: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
442 |
self.__upgrade_image(progtrack=progtrack) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
443 |
return |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
444 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
445 |
# If the image has already been upgraded, first ensure that its |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
446 |
# structure is valid. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
447 |
self.mkdirs() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
448 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
449 |
# Ensure structure for publishers is valid. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
450 |
for pub in self.gen_publishers(): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
451 |
pub.create_meta_root() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
452 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
453 |
# Once its structure is valid, then ensure state information |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
454 |
# is intact. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
455 |
kdir = os.path.join(self.imgdir, "state", |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
456 |
self.IMG_CATALOG_KNOWN) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
457 |
kcattrs = os.path.join(kdir, "catalog.attrs") |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
458 |
idir = os.path.join(self.imgdir, "state", |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
459 |
self.IMG_CATALOG_INSTALLED) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
460 |
icattrs = os.path.join(idir, "catalog.attrs") |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
461 |
if not os.path.isfile(kcattrs) and os.path.isfile(icattrs): |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
462 |
# If the known catalog doesn't exist, but the installed |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
463 |
# catalog does, then copy the installed catalog to the |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
464 |
# known catalog directory so that state information can |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
465 |
# be preserved during the rebuild. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
466 |
for fname in os.listdir(idir): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
467 |
portable.copyfile(os.path.join(idir, fname), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
468 |
os.path.join(kdir, fname)) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
469 |
self.__rebuild_image_catalogs(progtrack=progtrack) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
470 |
|
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
471 |
def set_attrs(self, is_zone, prefix, mirrors=EmptyI, origins=EmptyI, |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
472 |
ssl_key=None, ssl_cert=None, refresh_allowed=True, progtrack=None, |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
473 |
variants=EmptyDict): |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
474 |
"""Creates a new image with the given attributes if it does not |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
475 |
exist or sets the attributes of an already existing image.""" |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
476 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
477 |
if not os.path.exists(os.path.join(self.imgdir, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
478 |
imageconfig.CFG_FILE)): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
479 |
op = "image-create" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
480 |
else: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
481 |
op = "image-set-attributes" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
482 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
483 |
# Create the publisher object before creating the image |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
484 |
# so that if creation of the Publisher object fails, an |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
485 |
# empty, useless image won't be left behind. |
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1085
diff
changeset
|
486 |
repo = publisher.Repository() |
1504
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
487 |
for o in origins: |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
488 |
repo.add_origin(o, ssl_cert=ssl_cert, ssl_key=ssl_key) |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
489 |
for m in mirrors: |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
490 |
repo.add_mirror(m, ssl_cert=ssl_cert, ssl_key=ssl_key) |
265a1d6b86bd
9969 client support for multiple origins desired
Shawn Walker <srw@sun.com>
parents:
1503
diff
changeset
|
491 |
|
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1085
diff
changeset
|
492 |
newpub = publisher.Publisher(prefix, |
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1085
diff
changeset
|
493 |
meta_root=self._get_publisher_meta_root(prefix), |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
494 |
repositories=[repo], transport=self.transport) |
1086
16500d7bf1ca
8321 image_create should not validate publisher uri
Shawn Walker <srw@sun.com>
parents:
1085
diff
changeset
|
495 |
|
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
496 |
# Initialize and store the configuration object. |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
497 |
self.cfg_cache = imageconfig.ImageConfig(self.root, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
498 |
self._get_publisher_meta_dir()) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
499 |
self.history.log_operation_start(op) |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
500 |
|
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
501 |
# Determine and add the default variants for the image. |
111 | 502 |
if is_zone: |
503 |
self.cfg_cache.filters["opensolaris.zone"] = "nonglobal" |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
504 |
self.cfg_cache.variants[ |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
505 |
"variant.opensolaris.zone"] = "nonglobal" |
838
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
506 |
else: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
507 |
self.cfg_cache.variants[ |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
508 |
"variant.opensolaris.zone"] = "global" |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
509 |
|
838
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
510 |
self.cfg_cache.variants["variant.arch"] = \ |
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
511 |
variants.get("variant.arch", platform.processor()) |
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
512 |
|
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
513 |
# After setting up the default variants, add any overrides or |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
514 |
# additional variants specified. |
838
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
515 |
self.cfg_cache.variants.update(variants) |
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
516 |
|
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
517 |
# Now everything is ready for publisher configuration. |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
518 |
self.cfg_cache.preferred_publisher = newpub.prefix |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
519 |
self.add_publisher(newpub, refresh_allowed=refresh_allowed, |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
520 |
progtrack=progtrack) |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
521 |
|
1143
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1141
diff
changeset
|
522 |
# No need to save configuration as add_publisher will do that |
71becfca5cfd
8777 image-create traceback with --no-refresh
Shawn Walker <srw@sun.com>
parents:
1141
diff
changeset
|
523 |
# if successful. |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
524 |
self.history.log_operation_end() |
104
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
525 |
|
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
302
diff
changeset
|
526 |
def is_liveroot(self): |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
527 |
return bool(self.root == "/" or |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
528 |
DebugValues.get_value("simulate_live_root")) |
281
81a0bb7f7d63
217 packages need to be able to [un]install users (groups, roles, etc)
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
271
diff
changeset
|
529 |
|
344
4c887185d780
528 pkg list -u gives confusing output
Dan Price <dp@eng.sun.com>
parents:
342
diff
changeset
|
530 |
def is_zone(self): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
531 |
return self.cfg_cache.variants[ |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
532 |
"variant.opensolaris.zone"] == "nonglobal" |
838
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
533 |
|
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
534 |
def get_arch(self): |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
535 |
if "variant.arch" in self.new_variants: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
536 |
return self.new_variants["variant.arch"] |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
537 |
else: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
538 |
return self.cfg_cache.variants["variant.arch"] |
344
4c887185d780
528 pkg list -u gives confusing output
Dan Price <dp@eng.sun.com>
parents:
342
diff
changeset
|
539 |
|
29
f621f1df0849
fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents:
26
diff
changeset
|
540 |
def get_root(self): |
f621f1df0849
fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents:
26
diff
changeset
|
541 |
return self.root |
f621f1df0849
fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents:
26
diff
changeset
|
542 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
543 |
def gen_publishers(self, inc_disabled=False): |
104
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
544 |
if not self.cfg_cache: |
835
34ec4401dc48
686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents:
834
diff
changeset
|
545 |
raise CfgCacheError, "empty ImageConfig" |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
546 |
for p in self.cfg_cache.publishers: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
547 |
pub = self.cfg_cache.publishers[p] |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
548 |
if inc_disabled or not pub.disabled: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
549 |
yield self.cfg_cache.publishers[p] |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
550 |
|
479
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
462
diff
changeset
|
551 |
def check_cert_validity(self): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
552 |
"""Look through the publishers defined for the image. Print |
479
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
462
diff
changeset
|
553 |
a message and exit with an error if one of the certificates |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
462
diff
changeset
|
554 |
has expired. If certificates are getting close to expiration, |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
462
diff
changeset
|
555 |
print a warning instead.""" |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
462
diff
changeset
|
556 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
557 |
for p in self.gen_publishers(): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
558 |
for r in p.repositories: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
559 |
for uri in r.origins: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
560 |
if uri.ssl_cert: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
561 |
misc.validate_ssl_cert( |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
562 |
uri.ssl_cert, |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
563 |
prefix=p.prefix, uri=uri) |
479
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
462
diff
changeset
|
564 |
return True |
de75c17238ff
2951 Client should check if its SSL certificates have expired
johansen <johansen@sun.com>
parents:
462
diff
changeset
|
565 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
566 |
def has_publisher(self, prefix=None, alias=None): |
1252
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
1237
diff
changeset
|
567 |
"""Returns a boolean value indicating whether a publisher |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
1237
diff
changeset
|
568 |
exists in the image configuration that matches the given |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
1237
diff
changeset
|
569 |
prefix or alias.""" |
3b1b69011fcf
8709 ImageInterface.has_publisher has incorrect docstring
Shawn Walker <srw@sun.com>
parents:
1237
diff
changeset
|
570 |
for pub in self.gen_publishers(inc_disabled=True): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
571 |
if prefix == pub.prefix or (alias and |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
572 |
alias == pub.alias): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
573 |
return True |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
574 |
return False |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
575 |
|
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
576 |
def remove_publisher(self, prefix=None, alias=None, progtrack=None): |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
577 |
if not progtrack: |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
578 |
progtrack = progress.QuietProgressTracker() |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
579 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
580 |
self.history.log_operation_start("remove-publisher") |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
581 |
try: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
582 |
pub = self.get_publisher(prefix=prefix, |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
583 |
alias=alias) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
584 |
except api_errors.ApiException, e: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
585 |
self.history.log_operation_end(e) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
586 |
raise |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
587 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
588 |
if pub.prefix == self.cfg_cache.preferred_publisher: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
589 |
e = api_errors.RemovePreferredPublisher() |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
590 |
self.history.log_operation_end(error=e) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
591 |
raise e |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
592 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
593 |
self.cfg_cache.remove_publisher(pub.prefix) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
594 |
self.remove_publisher_metadata(pub, progtrack=progtrack) |
551 | 595 |
self.save_config() |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
596 |
self.history.log_operation_end() |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
597 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
598 |
def get_publishers(self): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
599 |
return self.cfg_cache.publishers |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
600 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
601 |
def get_publisher(self, prefix=None, alias=None, origin=None): |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
602 |
publishers = [p for p in self.get_publishers().values()] |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
603 |
for pub in publishers: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
604 |
if prefix and prefix == pub.prefix: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
605 |
return pub |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
606 |
elif alias and alias == pub.alias: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
607 |
return pub |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
608 |
elif origin and \ |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
609 |
pub.selected_repository.has_origin(origin): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
610 |
return pub |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
611 |
raise api_errors.UnknownPublisher(max(prefix, alias, origin)) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
612 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
613 |
def get_preferred_publisher(self): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
614 |
"""Returns the prefix of the preferred publisher.""" |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
615 |
return self.cfg_cache.preferred_publisher |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
616 |
|
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
617 |
def set_preferred_publisher(self, prefix=None, alias=None, pub=None): |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
618 |
"""Sets the preferred publisher for packaging operations. |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
619 |
|
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
620 |
'prefix' is an optional string value specifying the name of |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
621 |
a publisher; ignored if 'pub' is provided. |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
622 |
|
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
623 |
'alias' is an optional string value specifying the alias of |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
624 |
a publisher; ignored if 'pub' is provided. |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
625 |
|
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
626 |
'pub' is an optional Publisher object identifying the |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
627 |
publisher to set as the preferred publisher. |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
628 |
|
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
629 |
One of the above parameters must be provided.""" |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
630 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
631 |
self.history.log_operation_start("set-preferred-publisher") |
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
632 |
|
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
633 |
if not pub: |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
634 |
try: |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
635 |
pub = self.get_publisher(prefix=prefix, |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
636 |
alias=alias) |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
637 |
except api_errors.UnknownPublisher, e: |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
638 |
self.history.log_operation_end(error=e) |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
639 |
raise |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
640 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
641 |
if pub.disabled: |
1256
921590dc232b
8863 error message unclear when trying to disable preferred publisher
Shawn Walker <srw@sun.com>
parents:
1252
diff
changeset
|
642 |
e = api_errors.SetDisabledPublisherPreferred(pub) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
643 |
self.history.log_operation_end(error=e) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
644 |
raise e |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
645 |
self.cfg_cache.preferred_publisher = pub.prefix |
551 | 646 |
self.save_config() |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
647 |
self.history.log_operation_end() |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
648 |
|
551 | 649 |
def set_property(self, prop_name, prop_value): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
650 |
assert prop_name != "preferred-publisher" |
551 | 651 |
self.cfg_cache.properties[prop_name] = prop_value |
652 |
self.save_config() |
|
653 |
||
654 |
def get_property(self, prop_name): |
|
655 |
return self.cfg_cache.properties[prop_name] |
|
656 |
||
657 |
def has_property(self, prop_name): |
|
658 |
return prop_name in self.cfg_cache.properties |
|
659 |
||
660 |
def delete_property(self, prop_name): |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
661 |
assert prop_name != "preferred-publisher" |
551 | 662 |
del self.cfg_cache.properties[prop_name] |
663 |
self.save_config() |
|
664 |
||
665 |
def properties(self): |
|
666 |
for p in self.cfg_cache.properties: |
|
667 |
yield p |
|
668 |
||
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
669 |
def add_publisher(self, pub, refresh_allowed=True, progtrack=None): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
670 |
"""Adds the provided publisher object to the image |
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
671 |
configuration. |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
672 |
|
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
673 |
'refresh_allowed' is an optional, boolean value indicating |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
674 |
whether the publisher's metadata should be retrieved when adding |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
675 |
it to the image's configuration. |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
676 |
|
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
677 |
'progtrack' is an optional ProgressTracker object.""" |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
678 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
679 |
self.history.log_operation_start("add-publisher") |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
680 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
681 |
for p in self.cfg_cache.publishers.values(): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
682 |
if pub == p or (pub.alias and pub.alias == p.alias): |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
683 |
error = api_errors.DuplicatePublisher(pub) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
684 |
self.history.log_operation_end(error=error) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
685 |
raise error |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
686 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
687 |
if not progtrack: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
688 |
progtrack = progress.QuietProgressTracker() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
689 |
|
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
690 |
# Must assign this first before performing any more operations. |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
691 |
pub.meta_root = self._get_publisher_meta_root(pub.prefix) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
692 |
pub.transport = self.transport |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
693 |
self.cfg_cache.publishers[pub.prefix] = pub |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
694 |
|
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
695 |
# Ensure that if the publisher's meta directory already exists |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
696 |
# for some reason that the data within is not used. |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
697 |
pub.remove_meta_root() |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
698 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
699 |
if refresh_allowed: |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
700 |
try: |
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
701 |
# First, verify that the publisher has a valid |
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
702 |
# pkg(5) repository. |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
703 |
self.transport.valid_publisher_test(pub) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
704 |
self.refresh_publishers(pubs=[pub], |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
705 |
progtrack=progtrack) |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
706 |
except Exception, e: |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
707 |
# Remove the newly added publisher since the |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
708 |
# retrieval failed. |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
709 |
self.cfg_cache.remove_publisher(pub.prefix) |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
710 |
self.history.log_operation_end(error=e) |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
711 |
raise |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
712 |
except: |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
713 |
# Remove the newly added publisher since the |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
714 |
# retrieval failed. |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
715 |
self.cfg_cache.remove_publisher(pub.prefix) |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
716 |
self.history.log_operation_end( |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
717 |
result=history.RESULT_FAILED_UNKNOWN) |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
718 |
raise |
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
719 |
|
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
720 |
# Only after success should the configuration be saved. |
551 | 721 |
self.save_config() |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
722 |
self.history.log_operation_end() |
539
7486304966c5
1449 pkg requires operational history
Shawn Walker <shawn.walker@sun.com>
parents:
537
diff
changeset
|
723 |
|
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
226
diff
changeset
|
724 |
def verify(self, fmri, progresstracker, **args): |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
725 |
"""generator that returns any errors in installed pkgs |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
226
diff
changeset
|
726 |
as tuple of action, list of errors""" |
222
12006bf2a260
4 We need to be able to verify that package(s) is/are correctly installed
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
221
diff
changeset
|
727 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
728 |
for act in self.get_manifest(fmri).gen_actions( |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
729 |
self.list_excludes()): |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
226
diff
changeset
|
730 |
errors = act.verify(self, pkg_fmri=fmri, **args) |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
226
diff
changeset
|
731 |
progresstracker.verify_add_progress(fmri) |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
226
diff
changeset
|
732 |
actname = act.distinguished_name() |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
226
diff
changeset
|
733 |
if errors: |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
226
diff
changeset
|
734 |
progresstracker.verify_yield_error(actname, |
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
226
diff
changeset
|
735 |
errors) |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
736 |
yield (act, errors) |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
737 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
738 |
def __call_imageplan_evaluate(self, ip, verbose=False): |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
739 |
if verbose: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
740 |
logger.info(_("Before evaluation:")) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
741 |
logger.info(ip) |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
742 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
743 |
# A plan can be requested without actually performing an |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
744 |
# operation on the image. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
745 |
if self.history.operation_name: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
746 |
self.history.operation_start_state = ip.get_plan() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
747 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
748 |
try: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
749 |
ip.evaluate() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
750 |
except constraint.ConstraintException, e: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
751 |
raise api_errors.PlanCreationException( |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
752 |
constraint_violations=str(e).split("\n")) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
753 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
754 |
self.imageplan = ip |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
755 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
756 |
if self.history.operation_name: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
757 |
self.history.operation_end_state = \ |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
758 |
ip.get_plan(full=False) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
759 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
760 |
if verbose: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
761 |
logger.info(_("After evaluation:")) |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
762 |
ip.display() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
763 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
764 |
def image_change_variant(self, variants, progtrack, check_cancelation, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
765 |
noexecute, verbose=False): |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
766 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
767 |
ip = imageplan.ImagePlan(self, progtrack, lambda: False, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
768 |
noexecute=noexecute, variants=variants, |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
769 |
recursive_removal=True) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
770 |
progtrack.evaluate_start() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
771 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
772 |
# make sure that some variants are actually changing |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
773 |
variants = dict(set(variants.iteritems()) - \ |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
774 |
set(self.cfg_cache.variants.iteritems())) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
775 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
776 |
if not variants: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
777 |
self.__call_imageplan_evaluate(ip, verbose) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
778 |
logger.info("No variant changes.") |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
779 |
return |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
780 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
781 |
# |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
782 |
# only get manifests for all architectures if we're |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
783 |
# changing the architecture variant |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
784 |
# |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
785 |
if "variant.arch" in variants: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
786 |
self.arch_change = True |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
787 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
788 |
# |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
789 |
# we can't set self.new_variants until after we |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
790 |
# instantiate the image plan since the image plan has |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
791 |
# to cache information like the old excludes, and |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
792 |
# once we set new_variants things like self.list_excludes() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
793 |
# and self.get_arch() will report valus based off of the |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
794 |
# new variants we're moving too. |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
795 |
# |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
796 |
self.new_variants = variants |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
797 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
798 |
for fmri in self.gen_installed_pkgs(): |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
799 |
m = self.get_manifest(fmri) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
800 |
m_arch = m.get_variants("variant.arch") |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
801 |
if not m_arch: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
802 |
# keep packages that don't have an explicit arch |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
803 |
ip.propose_fmri(fmri) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
804 |
elif self.get_arch() in m_arch: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
805 |
# keep packages that match the current arch |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
806 |
ip.propose_fmri(fmri) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
807 |
else: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
808 |
# remove packages for different archs |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
809 |
ip.propose_fmri_removal(fmri) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
810 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
811 |
self.__call_imageplan_evaluate(ip, verbose) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
812 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
813 |
def image_config_update(self): |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
814 |
if not self.new_variants: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
815 |
return |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
816 |
ic = self.cfg_cache |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
817 |
ic.variants.update(self.new_variants) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
818 |
ic.write(self.imgdir) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
819 |
ic = imageconfig.ImageConfig(self.root, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
820 |
self._get_publisher_meta_dir()) |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
821 |
ic.read(self.imgdir) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
822 |
self.cfg_cache = ic |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
823 |
|
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
824 |
def repair(self, repairs, progtrack): |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
825 |
"""Repair any actions in the fmri that failed a verify.""" |
687
3d7060f40501
4450 pkg fix passes bogus cancellation point to pkgplan/imageplan
Brad Hall <bhall@eng.sun.com>
parents:
685
diff
changeset
|
826 |
# XXX: This (lambda x: False) is temporary until we move pkg fix |
3d7060f40501
4450 pkg fix passes bogus cancellation point to pkgplan/imageplan
Brad Hall <bhall@eng.sun.com>
parents:
685
diff
changeset
|
827 |
# into the api and can actually use the |
3d7060f40501
4450 pkg fix passes bogus cancellation point to pkgplan/imageplan
Brad Hall <bhall@eng.sun.com>
parents:
685
diff
changeset
|
828 |
# api::__check_cancelation() function. |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
829 |
pps = [] |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
830 |
for fmri, actions in repairs: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
831 |
logger.info("Repairing: %-50s" % fmri.get_pkg_stem()) |
838
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
832 |
m = self.get_manifest(fmri) |
692 | 833 |
pp = pkgplan.PkgPlan(self, progtrack, lambda: False) |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
834 |
pp.propose_repair(fmri, m, actions) |
838
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
835 |
pp.evaluate(self.list_excludes(), self.list_excludes()) |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
836 |
pps.append(pp) |
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
837 |
|
692 | 838 |
ip = imageplan.ImagePlan(self, progtrack, lambda: False) |
1195
cd29e45e4023
9384 pkg fix unexpectedly indexes packages
Brock Pytlik <bpytlik@sun.com>
parents:
1191
diff
changeset
|
839 |
ip.update_index = False |
625
e46b345645d6
3799 need to start progress tracker going early on
Brock Pytlik <bpytlik@sun.com>
parents:
621
diff
changeset
|
840 |
progtrack.evaluate_start() |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
841 |
ip.pkg_plans = pps |
687
3d7060f40501
4450 pkg fix passes bogus cancellation point to pkgplan/imageplan
Brad Hall <bhall@eng.sun.com>
parents:
685
diff
changeset
|
842 |
|
3d7060f40501
4450 pkg fix passes bogus cancellation point to pkgplan/imageplan
Brad Hall <bhall@eng.sun.com>
parents:
685
diff
changeset
|
843 |
ip.evaluate() |
1328
5c3747a4fe0a
9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1288
diff
changeset
|
844 |
if ip.actuators.reboot_needed() and self.is_liveroot(): |
5c3747a4fe0a
9387 pkg fix should honor reboot-needed flag
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1288
diff
changeset
|
845 |
raise api_errors.RebootNeededOnLiveImageException() |
687
3d7060f40501
4450 pkg fix passes bogus cancellation point to pkgplan/imageplan
Brad Hall <bhall@eng.sun.com>
parents:
685
diff
changeset
|
846 |
ip.preexecute() |
3d7060f40501
4450 pkg fix passes bogus cancellation point to pkgplan/imageplan
Brad Hall <bhall@eng.sun.com>
parents:
685
diff
changeset
|
847 |
ip.execute() |
583
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
848 |
|
fc856572d86e
388 pkg command needs a "fix" subcommand or similar
Brad Hall <bhall@eng.sun.com>
parents:
582
diff
changeset
|
849 |
return 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:
221
diff
changeset
|
850 |
|
50 | 851 |
def has_manifest(self, fmri): |
45
8a3f00dea14f
catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents:
39
diff
changeset
|
852 |
mpath = fmri.get_dir_path() |
8a3f00dea14f
catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents:
39
diff
changeset
|
853 |
|
8a3f00dea14f
catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents:
39
diff
changeset
|
854 |
local_mpath = "%s/pkg/%s/manifest" % (self.imgdir, mpath) |
8a3f00dea14f
catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents:
39
diff
changeset
|
855 |
|
8a3f00dea14f
catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents:
39
diff
changeset
|
856 |
if (os.path.exists(local_mpath)): |
50 | 857 |
return True |
858 |
||
859 |
return False |
|
45
8a3f00dea14f
catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents:
39
diff
changeset
|
860 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
861 |
def __fetch_manifest(self, fmri, excludes=EmptyI): |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
862 |
"""A wrapper call for getting manifests. This invokes |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
863 |
the transport method, gets the manifest, and performs |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
864 |
any additional image-related processing.""" |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
865 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
866 |
m = self.transport.get_manifest(fmri, excludes, |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
867 |
self.state.get_intent_str(fmri)) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
868 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
869 |
# What is the client currently processing? |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
870 |
targets = self.state.get_targets() |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
871 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
872 |
intent = None |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
873 |
for entry in targets: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
874 |
target, reason = entry |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
875 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
876 |
# Ignore the publisher for comparison. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
877 |
np_target = target.get_fmri(anarchy=True) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
878 |
np_fmri = fmri.get_fmri(anarchy=True) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
879 |
if np_target == np_fmri: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
880 |
intent = reason |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
881 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
882 |
# If no intent could be found, assume INTENT_INFO. |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
883 |
self.state.set_touched_manifest(fmri, |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
884 |
max(intent, imagestate.INTENT_INFO)) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
885 |
|
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
886 |
return m |
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
887 |
|
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
888 |
def __touch_manifest(self, fmri): |
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
889 |
"""Perform steps necessary to 'touch' a manifest to provide |
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
890 |
intent information. Ignores most exceptions as this operation |
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
891 |
is only for informational purposes.""" |
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
892 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
893 |
# What is the client currently processing? |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
894 |
target, intent = self.state.get_target() |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
895 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
896 |
# Ignore dry-runs of operations or operations which do not have |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
897 |
# a set target. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
898 |
if not target or intent == imagestate.INTENT_EVALUATE: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
899 |
return |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
900 |
|
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
901 |
if not self.state.get_touched_manifest(fmri, intent): |
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
902 |
# If the manifest for this fmri hasn't been "seen" |
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
903 |
# before, determine if intent information needs to be |
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
904 |
# provided. |
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
905 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
906 |
# Ignore the publisher for comparison. |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
907 |
np_target = target.get_fmri(anarchy=True) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
908 |
np_fmri = fmri.get_fmri(anarchy=True) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
909 |
if np_target == np_fmri: |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
910 |
# If the client is currently processing |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
911 |
# the given fmri (for an install, etc.) |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
912 |
# then intent information is needed. |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
913 |
try: |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
914 |
self.transport.touch_manifest(fmri, |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
915 |
self.state.get_intent_str(fmri)) |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
916 |
except (api_errors.UnknownPublisher, |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
917 |
api_errors.TransportError): |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
918 |
# It's not fatal if we can't find |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
919 |
# or reach the publisher. |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
920 |
pass |
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
921 |
self.state.set_touched_manifest(fmri, intent) |
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
922 |
|
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
923 |
def get_manifest_path(self, fmri): |
956
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
924 |
"""Return path to on-disk manifest""" |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
925 |
mpath = os.path.join(self.imgdir, "pkg", |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
926 |
fmri.get_dir_path(), "manifest") |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
927 |
return mpath |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
928 |
|
877
b23f809e8abd
6653 we should elide alternate architectures from in-memory manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
855
diff
changeset
|
929 |
def __get_manifest(self, fmri, excludes=EmptyI): |
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
930 |
"""Find on-disk manifest and create in-memory Manifest |
956
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
931 |
object.... grab from server if needed""" |
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
932 |
|
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
933 |
try: |
1068
9400aa8afd32
2557 catalog cache pickle file dependent on fmri and version object definitions
Shawn Walker <srw@sun.com>
parents:
1045
diff
changeset
|
934 |
return manifest.CachedManifest(fmri, self.pkgdir, |
1037
56ff5f4fab83
8050 image-update fails from b110 to b111 at SUNWgnome-system-monitor manifest
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
999
diff
changeset
|
935 |
self.cfg_cache.preferred_publisher, |
56ff5f4fab83
8050 image-update fails from b110 to b111 at SUNWgnome-system-monitor manifest
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
999
diff
changeset
|
936 |
excludes) |
956
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
937 |
except KeyError: |
1191
a48bee2a4b2e
305 http_proxy value needs more checking for valid url syntax
johansen <johansen@sun.com>
parents:
1158
diff
changeset
|
938 |
return self.__fetch_manifest(fmri, excludes) |
956
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
939 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
940 |
def get_manifest(self, fmri, all_arch=False): |
956
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
941 |
"""return manifest; uses cached version if available. |
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
942 |
all_arch controls whether manifest contains actions |
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
943 |
for all architectures""" |
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
944 |
|
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
945 |
# Normally elide other arch variants |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
946 |
if self.arch_change or all_arch: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
947 |
all_arch = True |
956
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
948 |
v = EmptyI |
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
949 |
else: |
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
950 |
arch = {"variant.arch": self.get_arch()} |
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
951 |
v = [variant.Variants(arch).allow_action] |
877
b23f809e8abd
6653 we should elide alternate architectures from in-memory manifests
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
855
diff
changeset
|
952 |
|
1237
68df51e3327f
4231 Remove bug 4263 changes for bug 3505 manifest caching
Shawn Walker <srw@sun.com>
parents:
1231
diff
changeset
|
953 |
m = self.__get_manifest(fmri, v) |
567
ea1d96e269a4
3505 client action and manifest creation are wasteful
johansen <johansen@sun.com>
parents:
565
diff
changeset
|
954 |
|
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
955 |
self.__touch_manifest(fmri) |
296
576858fb8376
398 disambiguate packages matching the default authority
johansen <johansen@sun.com>
parents:
289
diff
changeset
|
956 |
return m |
576858fb8376
398 disambiguate packages matching the default authority
johansen <johansen@sun.com>
parents:
289
diff
changeset
|
957 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
958 |
def set_pkg_state(self, pfmri, state): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
959 |
"""Sets the recorded image state of the specified package. |
1358
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
960 |
The caller is responsible for also calling save_pkg_state |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
961 |
after they are finished updating package state information. |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
962 |
'state' must be one of the following image constants: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
963 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
964 |
PKG_STATE_INSTALLED |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
965 |
Indicates that the package is installed. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
966 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
967 |
PKG_STATE_KNOWN |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
968 |
Indicates that the package is currently present in |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
969 |
a repository catalog. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
970 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
971 |
PKG_STATE_UNINSTALLED |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
972 |
Clears the INSTALLED state of the package. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
973 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
974 |
PKG_STATE_UNKNOWN |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
975 |
Clears the KNOWN state of the package.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
976 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
977 |
kcat = self.get_catalog(self.IMG_CATALOG_KNOWN) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
978 |
entry = kcat.get_entry(pfmri) |
195
b23d0425f0f7
11 use FMRIs with fully specified authorities internally
johansen <johansen@sun.com>
parents:
192
diff
changeset
|
979 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
980 |
mdata = entry.get("metadata", {}) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
981 |
states = set(mdata.get("states", set())) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
982 |
if state == self.PKG_STATE_UNKNOWN: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
983 |
states.discard(self.PKG_STATE_KNOWN) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
984 |
elif state == self.PKG_STATE_UNINSTALLED: |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
985 |
icat = self.get_catalog(self.IMG_CATALOG_INSTALLED) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
986 |
icat.remove_package(pfmri) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
987 |
states.discard(self.PKG_STATE_INSTALLED) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
988 |
# XXX This needs to be changed once publisher |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
989 |
# priortisation is implemented. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
990 |
states.discard(self.__PKG_STATE_PREFERRED) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
991 |
elif state == self.PKG_STATE_INSTALLED: |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
992 |
states.add(state) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
993 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
994 |
# XXX The below needs to be removed once publisher |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
995 |
# priortisation is implemented. |
356
672e0af33ea8
1536 empty installed files generate tracebacks
johansen <johansen@sun.com>
parents:
347
diff
changeset
|
996 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
997 |
# If this package is being marked as 'installed', then |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
998 |
# also mark if it is being installed from a publisher |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
999 |
# that is currently preferred. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1000 |
if pfmri.publisher == self.get_preferred_publisher(): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1001 |
states.add(self.__PKG_STATE_PREFERRED) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1002 |
else: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1003 |
# All other states should simply be added to the |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1004 |
# existing set of states. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1005 |
states.add(state) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1006 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1007 |
if self.PKG_STATE_KNOWN not in states and \ |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1008 |
self.PKG_STATE_INSTALLED not in states: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1009 |
# Package is no longer known or installed, so isn't |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1010 |
# upgradable. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1011 |
states.discard(self.PKG_STATE_UPGRADABLE) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1012 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1013 |
if not states or (len(states) == 1 and |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1014 |
(self.PKG_STATE_V0 in states or |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1015 |
self.PKG_STATE_V1 in states)): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1016 |
# This entry is no longer available and has no |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1017 |
# meaningful state information, so should be |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1018 |
# discarded. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1019 |
kcat.remove_package(pfmri) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1020 |
return |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1021 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1022 |
if (self.PKG_STATE_INSTALLED in states and |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1023 |
self.PKG_STATE_UNINSTALLED in states) or ( |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1024 |
self.PKG_STATE_KNOWN in states and |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1025 |
self.PKG_STATE_UNKNOWN in states): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1026 |
raise api_errors.ImagePkgStateError(pfmri, states) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1027 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1028 |
# Catalog format only supports lists. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1029 |
mdata["states"] = list(states) |
956
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
1030 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1031 |
# Now record the package state. |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1032 |
kcat.update_entry(pfmri, metadata=mdata) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1033 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1034 |
if state == self.PKG_STATE_INSTALLED: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1035 |
# If the package is being marked as installed, then |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1036 |
# it shouldn't already exist in the installed catalog |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1037 |
# and should be added. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1038 |
icat = self.get_catalog(self.IMG_CATALOG_INSTALLED) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1039 |
icat.append(kcat, pfmri=pfmri) |
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1040 |
self.__catalog_new_installs.add(pfmri) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1041 |
elif self.PKG_STATE_INSTALLED in states: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1042 |
# If some other state has been changed and the package |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1043 |
# is still marked as installed, then simply update the |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1044 |
# existing entry (which should already exist). |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1045 |
icat = self.get_catalog(self.IMG_CATALOG_INSTALLED) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1046 |
icat.update_entry(pfmri, metadata=mdata) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
1047 |
|
1358
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
1048 |
def save_pkg_state(self): |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
1049 |
"""Saves current package state information.""" |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
1050 |
|
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1051 |
# Temporarily redirect the catalogs to a different location, |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1052 |
# so that if the save is interrupted, the image won't be left |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1053 |
# with invalid state, and then save them. |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1054 |
tmp_state_root = self.temporary_dir() |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1055 |
|
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1056 |
try: |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1057 |
for name in (self.IMG_CATALOG_KNOWN, |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1058 |
self.IMG_CATALOG_INSTALLED): |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1059 |
cpath = os.path.join(tmp_state_root, name) |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1060 |
|
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1061 |
# Must copy the old catalog data to the new |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1062 |
# destination as only changed files will be |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1063 |
# written. |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1064 |
cat = self.get_catalog(name) |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1065 |
shutil.copytree(cat.meta_root, cpath) |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1066 |
cat.meta_root = cpath |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1067 |
cat.finalize(pfmris=self.__catalog_new_installs) |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1068 |
cat.save() |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1069 |
|
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1070 |
# Next, preserve the old installed state dir, rename the |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1071 |
# new one into place, and then remove the old one. |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1072 |
state_root = os.path.join(self.imgdir, "state") |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1073 |
orig_state_root = self.__salvagedir(state_root) |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1074 |
portable.rename(tmp_state_root, state_root) |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1075 |
shutil.rmtree(orig_state_root, True) |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1076 |
finally: |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1077 |
# Regardless of success, the following must happen. |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1078 |
for name in (self.IMG_CATALOG_KNOWN, |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1079 |
self.IMG_CATALOG_INSTALLED): |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1080 |
cat = self.get_catalog(name) |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1081 |
cat.meta_root = os.path.join(self.imgdir, |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1082 |
"state", name) |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1083 |
if os.path.exists(tmp_state_root): |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1084 |
shutil.rmtree(tmp_state_root, True) |
195
b23d0425f0f7
11 use FMRIs with fully specified authorities internally
johansen <johansen@sun.com>
parents:
192
diff
changeset
|
1085 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1086 |
def get_catalog(self, name): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1087 |
"""Returns the requested image catalog. |
195
b23d0425f0f7
11 use FMRIs with fully specified authorities internally
johansen <johansen@sun.com>
parents:
192
diff
changeset
|
1088 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1089 |
'name' must be one of the following image constants: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1090 |
IMG_CATALOG_KNOWN |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1091 |
The known catalog contains all of packages that are |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1092 |
installed or available from a publisher's repository. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1093 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1094 |
IMG_CATALOG_INSTALLED |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1095 |
The installed catalog is a subset of the 'known' |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1096 |
catalog that only contains installed packages.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1097 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1098 |
if not self.imgdir: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1099 |
raise RuntimeError("self.imgdir must be set") |
418
21621fd99956
2543 eliminate unnecessary stat() calls from gen_installed_pkgs()
Danek Duvall <danek.duvall@sun.com>
parents:
409
diff
changeset
|
1100 |
|
717
c40259b4ce98
4569 pkg uninstall tracesback when lacking permissions
Brock Pytlik <bpytlik@sun.com>
parents:
715
diff
changeset
|
1101 |
try: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1102 |
return self.__catalogs[name] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1103 |
except KeyError: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1104 |
pass |
195
b23d0425f0f7
11 use FMRIs with fully specified authorities internally
johansen <johansen@sun.com>
parents:
192
diff
changeset
|
1105 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1106 |
croot = os.path.join(self.imgdir, "state", name) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
1107 |
try: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1108 |
os.makedirs(croot) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
1109 |
except EnvironmentError, e: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1110 |
if e.errno in (errno.EACCES, errno.EROFS): |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1111 |
# Allow operations to work for |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1112 |
# unprivileged users. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1113 |
croot = None |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1114 |
elif e.errno != errno.EEXIST: |
658
e470d4688084
4412 pkg refresh can strand one w/o packages after upgrade from 86
Danek Duvall <danek.duvall@sun.com>
parents:
655
diff
changeset
|
1115 |
raise |
e470d4688084
4412 pkg refresh can strand one w/o packages after upgrade from 86
Danek Duvall <danek.duvall@sun.com>
parents:
655
diff
changeset
|
1116 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1117 |
def manifest_cb(cat, f): |
1449
a721d9b0aad2
12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents:
1435
diff
changeset
|
1118 |
# Only allow lazy-load for packages from non-v1 sources. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1119 |
# Assume entries for other sources have all data |
1449
a721d9b0aad2
12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents:
1435
diff
changeset
|
1120 |
# required in catalog. This prevents manifest retrieval |
a721d9b0aad2
12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents:
1435
diff
changeset
|
1121 |
# for packages that don't have any related action data |
a721d9b0aad2
12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents:
1435
diff
changeset
|
1122 |
# in the catalog because they don't have any related |
a721d9b0aad2
12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents:
1435
diff
changeset
|
1123 |
# action data in their manifest. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1124 |
entry = cat.get_entry(f) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1125 |
states = entry["metadata"]["states"] |
1449
a721d9b0aad2
12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents:
1435
diff
changeset
|
1126 |
if self.PKG_STATE_V1 not in states: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1127 |
return self.get_manifest(f, all_arch=True) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1128 |
return None |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1129 |
|
1358
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
1130 |
# batch_mode is set to True here as any operations that modify |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
1131 |
# the catalogs (add or remove entries) are only done during an |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
1132 |
# image upgrade or metadata refresh. In both cases, the catalog |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
1133 |
# is resorted and finalized so this is always safe to use. |
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
1134 |
cat = pkg.catalog.Catalog(batch_mode=True, |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1135 |
manifest_cb=manifest_cb, meta_root=croot, sign=False) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1136 |
self.__catalogs[name] = cat |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1137 |
return cat |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1138 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1139 |
def remove_catalogs(self): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1140 |
"""Removes all image catalogs and their directories.""" |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
1141 |
|
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1142 |
self.__init_catalogs() |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1143 |
for name in (self.IMG_CATALOG_KNOWN, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1144 |
self.IMG_CATALOG_INSTALLED): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1145 |
shutil.rmtree(os.path.join(self.imgdir, "state", name)) |
418
21621fd99956
2543 eliminate unnecessary stat() calls from gen_installed_pkgs()
Danek Duvall <danek.duvall@sun.com>
parents:
409
diff
changeset
|
1146 |
|
556
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
1147 |
def get_version_installed(self, pfmri): |
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
1148 |
"""Returns an fmri of the installed package matching the |
1c3526ca7b9e
2022 client should provide operational intent to server
Shawn Walker <shawn.walker@sun.com>
parents:
554
diff
changeset
|
1149 |
package stem of the given fmri or None if no match is found.""" |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1150 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1151 |
cat = self.get_catalog(self.IMG_CATALOG_INSTALLED) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1152 |
for ver, fmris in cat.fmris_by_version(pfmri.pkg_name): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1153 |
return fmris[0] |
423
5c756997bf67
2253 With the latest build of the pkg repo, can't install packages from additional authorities
Danek Duvall <danek.duvall@sun.com>
parents:
419
diff
changeset
|
1154 |
return None |
5c756997bf67
2253 With the latest build of the pkg repo, can't install packages from additional authorities
Danek Duvall <danek.duvall@sun.com>
parents:
419
diff
changeset
|
1155 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1156 |
def fmri_set_default_publisher(self, fmri): |
195
b23d0425f0f7
11 use FMRIs with fully specified authorities internally
johansen <johansen@sun.com>
parents:
192
diff
changeset
|
1157 |
"""If the FMRI supplied as an argument does not have |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1158 |
a publisher, set it to the image's preferred publisher.""" |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1159 |
|
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1160 |
if fmri.has_publisher(): |
195
b23d0425f0f7
11 use FMRIs with fully specified authorities internally
johansen <johansen@sun.com>
parents:
192
diff
changeset
|
1161 |
return |
b23d0425f0f7
11 use FMRIs with fully specified authorities internally
johansen <johansen@sun.com>
parents:
192
diff
changeset
|
1162 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1163 |
fmri.set_publisher(self.get_preferred_publisher(), True) |
296
576858fb8376
398 disambiguate packages matching the default authority
johansen <johansen@sun.com>
parents:
289
diff
changeset
|
1164 |
|
135
a1e20e9a9845
add CLI test suite, correct bugs found by test suite, ration out CLI options
Stephen Hahn <sch@Sun.COM>
parents:
116
diff
changeset
|
1165 |
def has_version_installed(self, fmri): |
59
eef94b0c0694
require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents:
51
diff
changeset
|
1166 |
"""Check that the version given in the FMRI or a successor is |
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
302
diff
changeset
|
1167 |
installed in the current image.""" |
258
b3b7592412ec
270 Need ability to rename packages
johansen <johansen@sun.com>
parents:
251
diff
changeset
|
1168 |
|
560
4c8d82d58131
3569 pkg state code obviates use of _get_version_installed
Shawn Walker <shawn.walker@sun.com>
parents:
556
diff
changeset
|
1169 |
v = self.get_version_installed(fmri) |
59
eef94b0c0694
require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents:
51
diff
changeset
|
1170 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1171 |
if v and not fmri.publisher: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1172 |
fmri.set_publisher(v.get_publisher_str()) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1173 |
elif not fmri.publisher: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1174 |
fmri.set_publisher(self.get_preferred_publisher(), True) |
266
5e5bff6fedce
582 Importing packages seemingly misrecords dependencies
johansen <johansen@sun.com>
parents:
260
diff
changeset
|
1175 |
|
1288
4248f27af42a
10417 rename v0 support should be removed everywhere
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
1176 |
if v and v.is_successor(fmri): |
258
b3b7592412ec
270 Need ability to rename packages
johansen <johansen@sun.com>
parents:
251
diff
changeset
|
1177 |
return True |
59
eef94b0c0694
require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents:
51
diff
changeset
|
1178 |
return False |
eef94b0c0694
require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents:
51
diff
changeset
|
1179 |
|
258
b3b7592412ec
270 Need ability to rename packages
johansen <johansen@sun.com>
parents:
251
diff
changeset
|
1180 |
def older_version_installed(self, fmri): |
b3b7592412ec
270 Need ability to rename packages
johansen <johansen@sun.com>
parents:
251
diff
changeset
|
1181 |
"""This method is used by the package plan to determine if an |
1288
4248f27af42a
10417 rename v0 support should be removed everywhere
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
1182 |
older version of the package is installed. This takes the |
4248f27af42a
10417 rename v0 support should be removed everywhere
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
1183 |
destination fmri and checks if an older package exists.""" |
258
b3b7592412ec
270 Need ability to rename packages
johansen <johansen@sun.com>
parents:
251
diff
changeset
|
1184 |
|
560
4c8d82d58131
3569 pkg state code obviates use of _get_version_installed
Shawn Walker <shawn.walker@sun.com>
parents:
556
diff
changeset
|
1185 |
v = self.get_version_installed(fmri) |
258
b3b7592412ec
270 Need ability to rename packages
johansen <johansen@sun.com>
parents:
251
diff
changeset
|
1186 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1187 |
assert fmri.has_publisher() |
268
3d53da66d4a4
582 Importing packages seemingly misrecords dependencies
johansen <johansen@sun.com>
parents:
266
diff
changeset
|
1188 |
|
258
b3b7592412ec
270 Need ability to rename packages
johansen <johansen@sun.com>
parents:
251
diff
changeset
|
1189 |
if v: |
b3b7592412ec
270 Need ability to rename packages
johansen <johansen@sun.com>
parents:
251
diff
changeset
|
1190 |
return v |
b3b7592412ec
270 Need ability to rename packages
johansen <johansen@sun.com>
parents:
251
diff
changeset
|
1191 |
return None |
b3b7592412ec
270 Need ability to rename packages
johansen <johansen@sun.com>
parents:
251
diff
changeset
|
1192 |
|
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1193 |
def get_pkg_state(self, pfmri): |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1194 |
"""Returns the list of states a package is in for this image.""" |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1195 |
|
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1196 |
cat = self.get_catalog(self.IMG_CATALOG_KNOWN) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1197 |
try: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1198 |
entry = cat.get_entry(pfmri) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1199 |
except api_errors.UnknownCatalogEntry: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1200 |
return [] |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1201 |
return entry["metadata"]["states"] |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1202 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1203 |
def is_pkg_installed(self, pfmri): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1204 |
"""Returns a boolean value indicating whether the specified |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1205 |
package is installed.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1206 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1207 |
# Avoid loading the installed catalog if the known catalog |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1208 |
# is already loaded. This is safe since the installed |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1209 |
# catalog is a subset of the known, and a specific entry |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1210 |
# is being retrieved. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1211 |
if not self.__catalog_loaded(self.IMG_CATALOG_KNOWN): |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1212 |
cat = self.get_catalog(self.IMG_CATALOG_INSTALLED) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1213 |
else: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1214 |
cat = self.get_catalog(self.IMG_CATALOG_KNOWN) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1215 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1216 |
try: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1217 |
entry = cat.get_entry(pfmri) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1218 |
except api_errors.UnknownCatalogEntry: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1219 |
return False |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1220 |
states = entry["metadata"]["states"] |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1221 |
return self.PKG_STATE_INSTALLED in states |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1222 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1223 |
def is_pkg_preferred(self, pfmri): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1224 |
"""Compatibility function for use by pkg.client.api only. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1225 |
Should be removed once publishers are ranked by priority. |
135
a1e20e9a9845
add CLI test suite, correct bugs found by test suite, ration out CLI options
Stephen Hahn <sch@Sun.COM>
parents:
116
diff
changeset
|
1226 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1227 |
Returns a boolean value indicating whether the specified |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1228 |
package was installed from a publisher that was preferred at |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1229 |
the time of installation, or is from the same publisher as |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1230 |
the currently preferred publisher.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1231 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1232 |
if pfmri.publisher == self.get_preferred_publisher(): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1233 |
return True |
195
b23d0425f0f7
11 use FMRIs with fully specified authorities internally
johansen <johansen@sun.com>
parents:
192
diff
changeset
|
1234 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1235 |
# Avoid loading the installed catalog if the known catalog |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1236 |
# is already loaded. This is safe since the installed |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1237 |
# catalog is a subset of the known, and a specific entry |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1238 |
# is being retrieved. |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1239 |
if not self.__catalog_loaded(self.IMG_CATALOG_KNOWN): |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1240 |
cat = self.get_catalog(self.IMG_CATALOG_INSTALLED) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1241 |
else: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1242 |
cat = self.get_catalog(self.IMG_CATALOG_KNOWN) |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1243 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1244 |
try: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1245 |
entry = cat.get_entry(pfmri) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1246 |
except api_errors.UnknownCatalogEntry: |
135
a1e20e9a9845
add CLI test suite, correct bugs found by test suite, ration out CLI options
Stephen Hahn <sch@Sun.COM>
parents:
116
diff
changeset
|
1247 |
return False |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1248 |
states = entry["metadata"]["states"] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1249 |
return self.__PKG_STATE_PREFERRED in states |
135
a1e20e9a9845
add CLI test suite, correct bugs found by test suite, ration out CLI options
Stephen Hahn <sch@Sun.COM>
parents:
116
diff
changeset
|
1250 |
|
838
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
1251 |
def list_excludes(self, new_variants=None): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1252 |
"""Generate a list of callables that each return True if an |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1253 |
action is to be included in the image using the currently |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1254 |
defined variants for the image, or an updated set if |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1255 |
new_variants are specified. The callables take a single action |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1256 |
argument. Variants, facets and filters will be handled in |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1257 |
this fashion.""" |
956
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
1258 |
|
838
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
1259 |
# XXX simple for now; facets and filters need impl. |
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
1260 |
if new_variants: |
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
1261 |
new_vars = self.cfg_cache.variants.copy() |
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
1262 |
new_vars.update(new_variants) |
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
1263 |
return [new_vars.allow_action] |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
1264 |
elif self.new_variants: |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
1265 |
new_vars = self.cfg_cache.variants.copy() |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
1266 |
new_vars.update(self.new_variants) |
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
1267 |
return [new_vars.allow_action] |
838
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
1268 |
else: |
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
1269 |
return [self.cfg_cache.variants.allow_action] |
aafbe4737188
3245 need to support creation of multi-architecture (fat) packages
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
835
diff
changeset
|
1270 |
|
432
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1271 |
def __build_dependents(self, progtrack): |
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1272 |
"""Build a dictionary mapping packages to the list of packages |
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1273 |
that have required dependencies on them.""" |
956
adf6bdfdb3b5
6904 image.installed_file_authority always tries to open installed file r+
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
941
diff
changeset
|
1274 |
|
432
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1275 |
self.__req_dependents = {} |
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1276 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1277 |
cat = self.get_catalog(self.IMG_CATALOG_INSTALLED) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1278 |
for f, actions in cat.actions([cat.DEPENDENCY], |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1279 |
excludes=self.list_excludes()): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1280 |
progtrack.evaluate_progress(f) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1281 |
for a in actions: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1282 |
if a.name != "depend" or \ |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1283 |
a.attrs["type"] != "require": |
432
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1284 |
continue |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1285 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1286 |
dfmri = self.strtofmri(a.attrs["fmri"]) |
432
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1287 |
if dfmri not in self.__req_dependents: |
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1288 |
self.__req_dependents[dfmri] = [] |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1289 |
self.__req_dependents[dfmri].append(f) |
432
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1290 |
|
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1291 |
def get_dependents(self, pfmri, progtrack): |
104
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
1292 |
"""Return a list of the packages directly dependent on the given |
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
1293 |
FMRI.""" |
67
62c897652bbc
Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents:
63
diff
changeset
|
1294 |
|
432
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1295 |
if not hasattr(self, "_Image__req_dependents"): |
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1296 |
self.__build_dependents(progtrack) |
67
62c897652bbc
Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents:
63
diff
changeset
|
1297 |
|
432
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1298 |
dependents = [] |
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1299 |
# We run through all the keys, in case a package is depended |
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1300 |
# upon under multiple versions. That is, if pkgA depends on |
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1301 |
# libc@1 and pkgB depends on libc@2, we need to return both pkgA |
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1302 |
# and pkgB. If we used package names as keys, this would be |
1288
4248f27af42a
10417 rename v0 support should be removed everywhere
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
1303 |
# simpler, but it wouldn't handle catalog operations (such as |
4248f27af42a
10417 rename v0 support should be removed everywhere
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
1304 |
# rename) that might have been applied to the fmri. |
432
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1305 |
for f in self.__req_dependents.iterkeys(): |
1288
4248f27af42a
10417 rename v0 support should be removed everywhere
Shawn Walker <srw@sun.com>
parents:
1271
diff
changeset
|
1306 |
if pfmri.is_successor(f): |
432
578875da6e04
48 Removing a dependency is not flagged, and recovery is not obvious
Danek Duvall <danek.duvall@sun.com>
parents:
429
diff
changeset
|
1307 |
dependents.extend(self.__req_dependents[f]) |
67
62c897652bbc
Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents:
63
diff
changeset
|
1308 |
return dependents |
62c897652bbc
Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents:
63
diff
changeset
|
1309 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1310 |
def __rebuild_image_catalogs(self, progtrack=None): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1311 |
"""Rebuilds the image catalogs based on the available publisher |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1312 |
catalogs.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1313 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1314 |
if not progtrack: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1315 |
progtrack = progress.QuietProgressTracker() |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1316 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1317 |
progtrack.cache_catalogs_start() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1318 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1319 |
publist = list(self.gen_publishers()) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1320 |
if not publist: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1321 |
# No publishers, so nothing can be known or installed. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1322 |
self.remove_catalogs() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1323 |
progtrack.cache_catalogs_done() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1324 |
return |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1325 |
|
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1326 |
self.history.log_operation_start("rebuild-image-catalogs") |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1327 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1328 |
# The image catalogs need to be updated, but this is a bit |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1329 |
# tricky as previously known packages must remain known even |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1330 |
# if PKG_STATE_KNOWN is no longer true if any other state |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1331 |
# information is present. This is to allow freezing, etc. of |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1332 |
# package states on a permanent basis even if the package is |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1333 |
# no longer available from a publisher repository. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1334 |
old_kcat = self.get_catalog(self.IMG_CATALOG_KNOWN) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1335 |
|
1358
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
1336 |
# batch_mode is set to True here since without it, catalog |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1337 |
# population time is almost doubled (since the catalog is |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1338 |
# re-sorted and stats are generated for every operation). |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1339 |
# In addition, the new catalog is first created in a new |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1340 |
# temporary directory so that it can be moved into place |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1341 |
# at the very end of this process (to minimize the chance |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1342 |
# that failure or interruption will cause the image to be |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1343 |
# left in an inconsistent state). |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1344 |
tmp_state_root = self.temporary_dir() |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1345 |
|
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1346 |
kcat = pkg.catalog.Catalog(batch_mode=True, |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1347 |
meta_root=os.path.join(tmp_state_root, |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1348 |
self.IMG_CATALOG_KNOWN), sign=False) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1349 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1350 |
# XXX if any of the below fails for any reason, the old 'known' |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1351 |
# catalog needs to be re-loaded so the client is in a consistent |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1352 |
# state. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1353 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1354 |
# All enabled publisher catalogs must be processed. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1355 |
pub_cats = [(pub.prefix, pub.catalog) for pub in publist] |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1356 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1357 |
# XXX For backwards compatibility, 'upgradability' of packages |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1358 |
# is calculated and stored based on whether a given pkg stem |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1359 |
# matches the newest version in the catalog. This is quite |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1360 |
# expensive (due to overhead), but at least the cost is |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1361 |
# consolidated here. This comparison is also cross-publisher, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1362 |
# as it used to be. In the future, it could likely be improved |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1363 |
# by usage of the SAT solver. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1364 |
newest = {} |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1365 |
for pfx, cat in [(None, old_kcat)] + pub_cats: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1366 |
for f in cat.fmris(): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1367 |
nver = newest.get(f.pkg_name, None) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1368 |
newest[f.pkg_name] = max(nver, f.version) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1369 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1370 |
# Next, copy all of the entries for the catalog parts that |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1371 |
# currently exist into the image 'known' catalog. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1372 |
def pub_append_cb(src_cat, f, ignored): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1373 |
# Need to get any state information from the old 'known' |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1374 |
# catalog and return it so that it will be merged with |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1375 |
# the new 'known' catalog. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1376 |
try: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1377 |
entry = old_kcat.get_entry(f) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1378 |
old_kcat.remove_package(f) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1379 |
except api_errors.UnknownCatalogEntry: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1380 |
# If the package can't be found |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1381 |
# in the previous 'known' |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1382 |
# catalog, then this is a |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1383 |
# completely new package. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1384 |
states = set() |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1385 |
mdata = { "states": states } |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1386 |
else: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1387 |
mdata = entry["metadata"] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1388 |
states = set(mdata["states"]) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1389 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1390 |
if src_cat.version == 0: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1391 |
states.add(self.PKG_STATE_V0) |
1449
a721d9b0aad2
12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents:
1435
diff
changeset
|
1392 |
states.discard(self.PKG_STATE_V1) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1393 |
else: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1394 |
# Assume V1 catalog source. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1395 |
states.add(self.PKG_STATE_V1) |
1449
a721d9b0aad2
12273 client catalog can mis-merge state information / lazy-load can fail
Shawn Walker <srw@sun.com>
parents:
1435
diff
changeset
|
1396 |
states.discard(self.PKG_STATE_V0) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1397 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1398 |
states.add(self.PKG_STATE_KNOWN) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1399 |
nver = newest.get(f.pkg_name, None) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1400 |
if not nver or f.version == nver: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1401 |
states.discard(self.PKG_STATE_UPGRADABLE) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1402 |
elif nver: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1403 |
states.add(self.PKG_STATE_UPGRADABLE) |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1404 |
|
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1405 |
dp = src_cat.get_part("catalog.dependency.C", |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1406 |
must_exist=True) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1407 |
try: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1408 |
dpent = dp.get_entry(f) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1409 |
except (api_errors.UnknownCatalogEntry, AttributeError): |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1410 |
dpent = None |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1411 |
states.discard(self.PKG_STATE_OBSOLETE) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1412 |
states.discard(self.PKG_STATE_RENAMED) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1413 |
if dpent: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1414 |
mfst = pkg.manifest.Manifest() |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1415 |
mfst.set_content("\n".join(dpent["actions"])) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1416 |
if mfst.getbool("pkg.obsolete", "false"): |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1417 |
states.add(self.PKG_STATE_OBSOLETE) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1418 |
elif mfst.getbool("pkg.renamed", "false"): |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1419 |
states.add(self.PKG_STATE_RENAMED) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
1420 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1421 |
mdata["states"] = list(states) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1422 |
return True, mdata |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1423 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1424 |
for pfx, cat in pub_cats: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1425 |
kcat.append(cat, cb=pub_append_cb, pubs=[pfx]) |
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1426 |
|
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1427 |
# Determine what publishers actually need sorting. This |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1428 |
# information can be passed on to catalog finalize() to |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1429 |
# improve catalog write performance. |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1430 |
final_pubs = set([p for p in kcat.publishers()]) |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1431 |
|
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1432 |
# Remove any publishers that have a v1 catalog and don't have |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1433 |
# packages that are not present in the current v1 catalog. |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1434 |
final_pubs.difference_update(set([ |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1435 |
pfx for pfx, cat in pub_cats |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1436 |
if cat.version == 1 and pfx not in old_kcat.publishers() |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1437 |
])) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1438 |
pub_cats = None |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1439 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1440 |
# Next, add any remaining entries in the previous 'known' |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1441 |
# catalog to the new one, but clear PKG_STATE_KNOWN and |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1442 |
# drop any entries that have no remaining state information. |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1443 |
def old_append_cb(src_cat, f, entry): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1444 |
# Need to get any state information from the old 'known' |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1445 |
# catalog and return it so that it will be merged with |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1446 |
# the new 'known' catalog. |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1447 |
mdata = entry["metadata"] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1448 |
states = set(mdata["states"]) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1449 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1450 |
states.discard(self.PKG_STATE_KNOWN) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1451 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1452 |
# Since this package is no longer available, it |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1453 |
# can only be considered upgradable if it is |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1454 |
# installed and there is a newer version |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1455 |
# available. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1456 |
nver = newest.get(f.pkg_name, None) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1457 |
if self.PKG_STATE_INSTALLED not in states or \ |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1458 |
(nver and f.version == nver): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1459 |
states.discard(self.PKG_STATE_UPGRADABLE) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1460 |
elif nver: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1461 |
states.add(self.PKG_STATE_UPGRADABLE) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1462 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1463 |
if not states or (len(states) == 1 and |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1464 |
(self.PKG_STATE_V0 in states or |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1465 |
self.PKG_STATE_V1 in states)): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1466 |
# This entry is no longer available and |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1467 |
# has no meaningful state information, so |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1468 |
# should be skipped. |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1469 |
return False, None |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1470 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1471 |
# The package is either installed, frozen, or is |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1472 |
# in some other state that needs preservation. |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1473 |
mdata["states"] = list(states) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1474 |
return True, mdata |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1475 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1476 |
kcat.append(old_kcat, cb=old_append_cb) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1477 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1478 |
# Finally, re-populate the 'installed' catalog based on the |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1479 |
# contents of the new, 'known' catalog and save them both. |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1480 |
def installed_append_cb(src_cat, f, entry): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1481 |
states = entry["metadata"]["states"] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1482 |
if self.PKG_STATE_INSTALLED in states: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1483 |
return True, None |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1484 |
return False, None |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1485 |
|
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1486 |
# Create the new installed catalog in a temporary location. |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1487 |
icat = pkg.catalog.Catalog(batch_mode=True, |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1488 |
meta_root=os.path.join(tmp_state_root, |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1489 |
self.IMG_CATALOG_INSTALLED), sign=False) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1490 |
icat.append(kcat, cb=installed_append_cb) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1491 |
|
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1492 |
# Save the new catalogs. |
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1493 |
root_mode = 0755 |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1494 |
for cat in kcat, icat: |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1495 |
os.makedirs(cat.meta_root, mode=root_mode) |
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1496 |
cat.finalize(pubs=final_pubs) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1497 |
cat.save() |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1498 |
|
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1499 |
# Next, preserve the old installed state dir, rename the |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1500 |
# new one into place, and then remove the old one. |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1501 |
state_root = os.path.join(self.imgdir, "state") |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1502 |
orig_state_root = self.__salvagedir(state_root) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1503 |
portable.rename(tmp_state_root, state_root) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1504 |
shutil.rmtree(orig_state_root, True) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1505 |
|
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1506 |
# Ensure in-memory catalogs get reloaded. |
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1507 |
self.__init_catalogs() |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1508 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1509 |
progtrack.cache_catalogs_done() |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1510 |
self.history.log_operation_end() |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1511 |
|
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1512 |
def refresh_publishers(self, full_refresh=False, immediate=False, |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1513 |
pubs=None, progtrack=None): |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1514 |
"""Refreshes the metadata (e.g. catalog) for one or more |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1515 |
publishers. |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1516 |
|
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1517 |
'full_refresh' is an optional boolean value indicating whether |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1518 |
a full retrieval of publisher metadata (e.g. catalogs) or only |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1519 |
an update to the existing metadata should be performed. When |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1520 |
True, 'immediate' is also set to True. |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1521 |
|
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1522 |
'immediate' is an optional boolean value indicating whether the |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1523 |
a refresh should occur now. If False, a publisher's selected |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1524 |
repository will only be checked for updates if the update |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1525 |
interval period recorded in the image configuration has been |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1526 |
exceeded. |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1527 |
|
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1528 |
'pubs' is a list of publisher prefixes or publisher objects |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1529 |
to refresh. Passing an empty list or using the default value |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1530 |
implies all publishers.""" |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1531 |
|
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1532 |
if not progtrack: |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1533 |
progtrack = progress.QuietProgressTracker() |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1534 |
|
1102
5ea5cdb4360d
5014 api sets successful result for image-create with failed catalog refresh
Shawn Walker <srw@sun.com>
parents:
1087
diff
changeset
|
1535 |
self.history.log_operation_start("refresh-publishers") |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1536 |
|
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1537 |
# Verify validity of certificates before attempting network |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1538 |
# operations. |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1539 |
try: |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1540 |
self.check_cert_validity() |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1541 |
except api_errors.ExpiringCertificate, e: |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1542 |
logger.error(str(e)) |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1543 |
|
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1544 |
pubs_to_refresh = [] |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1545 |
|
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1546 |
if not pubs: |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1547 |
# Omit disabled publishers. |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1548 |
pubs = [p for p in self.gen_publishers()] |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1549 |
for pub in pubs: |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1550 |
p = pub |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1551 |
if not isinstance(p, publisher.Publisher): |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1552 |
p = self.get_publisher(prefix=p) |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1553 |
if p.disabled: |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1554 |
e = api_errors.DisabledPublisher(p) |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1555 |
self.history.log_operation_end(error=e) |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1556 |
raise e |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1557 |
pubs_to_refresh.append(p) |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1558 |
|
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1559 |
if not pubs_to_refresh: |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1560 |
self.history.log_operation_end() |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1561 |
return |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1562 |
|
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1563 |
try: |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1564 |
# Ensure Image directory structure is valid. |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1565 |
self.mkdirs() |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1566 |
except Exception, e: |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1567 |
self.history.log_operation_end(error=e) |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1568 |
raise |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1569 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1570 |
progtrack.refresh_start(len(pubs_to_refresh)) |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1571 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1572 |
failed = [] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1573 |
total = 0 |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1574 |
succeeded = set() |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1575 |
updated = 0 |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1576 |
for pub in pubs_to_refresh: |
201
63e78f600aa7
185 traceback on pkg refresh when hostname lookup fails
Danek Duvall <danek.duvall@sun.com>
parents:
195
diff
changeset
|
1577 |
total += 1 |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1578 |
progtrack.refresh_progress(pub.prefix) |
235
61994d15c39b
373 design a nice default output for install/update/remove
Dan Price <dp@eng.sun.com>
parents:
226
diff
changeset
|
1579 |
try: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1580 |
if pub.refresh(full_refresh=full_refresh, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1581 |
immediate=immediate): |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1582 |
updated += 1 |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1583 |
except api_errors.ApiException, e: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1584 |
failed.append((pub, e)) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1585 |
continue |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1586 |
succeeded.add(pub.prefix) |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1587 |
progtrack.refresh_done() |
625
e46b345645d6
3799 need to start progress tracker going early on
Brock Pytlik <bpytlik@sun.com>
parents:
621
diff
changeset
|
1588 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1589 |
if updated: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1590 |
self.__rebuild_image_catalogs(progtrack=progtrack) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1591 |
|
201
63e78f600aa7
185 traceback on pkg refresh when hostname lookup fails
Danek Duvall <danek.duvall@sun.com>
parents:
195
diff
changeset
|
1592 |
if failed: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1593 |
e = api_errors.CatalogRefreshException(failed, total, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1594 |
len(succeeded)) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1595 |
self.history.log_operation_end(error=e) |
1435
f65591874aef
12221 client traceback if refresh fails due to exception
Shawn Walker <srw@sun.com>
parents:
1431
diff
changeset
|
1596 |
raise e |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1597 |
self.history.log_operation_end() |
116
9c9942a52984
(image flag day) remove pkg catalog, improve pkg status, localize pkg(1), use
Stephen Hahn <sch@Sun.COM>
parents:
111
diff
changeset
|
1598 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1599 |
def _get_publisher_meta_dir(self): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1600 |
if self.__upgraded: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1601 |
return IMG_PUB_DIR |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1602 |
return "catalog" |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
1603 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1604 |
def _get_publisher_meta_root(self, prefix): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1605 |
return os.path.join(self.imgdir, self._get_publisher_meta_dir(), |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1606 |
prefix) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1607 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1608 |
def remove_publisher_metadata(self, pub, progtrack=None): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1609 |
"""Removes the metadata for the specified publisher object.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1610 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1611 |
pub.remove_meta_root() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1612 |
self.__rebuild_image_catalogs(progtrack=progtrack) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1613 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1614 |
def gen_installed_pkg_names(self, anarchy=True): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1615 |
"""A generator function that produces FMRI strings as it |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1616 |
iterates over the list of installed packages. This is |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1617 |
faster than gen_installed_pkgs when only the FMRI string |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1618 |
is needed.""" |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1619 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1620 |
cat = self.get_catalog(self.IMG_CATALOG_INSTALLED) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1621 |
for f in cat.fmris(objects=False): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1622 |
if anarchy: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1623 |
# Catalog entries always have publisher prefix. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1624 |
yield "pkg:/%s" % f[6:].split("/", 1)[-1] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1625 |
continue |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1626 |
yield f |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1627 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1628 |
def gen_installed_pkgs(self): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1629 |
"""Return an iteration through the installed packages.""" |
1068
9400aa8afd32
2557 catalog cache pickle file dependent on fmri and version object definitions
Shawn Walker <srw@sun.com>
parents:
1045
diff
changeset
|
1630 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1631 |
cat = self.get_catalog(self.IMG_CATALOG_INSTALLED) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1632 |
for f in cat.fmris(): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1633 |
yield f |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1634 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1635 |
def __upgrade_image(self, progtrack=None): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1636 |
"""Transform the existing image structure and its data to |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1637 |
the newest format.""" |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
1638 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1639 |
if self.__upgraded: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1640 |
return |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1641 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1642 |
assert self.imgdir |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1643 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1644 |
def installed_file_publisher(filepath): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1645 |
"""Find the pkg's installed file named by filepath. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1646 |
Return the publisher that installed this package.""" |
835
34ec4401dc48
686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents:
834
diff
changeset
|
1647 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1648 |
f = file(filepath) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1649 |
try: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1650 |
flines = f.readlines() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1651 |
version, pub = flines |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1652 |
version = version.strip() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1653 |
pub = pub.strip() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1654 |
f.close() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1655 |
except ValueError: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1656 |
# If ValueError occurs, the installed file is of |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1657 |
# a previous format. For upgrades to work, it's |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1658 |
# necessary to assume that the package was |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1659 |
# installed from the preferred publisher. Here, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1660 |
# the publisher is setup to record that. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1661 |
if flines: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1662 |
pub = flines[0] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1663 |
pub = pub.strip() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1664 |
newpub = "%s_%s" % ( |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1665 |
pkg.fmri.PREF_PUB_PFX, pub) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1666 |
else: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1667 |
newpub = "%s_%s" % ( |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1668 |
pkg.fmri.PREF_PUB_PFX, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1669 |
self.get_preferred_publisher()) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1670 |
pub = newpub |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1671 |
assert pub |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1672 |
return pub |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1673 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1674 |
if not progtrack: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1675 |
progtrack = progress.QuietProgressTracker() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1676 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1677 |
# Not technically 'caching', but close enough ... |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1678 |
progtrack.cache_catalogs_start() |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1679 |
self.history.log_operation_start("upgrade-image") |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1680 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1681 |
# First, load the old package state information. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1682 |
installed_state_dir = "%s/state/installed" % self.imgdir |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1683 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1684 |
# If the state directory structure has already been created, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1685 |
# loading information from it is fast. The directory is |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1686 |
# populated with files, named by their (url-encoded) FMRI, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1687 |
# which point to the "installed" file in the corresponding |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1688 |
# directory under /var/pkg. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1689 |
installed = {} |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1690 |
def add_installed_entry(f): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1691 |
path = "%s/pkg/%s/installed" % \ |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1692 |
(self.imgdir, f.get_dir_path()) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1693 |
pub = installed_file_publisher(path) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1694 |
f.set_publisher(pub) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1695 |
installed[f.pkg_name] = f |
835
34ec4401dc48
686 Client needs a way to tell that a response is actually from an IPS server
johansen <johansen@sun.com>
parents:
834
diff
changeset
|
1696 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1697 |
if os.path.isdir(installed_state_dir): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1698 |
for pl in sorted(os.listdir(installed_state_dir)): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1699 |
fmristr = "%s" % urllib.unquote(pl) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1700 |
f = pkg.fmri.PkgFmri(fmristr) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1701 |
add_installed_entry(f) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1702 |
else: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1703 |
# Otherwise, we must iterate through the earlier |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1704 |
# installed state. One day, this can be removed. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1705 |
proot = "%s/pkg" % self.imgdir |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1706 |
for pd in sorted(os.listdir(proot)): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1707 |
for vd in sorted(os.listdir("%s/%s" % \ |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1708 |
(proot, pd))): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1709 |
path = "%s/pkg/%s/installed" % \ |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1710 |
(self.imgdir, pd, vd) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1711 |
if not os.path.exists(path): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1712 |
continue |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1713 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1714 |
fmristr = urllib.unquote("%s@%s" % (pd, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1715 |
vd)) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1716 |
f = pkg.fmri.PkgFmri(fmristr) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1717 |
add_installed_entry(f) |
1068
9400aa8afd32
2557 catalog cache pickle file dependent on fmri and version object definitions
Shawn Walker <srw@sun.com>
parents:
1045
diff
changeset
|
1718 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1719 |
# Create the new image catalogs. |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1720 |
kcat = pkg.catalog.Catalog(batch_mode=True, sign=False) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1721 |
icat = pkg.catalog.Catalog(batch_mode=True, sign=False) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1722 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1723 |
# XXX For backwards compatibility, 'upgradability' of packages |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1724 |
# is calculated and stored based on whether a given pkg stem |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1725 |
# matches the newest version in the catalog. This is quite |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1726 |
# expensive (due to overhead), but at least the cost is |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1727 |
# consolidated here. This comparison is also cross-publisher, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1728 |
# as it used to be. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1729 |
newest = {} |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1730 |
old_pub_cats = [] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1731 |
for pub in self.gen_publishers(): |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
1732 |
try: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1733 |
old_cat = pkg.server.catalog.ServerCatalog( |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1734 |
pub.meta_root, read_only=True, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1735 |
publisher=pub.prefix) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1736 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1737 |
old_pub_cats.append((pub, old_cat)) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1738 |
for f in old_cat.fmris(): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1739 |
nver = newest.get(f.pkg_name, None) |
1353
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1740 |
newest[f.pkg_name] = max(nver, |
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1741 |
f.version) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1742 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
1743 |
except EnvironmentError, e: |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
1744 |
# If a catalog file is just missing, ignore it. |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
1745 |
# If there's a worse error, make sure the user |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
1746 |
# knows about it. |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1747 |
if e.errno != errno.ENOENT: |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
1748 |
raise |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
1749 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1750 |
# Next, load the existing catalog data and convert it. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1751 |
pub_cats = [] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1752 |
for pub, old_cat in old_pub_cats: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1753 |
new_cat = pub.catalog |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1754 |
new_cat.batch_mode = True |
1358
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
1755 |
new_cat.sign = False |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1756 |
if new_cat.exists: |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1757 |
new_cat.destroy() |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
1758 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1759 |
# First convert the old publisher catalog to |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1760 |
# the new format. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1761 |
for f in old_cat.fmris(): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1762 |
new_cat.add_package(f) |
1068
9400aa8afd32
2557 catalog cache pickle file dependent on fmri and version object definitions
Shawn Walker <srw@sun.com>
parents:
1045
diff
changeset
|
1763 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1764 |
# Now populate the image catalogs. |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1765 |
states = [self.PKG_STATE_KNOWN, |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1766 |
self.PKG_STATE_V0] |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1767 |
mdata = { "states": states } |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1768 |
if f.version != newest[f.pkg_name]: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1769 |
states.append(self.PKG_STATE_UPGRADABLE) |
1068
9400aa8afd32
2557 catalog cache pickle file dependent on fmri and version object definitions
Shawn Walker <srw@sun.com>
parents:
1045
diff
changeset
|
1770 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1771 |
inst_fmri = installed.get(f.pkg_name, None) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1772 |
if inst_fmri and \ |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1773 |
inst_fmri.version == f.version and \ |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1774 |
pkg.fmri.is_same_publisher(f.publisher, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1775 |
inst_fmri.publisher): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1776 |
states.append(self.PKG_STATE_INSTALLED) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1777 |
if inst_fmri.preferred_publisher(): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1778 |
# Strip the PREF_PUB_PFX. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1779 |
inst_fmri.set_publisher( |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1780 |
inst_fmri.get_publisher()) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1781 |
states.append( |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1782 |
self.__PKG_STATE_PREFERRED) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1783 |
icat.add_package(f, metadata=mdata) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1784 |
del installed[f.pkg_name] |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1785 |
kcat.add_package(f, metadata=mdata) |
1068
9400aa8afd32
2557 catalog cache pickle file dependent on fmri and version object definitions
Shawn Walker <srw@sun.com>
parents:
1045
diff
changeset
|
1786 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1787 |
# Normally, the Catalog's attributes are automatically |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1788 |
# populated as a result of catalog operations. But in |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1789 |
# this case, the new Catalog's attributes should match |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1790 |
# those of the old catalog. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1791 |
old_lm = old_cat.last_modified() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1792 |
if old_lm: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1793 |
# Can be None for empty v0 catalogs. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1794 |
old_lm = pkg.catalog.ts_to_datetime(old_lm) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1795 |
new_cat.last_modified = old_lm |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1796 |
new_cat.version = 0 |
1068
9400aa8afd32
2557 catalog cache pickle file dependent on fmri and version object definitions
Shawn Walker <srw@sun.com>
parents:
1045
diff
changeset
|
1797 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1798 |
# Add to the list of catalogs to save. |
1358
6fec8fbc15a6
11324 package state written to parent boot environment during image-update
Shawn Walker <srw@sun.com>
parents:
1353
diff
changeset
|
1799 |
new_cat.batch_mode = False |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1800 |
pub_cats.append(new_cat) |
1068
9400aa8afd32
2557 catalog cache pickle file dependent on fmri and version object definitions
Shawn Walker <srw@sun.com>
parents:
1045
diff
changeset
|
1801 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1802 |
# Discard the old catalog objects. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1803 |
old_pub_cats = None |
1068
9400aa8afd32
2557 catalog cache pickle file dependent on fmri and version object definitions
Shawn Walker <srw@sun.com>
parents:
1045
diff
changeset
|
1804 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1805 |
for f in installed.values(): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1806 |
# Any remaining FMRIs need to be added to all of the |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1807 |
# image catalogs. |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1808 |
states = [self.PKG_STATE_INSTALLED, self.PKG_STATE_V0] |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1809 |
mdata = { "states": states } |
1353
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1810 |
# This package may be installed from a publisher that |
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1811 |
# is no longer known or has been disabled. |
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1812 |
if f.pkg_name in newest and \ |
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1813 |
f.version != newest[f.pkg_name]: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1814 |
states.append(self.PKG_STATE_UPGRADABLE) |
1353
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1815 |
|
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1816 |
if f.preferred_publisher(): |
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1817 |
# Strip the PREF_PUB_PFX. |
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1818 |
f.set_publisher(f.get_publisher()) |
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1819 |
|
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1820 |
# Set preferred state. |
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1821 |
states.append(self.__PKG_STATE_PREFERRED) |
b9535ddac1c6
11319 image format upgrade can traceback on installed packages from disabled publisher
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1822 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1823 |
icat.add_package(f, metadata=mdata) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1824 |
kcat.add_package(f, metadata=mdata) |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
1825 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1826 |
for cat in pub_cats + [kcat, icat]: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1827 |
cat.finalize() |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
1828 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1829 |
# Data conversion finished. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1830 |
self.__upgraded = True |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
1831 |
|
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
1832 |
try: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1833 |
# Ensure Image directory structure is valid. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1834 |
self.mkdirs() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1835 |
except api_errors.PermissionsException, e: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1836 |
progtrack.cache_catalogs_done() |
1087
293c0aa5f32e
8214 load_catalogs should only load catalog data when needed
Shawn Walker <srw@sun.com>
parents:
1086
diff
changeset
|
1837 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1838 |
# An unprivileged user is attempting to use the |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1839 |
# new client with an old image. Since none of |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1840 |
# the changes can be saved, warn the user and |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1841 |
# then return. |
715
5620652f5927
4886 api.info shouldn't be reloading the catalog from disk needlessly
Brock Pytlik <bpytlik@sun.com>
parents:
703
diff
changeset
|
1842 |
|
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1843 |
# Because the new image catalogs couldn't be saved, |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1844 |
# store them in the image's internal cache so that |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1845 |
# operations can function as expected. |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1846 |
self.__catalogs[self.IMG_CATALOG_KNOWN] = kcat |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1847 |
self.__catalogs[self.IMG_CATALOG_INSTALLED] = icat |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1848 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1849 |
# Raising an exception here would be a decidedly |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1850 |
# bad thing as it would disrupt find_root, etc. |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1851 |
logger.warning("Package operation performance is " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1852 |
"currently degraded.\nThis can be resolved by " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
1853 |
"executing 'pkg refresh' as a privileged user.\n") |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1854 |
self.history.log_operation_end() |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
1855 |
return |
418
21621fd99956
2543 eliminate unnecessary stat() calls from gen_installed_pkgs()
Danek Duvall <danek.duvall@sun.com>
parents:
409
diff
changeset
|
1856 |
|
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1857 |
# This has to be done after the permissions check above. |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1858 |
tmp_state_root = self.temporary_dir() |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1859 |
|
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1860 |
# Create new image catalogs. |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1861 |
kcat.meta_root = os.path.join(tmp_state_root, |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1862 |
self.IMG_CATALOG_KNOWN) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1863 |
icat.meta_root = os.path.join(tmp_state_root, |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1864 |
self.IMG_CATALOG_INSTALLED) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1865 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1866 |
# Assume that since mkdirs succeeded that the remaining data |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1867 |
# can be saved and the image structure can be upgraded. But |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1868 |
# first, attempt to save the image catalogs before changing |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1869 |
# structure. |
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1870 |
root_mode = 0755 |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1871 |
for cat in icat, kcat: |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1872 |
os.makedirs(cat.meta_root, mode=root_mode) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1873 |
cat.save() |
418
21621fd99956
2543 eliminate unnecessary stat() calls from gen_installed_pkgs()
Danek Duvall <danek.duvall@sun.com>
parents:
409
diff
changeset
|
1874 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1875 |
# Next, reset the publisher meta_roots to reflect the new |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1876 |
# directory structure and move each publisher's catalog files |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1877 |
# to the new catalog root. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1878 |
for pub in self.gen_publishers(): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1879 |
old_root = pub.meta_root |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1880 |
pub.meta_root = self._get_publisher_meta_root( |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1881 |
pub.prefix) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1882 |
pub.create_meta_root() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1883 |
for fname in os.listdir(old_root): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1884 |
src = os.path.join(old_root, fname) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1885 |
if fname == "last_refreshed": |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1886 |
dest = os.path.join(pub.meta_root, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1887 |
fname) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1888 |
else: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1889 |
dest = os.path.join(pub.catalog_root, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1890 |
fname) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1891 |
portable.rename(src, dest) |
418
21621fd99956
2543 eliminate unnecessary stat() calls from gen_installed_pkgs()
Danek Duvall <danek.duvall@sun.com>
parents:
409
diff
changeset
|
1892 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1893 |
# Next, save all of the new publisher catalogs. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1894 |
for cat in pub_cats: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1895 |
cat.save() |
226
8939051a496c
376 image must use default authority when none specified
johansen <johansen@sun.com>
parents:
222
diff
changeset
|
1896 |
|
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1897 |
# Next, preserve the old catalog and state directories. |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1898 |
# Then, rename the new state directory into place, and then |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1899 |
# remove the old catalog and state directories. |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1900 |
cat_root = os.path.join(self.imgdir, "catalog") |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1901 |
orig_cat_root = self.__salvagedir(cat_root) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1902 |
|
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1903 |
state_root = os.path.join(self.imgdir, "state") |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1904 |
orig_state_root = self.__salvagedir(state_root) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1905 |
|
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1906 |
portable.rename(tmp_state_root, state_root) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1907 |
|
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1908 |
# Ensure in-memory catalogs get reloaded. |
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
1909 |
self.__init_catalogs() |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1910 |
|
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1911 |
# Finally, dump the old, unused dirs and mark complete. |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1912 |
shutil.rmtree(orig_cat_root, True) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1913 |
shutil.rmtree(orig_state_root, True) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1914 |
progtrack.cache_catalogs_done() |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
1915 |
self.history.log_operation_end() |
516
53da6297fb65
3039 Install and Image-update should check index consistency with installed packages
Brock Pytlik <bpytlik@sun.com>
parents:
499
diff
changeset
|
1916 |
|
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
302
diff
changeset
|
1917 |
def strtofmri(self, myfmri): |
423
5c756997bf67
2253 With the latest build of the pkg repo, can't install packages from additional authorities
Danek Duvall <danek.duvall@sun.com>
parents:
419
diff
changeset
|
1918 |
return pkg.fmri.PkgFmri(myfmri, self.attrs["Build-Release"]) |
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
302
diff
changeset
|
1919 |
|
526
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
518
diff
changeset
|
1920 |
def strtomatchingfmri(self, myfmri): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1921 |
return pkg.fmri.MatchingPkgFmri(myfmri, |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1922 |
self.attrs["Build-Release"]) |
526
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
518
diff
changeset
|
1923 |
|
655
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
1924 |
def load_constraints(self, progtrack): |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
1925 |
"""Load constraints for all install pkgs""" |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1926 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1927 |
cat = self.get_catalog(self.IMG_CATALOG_INSTALLED) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1928 |
for f, actions in cat.actions([cat.DEPENDENCY], |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1929 |
excludes=self.list_excludes()): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1930 |
if not self.constraints.start_loading(f): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1931 |
# skip loading if already done |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1932 |
continue |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1933 |
|
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1934 |
for a in actions: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1935 |
if a.name != "depend": |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1936 |
continue |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1937 |
progtrack.evaluate_progress() |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1938 |
con = a.parse(self, f.get_name())[1] |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1939 |
self.constraints.update_constraints(con) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1940 |
self.constraints.finish_loading(f) |
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
302
diff
changeset
|
1941 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1942 |
def __get_installed_unbound_inc_list(self): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1943 |
"""Returns list of packages containing incorporation |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1944 |
dependencies on which no other pkgs depend.""" |
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
302
diff
changeset
|
1945 |
|
655
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
1946 |
inc_tuples = [] |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
1947 |
dependents = set() |
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
302
diff
changeset
|
1948 |
|
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1949 |
cat = self.get_catalog(self.IMG_CATALOG_INSTALLED) |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1950 |
for f, actions in cat.actions([cat.DEPENDENCY], |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1951 |
excludes=self.list_excludes()): |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1952 |
for a in actions: |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1953 |
if a.name != "depend": |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1954 |
continue |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1955 |
fmri_name = f.get_pkg_stem() |
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1956 |
con_fmri = a.get_constrained_fmri(self) |
655
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
1957 |
if con_fmri: |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
1958 |
con_name = con_fmri.get_pkg_stem() |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
1959 |
dependents.add(con_name) |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
1960 |
inc_tuples.append((fmri_name, con_name)) |
1369
e86145680c34
11359 catalog should offer lazy-load mechanism for action metadata
Shawn Walker <srw@sun.com>
parents:
1358
diff
changeset
|
1961 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1962 |
# remove those incorporations which are depended on by other |
655
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
1963 |
# incorporations. |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
1964 |
deletions = 0 |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
1965 |
for i, a in enumerate(inc_tuples[:]): |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
1966 |
if a[0] in dependents: |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
1967 |
del inc_tuples[i - deletions] |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
1968 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1969 |
for p in set([ a[0] for a in inc_tuples ]): |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
1970 |
yield pkg.fmri.PkgFmri(p, self.attrs["Build-Release"]) |
195
b23d0425f0f7
11 use FMRIs with fully specified authorities internally
johansen <johansen@sun.com>
parents:
192
diff
changeset
|
1971 |
|
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
1972 |
def get_user_by_name(self, name): |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
1973 |
return portable.get_user_by_name(name, self.root, |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
1974 |
self.type != IMG_USER) |
173
da329417a206
18 Actions should use passwd and group databases from image, if possible
Danek Duvall <danek.duvall@sun.com>
parents:
172
diff
changeset
|
1975 |
|
339
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1976 |
def get_name_by_uid(self, uid, returnuid = False): |
173
da329417a206
18 Actions should use passwd and group databases from image, if possible
Danek Duvall <danek.duvall@sun.com>
parents:
172
diff
changeset
|
1977 |
# XXX What to do about IMG_PARTIAL? |
339
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1978 |
try: |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
1979 |
return portable.get_name_by_uid(uid, self.root, |
339
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1980 |
self.type != IMG_USER) |
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1981 |
except KeyError: |
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1982 |
if returnuid: |
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1983 |
return uid |
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1984 |
else: |
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1985 |
raise |
243
ca57127811b8
399 pkg list on explicit packages fails with no output, exit status of 1
Stephen Hahn <sch@Sun.COM>
parents:
239
diff
changeset
|
1986 |
|
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
1987 |
def get_group_by_name(self, name): |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
1988 |
return portable.get_group_by_name(name, self.root, |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
1989 |
self.type != IMG_USER) |
173
da329417a206
18 Actions should use passwd and group databases from image, if possible
Danek Duvall <danek.duvall@sun.com>
parents:
172
diff
changeset
|
1990 |
|
339
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1991 |
def get_name_by_gid(self, gid, returngid = False): |
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1992 |
try: |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
1993 |
return portable.get_name_by_gid(gid, self.root, |
339
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1994 |
self.type != IMG_USER) |
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1995 |
except KeyError: |
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1996 |
if returngid: |
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1997 |
return gid |
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1998 |
else: |
d8e57580599b
1271 pkg verify tracebacks on files owned by my uid...
Danek Duvall <danek.duvall@sun.com>
parents:
331
diff
changeset
|
1999 |
raise |
173
da329417a206
18 Actions should use passwd and group databases from image, if possible
Danek Duvall <danek.duvall@sun.com>
parents:
172
diff
changeset
|
2000 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2001 |
@staticmethod |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2002 |
def __multimatch(name, patterns): |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2003 |
"""Applies a matcher to a name across a list of patterns. |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2004 |
Returns all tuples of patterns which match the name. Each tuple |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2005 |
contains the index into the original list, the pattern itself, |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2006 |
the package version, the publisher, and the raw publisher |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2007 |
string.""" |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2008 |
return [ |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2009 |
(i, pat, pat.tuple()[2], |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2010 |
pat.publisher, pat.publisher) |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2011 |
for i, (pat, m) in enumerate(patterns) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2012 |
if m(name, pat.tuple()[1]) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2013 |
] |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2014 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2015 |
def __inventory(self, patterns=None, all_known=False, matcher=None, |
1045
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2016 |
constraint=pkg.version.CONSTRAINT_AUTO, ordered=True): |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2017 |
"""Private method providing the back-end for inventory().""" |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2018 |
|
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2019 |
if not matcher: |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2020 |
matcher = pkg.fmri.fmri_match |
59
eef94b0c0694
require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents:
51
diff
changeset
|
2021 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2022 |
if not patterns: |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2023 |
patterns = [] |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2024 |
|
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2025 |
# Store the original patterns before we possibly turn them into |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2026 |
# PkgFmri objects, so we can give them back to the user in error |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2027 |
# messages. |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2028 |
opatterns = patterns[:] |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2029 |
|
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2030 |
# Match the matching function with the pattern so that we can |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2031 |
# change it per-pattern, depending on whether it has glob |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2032 |
# characters or nails down the pattern with a leading pkg:/. |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2033 |
patterns = [ (i, matcher) for i in patterns ] |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2034 |
|
526
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
518
diff
changeset
|
2035 |
illegals = [] |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2036 |
for i, (pat, m) in enumerate(patterns): |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2037 |
if not isinstance(pat, pkg.fmri.PkgFmri): |
526
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
518
diff
changeset
|
2038 |
try: |
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
518
diff
changeset
|
2039 |
if "*" in pat or "?" in pat: |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2040 |
patterns[i] = ( |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2041 |
pkg.fmri.MatchingPkgFmri( |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2042 |
pat, "5.11"), |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2043 |
pkg.fmri.glob_match) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2044 |
elif pat.startswith("pkg:/"): |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2045 |
patterns[i] = ( |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2046 |
pkg.fmri.PkgFmri(pat, |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2047 |
"5.11"), |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2048 |
pkg.fmri.exact_name_match) |
526
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
518
diff
changeset
|
2049 |
else: |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2050 |
patterns[i] = ( |
526
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
518
diff
changeset
|
2051 |
pkg.fmri.PkgFmri(pat, |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2052 |
"5.11"), |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2053 |
pkg.fmri.fmri_match) |
526
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
518
diff
changeset
|
2054 |
except pkg.fmri.IllegalFmri, e: |
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
518
diff
changeset
|
2055 |
illegals.append(e) |
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
518
diff
changeset
|
2056 |
|
8c243883ae41
822 Depot traceback on "pkgsend -s <server> open foo"
Dan Price <dp@eng.sun.com>
parents:
518
diff
changeset
|
2057 |
if illegals: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2058 |
raise api_errors.InventoryException(illegal=illegals) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2059 |
|
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2060 |
# matchingpats is the set of all the patterns which matched a |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2061 |
# package in the catalog. This allows us to return partial |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2062 |
# failure if some patterns match and some don't. |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2063 |
# XXX It would be nice to keep track of why some patterns failed |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2064 |
# to match -- based on name, version, or publisher. |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2065 |
matchingpats = set() |
59
eef94b0c0694
require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents:
51
diff
changeset
|
2066 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2067 |
if all_known: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2068 |
cat = self.get_catalog(self.IMG_CATALOG_KNOWN) |
1045
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2069 |
else: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2070 |
cat = self.get_catalog(self.IMG_CATALOG_INSTALLED) |
1045
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2071 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2072 |
if ordered: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2073 |
names = sorted(cat.names()) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2074 |
else: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2075 |
names = cat.names() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2076 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2077 |
for name in names: |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2078 |
# Eliminate all patterns not matching "name". If there |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2079 |
# are no patterns left, go on to the next name, but only |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2080 |
# if there were any to start with. |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2081 |
matches = self.__multimatch(name, patterns) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2082 |
if patterns and not matches: |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2083 |
continue |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2084 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2085 |
rversions = reversed(list(cat.entries_by_version(name))) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2086 |
for ver, entries in rversions: |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2087 |
# If a pattern specified a version and that |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2088 |
# version isn't succeeded by "ver", then record |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2089 |
# the pattern for removal from consideration. |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2090 |
nomatch = [] |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2091 |
for i, match in enumerate(matches): |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2092 |
if match[2] and \ |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2093 |
not ver.is_successor(match[2], |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2094 |
constraint): |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2095 |
nomatch.append(i) |
221
e1dbb27a23b5
52 catalog can leave inventory behind, making pkg(1) blind
Stephen Hahn <sch@Sun.COM>
parents:
219
diff
changeset
|
2096 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2097 |
# Eliminate the name matches that didn't match |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2098 |
# on versions. We need to create a new list |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2099 |
# because we need to reuse the original |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2100 |
# "matches" for each new version. |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2101 |
vmatches = [ |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2102 |
matches[i] |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2103 |
for i, match in enumerate(matches) |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2104 |
if i not in nomatch |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2105 |
] |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2106 |
|
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2107 |
# If we deleted all contenders (if we had any to |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2108 |
# begin with), go on to the next version. |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2109 |
if matches and not vmatches: |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2110 |
continue |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2111 |
|
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2112 |
# Like the version skipping above, do the same |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2113 |
# for publishers. |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2114 |
publist = set([f[0].publisher for f in entries]) |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2115 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2116 |
nomatch = [] |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2117 |
for i, match in enumerate(vmatches): |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2118 |
if match[3] and \ |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2119 |
match[3] not in publist: |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2120 |
nomatch.append(i) |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2121 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2122 |
pmatches = [ |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2123 |
vmatches[i] |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2124 |
for i, match in enumerate(vmatches) |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2125 |
if i not in nomatch |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2126 |
] |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2127 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2128 |
if vmatches and not pmatches: |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2129 |
continue |
104
ecfc64baf22e
add naive configuration, naive global/preferred authorities, delete content
Stephen Hahn <sch@sun.com>
parents:
87
diff
changeset
|
2130 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2131 |
# If no patterns were specified or any still- |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2132 |
# matching pattern specified no publisher, we |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2133 |
# use the entire list of publishers for this |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2134 |
# version. Otherwise, we use the intersection |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2135 |
# of the list of publishers in pubstate, and |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2136 |
# the publishers in the patterns. |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2137 |
aset = set(i[3] for i in pmatches) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2138 |
if aset and None not in aset: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2139 |
publist = set( |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2140 |
m[3] |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2141 |
for m in pmatches |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2142 |
if m[3] in publist |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2143 |
) |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2144 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2145 |
matchingpats |= set(i[:2] for i in vmatches) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2146 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2147 |
for f, entry in entries: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2148 |
if f.publisher not in publist: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2149 |
continue |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2150 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2151 |
states = entry["metadata"]["states"] |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2152 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2153 |
known = self.PKG_STATE_KNOWN in states |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2154 |
st = { |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2155 |
"frozen": False, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2156 |
"in_catalog": known, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2157 |
"incorporated": False, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2158 |
"excludes": False, |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2159 |
"upgradable": self.PKG_STATE_UPGRADABLE in states, |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2160 |
"obsolete": self.PKG_STATE_OBSOLETE in states, |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2161 |
"renamed": self.PKG_STATE_RENAMED in states |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2162 |
} |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2163 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2164 |
if self.PKG_STATE_INSTALLED in states: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2165 |
st["state"] = \ |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2166 |
self.PKG_STATE_INSTALLED |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2167 |
elif known: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2168 |
# XXX long-term, a package could |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2169 |
# be 'frozen' or something else |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2170 |
# and no longer available (in a |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2171 |
# catalog). |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2172 |
st["state"] = \ |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2173 |
self.PKG_STATE_KNOWN |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2174 |
else: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2175 |
# Must be in some other state; |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2176 |
# see comment above. |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2177 |
st["state"] = None |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2178 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2179 |
yield f, st |
329 | 2180 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2181 |
nonmatchingpats = [ |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2182 |
opatterns[i] |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2183 |
for i, f in set(enumerate((p[0] for p in patterns))) - matchingpats |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2184 |
] |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2185 |
|
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2186 |
if nonmatchingpats: |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2187 |
raise api_errors.InventoryException( |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2188 |
notfound=nonmatchingpats) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2189 |
|
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2190 |
def inventory(self, *args, **kwargs): |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2191 |
"""Enumerate the package FMRIs in the image's catalog, yielding |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2192 |
a list of tuples of the format (fmri, pkg state dict). |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2193 |
|
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2194 |
If "patterns" is None (the default) or an empty sequence, all |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2195 |
package names will match. Otherwise, it is a list of patterns |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2196 |
to match against FMRIs in the catalog. |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2197 |
|
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2198 |
If "all_known" is False (the default), only installed packages |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2199 |
will be enumerated. If True, all known packages will be |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2200 |
enumerated. |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2201 |
|
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2202 |
The "matcher" parameter should specify a function taking two |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2203 |
string arguments: a name and a pattern, returning True if the |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2204 |
pattern matches the name, and False otherwise. By default, the |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2205 |
matcher will be pkg.fmri.fmri_match(). |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2206 |
|
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2207 |
The "constraint" parameter defines how a version specified in a |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2208 |
pattern matches a version in the catalog. By default, a natural |
1045
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2209 |
"subsetting" constraint is used. |
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2210 |
|
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2211 |
The "ordered" parameter is a boolean value that indicates |
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2212 |
whether the returned list should first be sorted by name before |
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2213 |
being sorted by version (descending). By default, this is True. |
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2214 |
""" |
161
e0322fe7842c
Simplify and correct the package matching code.
Danek Duvall <danek.duvall@sun.com>
parents:
157
diff
changeset
|
2215 |
|
1158
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2216 |
# "preferred" is a private argument that is currently only used |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2217 |
# in evaluate_fmri(), but could be made more generally useful. |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2218 |
# "preferred" ensures that all potential matches from the |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2219 |
# preferred publisher are generated before those from |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2220 |
# non-preferred publishers. In the current implementation, this |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2221 |
# consumes more memory. |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2222 |
preferred = kwargs.pop("preferred", False) |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2223 |
if not preferred: |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2224 |
for f in self.__inventory(*args, **kwargs): |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2225 |
yield f |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2226 |
else: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2227 |
ppub = self.get_preferred_publisher() |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2228 |
nplist = [] |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2229 |
for f in self.__inventory(*args, **kwargs): |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2230 |
if f[0].publisher == ppub: |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2231 |
yield f |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2232 |
else: |
1158
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2233 |
nplist.append(f) |
419
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2234 |
|
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2235 |
for f in nplist: |
a38f1ed7cf76
1867 'pkg list' takes *WAY* too long
Danek Duvall <danek.duvall@sun.com>
parents:
418
diff
changeset
|
2236 |
yield f |
59
eef94b0c0694
require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents:
51
diff
changeset
|
2237 |
|
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
2238 |
def update_index_dir(self, postfix="index"): |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
2239 |
"""Since the index directory will not reliably be updated when |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
2240 |
the image root is, this should be called prior to using the |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
2241 |
index directory. |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
2242 |
""" |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
2243 |
self.index_dir = os.path.join(self.imgdir, postfix) |
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
2244 |
|
388
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2245 |
def incoming_download_dir(self): |
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2246 |
"""Return the directory path for incoming downloads |
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2247 |
that have yet to be completed. Once a file has been |
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2248 |
successfully downloaded, it is moved to the cached download |
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2249 |
directory.""" |
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2250 |
|
554
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
2251 |
return self.dl_cache_incoming |
388
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2252 |
|
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2253 |
def cached_download_dir(self): |
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2254 |
"""Return the directory path for cached content. |
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2255 |
Files that have been successfully downloaded live here.""" |
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2256 |
|
554
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
2257 |
return self.dl_cache_dir |
251
6c3d70b74865
470 pkg image-update can fail under some conditions
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
243
diff
changeset
|
2258 |
|
6c3d70b74865
470 pkg image-update can fail under some conditions
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
243
diff
changeset
|
2259 |
def cleanup_downloads(self): |
388
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2260 |
"""Clean up any downloads that were in progress but that |
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2261 |
did not successfully finish.""" |
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2262 |
|
554
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
2263 |
shutil.rmtree(self.dl_cache_incoming, True) |
388
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2264 |
|
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2265 |
def cleanup_cached_content(self): |
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2266 |
"""Delete the directory that stores all of our cached |
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2267 |
downloaded content. This may take a while for a large |
554
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
2268 |
directory hierarchy. Don't clean up caches if the |
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
2269 |
user overrode the underlying setting using PKG_CACHEDIR. """ |
388
5a08791fb814
2188 Client must fail gracefully when network timeout occurs
johansen <johansen@sun.com>
parents:
384
diff
changeset
|
2270 |
|
554
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
2271 |
if not self.is_user_cache_dir and \ |
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
2272 |
self.cfg_cache.get_policy(imageconfig.FLUSH_CONTENT_CACHE): |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
2273 |
logger.info("Deleting content cache") |
554
fe196874250d
3508 zone install should utilize/populate global zone d/l cache
Dan Price <dp@eng.sun.com>
parents:
552
diff
changeset
|
2274 |
shutil.rmtree(self.dl_cache_dir, True) |
289
c2e63370fb2b
160 Make IPS cross-platform for use across other supported OS's
Tom Mueller <Tom.Mueller@Sun.COM>
parents:
285
diff
changeset
|
2275 |
|
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2276 |
def __salvagedir(self, path): |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2277 |
sdir = os.path.normpath( |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2278 |
os.path.join(self.imgdir, "lost+found", |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2279 |
path + "-" + time.strftime("%Y%m%dT%H%M%SZ"))) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2280 |
|
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2281 |
parent = os.path.dirname(sdir) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2282 |
if not os.path.exists(parent): |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2283 |
os.makedirs(parent) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2284 |
shutil.move(os.path.normpath(os.path.join(self.root, path)), |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2285 |
sdir) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2286 |
return sdir |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2287 |
|
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
302
diff
changeset
|
2288 |
def salvagedir(self, path): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2289 |
"""Called when directory contains something and it's not |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2290 |
supposed to because it's being deleted. XXX Need to work out a |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2291 |
better error passback mechanism. Path is rooted in /....""" |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
2292 |
|
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2293 |
sdir = self.__salvagedir(path) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
2294 |
logger.warning("\nWarning - directory %s not empty - contents " |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
2295 |
"preserved in %s" % (path, sdir)) |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2296 |
|
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2297 |
def temporary_dir(self): |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2298 |
"""create a temp directory under image directory for various |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2299 |
purposes""" |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2300 |
tempdir = os.path.normpath(os.path.join(self.imgdir, "tmp")) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2301 |
try: |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2302 |
if not os.path.exists(tempdir): |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2303 |
os.makedirs(tempdir) |
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
2304 |
rval = tempfile.mkdtemp(dir=tempdir) |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
2305 |
|
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
2306 |
# Force standard mode. |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
2307 |
root_mode = 0755 |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
2308 |
os.chmod(rval, root_mode) |
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
2309 |
return rval |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2310 |
except EnvironmentError, e: |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2311 |
if e.errno == errno.EACCES: |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2312 |
raise api_errors.PermissionsException( |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2313 |
e.filename) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
2314 |
if e.errno == errno.EROFS: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
2315 |
raise api_errors.ReadOnlyFileSystemException( |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
2316 |
e.filename) |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2317 |
raise |
251
6c3d70b74865
470 pkg image-update can fail under some conditions
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
243
diff
changeset
|
2318 |
|
462
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
461
diff
changeset
|
2319 |
def temporary_file(self): |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2320 |
"""create a temp file under image directory for various |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2321 |
purposes""" |
462
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
461
diff
changeset
|
2322 |
tempdir = os.path.normpath(os.path.join(self.imgdir, "tmp")) |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2323 |
try: |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2324 |
if not os.path.exists(tempdir): |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2325 |
os.makedirs(tempdir) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2326 |
fd, name = tempfile.mkstemp(dir=tempdir) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2327 |
os.close(fd) |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2328 |
except EnvironmentError, e: |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2329 |
if e.errno == errno.EACCES: |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2330 |
raise api_errors.PermissionsException( |
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2331 |
e.filename) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
2332 |
if e.errno == errno.EROFS: |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
2333 |
raise api_errors.ReadOnlyFileSystemException( |
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1402
diff
changeset
|
2334 |
e.filename) |
1402
c0fb578f911a
11384 cascading failure hides exception during image creation
Shawn Walker <srw@sun.com>
parents:
1370
diff
changeset
|
2335 |
raise |
462
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
461
diff
changeset
|
2336 |
return name |
910600c14093
45 "move" action for files that are renamed, but must be preserved
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
461
diff
changeset
|
2337 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2338 |
def __filter_install_matches(self, matches): |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2339 |
"""Attempts to eliminate redundant matches found during |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2340 |
packaging operations: |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2341 |
|
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2342 |
* First, stems of installed packages for publishers that |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2343 |
are now unknown (no longer present in the image |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2344 |
configuration) are dropped. |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2345 |
|
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2346 |
* Second, if multiple matches are still present, stems of |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2347 |
of installed packages, that are not presently in the |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2348 |
corresponding publisher's catalog, are dropped. |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2349 |
|
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2350 |
* Finally, if multiple matches are still present, all |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2351 |
stems except for those in state PKG_STATE_INSTALLED are |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2352 |
dropped. |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2353 |
|
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2354 |
Returns a list of the filtered matches, along with a dict of |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2355 |
their unique names.""" |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2356 |
|
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2357 |
olist = [] |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2358 |
onames = set() |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2359 |
|
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2360 |
# First eliminate any duplicate matches that are for unknown |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2361 |
# publishers (publishers which have been removed from the image |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2362 |
# configuration). |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2363 |
publist = set(p.prefix for p in self.get_publishers().values()) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2364 |
for m, st in matches: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2365 |
if m.publisher in publist: |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2366 |
onames.add(m.get_pkg_stem()) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2367 |
olist.append((m, st)) |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2368 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2369 |
# Next, if there are still multiple matches, eliminate matches |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2370 |
# belonging to publishers that no longer have the FMRI in their |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2371 |
# catalog. |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2372 |
found_state = False |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2373 |
if len(onames) > 1: |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2374 |
mlist = [] |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2375 |
mnames = set() |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2376 |
for m, st in olist: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2377 |
if not st["in_catalog"]: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2378 |
continue |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2379 |
if st["state"] == self.PKG_STATE_INSTALLED: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2380 |
found_state = True |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2381 |
mnames.add(m.get_pkg_stem()) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2382 |
mlist.append((m, st)) |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2383 |
olist = mlist |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2384 |
onames = mnames |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2385 |
|
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2386 |
# Finally, if there are still multiple matches, and a known |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2387 |
# stem is installed, then eliminate any stems that do not |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2388 |
# have an installed version. |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2389 |
if found_state and len(onames) > 1: |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2390 |
mlist = [] |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2391 |
mnames = set() |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2392 |
for m, st in olist: |
1463
0ef25025d601
12340 catalog storage performance regression
Shawn Walker <srw@sun.com>
parents:
1461
diff
changeset
|
2393 |
if st["state"] == self.PKG_STATE_INSTALLED: |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2394 |
mnames.add(m.get_pkg_stem()) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2395 |
mlist.append((m, st)) |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2396 |
olist = mlist |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2397 |
onames = mnames |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2398 |
|
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2399 |
return olist, onames |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2400 |
|
625
e46b345645d6
3799 need to start progress tracker going early on
Brock Pytlik <bpytlik@sun.com>
parents:
621
diff
changeset
|
2401 |
def make_install_plan(self, pkg_list, progtrack, check_cancelation, |
1158
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2402 |
noexecute, filters=None, verbose=False, multimatch_ignore=False): |
296
576858fb8376
398 disambiguate packages matching the default authority
johansen <johansen@sun.com>
parents:
289
diff
changeset
|
2403 |
"""Take a list of packages, specified in pkg_list, and attempt |
329 | 2404 |
to assemble an appropriate image plan. This is a helper |
429
6c9cbb6e6600
983 pkg search returns just one action per package/token-type combo
Brock Pytlik <bpytlik@sun.com>
parents:
423
diff
changeset
|
2405 |
routine for some common operations in the client. |
296
576858fb8376
398 disambiguate packages matching the default authority
johansen <johansen@sun.com>
parents:
289
diff
changeset
|
2406 |
|
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2407 |
This method checks all publishers for a package match; |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2408 |
however, it defaults to choosing the preferred publisher |
296
576858fb8376
398 disambiguate packages matching the default authority
johansen <johansen@sun.com>
parents:
289
diff
changeset
|
2409 |
when an ambiguous package name is specified. If the user |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2410 |
wishes to install a package from a non-preferred publisher, |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2411 |
the full FMRI that contains a publisher should be used |
1158
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2412 |
to name the package. |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2413 |
|
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2414 |
'multimatch_ignore' is an optional, boolean value that |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2415 |
indicates whether packages that have multiple matches for |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2416 |
only non-preferred publishers should be ignored when creating |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2417 |
the install plan. This is intended to be used during an |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2418 |
image-update. |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2419 |
""" |
296
576858fb8376
398 disambiguate packages matching the default authority
johansen <johansen@sun.com>
parents:
289
diff
changeset
|
2420 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2421 |
if filters is None: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2422 |
filters = [] |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2423 |
|
172 | 2424 |
error = 0 |
625
e46b345645d6
3799 need to start progress tracker going early on
Brock Pytlik <bpytlik@sun.com>
parents:
621
diff
changeset
|
2425 |
ip = imageplan.ImagePlan(self, progtrack, check_cancelation, |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2426 |
filters=filters, noexecute=noexecute) |
172 | 2427 |
|
625
e46b345645d6
3799 need to start progress tracker going early on
Brock Pytlik <bpytlik@sun.com>
parents:
621
diff
changeset
|
2428 |
progtrack.evaluate_start() |
655
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2429 |
self.load_constraints(progtrack) |
307
3a857fd8b787
787 optional dependencies are required
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
302
diff
changeset
|
2430 |
|
1141
a74d6815a7fc
4178 unfound_fmris is a poor name
Rich Burridge <rich.burridge@sun.com>
parents:
1133
diff
changeset
|
2431 |
unmatched_fmris = [] |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2432 |
multiple_matches = [] |
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2433 |
illegal_fmris = [] |
655
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2434 |
constraint_violations = [] |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2435 |
|
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2436 |
# order package list so that any unbound incorporations are |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2437 |
# done first |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2438 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2439 |
inc_list = list(self.__get_installed_unbound_inc_list()) |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2440 |
|
655
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2441 |
head = [] |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2442 |
tail = [] |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2443 |
for s in pkg_list: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2444 |
try: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2445 |
p = pkg.fmri.PkgFmri(s, |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2446 |
self.attrs["Build-Release"]) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2447 |
except pkg.fmri.IllegalFmri: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2448 |
illegal_fmris.append(s) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2449 |
error = 1 |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2450 |
continue |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2451 |
|
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2452 |
for inc in inc_list: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2453 |
if inc.pkg_name == p.pkg_name: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2454 |
head.append((s, p)) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2455 |
break |
655
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2456 |
else: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2457 |
tail.append((s, p)) |
655
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2458 |
pkg_list = head + tail |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2459 |
|
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2460 |
# This approach works only for cases w/ simple |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2461 |
# incorporations; the apply_constraints_to_fmri |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2462 |
# call below binds the version too quickly. This |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2463 |
# awaits a proper solver. |
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2464 |
|
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2465 |
# XXX This logic is very inefficient for cases like image-update |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2466 |
# where the entire package inventory is matched against each |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2467 |
# package (think num_installed * available_pkgs). |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2468 |
ppub = self.get_preferred_publisher() |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2469 |
for p, conp in pkg_list: |
625
e46b345645d6
3799 need to start progress tracker going early on
Brock Pytlik <bpytlik@sun.com>
parents:
621
diff
changeset
|
2470 |
progtrack.evaluate_progress() |
172 | 2471 |
try: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2472 |
conp = \ |
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2473 |
self.constraints.apply_constraints_to_fmri( |
1085
aa3274c0fe55
8392 backpublishing variant-aware SUNWipkg to 101 will break zones on those builds
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
1075
diff
changeset
|
2474 |
conp, auto=True) |
655
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2475 |
except constraint.ConstraintException, e: |
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2476 |
error = 1 |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2477 |
constraint_violations.extend(str(e).split("\n")) |
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2478 |
continue |
931
2c497b23356a
7200 package name matching too loose on upgrade
Danek Duvall <danek.duvall@sun.com>
parents:
926
diff
changeset
|
2479 |
|
2c497b23356a
7200 package name matching too loose on upgrade
Danek Duvall <danek.duvall@sun.com>
parents:
926
diff
changeset
|
2480 |
# If we were passed in an fmri object or a string that |
2c497b23356a
7200 package name matching too loose on upgrade
Danek Duvall <danek.duvall@sun.com>
parents:
926
diff
changeset
|
2481 |
# anchors the package stem with the scheme, match on the |
2c497b23356a
7200 package name matching too loose on upgrade
Danek Duvall <danek.duvall@sun.com>
parents:
926
diff
changeset
|
2482 |
# stem exactly as given. Otherwise we can let the |
2c497b23356a
7200 package name matching too loose on upgrade
Danek Duvall <danek.duvall@sun.com>
parents:
926
diff
changeset
|
2483 |
# default, looser matching mechanism be used. |
2c497b23356a
7200 package name matching too loose on upgrade
Danek Duvall <danek.duvall@sun.com>
parents:
926
diff
changeset
|
2484 |
# inventory() will override if globbing characters are |
2c497b23356a
7200 package name matching too loose on upgrade
Danek Duvall <danek.duvall@sun.com>
parents:
926
diff
changeset
|
2485 |
# used. |
2c497b23356a
7200 package name matching too loose on upgrade
Danek Duvall <danek.duvall@sun.com>
parents:
926
diff
changeset
|
2486 |
matcher = None |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2487 |
if isinstance(p, pkg.fmri.PkgFmri) or \ |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2488 |
p.startswith("pkg:/"): |
931
2c497b23356a
7200 package name matching too loose on upgrade
Danek Duvall <danek.duvall@sun.com>
parents:
926
diff
changeset
|
2489 |
matcher = pkg.fmri.exact_name_match |
2c497b23356a
7200 package name matching too loose on upgrade
Danek Duvall <danek.duvall@sun.com>
parents:
926
diff
changeset
|
2490 |
|
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2491 |
try: |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2492 |
matches = list(self.inventory([conp], |
1045
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2493 |
all_known=True, matcher=matcher, |
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2494 |
ordered=False)) |
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2495 |
except api_errors.InventoryException, e: |
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2496 |
assert(not (e.notfound and e.illegal)) |
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2497 |
assert(e.notfound or e.illegal) |
172 | 2498 |
error = 1 |
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2499 |
if e.notfound: |
1141
a74d6815a7fc
4178 unfound_fmris is a poor name
Rich Burridge <rich.burridge@sun.com>
parents:
1133
diff
changeset
|
2500 |
unmatched_fmris.append(p) |
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2501 |
else: |
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2502 |
illegal_fmris.append(p) |
172 | 2503 |
continue |
2504 |
||
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2505 |
pnames = set() |
296
576858fb8376
398 disambiguate packages matching the default authority
johansen <johansen@sun.com>
parents:
289
diff
changeset
|
2506 |
pmatch = [] |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2507 |
npnames = set() |
296
576858fb8376
398 disambiguate packages matching the default authority
johansen <johansen@sun.com>
parents:
289
diff
changeset
|
2508 |
npmatch = [] |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2509 |
for m, st in matches: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2510 |
if m.publisher == ppub: |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2511 |
pnames.add(m.get_pkg_stem()) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2512 |
pmatch.append((m, st)) |
296
576858fb8376
398 disambiguate packages matching the default authority
johansen <johansen@sun.com>
parents:
289
diff
changeset
|
2513 |
else: |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2514 |
npnames.add(m.get_pkg_stem()) |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2515 |
npmatch.append((m, st)) |
172 | 2516 |
|
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2517 |
pfmri = None |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2518 |
# If we have more than one possible match from the |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2519 |
# preferred publisher, try to narrow it down to one |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2520 |
# non-obsolete package. |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2521 |
if len(pnames) > 1: |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2522 |
# Filter out packages whose newest version is |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2523 |
# obsolete. If there's more than one package |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2524 |
# left, then there's still a conflict, but if |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2525 |
# there's only one, we can assume that's the one |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2526 |
# we want. If there are none, we'll try again |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2527 |
# with the non-preferred publisher. |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2528 |
d = {} |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2529 |
for m, st in pmatch: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2530 |
d.setdefault(m.get_pkg_stem(), (m, st)) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2531 |
nonobs = [ |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2532 |
(m, st) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2533 |
for stem, (m, st) in d.iteritems() |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2534 |
if not st["obsolete"] and not st["renamed"] |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2535 |
] |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2536 |
if len(nonobs) > 1: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2537 |
# There can only be one preferred publisher, so |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2538 |
# filtering is pointless and these are truly |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2539 |
# ambiguous matches. |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2540 |
multiple_matches.append((p, pnames)) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2541 |
error = 1 |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2542 |
continue |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2543 |
if nonobs: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2544 |
pfmri, status = nonobs[0] |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2545 |
|
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2546 |
# If we couldn't find exactly one non-obsolete match |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2547 |
# from the preferred publisher, try to find one from the |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2548 |
# non-preferred publishers, if any matches exist. |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2549 |
if not pfmri and len(npnames) > 1: |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2550 |
npmatch, npnames = \ |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2551 |
self.__filter_install_matches(npmatch) |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2552 |
d = {} |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2553 |
for m, st in npmatch: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2554 |
d.setdefault(m.get_pkg_stem(), (m, st)) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2555 |
nonobs = [ |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2556 |
(m, st) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2557 |
for stem, (m, st) in d.iteritems() |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2558 |
if not st["obsolete"] and not st["renamed"] |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2559 |
] |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2560 |
if len(nonobs) > 1: |
1158
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2561 |
if multimatch_ignore: |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2562 |
# Caller has requested that this |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2563 |
# package be skipped if multiple |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2564 |
# matches are found. |
78582c4403a9
8616 operations should use same publisher when only non-preferred has package
Shawn Walker <srw@sun.com>
parents:
1143
diff
changeset
|
2565 |
continue |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2566 |
# If there are still multiple matches |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2567 |
# after filtering, fail. |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2568 |
multiple_matches.append((p, npnames)) |
988
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2569 |
error = 1 |
a851ba83a5aa
6654 pkg list state incorrect after publisher removal when another publisher has it
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
964
diff
changeset
|
2570 |
continue |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2571 |
if nonobs: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2572 |
pfmri, status = nonobs[0] |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2573 |
|
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2574 |
|
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2575 |
# At this point, either there's exactly one preferred or |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2576 |
# non-preferred match, or all possible matches are |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2577 |
# obsolete, so it doesn't really matter what we choose, |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2578 |
# nothing will actually get installed. So choose the |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2579 |
# latest. |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2580 |
# |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2581 |
# Although looking at what's already installed in the |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2582 |
# procedure above is incredibly complicated, here's an |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2583 |
# instance where it would give us better results. If we |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2584 |
# chose something already installed, then it would get |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2585 |
# removed, rather than nothing happening. If things |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2586 |
# were still ambiguous, we could error out. |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2587 |
if not pfmri: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2588 |
if pmatch: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2589 |
pfmri, status = pmatch[0] |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2590 |
else: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2591 |
pfmri, status = npmatch[0] |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2592 |
|
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2593 |
if status["obsolete"]: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2594 |
vi = self.get_version_installed(pfmri) |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2595 |
if vi: |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2596 |
ip.propose_fmri_removal(vi) |
296
576858fb8376
398 disambiguate packages matching the default authority
johansen <johansen@sun.com>
parents:
289
diff
changeset
|
2597 |
else: |
1461
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2598 |
# Take this fork for a renamed package, since |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2599 |
# the rename will happen as part of the eval. |
fdf40c8c6765
820 Need a way to obsolete packages
Danek Duvall <danek.duvall@sun.com>
parents:
1449
diff
changeset
|
2600 |
ip.propose_fmri(pfmri) |
172 | 2601 |
|
2602 |
if error != 0: |
|
1141
a74d6815a7fc
4178 unfound_fmris is a poor name
Rich Burridge <rich.burridge@sun.com>
parents:
1133
diff
changeset
|
2603 |
raise api_errors.PlanCreationException(unmatched_fmris, |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2604 |
multiple_matches, [], illegal_fmris, |
655
6eef82185057
2325 optional dependency enforcement can't handle fmris disappearing from the catalog
Bart Smaalders <Bart.Smaalders@Sun.COM>
parents:
648
diff
changeset
|
2605 |
constraint_violations=constraint_violations) |
172 | 2606 |
|
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
2607 |
self.__call_imageplan_evaluate(ip, verbose) |
45
8a3f00dea14f
catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents:
39
diff
changeset
|
2608 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2609 |
def make_uninstall_plan(self, fmri_list, recursive_removal, |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2610 |
progresstracker, check_cancelation, noexecute, verbose=False): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2611 |
ip = imageplan.ImagePlan(self, progresstracker, |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2612 |
check_cancelation, recursive_removal, noexecute=noexecute) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2613 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2614 |
err = 0 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2615 |
|
1141
a74d6815a7fc
4178 unfound_fmris is a poor name
Rich Burridge <rich.burridge@sun.com>
parents:
1133
diff
changeset
|
2616 |
unmatched_fmris = [] |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2617 |
multiple_matches = [] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2618 |
missing_matches = [] |
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2619 |
illegal_fmris = [] |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2620 |
|
625
e46b345645d6
3799 need to start progress tracker going early on
Brock Pytlik <bpytlik@sun.com>
parents:
621
diff
changeset
|
2621 |
progresstracker.evaluate_start() |
e46b345645d6
3799 need to start progress tracker going early on
Brock Pytlik <bpytlik@sun.com>
parents:
621
diff
changeset
|
2622 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2623 |
for ppat in fmri_list: |
625
e46b345645d6
3799 need to start progress tracker going early on
Brock Pytlik <bpytlik@sun.com>
parents:
621
diff
changeset
|
2624 |
progresstracker.evaluate_progress() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2625 |
try: |
1045
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2626 |
matches = list(self.inventory([ppat], |
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2627 |
ordered=False)) |
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2628 |
except api_errors.InventoryException, e: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2629 |
if e.illegal: |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2630 |
illegal_fmris.append(ppat) |
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2631 |
else: |
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2632 |
try: |
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2633 |
list(self.inventory([ppat], |
1045
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2634 |
all_known=True, |
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2635 |
ordered=False)) |
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2636 |
missing_matches.append(ppat) |
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2637 |
except api_errors.InventoryException: |
1141
a74d6815a7fc
4178 unfound_fmris is a poor name
Rich Burridge <rich.burridge@sun.com>
parents:
1133
diff
changeset
|
2638 |
unmatched_fmris.append(ppat) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2639 |
err = 1 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2640 |
continue |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2641 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2642 |
if len(matches) > 1: |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2643 |
matchlist = [m[0] for m in matches] |
922
0074b10d84e0
6874 stack trace on install with ambiguous package names
Danek Duvall <danek.duvall@sun.com>
parents:
918
diff
changeset
|
2644 |
multiple_matches.append((ppat, matchlist)) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2645 |
err = 1 |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2646 |
continue |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2647 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2648 |
# Propose the removal of the first (and only!) match. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2649 |
ip.propose_fmri_removal(matches[0][0]) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2650 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2651 |
if err == 1: |
1141
a74d6815a7fc
4178 unfound_fmris is a poor name
Rich Burridge <rich.burridge@sun.com>
parents:
1133
diff
changeset
|
2652 |
raise api_errors.PlanCreationException(unmatched_fmris, |
616
6d307b088d92
4056 make_uninstall_plan misreports trying to uninstall a known, but uninstalled package
Brock Pytlik <bpytlik@sun.com>
parents:
596
diff
changeset
|
2653 |
multiple_matches, missing_matches, illegal_fmris) |
1271
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
2654 |
|
036d87b0bd44
6831 need 'pkg change-variant' command
Edward Pilatowicz <Edward.Pilatowicz@Sun.COM>
parents:
1256
diff
changeset
|
2655 |
self.__call_imageplan_evaluate(ip, verbose) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2656 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2657 |
def ipkg_is_up_to_date(self, actual_cmd, check_cancelation, noexecute, |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
2658 |
refresh_allowed=True, progtrack=None): |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2659 |
""" Test whether SUNWipkg is updated to the latest version |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2660 |
known to be available for this image """ |
1352
5c92c9d342ef
11065 client v1 catalog support for v0 catalogs
Shawn Walker <srw@sun.com>
parents:
1328
diff
changeset
|
2661 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2662 |
# |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2663 |
# This routine makes the distinction between the "target image", |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2664 |
# which will be altered, and the "running image", which is |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2665 |
# to say whatever image appears to contain the version of the |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2666 |
# pkg command we're running. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2667 |
# |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2668 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2669 |
# |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2670 |
# There are two relevant cases here: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2671 |
# 1) Packaging code and image we're updating are the same |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2672 |
# image. (i.e. 'pkg image-update') |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2673 |
# |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2674 |
# 2) Packaging code's image and the image we're updating are |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2675 |
# different (i.e. 'pkg image-update -R') |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2676 |
# |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2677 |
# In general, we care about getting the user to run the |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2678 |
# most recent packaging code available for their build. So, |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2679 |
# if we're not in the liveroot case, we create a new image |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2680 |
# which represents "/" on the system. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2681 |
# |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2682 |
|
625
e46b345645d6
3799 need to start progress tracker going early on
Brock Pytlik <bpytlik@sun.com>
parents:
621
diff
changeset
|
2683 |
if not progtrack: |
e46b345645d6
3799 need to start progress tracker going early on
Brock Pytlik <bpytlik@sun.com>
parents:
621
diff
changeset
|
2684 |
progtrack = progress.QuietProgressTracker() |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2685 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2686 |
img = self |
926
6ee411c9026a
5871 publisher apis desired
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
922
diff
changeset
|
2687 |
|
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2688 |
if not img.is_liveroot(): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2689 |
cmdpath = os.path.join(os.getcwd(), actual_cmd) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2690 |
cmdpath = os.path.realpath(cmdpath) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2691 |
cmddir = os.path.dirname(os.path.realpath(cmdpath)) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2692 |
# |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2693 |
# Find the path to ourselves, and use that |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2694 |
# as a way to locate the image we're in. It's |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2695 |
# not perfect-- we could be in a developer's |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2696 |
# workspace, for example. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2697 |
# |
1370
face1fe579ab
11400 image objects should always have a root
Brock Pytlik <bpytlik@sun.com>
parents:
1369
diff
changeset
|
2698 |
newimg = Image(cmddir, progtrack=progtrack) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2699 |
|
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
2700 |
if refresh_allowed: |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
2701 |
# If refreshing publisher metadata is allowed, |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
2702 |
# then perform a refresh so that a new SUNWipkg |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
2703 |
# can be discovered. |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2704 |
try: |
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
2705 |
newimg.refresh_publishers( |
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
2706 |
progtrack=progtrack) |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2707 |
except api_errors.CatalogRefreshException, cre: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2708 |
cre.message = \ |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2709 |
_("SUNWipkg update check failed.") |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2710 |
raise |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2711 |
img = newimg |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2712 |
|
996
31d152a5212b
7582 pkg set-publisher --no-refresh will delete catalogs
Shawn Walker <Shawn.Walker@Sun.COM>
parents:
993
diff
changeset
|
2713 |
# XXX call to progress tracker that SUNWipkg is being refreshed |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2714 |
|
625
e46b345645d6
3799 need to start progress tracker going early on
Brock Pytlik <bpytlik@sun.com>
parents:
621
diff
changeset
|
2715 |
img.make_install_plan(["SUNWipkg"], progtrack, |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2716 |
check_cancelation, noexecute, filters = []) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2717 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2718 |
return img.imageplan.nothingtodo() |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2719 |
|
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2720 |
def installed_fmris_from_args(self, args): |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2721 |
"""Helper function to translate client command line arguments |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2722 |
into a list of installed fmris. Used by info, contents, |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2723 |
verify. |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2724 |
""" |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2725 |
found = [] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2726 |
notfound = [] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2727 |
illegals = [] |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2728 |
try: |
1045
62656c214151
8135 plan creation could be faster for install and uninstall
Shawn Walker <srw@sun.com>
parents:
1037
diff
changeset
|
2729 |
for m in self.inventory(args, ordered=False): |
565
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2730 |
found.append(m[0]) |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2731 |
except api_errors.InventoryException, e: |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2732 |
illegals = e.illegal |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2733 |
notfound = e.notfound |
1fb4f05220b9
3443 An api needs to be provided for safe interaction of front-ends
Brock Pytlik <bpytlik@sun.com>
parents:
562
diff
changeset
|
2734 |
return found, notfound, illegals |