[PATCH] (for pykickstart) Add a source option to repo declaration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As per conversations over on fedora-livecd-list, we'd like a reliable
method to indicate/detect what repos are for source vs which are for
built packages.  This allows consumers to parse the repo list and only
enable the correct repos at the appropriate time and reuse existing yum
objects to interact with source at a later point in the program.

My patch extents the FC6_RepoData and FC6_Repo with F8 counterparts,
and then sets the correct versions in control.py for F8.  It adds a
boolian option "--source" that stores true if given and is accessible
through "self.source".

This may need some changes in Anaconda, but not immediately if nobody
uses --source in their kickstart configs.  Or even if they do, anaconda
would just happily add the repos anyway and no harm is done except for
more repo processing time.

I'm completely open for discussion on better ways to accomplish this
but I figured I'd open the conversation with code (:

(also, is there a better place to discuss pykickstart?)

-- 
Jesse Keating
Fedora -- All my bits are free, are yours?
? source-repo.patch
? pykickstart/commands/.user.py.swp
Index: pykickstart/commands/repo.py
===================================================================
RCS file: /usr/local/CVS/pykickstart/pykickstart/commands/repo.py,v
retrieving revision 1.3
diff -u -r1.3 repo.py
--- pykickstart/commands/repo.py	9 Aug 2007 18:51:38 -0000	1.3
+++ pykickstart/commands/repo.py	19 Aug 2007 11:46:13 -0000
@@ -42,6 +42,18 @@
 
         return "repo --name=%s %s\n" % (self.name, urlopt)
 
+class F8_RepoData(BaseData):
+    def __init__(self, baseurl="", mirrorlist="", name="", source=False):
+        FC6_RepoData.__init__(self, baseurl, mirrorlist, name)
+
+        self.source = source
+
+    def __str__(self):
+        retval = FC6_RepoData.__str__(self)
+
+        if self.source:
+            return retval.strip() + " --source\n"
+
 class FC6_Repo(KickstartCommand):
     def __init__(self, writePriority=0, repoList=None):
         KickstartCommand.__init__(self, writePriority)
@@ -80,3 +92,25 @@
 
     def add(self, newObj):
         self.repoList.append(newObj)
+
+class F8_Repo(FC6_Repo)
+    def parse(self, args):
+        op = KSOptionParser(lineno=self.lineno)
+        op.add_option("--name", dest="name", required=1)
+        op.add_option("--baseurl")
+        op.add_option("--mirrorlist")
+        op.add_option("--source", action="store_true", default=False))
+
+        (opts, extra) = op.parse_args(args=args)
+
+        # This is lame, but I can't think of a better way to make sure only
+        # one of these two is specified.
+        if opts.baseurl and opts.mirrorlist:
+            raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Only one of --baseurl and --mirrorlist may be specified for repo command."))
+
+        if not opts.baseurl and not opts.mirrorlist:
+            raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --baseurl or --mirrorlist must be specified for repo command."))
+
+        rd = F8_RepoData()
+        self._setToObj(op, opts, rd)
+        self.add(rd)
Index: pykickstart/handlers/control.py
===================================================================
RCS file: /usr/local/CVS/pykickstart/pykickstart/handlers/control.py,v
retrieving revision 1.13
diff -u -r1.13 control.py
--- pykickstart/handlers/control.py	9 Aug 2007 18:51:38 -0000	1.13
+++ pykickstart/handlers/control.py	19 Aug 2007 11:46:13 -0000
@@ -332,7 +332,7 @@
         "poweroff": reboot.FC6_Reboot,
         "raid": raid.F7_Raid,
         "reboot": reboot.FC6_Reboot,
-        "repo": repo.FC6_Repo,
+        "repo": repo.F8_Repo,
         "rootpw": rootpw.F8_RootPw,
         "selinux": selinux.FC3_SELinux,
         "services": services.FC6_Services,
@@ -576,7 +576,7 @@
         "NetworkData": network.FC6_NetworkData,
         "PartData": partition.FC4_PartData,
         "RaidData": raid.F7_RaidData,
-        "RepoData": repo.FC6_RepoData,
+        "RepoData": repo.F8_RepoData,
         "UserData": user.F8_UserData,
         "VolGroupData": volgroup.FC3_VolGroupData,
         "ZFCPData": zfcp.FC3_ZFCPData,

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux