summaryrefslogtreecommitdiffstats
path: root/plugins/grub
diff options
context:
space:
mode:
authorJoel Andres Granados <jgranado@redhat.com>2008-10-28 13:41:58 +0100
committerJoel Andres Granados <jgranado@redhat.com>2008-10-28 13:41:58 +0100
commit11bdc2680d0b0523c0efdd4b3e9adba5496d3232 (patch)
tree7325f5b344cab7fb4139db7df8b88949e28d9ab5 /plugins/grub
parent6832bb37603698412993f166ff8a3317c87beadd (diff)
downloadfirstaidkit-11bdc2680d0b0523c0efdd4b3e9adba5496d3232.tar.gz
firstaidkit-11bdc2680d0b0523c0efdd4b3e9adba5496d3232.tar.xz
firstaidkit-11bdc2680d0b0523c0efdd4b3e9adba5496d3232.zip
Grup Plugin:
1. Correctly parse the partition arguments as we did with the device args. 2. Add the functionality of modifying particular partitions.
Diffstat (limited to 'plugins/grub')
-rw-r--r--plugins/grub/grub.py23
-rw-r--r--plugins/grub/grubUtils.py61
2 files changed, 58 insertions, 26 deletions
diff --git a/plugins/grub/grub.py b/plugins/grub/grub.py
index c215729..7e9604e 100644
--- a/plugins/grub/grub.py
+++ b/plugins/grub/grub.py
@@ -144,13 +144,16 @@ class Grub(Plugin):
self._reporting.info("Searching for locations in which to " \
"install grub.", origin = self)
- if len(self.args.install_to) > 0:
+ if len(self.args.installto_devs)+len(self.args.installto_parts) > 0:
# We install to the selected devices. Since grub-install
# will screat in case the device names are not valid, I think
# its not necesary to check here.
- for dev in self.args.install_to:
+ for dev in self.args.installto_devs:
self.install_grub_devs.append(Dname(dev))
+ for part in self.args.installto_parts:
+ self.install_grub_parts.append(Dname(part))
+
elif self.args.install_all:
# We install to all the devices
for (dev, parts) in self.devices.iteritems():
@@ -268,7 +271,7 @@ class Grub(Plugin):
# Install the grub in all devs pointing at the special root part.
for drive in self.install_grub_devs:
self._reporting.info("Trying to install grub on drive %s, " \
- "pointing to grub directory in %s."%(drive.name(), \
+ "pointing to grub directory in %s."%(drive.path(), \
grubroot.path()), origin = self)
try:
grubUtils.install_grub(grubroot, drive)
@@ -282,6 +285,20 @@ class Grub(Plugin):
self._result = ReturnFailure
return
+ for part in self.install_grub_parts:
+ self._reporting.info("Trying to install grub on part %s, " \
+ "pointing to grub directory in %s." % (part.path(), \
+ grubroot.path()), origin = self)
+ try:
+ grubUtils.install_grub(grubroot, part)
+ except:
+ self._reporting.error("Grub installation on part %s, " \
+ "pointing to grub directory in %s has failed." % \
+ (part.path(), grubroot.path()), \
+ origin = self)
+ self._result = ReturnFailure
+ return
+
self._reporting.info("Grub has successfully installed in all the " \
"chosen devices.", origin = self)
self._result = ReturnSuccess
diff --git a/plugins/grub/grubUtils.py b/plugins/grub/grubUtils.py
index 1959719..d4bba41 100644
--- a/plugins/grub/grubUtils.py
+++ b/plugins/grub/grubUtils.py
@@ -345,20 +345,26 @@ def get_grub_opts(args):
--install-all : This option will tell grub plugin that it must not ignore
any devices that have other bootloaders. In other word
its telling the plugin to install in all possible places.
- In case --install-to is also defined allong side this
- options, we will choose the list from install-to
-
- --install-to=dev1,dev2... : This tells the grub plugin the specific
- devices that should be considered for
- installation. All other devices will be
- ignored. If install-all is selected with
- this option, we will prefer the list
- described in install-to.
+ In case --installto-devs is also defined allong side this
+ options, we will choose the list from installto-devs
--install-auto : This will try to avoid overwriting other bootloaders.
- --recover=dev1,dev2 : Same as --install-to, just more intuitive for the
- user that does not know how grub works.
+ --installto-devs=dev1,dev2... : This tells the grub plugin the specific
+ devices that should be considered for
+ installation. All other devices will be
+ ignored. If install-all is selected with
+ this option, we will prefer the list
+ described in installto-devs.
+
+ --installto-parts=part1,part2... : The same as install to devs but give
+ a list of partitions.
+
+ --recover-devs=dev1,dev2 : Same as --installto-devs, just more intuitive
+ for the user that does not know how grub works.
+
+ --recover-parts=part1,part2 : Same as recover-devs but specifies the
+ partitions to be recovered.
We will return a object with all de relative information.
"""
@@ -366,13 +372,16 @@ def get_grub_opts(args):
# Create the object with the argument decision.
class grub_args:
install_all = False
- install_to = []
install_auto = False
+ installto_devs = []
+ installto_parts = []
retval = grub_args()
# Parse the args string
optsstr = ""
- longopts = ["install-all", "install-to="]
+ longopts = ["install-all", "install-auto", \
+ "installto-devs=", "recover-devs=", \
+ "installto-parts=", "recover-parts="]
try:
(opts, vals) = getopt.getopt( args.split(), optsstr, longopts )
except:
@@ -384,21 +393,27 @@ def get_grub_opts(args):
for (opt, val) in opts:
- if opt == "--install-all" and len(retval.install_to) == 0:
- if len(retval.install_to) == 0:
- retval.install_all = True
- retval.install_auto = False
+ # install all will be considered if no devs or parts have been parsed.
+ if opt == "--install-all" and \
+ (len(retval.installto_devs) + len(retval.installto_parts) == 0):
+ retval.install_all = True
+ retval.install_auto = False
+
+ # install auto is valid only when all other optiosn are not passed.
+ if opt == "--install-auto" and not retval.install_all and \
+ (len(retval.installto_devs) + len(retval.installto_parts) == 0):
+ retval.install_auto = True
- if opt in ( "--install-to", "--recover"):
- retval.install_to = val.split(',')
+ if opt in ( "--installto-devs", "--recover-devs" ):
+ retval.installto_devs = val.split(',')
retval.install_all = False
retval.install_auto = False
+ if opt in ( "--installto-parts", "--recover-parts" ):
+ retval.installto_parts = val.split(',')
+ retval.install_all = False
+ retval.install_auto = False
- if opt == "--install-auto":
- if len(retval.install_to) == 0 and \
- not retval.install_all:
- retval.install_auto = True
return retval