3 # Purpose: install grml-system to usb-device
4 # Authors: grml-team (grml.org), (c) Michael Prokop <mika@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2 or any later version.
7 ################################################################################
12 from optparse import OptionParser
15 usage = "usage: %prog [options] arg1 arg2"
16 parser = OptionParser(usage=usage)
18 parser.add_option("--bootoptions", dest="bootoptions", action="store", type="string",
19 help="use specified bootoptions as defaut")
20 parser.add_option("--dry-run", dest="dryrun", action="store_true",
21 help="do not actually execute any commands")
22 parser.add_option("--fat16", dest="fat16", action="store_true",
23 help="format specified partition with FAT16")
24 parser.add_option("--force", dest="force", action="store_true",
25 help="force any actions requiring manual interaction")
26 parser.add_option("--grub", dest="grub", action="store_true",
27 help="install grub bootloader instead of syslinux")
28 parser.add_option("--initrd", dest="initrd", action="store", type="string",
29 help="install specified initrd instead of the default")
30 parser.add_option("--kernel", dest="kernel", action="store", type="string",
31 help="install specified kernel instead of the default")
32 parser.add_option("--mbr", dest="mbr", action="store_true",
33 help="install master boot record (MBR) on the device")
34 parser.add_option("--squashfs", dest="squashfs", action="store", type="string",
35 help="install specified squashfs file instead of the default")
36 parser.add_option("--verbose", dest="verbose", action="store_true",
37 help="enable verbose mode")
38 parser.add_option("-v", "--version", dest="version", action="store_true",
39 help="display version and exit")
41 (options, args) = parser.parse_args()
44 # FIXME: implement argument handling
46 """Wrapper for executing a command. Either really executes
47 the command (default) or when using --dry-run commandline option
48 just displays what would be executed."""
50 print "would execute %s now" % command
52 print "executing %s" % command
54 def install_syslinux(device):
55 """Install syslinux on specified device."""
56 print("syslinux %s") % device
58 def install_grub(device):
59 """Install grub on specified device."""
60 print("grub-install %s") % device
62 def install_bootloader(device):
63 """Install bootloader on specified device."""
67 install_syslinux(device)
70 """Check for root permissions"""
71 if not os.geteuid()==0:
72 sys.exit("Error: please run this script with uid 0 (root).")
76 print("%s %s")% (os.path.basename(sys.argv[0]), prog_version)
80 parser.error("invalid usage")
84 device = args[len(args) - 1]
85 isos = args[0:len(args) - 1]
87 # FIXME: check for valid blockdevice
88 if device is not None:
89 install_bootloader(device)
92 print("iso = %s") % iso
94 if __name__ == "__main__":
97 ## END OF FILE #################################################################
98 # vim:foldmethod=marker expandtab ai ft=python