Updated chroot's cleanup function
[tools/mic.git] / micng / utils / kscommands / moblinrepo.py
1 #!/usr/bin/python -tt
2 #
3 # Yi Yang <yi.y.yang@intel.com>
4 #
5 # Copyright 2008, 2009, 2010 Intel, Inc.
6 #
7 # This copyrighted material is made available to anyone wishing to use, modify,
8 # copy, or redistribute it subject to the terms and conditions of the GNU
9 # General Public License v.2.  This program is distributed in the hope that it
10 # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
11 # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 # See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, write to the Free Software Foundation, Inc., 51
16 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  Any Red Hat
17 # trademarks that are incorporated in the source code or documentation are not
18 # subject to the GNU General Public License and may only be used or replicated
19 # with the express permission of Red Hat, Inc.
20 #
21 from pykickstart.base import *
22 from pykickstart.errors import *
23 from pykickstart.options import *
24 from pykickstart.commands.repo import *
25
26 class Moblin_RepoData(F8_RepoData):
27     def __init__(self, baseurl="", mirrorlist="", name="", priority=None,
28                  includepkgs=[], excludepkgs=[], save=False, proxy=None,
29                  proxy_username=None, proxy_password=None, debuginfo=False, source=False, gpgkey=None, disable=False):
30         F8_RepoData.__init__(self, baseurl=baseurl, mirrorlist=mirrorlist,
31                              name=name,  includepkgs=includepkgs,
32                              excludepkgs=excludepkgs)
33         self.save = save
34         self.proxy = proxy
35         self.proxy_username = proxy_username
36         self.proxy_password = proxy_password
37         self.debuginfo = debuginfo
38         self.disable = disable
39         self.source = source
40         self.gpgkey = gpgkey
41
42     def _getArgsAsStr(self):
43         retval = F8_RepoData._getArgsAsStr(self)
44
45         if self.save:
46             retval += " --save"
47         if self.proxy:
48             retval += " --proxy=%s" % self.proxy
49         if self.proxy_username:
50             retval += " --proxyuser=%s" % self.proxy_username
51         if self.proxy_password:
52             retval += " --proxypasswd=%s" % self.proxy_password
53         if self.debuginfo:
54             retval += " --debuginfo"
55         if self.source:
56             retval += " --source"
57         if self.gpgkey:
58             retval += " --gpgkey=%s" % self.gpgkey
59         if self.disable:
60             retval += " --disable"
61
62         return retval
63
64 class Moblin_Repo(F8_Repo):
65     def __init__(self, writePriority=0, repoList=None):
66         F8_Repo.__init__(self, writePriority, repoList)
67
68     def __str__(self):
69         retval = ""
70         for repo in self.repoList:
71             retval += repo.__str__()
72
73         return retval
74
75     def _getParser(self):
76         def list_cb (option, opt_str, value, parser):
77             for d in value.split(','):
78                 parser.values.ensure_value(option.dest, []).append(d)
79
80         op = F8_Repo._getParser(self)
81         op.add_option("--save", action="store_true", dest="save",
82                       default=False)
83         op.add_option("--proxy", type="string", action="store", dest="proxy",
84                       default=None, nargs=1)
85         op.add_option("--proxyuser", type="string", action="store", dest="proxy_username",
86                       default=None, nargs=1)
87         op.add_option("--proxypasswd", type="string", action="store", dest="proxy_password",
88                       default=None, nargs=1)
89         op.add_option("--debuginfo", action="store_true", dest="debuginfo",
90                       default=False)
91         op.add_option("--source", action="store_true", dest="source",
92                       default=False)
93         op.add_option("--disable", action="store_true", dest="disable",
94                       default=False)
95         op.add_option("--gpgkey", type="string", action="store", dest="gpgkey",
96                       default=None, nargs=1)
97         return op