author | Yiteng Zhang <yiteng.zhang@oracle.com> |
Mon, 09 Sep 2013 10:52:27 -0700 | |
changeset 2942 | 17aad7c202b0 |
parent 2898 | 723ece284e97 |
child 2958 | 868e07939116 |
child 2966 | 6a97d8a803d3 |
permissions | -rwxr-xr-x |
1516
8c950a3b4171
10485 move pkg(5) to Python 2.6
Rich Burridge <rich.burridge@sun.com>
parents:
1507
diff
changeset
|
1 |
#!/usr/bin/python2.6 |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
2 |
# |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
3 |
# CDDL HEADER START |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
4 |
# |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
5 |
# The contents of this file are subject to the terms of the |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
6 |
# Common Development and Distribution License (the "License"). |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
7 |
# You may not use this file except in compliance with the License. |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
8 |
# |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
9 |
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
10 |
# or http://www.opensolaris.org/os/licensing. |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
11 |
# See the License for the specific language governing permissions |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
12 |
# and limitations under the License. |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
13 |
# |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
14 |
# When distributing Covered Code, include this CDDL HEADER in each |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
15 |
# file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
16 |
# If applicable, add the following below this CDDL HEADER, with the |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
17 |
# fields enclosed by brackets "[]" replaced with your own identifying |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
18 |
# information: Portions Copyright [yyyy] [name of copyright owner] |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
19 |
# |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
20 |
# CDDL HEADER END |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
21 |
# |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
22 |
|
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
23 |
# |
2864
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
24 |
# Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved. |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
25 |
# |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
26 |
|
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
27 |
import calendar |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
28 |
import errno |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
29 |
import getopt |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
30 |
import gettext |
2728
69903f3b722b
7166082 pkg command does not handle Japanese character encoding on Solaris 11
Abhinandan Ekande <abhinandan.ekande@oracle.com>
parents:
2705
diff
changeset
|
31 |
import locale |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
32 |
import os |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
33 |
import shutil |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
34 |
import sys |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
35 |
import tempfile |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
36 |
import traceback |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
37 |
import urllib |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1600
diff
changeset
|
38 |
import warnings |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
39 |
|
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
40 |
import pkg.catalog as catalog |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
41 |
import pkg.client.progress as progress |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
42 |
import pkg.fmri |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
43 |
import pkg.manifest as manifest |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2058
diff
changeset
|
44 |
import pkg.client.api_errors as apx |
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
45 |
import pkg.client.pkgdefs as pkgdefs |
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
46 |
import pkg.client.publisher as publisher |
1977
1e2b423ee045
16565 transport module init exposes latent bug in packagemanager
johansen <johansen@opensolaris.org>
parents:
1974
diff
changeset
|
47 |
import pkg.client.transport.transport as transport |
1507
b956ea23d3a6
11735 pkg history data files should not be executable
Richard Lowe <richlowe@richlowe.net>
parents:
1431
diff
changeset
|
48 |
import pkg.misc as misc |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
49 |
import pkg.p5p |
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
50 |
import pkg.pkgsubprocess as subprocess |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
51 |
import pkg.publish.transaction as trans |
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
52 |
import pkg.server.repository as sr |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
53 |
import pkg.version as version |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
54 |
|
696
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
440
diff
changeset
|
55 |
from pkg.client import global_settings |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2058
diff
changeset
|
56 |
from pkg.misc import emsg, get_pkg_otw_size, msg, PipeError |
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
57 |
from pkg.client.debugvalues import DebugValues |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
58 |
|
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
59 |
# Globals |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
60 |
archive = False |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
61 |
cache_dir = None |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
62 |
src_cat = None |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
63 |
download_start = False |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
64 |
tmpdirs = [] |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
65 |
temp_root = None |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
66 |
xport = None |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
67 |
xport_cfg = None |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
68 |
dest_xport = None |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
69 |
targ_pub = None |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
70 |
target = None |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
71 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
72 |
def error(text): |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
73 |
"""Emit an error message prefixed by the command name """ |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
74 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
75 |
# If we get passed something like an Exception, we can convert |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
76 |
# it down to a string. |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
77 |
text = str(text) |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
78 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
79 |
# If the message starts with whitespace, assume that it should come |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
80 |
# *before* the command-name prefix. |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
81 |
text_nows = text.lstrip() |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
82 |
ws = text[:len(text) - len(text_nows)] |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
83 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
84 |
# This has to be a constant value as we can't reliably get our actual |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
85 |
# program name on all platforms. |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
86 |
emsg(ws + "pkgrecv: " + text_nows) |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
87 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
88 |
def usage(usage_error=None, retcode=2): |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
89 |
"""Emit a usage message and optionally prefix it with a more specific |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
90 |
error message. Causes program to exit.""" |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
91 |
|
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
92 |
if usage_error: |
971
67d3507036ab
2422 error/usage message program identification is inconsistent in pkgrecv
Tom Mueller <Tom.Mueller@sun.com>
parents:
856
diff
changeset
|
93 |
error(usage_error) |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
94 |
|
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
95 |
msg(_("""\ |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
96 |
Usage: |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
97 |
pkgrecv [-s src_uri] [-a] [-d (path|dest_uri)] [-c cache_dir] |
2864
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
98 |
[-kr] [-m match] [-n] [--raw] [--key src_key --cert src_cert] |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
99 |
[--dkey dest_key --dcert dest_cert] |
2116
01cac360e383
17279 pkgrecv should support ssl certs and keys
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2115
diff
changeset
|
100 |
(fmri|pattern) ... |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
101 |
pkgrecv [-s src_repo_uri] --newest |
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
102 |
pkgrecv [-s src_repo_uri] [-d path] [-p publisher ...] |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
103 |
[--key src_key --cert src_cert] [-n] --clone |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
104 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
105 |
Options: |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
106 |
-a Store the retrieved package data in a pkg(5) archive |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
107 |
at the location specified by -d. The file may not |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
108 |
already exist, and this option may only be used with |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
109 |
filesystem-based destinations. |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
110 |
|
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
111 |
-c cache_dir The path to a directory that will be used to cache |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
112 |
downloaded content. If one is not supplied, the |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
113 |
client will automatically pick a cache directory. |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
114 |
In the case where a download is interrupted, and a |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
115 |
cache directory was automatically chosen, use this |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
116 |
option to resume the download. |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
117 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
118 |
-d path_or_uri The filesystem path or URI of the target repository to |
2268
1f313c3e7cdf
17728 publication tools should require a repository to be specified
Shawn Walker <shawn.walker@oracle.com>
parents:
2219
diff
changeset
|
119 |
republish packages to. The target must already exist. |
1f313c3e7cdf
17728 publication tools should require a repository to be specified
Shawn Walker <shawn.walker@oracle.com>
parents:
2219
diff
changeset
|
120 |
New repositories can be created using pkgrepo(1). |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
121 |
|
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
122 |
-h Display this usage message. |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
123 |
|
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
124 |
-k Keep the retrieved package content compressed, ignored |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
125 |
when republishing. Should not be used with pkgsend. |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
126 |
|
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
127 |
-m match Controls matching behaviour using the following values: |
2871
5132092a4436
14851733 pkgrecv should default to retreving all-timestamps not just latest versions
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2864
diff
changeset
|
128 |
all-timestamps (default) |
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
129 |
includes all matching timestamps (implies |
2871
5132092a4436
14851733 pkgrecv should default to retreving all-timestamps not just latest versions
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2864
diff
changeset
|
130 |
all-versions) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
131 |
all-versions |
2871
5132092a4436
14851733 pkgrecv should default to retreving all-timestamps not just latest versions
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2864
diff
changeset
|
132 |
includes all matching versions |
5132092a4436
14851733 pkgrecv should default to retreving all-timestamps not just latest versions
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2864
diff
changeset
|
133 |
latest |
5132092a4436
14851733 pkgrecv should default to retreving all-timestamps not just latest versions
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2864
diff
changeset
|
134 |
includes only the latest version of each package |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
135 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
136 |
-n Perform a trial run with no changes made. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
137 |
|
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
138 |
-p publisher Only clone the given publisher. Can be specified |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
139 |
multiple times. Only valid with --clone. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
140 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
141 |
-r Recursively evaluates all dependencies for the provided |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
142 |
list of packages and adds them to the list. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
143 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
144 |
-s src_repo_uri A URI representing the location of a pkg(5) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
145 |
repository to retrieve package data from. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
146 |
|
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
147 |
--clone Make an exact copy of the source repository. By default, |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
148 |
the clone operation will only succeed if publishers in |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
149 |
the source repository are also present in the |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
150 |
destination. By using -p, the operation can be limited |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
151 |
to specific publishers which will be added to the |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
152 |
destination repository if not already present. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
153 |
Packages in the destination repository which are not in |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
154 |
the source will be removed. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
155 |
Cloning will leave the destination repository altered in |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
156 |
case of an error. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
157 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
158 |
--newest List the most recent versions of the packages available |
1732
05e756645b7f
8432 document proxy environment variables
Stephen Hahn <sch@sun.com>
parents:
1715
diff
changeset
|
159 |
from the specified repository and exit. (All other |
05e756645b7f
8432 document proxy environment variables
Stephen Hahn <sch@sun.com>
parents:
1715
diff
changeset
|
160 |
options except -s will be ignored.) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
161 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
162 |
--raw Retrieve and store the raw package data in a set of |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
163 |
directory structures by stem and version at the location |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
164 |
specified by -d. May only be used with filesystem- |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
165 |
based destinations. This can be used with pkgsend(1) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
166 |
include to conveniently modify and republish packages, |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
167 |
perhaps by correcting file contents or providing |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
168 |
additional package metadata. |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
169 |
|
2864
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
170 |
--key src_key Specify a client SSL key file to use for pkg retrieval. |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
171 |
|
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
172 |
--cert src_cert Specify a client SSL certificate file to use for pkg |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
173 |
retrieval. |
2116
01cac360e383
17279 pkgrecv should support ssl certs and keys
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2115
diff
changeset
|
174 |
|
2864
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
175 |
--dkey dest_key Specify a client SSL key file to use for pkg |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
176 |
publication. |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
177 |
|
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
178 |
--dcert dest_cert Specify a client SSL certificate file to use for pkg |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
179 |
publication. |
2116
01cac360e383
17279 pkgrecv should support ssl certs and keys
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2115
diff
changeset
|
180 |
|
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
181 |
Environment: |
2268
1f313c3e7cdf
17728 publication tools should require a repository to be specified
Shawn Walker <shawn.walker@oracle.com>
parents:
2219
diff
changeset
|
182 |
PKG_DEST Destination directory or URI |
1f313c3e7cdf
17728 publication tools should require a repository to be specified
Shawn Walker <shawn.walker@oracle.com>
parents:
2219
diff
changeset
|
183 |
PKG_SRC Source URI or path""")) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
184 |
sys.exit(retcode) |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
185 |
|
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
186 |
def cleanup(caller_error=False): |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
187 |
"""To be called at program finish.""" |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
188 |
|
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
189 |
for d in tmpdirs: |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
190 |
# If the cache_dir is in the list of directories that should |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
191 |
# be cleaned up, but we're exiting with an error, then preserve |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
192 |
# the directory so downloads may be resumed. |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
193 |
if d == cache_dir and caller_error and download_start: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
194 |
error(_("\n\nCached files were preserved in the " |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
195 |
"following directory:\n\t%s\nUse pkgrecv -c " |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
196 |
"to resume the interrupted download.") % cache_dir) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
197 |
continue |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
198 |
shutil.rmtree(d, ignore_errors=True) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
199 |
|
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
200 |
if caller_error and dest_xport and targ_pub and not archive: |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
201 |
try: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
202 |
dest_xport.publish_refresh_packages(targ_pub) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
203 |
except apx.TransportError: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
204 |
# If this fails, ignore it as this was a last ditch |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
205 |
# attempt anyway. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
206 |
pass |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
207 |
|
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
208 |
def abort(err=None, retcode=1): |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
209 |
"""To be called when a fatal error is encountered.""" |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
210 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
211 |
if err: |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
212 |
# Clear any possible output first. |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
213 |
msg("") |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
214 |
error(err) |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
215 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
216 |
cleanup(caller_error=True) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
217 |
sys.exit(retcode) |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
218 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
219 |
def get_tracker(): |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
220 |
try: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
221 |
progresstracker = \ |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
222 |
progress.FancyUNIXProgressTracker() |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
223 |
except progress.ProgressTrackerException: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
224 |
progresstracker = progress.CommandLineProgressTracker() |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
225 |
progresstracker.set_major_phase(progresstracker.PHASE_UTILITY) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
226 |
return progresstracker |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
227 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
228 |
def get_manifest(pfmri, xport_cfg, contents=False): |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
229 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
230 |
m = None |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
231 |
pkgdir = xport_cfg.get_pkg_dir(pfmri) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
232 |
mpath = xport_cfg.get_pkg_pathname(pfmri) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
233 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
234 |
if not os.path.exists(mpath): |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
235 |
m = xport.get_manifest(pfmri) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
236 |
else: |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2058
diff
changeset
|
237 |
# A FactoredManifest is used here to reduce peak memory |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2058
diff
changeset
|
238 |
# usage (notably when -r was specified). |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
239 |
try: |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2058
diff
changeset
|
240 |
m = manifest.FactoredManifest(pfmri, pkgdir) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
241 |
except: |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
242 |
abort(err=_("Unable to parse manifest '%(mpath)s' for " |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
243 |
"package '%(pfmri)s'") % locals()) |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
244 |
|
1132
1abf9cf8f69c
9206 pkgrecv'd packages may not have matching comment in manifest
Shawn Walker <srw@sun.com>
parents:
1118
diff
changeset
|
245 |
if contents: |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
246 |
return m.tostr_unsorted() |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
247 |
return m |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
248 |
|
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
249 |
def expand_fmri(pfmri, constraint=version.CONSTRAINT_AUTO): |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
250 |
"""Find matching fmri using CONSTRAINT_AUTO cache for performance. |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
251 |
Returns None if no matching fmri is found.""" |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
252 |
if isinstance(pfmri, str): |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
253 |
pfmri = pkg.fmri.PkgFmri(pfmri, "5.11") |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
254 |
|
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
255 |
# Iterate in reverse so newest version is evaluated first. |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
256 |
versions = [e for e in src_cat.fmris_by_version(pfmri.pkg_name)] |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
257 |
for v, fmris in reversed(versions): |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
258 |
for f in fmris: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
259 |
if not pfmri.version or \ |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
260 |
f.version.is_successor(pfmri.version, constraint): |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
261 |
return f |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
262 |
return |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
263 |
|
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
264 |
def get_dependencies(fmri_list, xport_cfg, tracker): |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
265 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
266 |
old_limit = sys.getrecursionlimit() |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
267 |
# The user may be recursing 'entire' or 'redistributable'. |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
268 |
sys.setrecursionlimit(3000) |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
269 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
270 |
s = set() |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
271 |
for f in fmri_list: |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
272 |
_get_dependencies(s, f, xport_cfg, tracker) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
273 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
274 |
# Restore the previous default. |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
275 |
sys.setrecursionlimit(old_limit) |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
276 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
277 |
return list(s) |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
278 |
|
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
279 |
def _get_dependencies(s, pfmri, xport_cfg, tracker): |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
280 |
"""Expand all dependencies.""" |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
281 |
# XXX??? |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
282 |
# tracker.evaluate_progress(pkgfmri=pfmri) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
283 |
s.add(pfmri) |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
284 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
285 |
m = get_manifest(pfmri, xport_cfg) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
286 |
for a in m.gen_actions_by_type("depend"): |
2324
75c4c6c9265b
18231 pkgrecv traceback for packages with require-any dependency when using -r
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2316
diff
changeset
|
287 |
for fmri_str in a.attrlist("fmri"): |
75c4c6c9265b
18231 pkgrecv traceback for packages with require-any dependency when using -r
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2316
diff
changeset
|
288 |
new_fmri = expand_fmri(fmri_str) |
75c4c6c9265b
18231 pkgrecv traceback for packages with require-any dependency when using -r
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2316
diff
changeset
|
289 |
if new_fmri and new_fmri not in s: |
75c4c6c9265b
18231 pkgrecv traceback for packages with require-any dependency when using -r
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2316
diff
changeset
|
290 |
_get_dependencies(s, new_fmri, xport_cfg, tracker) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
291 |
return s |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
292 |
|
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
293 |
def get_sizes(mfst): |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
294 |
"""Takes a manifest and return |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
295 |
(get_bytes, get_files, send_bytes, send_comp_bytes) tuple.""" |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
296 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
297 |
getb = 0 |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
298 |
getf = 0 |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
299 |
sendb = 0 |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
300 |
sendcb = 0 |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
301 |
|
2352
3c17f86cd994
18105 api should support multiple repositories (origins) with different package data
Shawn Walker <shawn.walker@oracle.com>
parents:
2324
diff
changeset
|
302 |
for a in mfst.gen_actions(): |
3c17f86cd994
18105 api should support multiple repositories (origins) with different package data
Shawn Walker <shawn.walker@oracle.com>
parents:
2324
diff
changeset
|
303 |
if a.has_payload: |
3c17f86cd994
18105 api should support multiple repositories (origins) with different package data
Shawn Walker <shawn.walker@oracle.com>
parents:
2324
diff
changeset
|
304 |
getb += get_pkg_otw_size(a) |
3c17f86cd994
18105 api should support multiple repositories (origins) with different package data
Shawn Walker <shawn.walker@oracle.com>
parents:
2324
diff
changeset
|
305 |
getf += 1 |
3c17f86cd994
18105 api should support multiple repositories (origins) with different package data
Shawn Walker <shawn.walker@oracle.com>
parents:
2324
diff
changeset
|
306 |
sendb += int(a.attrs.get("pkg.size", 0)) |
3c17f86cd994
18105 api should support multiple repositories (origins) with different package data
Shawn Walker <shawn.walker@oracle.com>
parents:
2324
diff
changeset
|
307 |
sendcb += int(a.attrs.get("pkg.csize", 0)) |
2539
82d3275709e9
18533 pkgrecv -a stack traces when pulling packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2503
diff
changeset
|
308 |
if a.name == "signature": |
82d3275709e9
18533 pkgrecv -a stack traces when pulling packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2503
diff
changeset
|
309 |
getf += len(a.get_chain_certs()) |
82d3275709e9
18533 pkgrecv -a stack traces when pulling packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2503
diff
changeset
|
310 |
getb += a.get_action_chain_csize() |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
311 |
return getb, getf, sendb, sendcb |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
312 |
|
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
313 |
def add_hashes_to_multi(mfst, multi): |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
314 |
"""Takes a manifest and a multi object and adds the hashes to the multi |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
315 |
object.""" |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
316 |
|
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
317 |
for a in mfst.gen_actions(): |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
318 |
if a.has_payload: |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
319 |
multi.add_action(a) |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
320 |
|
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
321 |
def prune(fmri_list, all_versions, all_timestamps): |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
322 |
"""Returns a filtered version of fmri_list based on the provided |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
323 |
parameters.""" |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
324 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
325 |
if all_timestamps: |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
326 |
pass |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
327 |
elif all_versions: |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
328 |
dedup = {} |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
329 |
for f in fmri_list: |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
330 |
dedup.setdefault(f.get_short_fmri(), []).append(f) |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
331 |
fmri_list = [sorted(dedup[f], reverse=True)[0] for f in dedup] |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
332 |
else: |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
333 |
dedup = {} |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
334 |
for f in fmri_list: |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
335 |
dedup.setdefault(f.pkg_name, []).append(f) |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
336 |
fmri_list = [sorted(dedup[f], reverse=True)[0] for f in dedup] |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
337 |
return fmri_list |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
338 |
|
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
339 |
def fetch_catalog(src_pub, tracker, txport, target_catalog, |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
340 |
include_updates=False): |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
341 |
"""Fetch the catalog from src_uri. |
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
342 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
343 |
target_catalog is a hint about whether this is a destination catalog, |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
344 |
which helps the progress tracker render the refresh output properly.""" |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
345 |
|
2310
ce10607d5332
11684 desire option to not propagate certs to non-global zones
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2286
diff
changeset
|
346 |
src_uri = src_pub.repository.origins[0].uri |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
347 |
tracker.refresh_start(1, full_refresh=True, |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
348 |
target_catalog=target_catalog) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
349 |
tracker.refresh_start_pub(src_pub) |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
350 |
|
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
351 |
if not src_pub.meta_root: |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
352 |
# Create a temporary directory for catalog. |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
353 |
cat_dir = tempfile.mkdtemp(dir=temp_root, |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
354 |
prefix=global_settings.client_name + "-") |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
355 |
tmpdirs.append(cat_dir) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
356 |
src_pub.meta_root = cat_dir |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
357 |
|
2057
874a83b3e8d1
10390 make pkgrecv gracefully handle existing packages in destination
johansen <johansen@opensolaris.org>
parents:
2054
diff
changeset
|
358 |
src_pub.transport = txport |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
359 |
try: |
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
360 |
src_pub.refresh(full_refresh=True, immediate=True, |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
361 |
progtrack=tracker, include_updates=include_updates) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
362 |
except apx.TransportError, e: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
363 |
# Assume that a catalog doesn't exist for the target publisher, |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
364 |
# and drive on. If there was an actual failure due to a |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
365 |
# transport issue, let the failure happen whenever some other |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
366 |
# operation is attempted later. |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
367 |
return catalog.Catalog(read_only=True) |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
368 |
finally: |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
369 |
tracker.refresh_end_pub(src_pub) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
370 |
tracker.refresh_done() |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
371 |
|
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
372 |
return src_pub.catalog |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
373 |
|
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
374 |
def main_func(): |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
375 |
global archive, cache_dir, download_start, xport, xport_cfg, \ |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
376 |
dest_xport, temp_root, targ_pub, target |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
377 |
|
2871
5132092a4436
14851733 pkgrecv should default to retreving all-timestamps not just latest versions
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2864
diff
changeset
|
378 |
all_timestamps = True |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
379 |
all_versions = False |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
380 |
dry_run = False |
420
0b6ecdba5641
2272 pkgrecv should uncompress by default
Brad Hall <bhall@eng.sun.com>
parents:
409
diff
changeset
|
381 |
keep_compressed = False |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
382 |
list_newest = False |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
383 |
recursive = False |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
384 |
src_uri = None |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
385 |
incoming_dir = None |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
386 |
src_pub = None |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
387 |
raw = False |
2116
01cac360e383
17279 pkgrecv should support ssl certs and keys
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2115
diff
changeset
|
388 |
key = None |
01cac360e383
17279 pkgrecv should support ssl certs and keys
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2115
diff
changeset
|
389 |
cert = None |
2864
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
390 |
dkey = None |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
391 |
dcert = None |
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
392 |
publishers = [] |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
393 |
clone = False |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
394 |
|
2028
b2c674e6ee28
16744 repository multi-publisher on-disk format should be formalized and implemented
Shawn Walker <shawn.walker@oracle.com>
parents:
2026
diff
changeset
|
395 |
temp_root = misc.config_temp_root() |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
396 |
|
2728
69903f3b722b
7166082 pkg command does not handle Japanese character encoding on Solaris 11
Abhinandan Ekande <abhinandan.ekande@oracle.com>
parents:
2705
diff
changeset
|
397 |
gettext.install("pkg", "/usr/share/locale", |
69903f3b722b
7166082 pkg command does not handle Japanese character encoding on Solaris 11
Abhinandan Ekande <abhinandan.ekande@oracle.com>
parents:
2705
diff
changeset
|
398 |
codeset=locale.getpreferredencoding()) |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
399 |
|
696
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
440
diff
changeset
|
400 |
global_settings.client_name = "pkgrecv" |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
401 |
target = os.environ.get("PKG_DEST", None) |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
402 |
src_uri = os.environ.get("PKG_SRC", None) |
696
6bbfd2dece6f
4371 user-agent string needs to be different for different client front-ends
Danek Duvall <danek.duvall@sun.com>
parents:
440
diff
changeset
|
403 |
|
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
404 |
try: |
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
405 |
opts, pargs = getopt.getopt(sys.argv[1:], "ac:D:d:hkm:np:rs:", |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
406 |
["cert=", "key=", "dcert=", "dkey=", "newest", "raw", |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
407 |
"debug=", "clone"]) |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
408 |
except getopt.GetoptError, e: |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
409 |
usage(_("Illegal option -- %s") % e.opt) |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
410 |
|
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
411 |
for opt, arg in opts: |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
412 |
if opt == "-a": |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
413 |
archive = True |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
414 |
elif opt == "-c": |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
415 |
cache_dir = arg |
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
416 |
elif opt == "--clone": |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
417 |
clone = True |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
418 |
elif opt == "-d": |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
419 |
target = arg |
2864
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
420 |
elif opt == "-D" or opt == "--debug": |
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
421 |
if arg in ["plan", "transport"]: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
422 |
key = arg |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
423 |
value = "True" |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
424 |
else: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
425 |
try: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
426 |
key, value = arg.split("=", 1) |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
427 |
except (AttributeError, ValueError): |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
428 |
usage(_("%(opt)s takes argument of form " |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
429 |
"name=value, not %(arg)s") % { |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
430 |
"opt": opt, "arg": arg }) |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
431 |
DebugValues.set_value(key, value) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
432 |
elif opt == "-h": |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
433 |
usage(retcode=0) |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
434 |
elif opt == "-k": |
420
0b6ecdba5641
2272 pkgrecv should uncompress by default
Brad Hall <bhall@eng.sun.com>
parents:
409
diff
changeset
|
435 |
keep_compressed = True |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
436 |
elif opt == "-m": |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
437 |
if arg == "all-timestamps": |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
438 |
all_timestamps = True |
2871
5132092a4436
14851733 pkgrecv should default to retreving all-timestamps not just latest versions
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2864
diff
changeset
|
439 |
all_versions = False |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
440 |
elif arg == "all-versions": |
2871
5132092a4436
14851733 pkgrecv should default to retreving all-timestamps not just latest versions
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2864
diff
changeset
|
441 |
all_timestamps = False |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
442 |
all_versions = True |
2871
5132092a4436
14851733 pkgrecv should default to retreving all-timestamps not just latest versions
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2864
diff
changeset
|
443 |
elif arg == "latest": |
5132092a4436
14851733 pkgrecv should default to retreving all-timestamps not just latest versions
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2864
diff
changeset
|
444 |
all_timestamps = False |
5132092a4436
14851733 pkgrecv should default to retreving all-timestamps not just latest versions
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2864
diff
changeset
|
445 |
all_versions = False |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
446 |
else: |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
447 |
usage(_("Illegal option value -- %s") % arg) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
448 |
elif opt == "-n": |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
449 |
dry_run = True |
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
450 |
elif opt == "-p": |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
451 |
publishers.append(arg) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
452 |
elif opt == "-r": |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
453 |
recursive = True |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
454 |
elif opt == "-s": |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
455 |
src_uri = arg |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
456 |
elif opt == "--newest": |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
457 |
list_newest = True |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
458 |
elif opt == "--raw": |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
459 |
raw = True |
2116
01cac360e383
17279 pkgrecv should support ssl certs and keys
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2115
diff
changeset
|
460 |
elif opt == "--key": |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
461 |
key = arg |
2116
01cac360e383
17279 pkgrecv should support ssl certs and keys
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2115
diff
changeset
|
462 |
elif opt == "--cert": |
01cac360e383
17279 pkgrecv should support ssl certs and keys
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2115
diff
changeset
|
463 |
cert = arg |
2864
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
464 |
elif opt == "--dkey": |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
465 |
dkey = arg |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
466 |
elif opt == "--dcert": |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
467 |
dcert = arg |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
468 |
|
2268
1f313c3e7cdf
17728 publication tools should require a repository to be specified
Shawn Walker <shawn.walker@oracle.com>
parents:
2219
diff
changeset
|
469 |
if not list_newest and not target: |
1f313c3e7cdf
17728 publication tools should require a repository to be specified
Shawn Walker <shawn.walker@oracle.com>
parents:
2219
diff
changeset
|
470 |
usage(_("a destination must be provided")) |
1f313c3e7cdf
17728 publication tools should require a repository to be specified
Shawn Walker <shawn.walker@oracle.com>
parents:
2219
diff
changeset
|
471 |
|
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
472 |
if not src_uri: |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
473 |
usage(_("a source repository must be provided")) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
474 |
else: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
475 |
src_uri = misc.parse_uri(src_uri) |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
476 |
|
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
477 |
if not cache_dir: |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
478 |
cache_dir = tempfile.mkdtemp(dir=temp_root, |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
479 |
prefix=global_settings.client_name + "-") |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
480 |
# Only clean-up cache dir if implicitly created by pkgrecv. |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
481 |
# User's cache-dirs should be preserved |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
482 |
tmpdirs.append(cache_dir) |
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
483 |
else: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
484 |
if clone: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
485 |
usage(_("--clone can not be used with -c.\n" |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
486 |
"Content will be downloaded directly to the " |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
487 |
"destination repository and re-downloading after a " |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
488 |
"pkgrecv failure will not be required.")) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
489 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
490 |
if clone and raw: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
491 |
usage(_("--clone can not be used with --raw.\n")) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
492 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
493 |
if clone and archive: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
494 |
usage(_("--clone can not be used with -a.\n")) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
495 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
496 |
if clone and list_newest: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
497 |
usage(_("--clone can not be used with --newest.\n")) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
498 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
499 |
if publishers and not clone: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
500 |
usage(_("-p can only be used with --clone.\n")) |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
501 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
502 |
incoming_dir = tempfile.mkdtemp(dir=temp_root, |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
503 |
prefix=global_settings.client_name + "-") |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
504 |
tmpdirs.append(incoming_dir) |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
505 |
|
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
506 |
# Create transport and transport config |
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
507 |
xport, xport_cfg = transport.setup_transport() |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2058
diff
changeset
|
508 |
xport_cfg.add_cache(cache_dir, readonly=False) |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2058
diff
changeset
|
509 |
xport_cfg.incoming_root = incoming_dir |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
510 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
511 |
# Since publication destinations may only have one repository configured |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
512 |
# per publisher, create destination as separate transport in case source |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
513 |
# and destination have identical publisher configuration but different |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
514 |
# repository endpoints. |
2057
874a83b3e8d1
10390 make pkgrecv gracefully handle existing packages in destination
johansen <johansen@opensolaris.org>
parents:
2054
diff
changeset
|
515 |
dest_xport, dest_xport_cfg = transport.setup_transport() |
2073
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2058
diff
changeset
|
516 |
dest_xport_cfg.add_cache(cache_dir, readonly=False) |
9fcacc9e5eaa
16998 transport should support publisher-specific write and read caches
Shawn Walker <shawn.walker@oracle.com>
parents:
2058
diff
changeset
|
517 |
dest_xport_cfg.incoming_root = incoming_dir |
2057
874a83b3e8d1
10390 make pkgrecv gracefully handle existing packages in destination
johansen <johansen@opensolaris.org>
parents:
2054
diff
changeset
|
518 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
519 |
# Configure src publisher(s). |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
520 |
transport.setup_publisher(src_uri, "source", xport, xport_cfg, |
2116
01cac360e383
17279 pkgrecv should support ssl certs and keys
Bart Smaalders <Bart.Smaalders@Oracle.COM>
parents:
2115
diff
changeset
|
521 |
remote_prefix=True, ssl_key=key, ssl_cert=cert) |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
522 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
523 |
args = (pargs, target, list_newest, all_versions, |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
524 |
all_timestamps, keep_compressed, raw, recursive, dry_run, |
2864
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
525 |
dest_xport_cfg, src_uri, dkey, dcert) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
526 |
|
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
527 |
if clone: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
528 |
args += (publishers,) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
529 |
return clone_repo(*args) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
530 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
531 |
if archive: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
532 |
# Retrieving package data for archival requires a different mode |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
533 |
# of operation so gets its own routine. Notably, it requires |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
534 |
# that all package data be retrieved before the archival process |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
535 |
# is started. |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
536 |
return archive_pkgs(*args) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
537 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
538 |
# Normal package transfer allows operations on a per-package basis. |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
539 |
return transfer_pkgs(*args) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
540 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
541 |
def check_processed(any_matched, any_unmatched, total_processed): |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
542 |
# Reduce unmatched patterns to those that were unmatched for all |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
543 |
# publishers. |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
544 |
unmatched = set(any_unmatched) - set(any_matched) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
545 |
|
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
546 |
if not unmatched: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
547 |
return |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
548 |
|
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
549 |
# If any match failures remain, abort with an error. |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
550 |
rval = 1 |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
551 |
if total_processed > 0: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
552 |
rval = 3 |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
553 |
abort(str(apx.PackageMatchErrors(unmatched_fmris=unmatched)), |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
554 |
retcode=rval) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
555 |
|
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
556 |
def get_matches(src_pub, tracker, xport, pargs, any_unmatched, any_matched, |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
557 |
all_versions, all_timestamps, recursive): |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
558 |
"""Returns the set of matching FMRIs for the given arguments.""" |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
559 |
global src_cat |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
560 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
561 |
src_cat = fetch_catalog(src_pub, tracker, xport, False) |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
562 |
# Avoid overhead of going through matching if user requested all |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
563 |
# packages. |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
564 |
if "*" not in pargs and "*@*" not in pargs: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
565 |
try: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
566 |
matches, refs, unmatched = \ |
2591
13f24c472f0b
19055 providing multiple exact fmris breaks pkgsign
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2569
diff
changeset
|
567 |
src_cat.get_matching_fmris(pargs) |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
568 |
except apx.PackageMatchErrors, e: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
569 |
abort(str(e)) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
570 |
|
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
571 |
# Track anything that failed to match. |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
572 |
any_unmatched.extend(unmatched) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
573 |
any_matched.extend(set(p for p in refs.values())) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
574 |
matches = list(set(f for m in matches.values() for f in m)) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
575 |
else: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
576 |
matches = [f for f in src_cat.fmris()] |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
577 |
|
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
578 |
if not matches: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
579 |
# No matches at all; nothing to do for this publisher. |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
580 |
return matches |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
581 |
|
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
582 |
matches = prune(matches, all_versions, all_timestamps) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
583 |
if recursive: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
584 |
msg(_("Retrieving manifests for dependency " |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
585 |
"evaluation ...")) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
586 |
matches = prune(get_dependencies(matches, xport_cfg, tracker), |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
587 |
all_versions, all_timestamps) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
588 |
|
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
589 |
return matches |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
590 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
591 |
def archive_pkgs(pargs, target, list_newest, all_versions, all_timestamps, |
2864
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
592 |
keep_compresed, raw, recursive, dry_run, dest_xport_cfg, src_uri, dkey, |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
593 |
dcert): |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
594 |
"""Retrieve source package data completely and then archive it.""" |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
595 |
|
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
596 |
global cache_dir, download_start, xport, xport_cfg |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
597 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
598 |
target = os.path.abspath(target) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
599 |
if os.path.exists(target): |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
600 |
error(_("Target archive '%s' already " |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
601 |
"exists.") % target) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
602 |
abort() |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
603 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
604 |
# Open the archive early so that permissions failures, etc. can be |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
605 |
# detected before actual work is started. |
2634
da6a36c6c9bd
7144038 pkgrecv -a creates archives even when -n is specified
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2633
diff
changeset
|
606 |
if not dry_run: |
da6a36c6c9bd
7144038 pkgrecv -a creates archives even when -n is specified
Saurabh Vyas <saurabh.vyas@oracle.com>
parents:
2633
diff
changeset
|
607 |
pkg_arc = pkg.p5p.Archive(target, mode="w") |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
608 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
609 |
basedir = tempfile.mkdtemp(dir=temp_root, |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
610 |
prefix=global_settings.client_name + "-") |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
611 |
tmpdirs.append(basedir) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
612 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
613 |
# Retrieve package data for all publishers. |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
614 |
any_unmatched = [] |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
615 |
any_matched = [] |
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
616 |
invalid_manifests = [] |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
617 |
total_processed = 0 |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
618 |
arc_bytes = 0 |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
619 |
archive_list = [] |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
620 |
for src_pub in xport_cfg.gen_publishers(): |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
621 |
# Root must be per publisher on the off chance that multiple |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
622 |
# publishers have the same package. |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
623 |
xport_cfg.pkg_root = os.path.join(basedir, src_pub.prefix) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
624 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
625 |
tracker = get_tracker() |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
626 |
msg(_("Retrieving packages for publisher %s ...") % |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
627 |
src_pub.prefix) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
628 |
if pargs == None or len(pargs) == 0: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
629 |
usage(_("must specify at least one pkgfmri")) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
630 |
|
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
631 |
matches = get_matches(src_pub, tracker, xport, pargs, |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
632 |
any_unmatched, any_matched, all_versions, all_timestamps, |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
633 |
recursive) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
634 |
if not matches: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
635 |
# No matches at all; nothing to do for this publisher. |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
636 |
continue |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
637 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
638 |
# First, retrieve the manifests and calculate package transfer |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
639 |
# sizes. |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
640 |
npkgs = len(matches) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
641 |
get_bytes = 0 |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
642 |
get_files = 0 |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
643 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
644 |
if not recursive: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
645 |
msg(_("Retrieving and evaluating %d package(s)...") % |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
646 |
npkgs) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
647 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
648 |
|
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
649 |
tracker.manifest_fetch_start(npkgs) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
650 |
|
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
651 |
good_matches = [] |
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
652 |
for f in matches: |
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
653 |
try: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
654 |
m = get_manifest(f, xport_cfg) |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
655 |
except apx.InvalidPackageErrors, e: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
656 |
invalid_manifests.extend(e.errors) |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
657 |
continue |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
658 |
good_matches.append(f) |
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
659 |
getb, getf, arcb, arccb = get_sizes(m) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
660 |
get_bytes += getb |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
661 |
get_files += getf |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
662 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
663 |
# Since files are going into the archive, progress |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
664 |
# can be tracked in terms of compressed bytes for |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
665 |
# the package files themselves. |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
666 |
arc_bytes += arccb |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
667 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
668 |
# Also include the the manifest file itself in the |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
669 |
# amount of bytes to archive. |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
670 |
try: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
671 |
fs = os.stat(m.pathname) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
672 |
arc_bytes += fs.st_size |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
673 |
except EnvironmentError, e: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
674 |
raise apx._convert_error(e) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
675 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
676 |
tracker.manifest_fetch_progress(completion=True) |
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
677 |
matches = good_matches |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
678 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
679 |
tracker.manifest_fetch_done() |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
680 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
681 |
# Next, retrieve the content for this publisher's packages. |
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
682 |
tracker.download_set_goal(len(matches), get_files, |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
683 |
get_bytes) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
684 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
685 |
if dry_run: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
686 |
# Don't call download_done here; it would cause an |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
687 |
# assertion failure since nothing was downloaded. |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
688 |
# Instead, call the method that simply finishes |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
689 |
# up the progress output. |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
690 |
tracker.download_done(dryrun=True) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
691 |
cleanup() |
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
692 |
total_processed = len(matches) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
693 |
continue |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
694 |
|
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
695 |
for f in matches: |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
696 |
tracker.download_start_pkg(f) |
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
697 |
pkgdir = xport_cfg.get_pkg_dir(f) |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
698 |
mfile = xport.multi_file_ni(src_pub, pkgdir, |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
699 |
progtrack=tracker) |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
700 |
m = get_manifest(f, xport_cfg) |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
701 |
add_hashes_to_multi(m, mfile) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
702 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
703 |
if mfile: |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
704 |
download_start = True |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
705 |
mfile.wait_files() |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
706 |
|
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
707 |
if not dry_run: |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
708 |
archive_list.append((f, m.pathname, pkgdir)) |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
709 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
710 |
# Nothing more to do for this package. |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
711 |
tracker.download_end_pkg(f) |
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
712 |
total_processed += 1 |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
713 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
714 |
tracker.download_done() |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
715 |
tracker.reset() |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
716 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
717 |
# Check processed patterns and abort with failure if some were |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
718 |
# unmatched. |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
719 |
check_processed(any_matched, any_unmatched, total_processed) |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
720 |
|
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
721 |
if not dry_run: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
722 |
# Now create archive and then archive retrieved package data. |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
723 |
while archive_list: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
724 |
pfmri, mpath, pkgdir = archive_list.pop() |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
725 |
pkg_arc.add_package(pfmri, mpath, pkgdir) |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
726 |
pkg_arc.close(progtrack=tracker) |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
727 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
728 |
# Dump all temporary data. |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
729 |
cleanup() |
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
730 |
|
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
731 |
if invalid_manifests: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
732 |
error(_("The following errors were encountered. The packages " |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
733 |
"listed were not\nreceived.\n%s") % |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
734 |
"\n".join(str(im) for im in invalid_manifests)) |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
735 |
if invalid_manifests and total_processed: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
736 |
return pkgdefs.EXIT_PARTIAL |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
737 |
if invalid_manifests: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
738 |
return pkgdefs.EXIT_OOPS |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
739 |
return pkgdefs.EXIT_OK |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
740 |
|
2898
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
741 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
742 |
def clone_repo(pargs, target, list_newest, all_versions, all_timestamps, |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
743 |
keep_compressed, raw, recursive, dry_run, dest_xport_cfg, src_uri, dkey, |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
744 |
dcert, publishers): |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
745 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
746 |
global cache_dir, download_start, xport, xport_cfg, dest_xport |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
747 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
748 |
invalid_manifests = [] |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
749 |
total_processed = 0 |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
750 |
modified_pubs = set() |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
751 |
deleted_pkgs = False |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
752 |
old_c_root = None |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
753 |
del_search_index = set() |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
754 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
755 |
# Turn target into a valid URI. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
756 |
target = publisher.RepositoryURI(misc.parse_uri(target)) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
757 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
758 |
if target.scheme != "file": |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
759 |
abort(err=_("Destination clone repository must be " |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
760 |
"filesystem-based.")) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
761 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
762 |
# Initialize the target repo. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
763 |
try: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
764 |
repo = sr.Repository(read_only=False, |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
765 |
root=target.get_pathname()) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
766 |
except sr.RepositoryInvalidError, e: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
767 |
txt = str(e) + "\n\n" |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
768 |
txt += _("To create a repository, use the pkgrepo command.") |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
769 |
abort(err=txt) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
770 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
771 |
def copy_catalog(src_cat_root, pub): |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
772 |
# Copy catalog files. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
773 |
c_root = repo.get_pub_rstore(pub).catalog_root |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
774 |
rstore_root = repo.get_pub_rstore(pub).root |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
775 |
try: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
776 |
# We just use mkdtemp() to find ourselves a directory |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
777 |
# which does not already exist. The created dir is not |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
778 |
# used. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
779 |
old_c_root = tempfile.mkdtemp(dir=rstore_root, |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
780 |
prefix='catalog-') |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
781 |
shutil.rmtree(old_c_root) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
782 |
shutil.move(c_root, old_c_root) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
783 |
shutil.copytree(src_cat_root, c_root) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
784 |
except Exception, e: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
785 |
abort(err=_("Unable to copy catalog files: %s") % e) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
786 |
return old_c_root |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
787 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
788 |
# Check if all publishers in src are also in target. If not, add |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
789 |
# depending on what publishers were specified by user. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
790 |
pubs_to_sync = [] |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
791 |
pubs_to_add = [] |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
792 |
src_pubs = {} |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
793 |
for sp in xport_cfg.gen_publishers(): |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
794 |
src_pubs[sp.prefix] = sp |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
795 |
dst_pubs = repo.get_publishers() |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
796 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
797 |
pubs_specified = False |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
798 |
unknown_pubs = [] |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
799 |
for p in publishers: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
800 |
if p not in src_pubs and p != '*': |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
801 |
abort(err=_("The publisher %s does not exist in the " |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
802 |
"source repository." % p)) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
803 |
pubs_specified = True |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
804 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
805 |
for sp in src_pubs: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
806 |
if sp not in dst_pubs and (sp in publishers or \ |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
807 |
'*' in publishers): |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
808 |
pubs_to_add.append(src_pubs[sp]) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
809 |
pubs_to_sync.append(src_pubs[sp]) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
810 |
elif sp in dst_pubs and (sp in publishers or '*' in publishers |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
811 |
or not pubs_specified): |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
812 |
pubs_to_sync.append(src_pubs[sp]) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
813 |
elif not pubs_specified: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
814 |
unknown_pubs.append(sp) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
815 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
816 |
# We only print warning if the user didn't specify any valid publishers |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
817 |
# to add/sync. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
818 |
if len(unknown_pubs): |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
819 |
txt = _("\nThe following publishers are present in the " |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
820 |
"source repository but not in the target repository.\n" |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
821 |
"Please use -p to specify which publishers need to be " |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
822 |
"cloned or -p '*' to clone all publishers.") |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
823 |
for p in unknown_pubs: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
824 |
txt += "\n %s\n" % p |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
825 |
abort(err=txt) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
826 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
827 |
# Create non-existent publishers. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
828 |
for p in pubs_to_add: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
829 |
if not dry_run: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
830 |
msg(_("Adding publisher %s ...") % p.prefix) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
831 |
repo.add_publisher(p) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
832 |
else: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
833 |
msg(_("Adding publisher %s (dry-run) ...") % p.prefix) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
834 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
835 |
for src_pub in pubs_to_sync: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
836 |
msg(_("Processing packages for publisher %s ...") % |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
837 |
src_pub.prefix) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
838 |
tracker = get_tracker() |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
839 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
840 |
src_basedir = tempfile.mkdtemp(dir=temp_root, |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
841 |
prefix=global_settings.client_name + "-") |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
842 |
tmpdirs.append(src_basedir) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
843 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
844 |
xport_cfg.pkg_root = src_basedir |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
845 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
846 |
# We make the destination repo our cache directory to save on |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
847 |
# IOPs. Have to remove all the old caches first. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
848 |
if not dry_run: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
849 |
xport_cfg.clear_caches(shared=True) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
850 |
xport_cfg.add_cache( |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
851 |
repo.get_pub_rstore(src_pub.prefix).file_root, |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
852 |
readonly=False) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
853 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
854 |
# Retrieve src and dest catalog for comparison. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
855 |
src_pub.meta_root = src_basedir |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
856 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
857 |
src_cat = fetch_catalog(src_pub, tracker, xport, False, |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
858 |
include_updates=True) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
859 |
src_cat_root = src_cat.meta_root |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
860 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
861 |
try: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
862 |
targ_cat = repo.get_catalog(pub=src_pub.prefix) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
863 |
except sr.RepositoryUnknownPublisher: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
864 |
targ_cat = catalog.Catalog(read_only=True) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
865 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
866 |
src_fmris = set([x for x in src_cat.fmris(last=False)]) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
867 |
targ_fmris = set([x for x in targ_cat.fmris(last=False)]) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
868 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
869 |
del src_cat |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
870 |
del targ_cat |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
871 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
872 |
to_add = [] |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
873 |
to_rm = [] |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
874 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
875 |
# We use bulk prefetching for faster transport of the manifests. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
876 |
# Prefetch requires an intent which it sends to the server. Here |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
877 |
# we just use operation=clone for all FMRIs. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
878 |
intent = "operation=clone;" |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
879 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
880 |
# Find FMRIs which need to be added/removed. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
881 |
to_add_set = src_fmris - targ_fmris |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
882 |
to_rm = targ_fmris - src_fmris |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
883 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
884 |
for f in to_add_set: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
885 |
to_add.append((f, intent)) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
886 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
887 |
del src_fmris |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
888 |
del targ_fmris |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
889 |
del to_add_set |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
890 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
891 |
# We have to do package removal first because after the sync we |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
892 |
# don't have the old catalog anymore and if we delete packages |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
893 |
# after the sync based on the current catalog we might delete |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
894 |
# files required by packages still in the repo. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
895 |
if len(to_rm) > 0: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
896 |
msg(_("Packages to remove:")) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
897 |
for f in to_rm: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
898 |
msg(" %s" % f.get_fmri(anarchy=True)) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
899 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
900 |
if not dry_run: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
901 |
msg(_("Removing packages ...")) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
902 |
if repo.get_pub_rstore( |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
903 |
src_pub.prefix).search_available: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
904 |
del_search_index.add(src_pub.prefix) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
905 |
repo.remove_packages(to_rm, progtrack=tracker, |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
906 |
pub=src_pub.prefix) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
907 |
deleted_pkgs = True |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
908 |
total_processed += len(to_rm) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
909 |
modified_pubs.add(src_pub.prefix) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
910 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
911 |
if len(to_add) == 0: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
912 |
msg(_("No packages to add.")) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
913 |
if deleted_pkgs: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
914 |
old_c_root = copy_catalog(src_cat_root, |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
915 |
src_pub.prefix) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
916 |
continue |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
917 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
918 |
get_bytes = 0 |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
919 |
get_files = 0 |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
920 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
921 |
# Retrieve manifests. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
922 |
# Try prefetching manifests in bulk first for faster, parallel |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
923 |
# transport. Retryable errors during prefetch are ignored and |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
924 |
# manifests are retrieved again during the "Reading" phase. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
925 |
src_pub.transport.prefetch_manifests(to_add, progtrack=tracker) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
926 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
927 |
# Need to change the output of mfst_fetch since otherwise we |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
928 |
# would see "Download Manifests x/y" twice, once from the |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
929 |
# prefetch and once from the actual manifest analysis. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
930 |
old_gti = tracker.mfst_fetch |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
931 |
tracker.mfst_fetch = progress.GoalTrackerItem( |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
932 |
_("Reading Manifests")) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
933 |
tracker.manifest_fetch_start(len(to_add)) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
934 |
for f, i in to_add: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
935 |
try: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
936 |
m = get_manifest(f, xport_cfg) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
937 |
except apx.InvalidPackageErrors, e: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
938 |
invalid_manifests.extend(e.errors) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
939 |
continue |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
940 |
getb, getf, sendb, sendcb = get_sizes(m) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
941 |
get_bytes += getb |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
942 |
get_files += getf |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
943 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
944 |
if dry_run: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
945 |
tracker.manifest_fetch_progress(completion=True) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
946 |
continue |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
947 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
948 |
# Move manifest into dest repo. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
949 |
targ_path = os.path.join( |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
950 |
repo.get_pub_rstore(src_pub.prefix).root, 'pkg') |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
951 |
dp = m.fmri.get_dir_path() |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
952 |
dst_path = os.path.join(targ_path, dp) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
953 |
src_path = os.path.join(src_basedir, dp, 'manifest') |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
954 |
dir_name = os.path.dirname(dst_path) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
955 |
try: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
956 |
misc.makedirs(dir_name) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
957 |
shutil.move(src_path, dst_path) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
958 |
except Exception, e: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
959 |
txt = _("Unable to copy manifest: %s") % e |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
960 |
abort(err=txt) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
961 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
962 |
tracker.manifest_fetch_progress(completion=True) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
963 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
964 |
tracker.manifest_fetch_done() |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
965 |
# Restore old GoalTrackerItem for manifest download. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
966 |
tracker.mfst_fetch = old_gti |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
967 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
968 |
if not dry_run: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
969 |
msg(_("\nAdding packages ...")) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
970 |
else: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
971 |
msg(_("\nAdding packages (dry-run) ...")) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
972 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
973 |
status = [] |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
974 |
status.append((_("Packages to add:"), str(len(to_add)))) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
975 |
status.append((_("Files to retrieve:"), str(get_files))) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
976 |
status.append((_("Estimated transfer size:"), misc.bytes_to_str( |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
977 |
get_bytes))) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
978 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
979 |
rjust_status = max(len(s[0]) for s in status) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
980 |
rjust_value = max(len(s[1]) for s in status) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
981 |
for s in status: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
982 |
msg("%s %s" % (s[0].rjust(rjust_status), |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
983 |
s[1].rjust(rjust_value))) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
984 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
985 |
if dry_run: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
986 |
continue |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
987 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
988 |
tracker.download_set_goal(len(to_add), get_files, get_bytes) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
989 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
990 |
# Retrieve package files. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
991 |
for f, i in to_add: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
992 |
tracker.download_start_pkg(f) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
993 |
mfile = xport.multi_file_ni(src_pub, None, |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
994 |
progtrack=tracker) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
995 |
m = get_manifest(f, xport_cfg) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
996 |
add_hashes_to_multi(m, mfile) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
997 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
998 |
if mfile: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
999 |
mfile.wait_files() |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1000 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1001 |
tracker.download_end_pkg(f) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1002 |
total_processed += 1 |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1003 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1004 |
tracker.download_done |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1005 |
tracker.reset() |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1006 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1007 |
modified_pubs.add(src_pub.prefix) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1008 |
old_c_root = copy_catalog(src_cat_root, src_pub.prefix) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1009 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1010 |
if invalid_manifests: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1011 |
error(_("The following packages could not be retrieved:\n%s") % |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1012 |
"\n".join(str(im) for im in invalid_manifests)) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1013 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1014 |
ret = 0 |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1015 |
# Run pkgrepo verify to check repo. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1016 |
if total_processed: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1017 |
msg(_("\n\nVerifying repository contents.")) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1018 |
cmd = os.path.join(os.path.dirname(misc.api_cmdpath()), |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1019 |
"pkgrepo") |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1020 |
args = [cmd, 'verify', '-s', |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1021 |
target.get_pathname()] |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1022 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1023 |
try: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1024 |
ret = subprocess.call(args) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1025 |
except OSError, e: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1026 |
raise RuntimeError, "cannot execute %s: %s" % (args, e) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1027 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1028 |
# Cleanup. If verification was ok, remove backup copy of old catalog. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1029 |
# If not, move old catalog back into place and remove messed up catalog. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1030 |
for pub in modified_pubs: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1031 |
c_root = repo.get_pub_rstore(pub).catalog_root |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1032 |
try: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1033 |
if ret: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1034 |
shutil.rmtree(c_root) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1035 |
shutil.move(old_c_root, c_root) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1036 |
else: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1037 |
shutil.rmtree(old_c_root) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1038 |
except Exception, e: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1039 |
error(_("Unable to remove catalog files: %s") % e) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1040 |
# We don't abort here to make sure we can |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1041 |
# restore/delete as much as we can. |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1042 |
continue |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1043 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1044 |
if ret: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1045 |
txt = _("Pkgrepo verify found errors in the updated repository." |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1046 |
"\nThe original package catalog has been restored.\n") |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1047 |
if deleted_pkgs: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1048 |
txt += _("Deleted packages can not be restored.\n") |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1049 |
txt += _("The clone operation can be retried; package content " |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1050 |
"that has already been retrieved will not be downloaded " |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1051 |
"again.") |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1052 |
abort(err=txt) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1053 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1054 |
if del_search_index: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1055 |
txt = _("\nThe search index for the following publishers has " |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1056 |
"been removed due to package removals.\n") |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1057 |
for p in del_search_index: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1058 |
txt += " %s\n" % p |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1059 |
txt += _("\nTo restore the search index for all publishers run" |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1060 |
"\n'pkgrepo refresh --no-catalog -s %s'.\n") % \ |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1061 |
target.get_pathname() |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1062 |
msg(txt) |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1063 |
|
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1064 |
cleanup() |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1065 |
if invalid_manifests and total_processed: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1066 |
return pkgdefs.EXIT_PARTIAL |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1067 |
if invalid_manifests: |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1068 |
return pkgdefs.EXIT_OOPS |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1069 |
return pkgdefs.EXIT_OK |
723ece284e97
16595528 pkgrecv should have a clone mode to exactly replicate repositories
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2871
diff
changeset
|
1070 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1071 |
def transfer_pkgs(pargs, target, list_newest, all_versions, all_timestamps, |
2864
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
1072 |
keep_compressed, raw, recursive, dry_run, dest_xport_cfg, src_uri, dkey, |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
1073 |
dcert): |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1074 |
"""Retrieve source package data and optionally republish it as each |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1075 |
package is retrieved. |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1076 |
""" |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1077 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1078 |
global cache_dir, download_start, xport, xport_cfg, dest_xport, targ_pub |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1079 |
|
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1080 |
any_unmatched = [] |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1081 |
any_matched = [] |
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1082 |
invalid_manifests = [] |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1083 |
total_processed = 0 |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1084 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1085 |
for src_pub in xport_cfg.gen_publishers(): |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1086 |
tracker = get_tracker() |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1087 |
if list_newest: |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1088 |
# Make sure the prog tracker knows we're doing a listing |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1089 |
# operation so that it suppresses irrelevant output. |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1090 |
tracker.set_purpose(tracker.PURPOSE_LISTING) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1091 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1092 |
if pargs or len(pargs) > 0: |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1093 |
usage(_("--newest takes no options")) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1094 |
|
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1095 |
src_cat = fetch_catalog(src_pub, tracker, |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1096 |
xport, False) |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1097 |
for f in src_cat.fmris(ordered=True, last=True): |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1098 |
msg(f.get_fmri()) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1099 |
continue |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1100 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1101 |
msg(_("Processing packages for publisher %s ...") % |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1102 |
src_pub.prefix) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1103 |
if pargs == None or len(pargs) == 0: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1104 |
usage(_("must specify at least one pkgfmri")) |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
1105 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1106 |
republish = False |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1107 |
|
2268
1f313c3e7cdf
17728 publication tools should require a repository to be specified
Shawn Walker <shawn.walker@oracle.com>
parents:
2219
diff
changeset
|
1108 |
if not raw: |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1109 |
basedir = tempfile.mkdtemp(dir=temp_root, |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1110 |
prefix=global_settings.client_name + "-") |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1111 |
tmpdirs.append(basedir) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1112 |
republish = True |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1113 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1114 |
# Turn target into a valid URI. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1115 |
target = misc.parse_uri(target) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1116 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1117 |
# Setup target for transport. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1118 |
targ_pub = transport.setup_publisher(target, |
2864
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
1119 |
src_pub.prefix, dest_xport, dest_xport_cfg, |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
1120 |
ssl_key=dkey, ssl_cert=dcert) |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
1121 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1122 |
# Files have to be decompressed for republishing. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1123 |
keep_compressed = False |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1124 |
if target.startswith("file://"): |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1125 |
# Check to see if the repository exists first. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1126 |
try: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1127 |
t = trans.Transaction(target, |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1128 |
xport=dest_xport, pub=targ_pub) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1129 |
except trans.TransactionRepositoryInvalidError, e: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1130 |
txt = str(e) + "\n\n" |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1131 |
txt += _("To create a repository, use " |
2177
7d7381339f63
17575 debug usage in pkg.depotd(1M) is incomplete
Saurabh Vyas <Saurabh.Vyas@Sun.COM>
parents:
2126
diff
changeset
|
1132 |
"the pkgrepo command.") |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1133 |
abort(err=txt) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1134 |
except trans.TransactionRepositoryConfigError, e: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1135 |
txt = str(e) + "\n\n" |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1136 |
txt += _("The repository configuration " |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1137 |
"for the repository located at " |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1138 |
"'%s' is not valid or the " |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1139 |
"specified path does not exist. " |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1140 |
"Please correct the configuration " |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1141 |
"of the repository or create a new " |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1142 |
"one.") % target |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1143 |
abort(err=txt) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1144 |
except trans.TransactionError, e: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1145 |
abort(err=e) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1146 |
else: |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1147 |
basedir = target = os.path.abspath(target) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1148 |
if not os.path.exists(basedir): |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1149 |
try: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1150 |
os.makedirs(basedir, misc.PKG_DIR_MODE) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1151 |
except Exception, e: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1152 |
error(_("Unable to create basedir " |
2826
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2820
diff
changeset
|
1153 |
"'%(dir)s': %(err)s") % |
cae308eb6426
7185135 i18n messages should use parameterized values
Tim Foster <tim.s.foster@oracle.com>
parents:
2820
diff
changeset
|
1154 |
{"dir": basedir, "err": e}) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1155 |
abort() |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
1156 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1157 |
xport_cfg.pkg_root = basedir |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1158 |
dest_xport_cfg.pkg_root = basedir |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
1159 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1160 |
if republish: |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1161 |
targ_cat = fetch_catalog(targ_pub, tracker, |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1162 |
dest_xport, True) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1163 |
|
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1164 |
matches = get_matches(src_pub, tracker, xport, pargs, |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1165 |
any_unmatched, any_matched, all_versions, all_timestamps, |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1166 |
recursive) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1167 |
if not matches: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1168 |
# No matches at all; nothing to do for this publisher. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1169 |
continue |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1170 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1171 |
def get_basename(pfmri): |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1172 |
open_time = pfmri.get_timestamp() |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1173 |
return "%d_%s" % \ |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1174 |
(calendar.timegm(open_time.utctimetuple()), |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1175 |
urllib.quote(str(pfmri), "")) |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
1176 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1177 |
# First, retrieve the manifests and calculate package transfer |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1178 |
# sizes. |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1179 |
npkgs = len(matches) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1180 |
get_bytes = 0 |
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
1181 |
get_files = 0 |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1182 |
send_bytes = 0 |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
1183 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1184 |
if not recursive: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1185 |
msg(_("Retrieving and evaluating %d package(s)...") % |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1186 |
npkgs) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1187 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1188 |
tracker.manifest_fetch_start(npkgs) |
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
1189 |
|
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
1190 |
pkgs_to_get = [] |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1191 |
while matches: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1192 |
f = matches.pop() |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1193 |
if republish and targ_cat.get_entry(f): |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1194 |
tracker.manifest_fetch_progress(completion=True) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1195 |
continue |
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1196 |
try: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1197 |
m = get_manifest(f, xport_cfg) |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1198 |
except apx.InvalidPackageErrors, e: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1199 |
invalid_manifests.extend(e.errors) |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1200 |
continue |
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
1201 |
pkgs_to_get.append(f) |
1431
62b6033670e4
10416 server catalog v1 support desired
Shawn Walker <srw@sun.com>
parents:
1352
diff
changeset
|
1202 |
|
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
1203 |
getb, getf, sendb, sendcb = get_sizes(m) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1204 |
get_bytes += getb |
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
1205 |
get_files += getf |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1206 |
if republish: |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1207 |
# For now, normal republication always uses |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1208 |
# uncompressed data as already compressed data |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1209 |
# is not supported for publication. |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1210 |
send_bytes += sendb |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1211 |
|
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1212 |
tracker.manifest_fetch_progress(completion=True) |
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1213 |
tracker.manifest_fetch_done() |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1214 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1215 |
# Next, retrieve and store the content for each package. |
2671
20a5c9aa2e6d
7160289 pkgrecv failing to pull build s11u1_13: pkgrecv: 'add_file' failed.
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2634
diff
changeset
|
1216 |
tracker.republish_set_goal(len(pkgs_to_get), get_bytes, |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1217 |
send_bytes) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1218 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1219 |
if dry_run: |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1220 |
tracker.republish_done(dryrun=True) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1221 |
cleanup() |
2057
874a83b3e8d1
10390 make pkgrecv gracefully handle existing packages in destination
johansen <johansen@opensolaris.org>
parents:
2054
diff
changeset
|
1222 |
continue |
874a83b3e8d1
10390 make pkgrecv gracefully handle existing packages in destination
johansen <johansen@opensolaris.org>
parents:
2054
diff
changeset
|
1223 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1224 |
processed = 0 |
2671
20a5c9aa2e6d
7160289 pkgrecv failing to pull build s11u1_13: pkgrecv: 'add_file' failed.
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2634
diff
changeset
|
1225 |
pkgs_to_get = sorted(pkgs_to_get) |
20a5c9aa2e6d
7160289 pkgrecv failing to pull build s11u1_13: pkgrecv: 'add_file' failed.
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2634
diff
changeset
|
1226 |
for f in pkgs_to_get: |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1227 |
tracker.republish_start_pkg(f) |
2633
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
1228 |
pkgdir = xport_cfg.get_pkg_dir(f) |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
1229 |
mfile = xport.multi_file_ni(src_pub, pkgdir, |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
1230 |
not keep_compressed, tracker) |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
1231 |
m = get_manifest(f, xport_cfg) |
14d197a1be01
7139651 pkgrecv doesn't scale with large repos
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2591
diff
changeset
|
1232 |
add_hashes_to_multi(m, mfile) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1233 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1234 |
if mfile: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1235 |
download_start = True |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1236 |
mfile.wait_files() |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1237 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1238 |
if not republish: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1239 |
# Nothing more to do for this package. |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1240 |
tracker.republish_end_pkg(f) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1241 |
continue |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1242 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1243 |
# Get first line of original manifest so that inclusion |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1244 |
# of the scheme can be determined. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1245 |
use_scheme = True |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1246 |
contents = get_manifest(f, xport_cfg, contents=True) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1247 |
if contents.splitlines()[0].find("pkg:/") == -1: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1248 |
use_scheme = False |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1249 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1250 |
pkg_name = f.get_fmri(include_scheme=use_scheme) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1251 |
pkgdir = xport_cfg.get_pkg_dir(f) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1252 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1253 |
# This is needed so any previous failures for a package |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1254 |
# can be aborted. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1255 |
trans_id = get_basename(f) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1256 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1257 |
if not targ_pub: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1258 |
targ_pub = transport.setup_publisher(target, |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1259 |
src_pub.prefix, dest_xport, dest_xport_cfg, |
2864
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
1260 |
remote_prefix=True, ssl_key=dkey, |
96d3957712da
16193298 pkgrepo, pkgrecv and pkgsend need SSL support for publishing and info retrieval
Erik Trauschke <Erik.Trauschke@oracle.com>
parents:
2826
diff
changeset
|
1261 |
ssl_cert=dcert) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1262 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1263 |
try: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1264 |
t = trans.Transaction(target, pkg_name=pkg_name, |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1265 |
trans_id=trans_id, xport=dest_xport, |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1266 |
pub=targ_pub, progtrack=tracker) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1267 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1268 |
# Remove any previous failed attempt to |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1269 |
# to republish this package. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1270 |
try: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1271 |
t.close(abandon=True) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1272 |
except: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1273 |
# It might not exist already. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1274 |
pass |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
1275 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1276 |
t.open() |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1277 |
for a in m.gen_actions(): |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1278 |
if a.name == "set" and \ |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1279 |
a.attrs.get("name", "") in ("fmri", |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1280 |
"pkg.fmri"): |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1281 |
# To be consistent with the |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1282 |
# server, the fmri can't be |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1283 |
# added to the manifest. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1284 |
continue |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1285 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1286 |
if hasattr(a, "hash"): |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1287 |
fname = os.path.join(pkgdir, |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1288 |
a.hash) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1289 |
a.data = lambda: open(fname, |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1290 |
"rb") |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1291 |
t.add(a) |
2286
938fbb350ad2
16867 pkgsign should handle existing signatures better
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2268
diff
changeset
|
1292 |
if a.name == "signature": |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1293 |
for fp in a.get_chain_certs(): |
2286
938fbb350ad2
16867 pkgsign should handle existing signatures better
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2268
diff
changeset
|
1294 |
fname = os.path.join( |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1295 |
pkgdir, fp) |
2286
938fbb350ad2
16867 pkgsign should handle existing signatures better
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2268
diff
changeset
|
1296 |
t.add_file(fname) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1297 |
# Always defer catalog update. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1298 |
t.close(add_to_catalog=False) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1299 |
except trans.TransactionError, e: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1300 |
abort(err=e) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1301 |
|
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1302 |
# Dump data retrieved so far after each successful |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1303 |
# republish to conserve space. |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1304 |
try: |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1305 |
shutil.rmtree(dest_xport_cfg.incoming_root) |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1306 |
shutil.rmtree(pkgdir) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1307 |
if cache_dir in tmpdirs: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1308 |
# If cache_dir is listed in tmpdirs, |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1309 |
# then it's safe to dump cache contents. |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1310 |
# Otherwise, it's a user cache directory |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1311 |
# and shouldn't be dumped. |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1312 |
shutil.rmtree(cache_dir) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1313 |
misc.makedirs(cache_dir) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1314 |
except EnvironmentError, e: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1315 |
raise apx._convert_error(e) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1316 |
misc.makedirs(dest_xport_cfg.incoming_root) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1317 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1318 |
processed += 1 |
2693
cfee571ea6d5
7154388 Progress tracking API and functionality improvements
Dan Price <daniel.price@oracle.com>
parents:
2671
diff
changeset
|
1319 |
tracker.republish_end_pkg(f) |
2115
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1320 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1321 |
tracker.republish_done() |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1322 |
tracker.reset() |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1323 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1324 |
if processed > 0: |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1325 |
# If any packages were published, trigger an update of |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1326 |
# the catalog. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1327 |
total_processed += processed |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1328 |
dest_xport.publish_refresh_packages(targ_pub) |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1329 |
|
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1330 |
# Prevent further use. |
c6a812ab117a
16818 pkgrecv -d should publish per-package, not in one lump
Shawn Walker <shawn.walker@oracle.com>
parents:
2073
diff
changeset
|
1331 |
targ_pub = None |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
1332 |
|
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1333 |
# Check processed patterns and abort with failure if some were |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1334 |
# unmatched. |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1335 |
check_processed(any_matched, any_unmatched, total_processed) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1336 |
|
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1337 |
# Dump all temporary data. |
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1338 |
cleanup() |
2705
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1339 |
if invalid_manifests: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1340 |
error(_("The following errors were encountered. The packages " |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1341 |
"listed were not\nreceived.\n%s") % |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1342 |
"\n".join(str(im) for im in invalid_manifests)) |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1343 |
if invalid_manifests and total_processed: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1344 |
return pkgdefs.EXIT_PARTIAL |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1345 |
if invalid_manifests: |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1346 |
return pkgdefs.EXIT_OOPS |
346bf63a998c
7140241 pkgrecv should gracefully ignore unsupported packages
Brock Pytlik <brock.pytlik@oracle.com>
parents:
2693
diff
changeset
|
1347 |
return pkgdefs.EXIT_OK |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
1348 |
|
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
1349 |
if __name__ == "__main__": |
1715
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1600
diff
changeset
|
1350 |
|
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1600
diff
changeset
|
1351 |
# Make all warnings be errors. |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1600
diff
changeset
|
1352 |
warnings.simplefilter('error') |
8f305f0a6864
8265 EINVAL on rmdir running "make test"
Dan Price <dp@eng.sun.com>
parents:
1600
diff
changeset
|
1353 |
|
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
1354 |
try: |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1355 |
__ret = main_func() |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1356 |
except (KeyboardInterrupt, apx.CanceledException): |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1357 |
try: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1358 |
cleanup(True) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1359 |
except: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1360 |
__ret = 99 |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1361 |
else: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1362 |
__ret = 1 |
2219
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1363 |
except (pkg.actions.ActionError, trans.TransactionError, RuntimeError, |
60ad60f7592c
2152 standalone package support needed (on-disk format)
Shawn Walker <shawn.walker@oracle.com>
parents:
2177
diff
changeset
|
1364 |
apx.ApiException), _e: |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1365 |
error(_e) |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1366 |
try: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1367 |
cleanup(True) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1368 |
except: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1369 |
__ret = 99 |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1370 |
else: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1371 |
__ret = 1 |
1974
6af683c5bde5
9203 pkgrecv should check for valid destination before beginning download
johansen <johansen@opensolaris.org>
parents:
1968
diff
changeset
|
1372 |
except PipeError: |
440
cbd8cd1564a9
2104 pkgrecv: Spurious error message while downloading package with no files
Brad Hall <bhall@eng.sun.com>
parents:
420
diff
changeset
|
1373 |
# We don't want to display any messages here to prevent |
cbd8cd1564a9
2104 pkgrecv: Spurious error message while downloading package with no files
Brad Hall <bhall@eng.sun.com>
parents:
420
diff
changeset
|
1374 |
# possible further broken pipe (EPIPE) errors. |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1375 |
try: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1376 |
cleanup(False) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1377 |
except: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1378 |
__ret = 99 |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1379 |
else: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1380 |
__ret = 1 |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1381 |
except SystemExit, _e: |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1382 |
try: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1383 |
cleanup(False) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1384 |
except: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1385 |
__ret = 99 |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1386 |
raise _e |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1387 |
except EnvironmentError, _e: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1388 |
if _e.errno != errno.ENOSPC and _e.errno != errno.EDQUOT: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1389 |
raise |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1390 |
|
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1391 |
txt = "\n" |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1392 |
if _e.errno == errno.EDQUOT: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1393 |
txt += _("Storage space quota exceeded.") |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1394 |
else: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1395 |
txt += _("No storage space left.") |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1396 |
|
2820
8c33db61e6a6
7197510 pkgrecv error handling traces back
thejaswini.k@oracle.com
parents:
2728
diff
changeset
|
1397 |
temp_root_path = misc.get_temp_root_path() |
8c33db61e6a6
7197510 pkgrecv error handling traces back
thejaswini.k@oracle.com
parents:
2728
diff
changeset
|
1398 |
tdirs = [temp_root_path] |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1399 |
if cache_dir not in tmpdirs: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1400 |
# Only include in message if user specified. |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1401 |
tdirs.append(cache_dir) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1402 |
if target and target.startswith("file://"): |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1403 |
tdirs.append(target) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1404 |
|
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1405 |
txt += "\n" |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1406 |
error(txt + _("Please verify that the filesystem containing " |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1407 |
"the following directories has enough space available:\n" |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1408 |
"%s") % "\n".join(tdirs)) |
2820
8c33db61e6a6
7197510 pkgrecv error handling traces back
thejaswini.k@oracle.com
parents:
2728
diff
changeset
|
1409 |
try: |
8c33db61e6a6
7197510 pkgrecv error handling traces back
thejaswini.k@oracle.com
parents:
2728
diff
changeset
|
1410 |
cleanup() |
8c33db61e6a6
7197510 pkgrecv error handling traces back
thejaswini.k@oracle.com
parents:
2728
diff
changeset
|
1411 |
except: |
8c33db61e6a6
7197510 pkgrecv error handling traces back
thejaswini.k@oracle.com
parents:
2728
diff
changeset
|
1412 |
__ret = 99 |
8c33db61e6a6
7197510 pkgrecv error handling traces back
thejaswini.k@oracle.com
parents:
2728
diff
changeset
|
1413 |
else: |
8c33db61e6a6
7197510 pkgrecv error handling traces back
thejaswini.k@oracle.com
parents:
2728
diff
changeset
|
1414 |
__ret = 1 |
375
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
1415 |
except: |
fa5286b09191
1773 Want tool to obtain contents of packages
johansen <johansen@sun.com>
parents:
diff
changeset
|
1416 |
traceback.print_exc() |
2569
1f9f50d0cde3
18977 pkg stack traces should tell customers to report issues to service
Shawn Walker <shawn.walker@oracle.com>
parents:
2549
diff
changeset
|
1417 |
error(misc.get_traceback_message()) |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1418 |
__ret = 99 |
2316
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1419 |
# Cleanup must be called *after* error messaging so that |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1420 |
# exceptions processed during cleanup don't cause the wrong |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1421 |
# traceback to be printed. |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1422 |
try: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1423 |
cleanup(True) |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1424 |
except: |
9eb53e68d674
17741 pkgrecv should allow wildcards in package versions
Shawn Walker <shawn.walker@oracle.com>
parents:
2310
diff
changeset
|
1425 |
pass |
1118
f2dd69165173
6342 pkgrecv should support local disk repository
Shawn Walker <srw@sun.com>
parents:
1063
diff
changeset
|
1426 |
sys.exit(__ret) |