Re: Update %package section

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

 



> I would like to ask you on one thing.
> With pykickstart I read anaconda-ks.cfg file.
> And I would like to modify %package section from Python script.
> I would like to delete some of the groups and some of then add it.
> 
> Can you advice me how to do it?
> 
> My code snippet looks like:
> 
> ~~~
> from pykickstart.parser import *
> ....
> ks = KickstartParser(makeVersion())
> ks.readKickstart(system_ks_path)
> ks.handler.packages.add(packages)
> ~~~

add just takes a list of strings, right from a kickstart file.  You can
call that to easily add stuff to the list.  For removing, here's what
you need to know:

* ks.handler.packages.environment holds just a single variable, and it's
  a string.  You can put whatever you want in there.

* ks.handler.packages.packageList and .excludedList are just lists of
  strings.  You can put whatever you want in those too.  You could also
  remove something from .packageList by using all the standard python
  list operations.  If you want to simulate the behavior of having
  "-package" in a kickstart file, you should also add it to
  .excludedList.  This is what add will do if you pass it ["-package"].

* ks.handler.packages.groupList and excludedGrouplist are lists of Group
  objects.  A Group object supports all the usual __lt__, __eq__, __ne__,
  etc. operations.  If you want to remove a group, you should be able to
  do something like this:

  x = Group(name="GroupIDontLike")
  ks.handler.packages.groupList.remove(x)

Hope that helps.

- Chris

_______________________________________________
Kickstart-list mailing list
Kickstart-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/kickstart-list



[Index of Archives]     [Red Hat General]     [CentOS Users]     [Fedora Users]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux