~racb/ubuntu/precise/cobbler/858860

« back to all changes in this revision

Viewing changes to .pc/49_ubuntu_add_arm_arch_support.patch/cobbler/item_repo.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short, Chuck Short, Clint Byrum, Robie Basak
  • Date: 2011-11-15 12:35:40 UTC
  • mfrom: (1.1.8)
  • Revision ID: package-import@ubuntu.com-20111115123540-5g139uuhg7z0hv5d
Tags: 2.2.2-0ubuntu1
[Chuck Short]
* New upstream release:
  + Use dh_python2 everywhere.
  + Folded debian/patches/49_ubuntu_add_arm_arch_support.patch
    and debian/patches/56_ubuntu_arm_generate_pxe_files.patch
    into one patch for easier upstreaming.
  + Dropped debian/patches/50_fix_cobbler_timezone.patch:
    Fix upstream.
  + Dropped debian/patches/47_ubuntu_add_oneiric_codename.patch
    in favor of debian/patches/47_ubuntu_add_codenames.patch:
    It adds "precise" and drops unsupported releases as well.
  + Dropped debian/patches/41_update_tree_path_with_arch.patch:
    No longer needed.
  + Dropped debian/patches/55_ubuntu_branding.patch: Will be moved
    to orchestra

 [Clint Byrum]
 * debian/cobbler.postinst: create users.digest mode 0600 so it
   is not world readable. (LP: #858860)
 * debian/control: cobbler needs to depend on python-cobbler
   (LP: #863738)
 * debian/patches/58_fix_egg_cache.patch: Do not point dangerous
   PYTHON_EGG_CACHE at world writable directory. (LP: #858875)
 * debian/cobbler-common.install: remove users.digest as it is
   not required and contains a known password that would leave
   cobblerd vulnerable if started before configuration is done
 * debian/cobbler-web.postinst: fix perms on webui_sessions to
   be more secure (LP: #863755)

 [Robie Basak]
 * Backport safe YAML load from upstream. (LP: #858883)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
"""
2
 
A Cobbler repesentation of a yum repo.
3
 
 
4
 
Copyright 2006-2009, Red Hat, Inc
5
 
Michael DeHaan <mdehaan@redhat.com>
6
 
 
7
 
This program is free software; you can redistribute it and/or modify
8
 
it under the terms of the GNU General Public License as published by
9
 
the Free Software Foundation; either version 2 of the License, or
10
 
(at your option) any later version.
11
 
 
12
 
This program is distributed in the hope that it will be useful,
13
 
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
GNU General Public License for more details.
16
 
 
17
 
You should have received a copy of the GNU General Public License
18
 
along with this program; if not, write to the Free Software
19
 
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20
 
02110-1301  USA
21
 
"""
22
 
 
23
 
import utils
24
 
import item
25
 
from cexceptions import *
26
 
from utils import _
27
 
import time
28
 
import codes
29
 
 
30
 
# this datastructure is described in great detail in item_distro.py -- read the comments there.
31
 
 
32
 
FIELDS = [
33
 
  ["arch","",0,"Arch",True,"ex: i386, x86_64",['i386','x86_64','ia64','ppc','s390', 'noarch', 'src'],"str"],
34
 
  ["breed","",0,"Breed",True,"",codes.VALID_REPO_BREEDS,"str"],
35
 
  ["comment","",0,"Comment",True,"Free form text description",0,"str"],
36
 
  ["ctime",0,0,"",False,"",0,"float"],
37
 
  ["depth",2,0,"",False,"",0,"float"],
38
 
  ["keep_updated",True,0,"Keep Updated",True,"Update this repo on next 'cobbler reposync'?",0,"bool"],
39
 
  ["mirror",None,0,"Mirror",True,"Address of yum or rsync repo to mirror",0,"str"],
40
 
  ["mtime",0,0,"",False,"",0,"float"],
41
 
  ["name","",0,"Name",True,"Ex: f10-i386-updates",0,"str"],
42
 
  ["owners","SETTINGS:default_ownership",0,"Owners",True,"Owners list for authz_ownership (space delimited)",[],"list"],
43
 
  ["parent",None,0,"",False,"",0,"str"],
44
 
  ["rpm_list",[],0,"RPM List",True,"Mirror just these RPMs (yum only)",0,"list"],
45
 
#  ["os_version","",0,"OS Version",True,"ex: rhel4"],
46
 
  ["uid",None,0,"",False,"",0,"str"],
47
 
  ["createrepo_flags",'<<inherit>>',0,"Createrepo Flags",True,"Flags to use with createrepo",0,"dict"],
48
 
  ["environment",{},0,"Environment Variables",True,"Use these environment variables during commands (key=value, space delimited)",0,"dict"],
49
 
  ["mirror_locally",True,0,"Mirror locally",True,"Copy files or just reference the repo externally?",0,"bool"],
50
 
  ["priority",99,0,"Priority",True,"Value for yum priorities plugin, if installed",0,"int"],
51
 
  ["yumopts",{},0,"Yum Options",True,"Options to write to yum config file",0,"dict"]
52
 
]
53
 
 
54
 
class Repo(item.Item):
55
 
 
56
 
    TYPE_NAME = _("repo")
57
 
    COLLECTION_TYPE = "repo"
58
 
 
59
 
    def make_clone(self):
60
 
        ds = self.to_datastruct()
61
 
        cloned = Repo(self.config)
62
 
        cloned.from_datastruct(ds)
63
 
        return cloned
64
 
 
65
 
    def get_fields(self):
66
 
        return FIELDS
67
 
 
68
 
    def _guess_breed(self):
69
 
        # backwards compatibility
70
 
        if (self.breed == "" or self.breed is None):
71
 
           if self.mirror.startswith("http://") or self.mirror.startswith("ftp://"):
72
 
              self.set_breed("yum")
73
 
           elif self.mirror.startswith("rhn://"):
74
 
              self.set_breed("rhn")
75
 
           else:
76
 
              self.set_breed("rsync")
77
 
 
78
 
    def set_mirror(self,mirror):
79
 
        """
80
 
        A repo is (initially, as in right now) is something that can be rsynced.
81
 
        reposync/repotrack integration over HTTP might come later.
82
 
        """
83
 
        self.mirror = mirror
84
 
        if self.arch is None or self.arch == "":
85
 
           if mirror.find("x86_64") != -1:
86
 
              self.set_arch("x86_64")
87
 
           elif mirror.find("x86") != -1 or mirror.find("i386") != -1:
88
 
              self.set_arch("i386")
89
 
           elif mirror.find("ia64") != -1:
90
 
              self.set_arch("ia64")
91
 
           elif mirror.find("s390") != -1:
92
 
              self.set_arch("s390x")
93
 
        self._guess_breed()
94
 
        return True
95
 
 
96
 
    def set_keep_updated(self,keep_updated):
97
 
        """
98
 
    This allows the user to disable updates to a particular repo for whatever reason.
99
 
    """
100
 
        self.keep_updated = utils.input_boolean(keep_updated)
101
 
        return True
102
 
 
103
 
    def set_yumopts(self,options,inplace=False):
104
 
        """
105
 
        Kernel options are a space delimited list,
106
 
        like 'a=b c=d e=f g h i=j' or a hash.
107
 
        """
108
 
        (success, value) = utils.input_string_or_hash(options,allow_multiples=False)
109
 
        if not success:
110
 
            raise CX(_("invalid yum options"))
111
 
        else:
112
 
            if inplace:
113
 
                for key in value.keys():
114
 
                    self.yumopts[key] = value[key]
115
 
            else:
116
 
                self.yumopts = value
117
 
            return True
118
 
 
119
 
    def set_environment(self,options,inplace=False):
120
 
        """
121
 
        Yum can take options from the environment.  This puts them there before
122
 
        each reposync.
123
 
        """
124
 
        (success, value) = utils.input_string_or_hash(options,allow_multiples=False)
125
 
        if not success:
126
 
            raise CX(_("invalid environment options"))
127
 
        else:
128
 
            if inplace:
129
 
                for key in value.keys():
130
 
                    self.environment[key] = value[key]
131
 
            else:
132
 
                self.environment = value
133
 
            return True
134
 
 
135
 
 
136
 
    def set_priority(self,priority):
137
 
        """
138
 
        Set the priority of the repository.  1= highest, 99=default
139
 
        Only works if host is using priorities plugin for yum.
140
 
        """
141
 
        try:
142
 
           priority = int(str(priority))
143
 
        except:
144
 
           raise CX(_("invalid priority level: %s") % priority)
145
 
        self.priority = priority
146
 
        return True
147
 
 
148
 
    def set_rpm_list(self,rpms):
149
 
        """
150
 
        Rather than mirroring the entire contents of a repository (Fedora Extras, for instance,
151
 
        contains games, and we probably don't want those), make it possible to list the packages
152
 
        one wants out of those repos, so only those packages + deps can be mirrored.
153
 
        """
154
 
        self.rpm_list = utils.input_string_or_list(rpms)
155
 
        return True
156
 
 
157
 
    def set_createrepo_flags(self,createrepo_flags):
158
 
        """
159
 
        Flags passed to createrepo when it is called.  Common flags to use would be
160
 
        -c cache or -g comps.xml to generate group information.
161
 
        """
162
 
        if createrepo_flags is None:
163
 
            createrepo_flags = ""
164
 
        self.createrepo_flags = createrepo_flags
165
 
        return True
166
 
 
167
 
    def set_breed(self,breed):
168
 
        if breed:
169
 
            return utils.set_repo_breed(self,breed)
170
 
 
171
 
    def set_os_version(self,os_version):
172
 
        if os_version:
173
 
            return utils.set_repo_os_version(self,os_version)
174
 
 
175
 
    def set_arch(self,arch):
176
 
        """
177
 
        Override the arch used for reposync
178
 
        """
179
 
        return utils.set_arch(self,arch,repo=True)
180
 
 
181
 
    def set_mirror_locally(self,value):
182
 
        self.mirror_locally = utils.input_boolean(value)
183
 
        return True
184
 
 
185
 
    def get_parent(self):
186
 
        """
187
 
        currently the Cobbler object space does not support subobjects of this object
188
 
        as it is conceptually not useful.
189
 
        """
190
 
        return None
191
 
 
192
 
    def check_if_valid(self):
193
 
        if self.name is None:
194
 
            raise CX("name is required")
195
 
        if self.mirror is None:
196
 
            raise CX("Error with repo %s - mirror is required" % (self.name))
197
 
 
198