src/modules/client/image.py
author Danek Duvall <danek.duvall@sun.com>
Mon, 06 Aug 2007 14:53:13 -0700
changeset 67 62c897652bbc
parent 63 ba3a4af65479
child 69 9eeb33eab728
permissions -rw-r--r--
Handle dependencies when removing a package.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
19
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
     1
#!/usr/bin/python
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
     2
#
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
     3
# CDDL HEADER START
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
     4
#
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
     8
#
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    11
# See the License for the specific language governing permissions
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    12
# and limitations under the License.
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    13
#
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    19
#
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    20
# CDDL HEADER END
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    21
#
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    22
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    23
# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    24
# Use is subject to license terms.
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    25
59
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
    26
import getopt
26
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    27
import os
34
8b9613402116 refactor catalog and package to be common; improve bump-server
Stephen Hahn <sch@sun.com>
parents: 33
diff changeset
    28
import re
45
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
    29
import urllib
34
8b9613402116 refactor catalog and package to be common; improve bump-server
Stephen Hahn <sch@sun.com>
parents: 33
diff changeset
    30
8b9613402116 refactor catalog and package to be common; improve bump-server
Stephen Hahn <sch@sun.com>
parents: 33
diff changeset
    31
import pkg.catalog as catalog
59
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
    32
import pkg.fmri as fmri
50
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
    33
import pkg.manifest as manifest
26
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    34
19
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    35
IMG_ENTIRE = 0
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    36
IMG_PARTIAL = 1
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    37
IMG_USER = 2
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    38
26
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    39
img_user_prefix = ".org.opensolaris,pkg"
30
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
    40
img_root_prefix = "var/pkg"
26
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    41
19
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    42
class Image(object):
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    43
        """An Image object is a directory tree containing the laid-down contents
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    44
        of a self-consistent graph of Packages.
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    45
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    46
        An Image has a root path.
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    47
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    48
        An Image of type IMG_ENTIRE does not have a parent Image.  Other Image
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    49
        types must have a parent Image.  The external state of the parent Image
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    50
        must be accessible from the Image's context, or duplicated within the
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    51
        Image (IMG_PARTIAL for zones, for instance).
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    52
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    53
        The parent of a user Image can be a partial Image.  The parent of a
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    54
        partial Image must be an entire Image.
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    55
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    56
        An Image of type IMG_USER stores its external state at self.root +
26
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    57
        ".org.opensolaris,pkg".
19
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    58
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    59
        An Image of type IMG_ENTIRE or IMG_PARTIAL stores its external state at
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    60
        self.root + "/var/pkg".
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    61
26
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    62
        An Image needs to be able to have a different repository set than the
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    63
        system's root Image.
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    64
29
f621f1df0849 fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents: 26
diff changeset
    65
        Directory layout
f621f1df0849 fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents: 26
diff changeset
    66
f621f1df0849 fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents: 26
diff changeset
    67
          $IROOT/catalog
f621f1df0849 fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents: 26
diff changeset
    68
               Directory containing catalogs for URIs of interest.  Filename is
f621f1df0849 fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents: 26
diff changeset
    69
               the escaped URI of the catalog.
f621f1df0849 fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents: 26
diff changeset
    70
30
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
    71
          $IROOT/file
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
    72
               Directory containing file hashes of installed packages.
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
    73
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
    74
          $IROOT/pkg
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
    75
               Directory containing manifests and states of installed packages.
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
    76
60
6bd5cd83cfb1 Reverse index database and searching support.
Danek Duvall <danek.duvall@sun.com>
parents: 59
diff changeset
    77
          $IROOT/index
6bd5cd83cfb1 Reverse index database and searching support.
Danek Duvall <danek.duvall@sun.com>
parents: 59
diff changeset
    78
               Directory containing reverse-index databases.
6bd5cd83cfb1 Reverse index database and searching support.
Danek Duvall <danek.duvall@sun.com>
parents: 59
diff changeset
    79
19
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
    80
        XXX Root path probably can't be absolute, so that we can combine or
30
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
    81
        reuse Image contents.
26
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    82
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    83
        XXX Image file format?  Image file manipulation API?"""
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    84
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    85
        def __init__(self):
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    86
                self.type = None
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    87
                self.root = None
30
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
    88
                self.imgdir = None
26
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    89
                self.repo_uris = []
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    90
                self.filter_tags = {}
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
    91
32
c26788b7217c begin client install; sequences are now timestamps; skeleton ELF module
Stephen Hahn <sch@sun.com>
parents: 30
diff changeset
    92
                self.catalogs = {}
45
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
    93
                self.authorities = {}
32
c26788b7217c begin client install; sequences are now timestamps; skeleton ELF module
Stephen Hahn <sch@sun.com>
parents: 30
diff changeset
    94
50
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
    95
                self.attrs = {}
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
    96
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
    97
                self.attrs["Policy-Require-Optional"] = False
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
    98
                self.attrs["Policy-Pursue-Latest"] = True
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
    99
63
ba3a4af65479 add -R/$PKG_IMAGE to pkg, and -n and -v to install
Danek Duvall <danek.duvall@sun.com>
parents: 60
diff changeset
   100
        def find_parent(self, d):
26
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   101
                # Ascend from current working directory to find first
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   102
                # encountered image.
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   103
                while True:
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   104
                        if os.path.isdir("%s/%s" % (d, img_user_prefix)):
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   105
                                # XXX Look at image file to determine filter
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   106
                                # tags and repo URIs.
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   107
                                self.type = IMG_USER
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   108
                                self.root = d
30
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
   109
                                self.imgdir = "%s/%s" % (d, img_user_prefix)
59
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   110
                                self.attrs["Build-Release"] = "5.11"
26
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   111
                                return
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   112
                        elif os.path.isdir("%s/%s" % (d, img_root_prefix)):
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   113
                                # XXX Look at image file to determine filter
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   114
                                # tags and repo URIs.
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   115
                                # XXX Look at image file to determine if this
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   116
                                # image is a partial image.
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   117
                                self.type = IMG_ENTIRE
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   118
                                self.root = d
30
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
   119
                                self.imgdir = "%s/%s" % (d, img_root_prefix)
59
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   120
                                self.attrs["Build-Release"] = "5.11"
26
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   121
                                return
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   122
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   123
                        assert d != "/"
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   124
63
ba3a4af65479 add -R/$PKG_IMAGE to pkg, and -n and -v to install
Danek Duvall <danek.duvall@sun.com>
parents: 60
diff changeset
   125
                        # XXX follow symlinks or not?
ba3a4af65479 add -R/$PKG_IMAGE to pkg, and -n and -v to install
Danek Duvall <danek.duvall@sun.com>
parents: 60
diff changeset
   126
                        d = os.path.normpath(os.path.join(d, os.path.pardir))
26
ab188d4682d5 catalog processing begins
"Stephen Hahn <sch@sun.com>"
parents: 22
diff changeset
   127
29
f621f1df0849 fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents: 26
diff changeset
   128
        def mkdirs(self):
30
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
   129
                if not os.path.isdir(self.imgdir + "/catalog"):
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
   130
                        os.makedirs(self.imgdir + "/catalog")
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
   131
                if not os.path.isdir(self.imgdir + "/file"):
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
   132
                        os.makedirs(self.imgdir + "/file")
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
   133
                if not os.path.isdir(self.imgdir + "/pkg"):
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
   134
                        os.makedirs(self.imgdir + "/pkg")
60
6bd5cd83cfb1 Reverse index database and searching support.
Danek Duvall <danek.duvall@sun.com>
parents: 59
diff changeset
   135
                if not os.path.isdir(self.imgdir + "/index"):
6bd5cd83cfb1 Reverse index database and searching support.
Danek Duvall <danek.duvall@sun.com>
parents: 59
diff changeset
   136
                        os.makedirs(self.imgdir + "/index")
29
f621f1df0849 fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents: 26
diff changeset
   137
f621f1df0849 fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents: 26
diff changeset
   138
        def set_attrs(self, type, root):
19
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
   139
                self.type = type
22
379f0f6809ff pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents: 19
diff changeset
   140
                self.root = root
379f0f6809ff pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents: 19
diff changeset
   141
                if self.type == IMG_USER:
30
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
   142
                        self.imgdir = self.root + "/" + img_user_prefix
22
379f0f6809ff pkgsend open, pkgsend add file, pkgsend close; Transaction object
"Stephen Hahn <sch@sun.com>"
parents: 19
diff changeset
   143
                else:
30
f06ad6cb4b3f stop using flavour terminology
Stephen Hahn <sch@sun.com>
parents: 29
diff changeset
   144
                        self.imgdir = self.root + "/" + img_root_prefix
19
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
   145
29
f621f1df0849 fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents: 26
diff changeset
   146
        def get_root(self):
f621f1df0849 fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents: 26
diff changeset
   147
                return self.root
f621f1df0849 fix install target; correct imports for module renames
"Stephen Hahn <sch@sun.com>"
parents: 26
diff changeset
   148
19
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
   149
        def set_resource(self, resource):
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
   150
                return
c5d16aa074bf begin comments on Image object
"Stephen Hahn <sch@sun.com>"
parents:
diff changeset
   151
50
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   152
        def get_matching_pkgs(self, pfmri):
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   153
                """Exact matches to the given FMRI.  Returns a list of (catalog,
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   154
                pkg) pairs."""
34
8b9613402116 refactor catalog and package to be common; improve bump-server
Stephen Hahn <sch@sun.com>
parents: 33
diff changeset
   155
8b9613402116 refactor catalog and package to be common; improve bump-server
Stephen Hahn <sch@sun.com>
parents: 33
diff changeset
   156
                m = []
8b9613402116 refactor catalog and package to be common; improve bump-server
Stephen Hahn <sch@sun.com>
parents: 33
diff changeset
   157
                for c in self.catalogs.values():
50
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   158
                        m.extend([(c, p) \
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   159
                            for p in c.get_matching_pkgs(pfmri, None)])
34
8b9613402116 refactor catalog and package to be common; improve bump-server
Stephen Hahn <sch@sun.com>
parents: 33
diff changeset
   160
8b9613402116 refactor catalog and package to be common; improve bump-server
Stephen Hahn <sch@sun.com>
parents: 33
diff changeset
   161
                return m
32
c26788b7217c begin client install; sequences are now timestamps; skeleton ELF module
Stephen Hahn <sch@sun.com>
parents: 30
diff changeset
   162
50
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   163
        def get_regex_matching_fmris(self, regex):
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   164
                """FMRIs matching the given regular expression.  Returns of a
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   165
                list of (catalog, PkgFmri) pairs."""
45
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
   166
50
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   167
                m = []
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   168
                for c in self.catalogs.values():
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   169
                        m.extend([(c, p) \
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   170
                            for p in c.get_regex_matching_fmris(regex)])
45
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
   171
50
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   172
                return m
45
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
   173
50
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   174
        def has_manifest(self, fmri):
45
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
   175
                mpath = fmri.get_dir_path()
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
   176
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
   177
                local_mpath = "%s/pkg/%s/manifest" % (self.imgdir, mpath)
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
   178
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
   179
                if (os.path.exists(local_mpath)):
50
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   180
                        return True
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   181
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   182
                return False
45
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
   183
50
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   184
        def get_manifest(self, fmri):
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   185
                m = manifest.Manifest()
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   186
                mcontent = file("%s/pkg/%s/manifest" % 
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   187
                    (self.imgdir, fmri.get_dir_path())).read()
51
d04d55e16d0b Simplify the action API and add real support for client-side installation
Danek Duvall <danek.duvall@sun.com>
parents: 50
diff changeset
   188
                m.set_fmri(fmri)
50
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   189
                m.set_content(mcontent)
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   190
                return m
45
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
   191
59
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   192
        def get_version_installed(self, pfmri):
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   193
                pd = pfmri.get_pkg_stem()
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   194
                pdir = "%s/pkg/%s" % (self.imgdir,
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   195
                    pfmri.get_dir_path(stemonly = True))
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   196
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   197
                try:
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   198
                        pkgs_inst = [ urllib.unquote("%s@%s" % (pd, vd))
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   199
                            for vd in os.listdir(pdir)
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   200
                            if os.path.exists("%s/%s/installed" % (pdir, vd)) ]
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   201
                except OSError:
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   202
                        raise LookupError, "no packages ever installed"
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   203
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   204
                if len(pkgs_inst) == 0:
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   205
                        raise LookupError, "no packages installed"
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   206
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   207
                assert len(pkgs_inst) <= 1
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   208
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   209
                return fmri.PkgFmri(pkgs_inst[0], None)
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   210
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   211
        def is_installed(self, fmri):
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   212
                """Check that the version given in the FMRI or a successor is
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   213
                installed in the current image."""
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   214
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   215
                try:
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   216
                        v = self.get_version_installed(fmri)
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   217
                except LookupError:
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   218
                        return False
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   219
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   220
                if v.is_successor(fmri):
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   221
                        return True
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   222
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   223
                return False
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   224
67
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   225
        def get_dependents(self, pfmri):
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   226
                """Return a list of the packages directly dependent on the given FMRI."""
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   227
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   228
                thedir = os.path.join(self.imgdir, "index", "depend",
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   229
                    urllib.quote(str(pfmri.get_pkg_stem())[5:], ""))
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   230
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   231
                if not os.path.isdir(thedir):
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   232
                        return []
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   233
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   234
                for v in os.listdir(thedir):
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   235
                        f = fmri.PkgFmri(pfmri.get_pkg_stem() + "@" + v,
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   236
                            self.attrs["Build-Release"])
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   237
                        if pfmri.is_successor(f):
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   238
                                dependents = [
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   239
                                    urllib.unquote(d)
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   240
                                    for d in os.listdir(os.path.join(thedir, v))
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   241
                                ]
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   242
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   243
                return dependents
62c897652bbc Handle dependencies when removing a package.
Danek Duvall <danek.duvall@sun.com>
parents: 63
diff changeset
   244
59
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   245
        def reload_catalogs(self):
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   246
                cdir = "%s/%s" % (self.imgdir, "catalog")
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   247
                for cf in os.listdir(cdir):
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   248
                        c = catalog.Catalog()
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   249
                        c.load("%s/%s" % (cdir, cf))
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   250
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   251
                        self.catalogs[cf] = c
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   252
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   253
                        # XXX XXX
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   254
                        # build up authorities
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   255
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   256
        def display_catalogs(self):
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   257
                for c in self.catalogs.values():
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   258
                        c.display()
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   259
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   260
        def display_inventory(self, args):
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   261
                """XXX Reimplement if we carve out the inventory as a has-a
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   262
                object from image."""
45
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
   263
59
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   264
                opts = []
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   265
                pargs = []
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   266
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   267
                verbose = False
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   268
                upgradable_only = False
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   269
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   270
                if len(args) > 0:
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   271
                         opts, pargs = getopt.getopt(args, "uv")
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   272
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   273
                for opt, arg in opts:
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   274
                        if opt == "-u":
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   275
                                upgradable_only = True
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   276
                        if opt == "-v":
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   277
                                verbose = True
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   278
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   279
                fmt_str = "%-50s %-10s %c%c%c%c"
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   280
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   281
                proot = "%s/pkg" % self.imgdir
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   282
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   283
                pkgs_inst = [ urllib.unquote("%s@%s" % (pd, vd))
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   284
                    for pd in os.listdir(proot)
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   285
                    for vd in os.listdir("%s/%s" % (proot, pd))
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   286
                    if os.path.exists("%s/%s/%s/installed" % (proot, pd, vd)) ]
50
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   287
59
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   288
                if len(pkgs_inst) == 0:
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   289
                        print "pkg: no packages installed"
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   290
                        return
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   291
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   292
                print fmt_str % ("FMRI", "STATE", "U", "F", "I", "X")
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   293
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   294
                for p in pkgs_inst:
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   295
                        f = fmri.PkgFmri(p, None)
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   296
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   297
                        upgradable = "-"
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   298
                        frozen = "-"
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   299
                        incorporated = "-"
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   300
                        excludes = "-"
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   301
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   302
                        if len(self.get_matching_pkgs(f)) > 1:
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   303
                                upgradable = "u"
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   304
                        elif upgradable_only:
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   305
                                continue
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   306
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   307
                        if not verbose:
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   308
                                pf = f.get_short_fmri()
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   309
                        else:
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   310
                                pf = str(f)
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   311
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   312
                        print fmt_str % (pf, "installed", upgradable, frozen,
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   313
                            incorporated, excludes)
eef94b0c0694 require dependencies; dependency following; pkg status; timestamp change
Stephen Hahn <sch@sun.com>
parents: 51
diff changeset
   314
45
8a3f00dea14f catalog refresh; basic catalog listing; precise manifest pulls
Stephen Hahn <sch@sun.com>
parents: 39
diff changeset
   315
50
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   316
if __name__ == "__main__":
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   317
        # XXX Need to construct a trivial image and catalog.
bfcb1661f019 basic image and package plans
Stephen Hahn <sch@sun.com>
parents: 45
diff changeset
   318
        pass