summaryrefslogtreecommitdiffstats
path: root/scripts/lib/mic/3rdparty/pykickstart/commands/repo.py
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@linux.intel.com>2013-08-24 15:31:34 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-10-01 22:56:03 +0100
commit9fc88f96d40b17c90bac53b90045a87b2d2cff84 (patch)
tree63010e5aabf895697655baf89bd668d6752b3f97 /scripts/lib/mic/3rdparty/pykickstart/commands/repo.py
parent53a1d9a788fd9f970af980da2ab975cca60685c4 (diff)
downloadpoky-9fc88f96d40b17c90bac53b90045a87b2d2cff84.tar.gz
wic: Add mic w/pykickstart
This is the starting point for the implemention described in [YOCTO 3847] which came to the conclusion that it would make sense to use kickstart syntax to implement image creation in OpenEmbedded. I subsequently realized that there was an existing tool that already implemented image creation using kickstart syntax, the Tizen/Meego mic tool. As such, it made sense to use that as a starting point - this commit essentially just copies the relevant Python code from the MIC tool to the scripts/lib dir, where it can be accessed by the previously created wic tool. Most of this will be removed or renamed by later commits, since we're initially focusing on partitioning only. Care should be taken so that we can easily add back any additional functionality should we decide later to expand the tool, though (we may also want to contribute our local changes to the mic tool to the Tizen project if it makes sense, and therefore should avoid gratuitous changes to the original code if possible). Added the /mic subdir from Tizen mic repo as a starting point: git clone git://review.tizen.org/tools/mic.git For reference, the top commit: commit 20164175ddc234a17b8a12c33d04b012347b1530 Author: Gui Chen <gui.chen@intel.com> Date: Sun Jun 30 22:32:16 2013 -0400 bump up to 0.19.2 Also added the /plugins subdir, moved to under the /mic subdir (to match the default plugin_dir location in mic.conf.in, which was renamed to yocto-image.conf (moved and renamed by later patches) and put into /scripts. (From OE-Core rev: 31f0360f1fd4ebc9dfcaed42d1c50d2448b4632e) Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart/commands/repo.py')
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/repo.py249
1 files changed, 249 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/repo.py b/scripts/lib/mic/3rdparty/pykickstart/commands/repo.py
new file mode 100644
index 0000000000..543ef947c1
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/repo.py
@@ -0,0 +1,249 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007, 2008, 2009 Red Hat, Inc.
5#
6# This copyrighted material is made available to anyone wishing to use, modify,
7# copy, or redistribute it subject to the terms and conditions of the GNU
8# General Public License v.2. This program is distributed in the hope that it
9# will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10# implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11# See the GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License along with
14# this program; if not, write to the Free Software Foundation, Inc., 51
15# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16# trademarks that are incorporated in the source code or documentation are not
17# subject to the GNU General Public License and may only be used or replicated
18# with the express permission of Red Hat, Inc.
19#
20from pykickstart.base import *
21from pykickstart.constants import *
22from pykickstart.errors import *
23from pykickstart.options import *
24
25import gettext
26import warnings
27_ = lambda x: gettext.ldgettext("pykickstart", x)
28
29class FC6_RepoData(BaseData):
30 removedKeywords = BaseData.removedKeywords
31 removedAttrs = BaseData.removedAttrs
32
33 def __init__(self, *args, **kwargs):
34 BaseData.__init__(self, *args, **kwargs)
35 self.baseurl = kwargs.get("baseurl", "")
36 self.mirrorlist = kwargs.get("mirrorlist", None)
37 self.name = kwargs.get("name", "")
38
39 def __eq__(self, y):
40 return self.name == y.name
41
42 def _getArgsAsStr(self):
43 retval = ""
44
45 if self.baseurl:
46 retval += "--baseurl=%s" % self.baseurl
47 elif self.mirrorlist:
48 retval += "--mirrorlist=%s" % self.mirrorlist
49
50 return retval
51
52 def __str__(self):
53 retval = BaseData.__str__(self)
54 retval += "repo --name=\"%s\" %s\n" % (self.name, self._getArgsAsStr())
55 return retval
56
57class F8_RepoData(FC6_RepoData):
58 removedKeywords = FC6_RepoData.removedKeywords
59 removedAttrs = FC6_RepoData.removedAttrs
60
61 def __init__(self, *args, **kwargs):
62 FC6_RepoData.__init__(self, *args, **kwargs)
63 self.cost = kwargs.get("cost", None)
64 self.includepkgs = kwargs.get("includepkgs", [])
65 self.excludepkgs = kwargs.get("excludepkgs", [])
66
67 def _getArgsAsStr(self):
68 retval = FC6_RepoData._getArgsAsStr(self)
69
70 if self.cost:
71 retval += " --cost=%s" % self.cost
72 if self.includepkgs:
73 retval += " --includepkgs=\"%s\"" % ",".join(self.includepkgs)
74 if self.excludepkgs:
75 retval += " --excludepkgs=\"%s\"" % ",".join(self.excludepkgs)
76
77 return retval
78
79class F11_RepoData(F8_RepoData):
80 removedKeywords = F8_RepoData.removedKeywords
81 removedAttrs = F8_RepoData.removedAttrs
82
83 def __init__(self, *args, **kwargs):
84 F8_RepoData.__init__(self, *args, **kwargs)
85 self.ignoregroups = kwargs.get("ignoregroups", None)
86
87 def _getArgsAsStr(self):
88 retval = F8_RepoData._getArgsAsStr(self)
89
90 if self.ignoregroups:
91 retval += " --ignoregroups=true"
92 return retval
93
94class F13_RepoData(F11_RepoData):
95 removedKeywords = F11_RepoData.removedKeywords
96 removedAttrs = F11_RepoData.removedAttrs
97
98 def __init__(self, *args, **kwargs):
99 F11_RepoData.__init__(self, *args, **kwargs)
100 self.proxy = kwargs.get("proxy", "")
101
102 def _getArgsAsStr(self):
103 retval = F11_RepoData._getArgsAsStr(self)
104
105 if self.proxy:
106 retval += " --proxy=\"%s\"" % self.proxy
107
108 return retval
109
110class F14_RepoData(F13_RepoData):
111 removedKeywords = F13_RepoData.removedKeywords
112 removedAttrs = F13_RepoData.removedAttrs
113
114 def __init__(self, *args, **kwargs):
115 F13_RepoData.__init__(self, *args, **kwargs)
116 self.noverifyssl = kwargs.get("noverifyssl", False)
117
118 def _getArgsAsStr(self):
119 retval = F13_RepoData._getArgsAsStr(self)
120
121 if self.noverifyssl:
122 retval += " --noverifyssl"
123
124 return retval
125
126RHEL6_RepoData = F14_RepoData
127
128F15_RepoData = F14_RepoData
129
130class FC6_Repo(KickstartCommand):
131 removedKeywords = KickstartCommand.removedKeywords
132 removedAttrs = KickstartCommand.removedAttrs
133
134 urlRequired = True
135
136 def __init__(self, writePriority=0, *args, **kwargs):
137 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
138 self.op = self._getParser()
139
140 self.repoList = kwargs.get("repoList", [])
141
142 def __str__(self):
143 retval = ""
144 for repo in self.repoList:
145 retval += repo.__str__()
146
147 return retval
148
149 def _getParser(self):
150 op = KSOptionParser()
151 op.add_option("--name", dest="name", required=1)
152 op.add_option("--baseurl")
153 op.add_option("--mirrorlist")
154 return op
155
156 def parse(self, args):
157 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
158
159 if len(extra) != 0:
160 mapping = {"command": "repo", "options": extra}
161 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping)
162
163 # This is lame, but I can't think of a better way to make sure only
164 # one of these two is specified.
165 if opts.baseurl and opts.mirrorlist:
166 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --baseurl and --mirrorlist may be specified for repo command."))
167
168 if self.urlRequired and not opts.baseurl and not opts.mirrorlist:
169 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --baseurl or --mirrorlist must be specified for repo command."))
170
171 rd = self.handler.RepoData()
172 self._setToObj(self.op, opts, rd)
173 rd.lineno = self.lineno
174
175 # Check for duplicates in the data list.
176 if rd in self.dataList():
177 warnings.warn(_("A repo with the name %s has already been defined.") % rd.name)
178
179 return rd
180
181 def dataList(self):
182 return self.repoList
183
184class F8_Repo(FC6_Repo):
185 removedKeywords = FC6_Repo.removedKeywords
186 removedAttrs = FC6_Repo.removedAttrs
187
188 def __str__(self):
189 retval = ""
190 for repo in self.repoList:
191 retval += repo.__str__()
192
193 return retval
194
195 def _getParser(self):
196 def list_cb (option, opt_str, value, parser):
197 for d in value.split(','):
198 parser.values.ensure_value(option.dest, []).append(d)
199
200 op = FC6_Repo._getParser(self)
201 op.add_option("--cost", action="store", type="int")
202 op.add_option("--excludepkgs", action="callback", callback=list_cb,
203 nargs=1, type="string")
204 op.add_option("--includepkgs", action="callback", callback=list_cb,
205 nargs=1, type="string")
206 return op
207
208 def methodToRepo(self):
209 if not self.handler.method.url:
210 raise KickstartError, formatErrorMsg(self.handler.method.lineno, msg=_("Method must be a url to be added to the repo list."))
211 reponame = "ks-method-url"
212 repourl = self.handler.method.url
213 rd = self.handler.RepoData(name=reponame, baseurl=repourl)
214 return rd
215
216class F11_Repo(F8_Repo):
217 removedKeywords = F8_Repo.removedKeywords
218 removedAttrs = F8_Repo.removedAttrs
219
220 def _getParser(self):
221 op = F8_Repo._getParser(self)
222 op.add_option("--ignoregroups", action="store", type="ksboolean")
223 return op
224
225class F13_Repo(F11_Repo):
226 removedKeywords = F11_Repo.removedKeywords
227 removedAttrs = F11_Repo.removedAttrs
228
229 def _getParser(self):
230 op = F11_Repo._getParser(self)
231 op.add_option("--proxy")
232 return op
233
234class F14_Repo(F13_Repo):
235 removedKeywords = F13_Repo.removedKeywords
236 removedAttrs = F13_Repo.removedAttrs
237
238 def _getParser(self):
239 op = F13_Repo._getParser(self)
240 op.add_option("--noverifyssl", action="store_true", default=False)
241 return op
242
243RHEL6_Repo = F14_Repo
244
245class F15_Repo(F14_Repo):
246 removedKeywords = F14_Repo.removedKeywords
247 removedAttrs = F14_Repo.removedAttrs
248
249 urlRequired = False