Do not execute mkfs.fat without prompting; update docs
authorMichael Prokop <mika@grml.org>
Mon, 16 Feb 2009 18:12:30 +0000 (19:12 +0100)
committerMichael Prokop <mika@grml.org>
Mon, 16 Feb 2009 18:12:30 +0000 (19:12 +0100)
grml2usb.8.txt
grml2usb.py

index 4962126..fa621e7 100644 (file)
@@ -30,22 +30,32 @@ The following options are supported:
 
 Use specified bootoptions as default.
 
+  *--bootloader-only*::
+
+Do *not* copy files but instead just install a bootloader.
+
+  *--copy-only*::
+
+Copy files only but do *not* install a bootloader.
+
   *--dry-run*::
 
-Do not actually execute any commands, instead just show what would be executed.
+Avoid executing commands, instead show what would be executed.
+Warning: please notice that the ISO has to be mounted anyway, otherwise
+identifying the grml flavour would not be possible.
 
   *--fat16*::
 
-Format specified partition with FAT16. **Important:** this will defstroy any existing
-data on the specified partition!
+Format specified partition with FAT16.
+**Important:** this will destroy any existing data on the specified partition!
 
   *--force*::
 
-Force any actions requiring manual interaction (like --fat16, --mbr).
+Force any (possible dangerous) actions requiring manual interaction (like --fat16).
 
   *--grub*::
 
-Install grub bootloader instead of syslinux.
+Install grub bootloader instead of syslinux. [Notice: not implemented yet.]
 
   *--help*::
 
@@ -54,28 +64,37 @@ Display usage information and exit.
   *--initrd=...*::
 
 Install specified initrd instead of the default. You might want to specify
-option *--kernel* as well.
+option *--kernel* as well. (Be aware when using multiboot setup.)
+[Notice: not implemented yet.]
 
   *--kernel=...*::
 
 Install specified kernel instead of the default. You might want to specify
 option *--initrd* as well. (Be aware when using multiboot setup.)
+[Notice: not implemented yet.]
+
+  *--lilo=...*::
+
+Use specified lilo executable to for installing master boot record (MBR)
+instead of the default, being /usr/share/grml2usb/lilo/lilo.static.
 
   *--mbr*::
 
-Install master boot record (MBR) on the device.
+Install a default master boot record (MBR) on the device.
 
-  *--squashfs=*::
+  *--quiet*::
 
-Install specified squashfs file as the default.
+Do not output anything but just errors on console.
 
-  *--syslinux*::
+  *--squashfs=*::
 
-Install syslinux bootloader (default, requires FAT16 filesystem on the specified partition).
+Install specified squashfs file instead of the default.
+[Notice: not implemented yet.]
 
   *--uninstall*::
 
 Uninstall grml ISO files.
+[Notice: not implemented yet.]
 
   *-v*, *--version*::
 
@@ -88,9 +107,15 @@ Enable verbose mode.
 Introduction
 ------------
 
-grml2usb installs grml on a given partition on your usb device and makes it
+grml2usb installs grml on a given partition of your usb device and makes it
 bootable.
 
+grml2usb provides multi-iso support, meaning you can specify several grml ISOs
+on the command line at once and select the grml flavour you would like to boot
+on the bootbrompt then. Notice that the default ISO (that's when pressing just
+enter on the bootprompt or wait until the timeout matches) will be the *first*
+one specified on the grml2usb command line.
+
 Directory layout on usb device
 ------------------------------
 
@@ -174,13 +199,15 @@ Usage examples
 
   # grml2usb /home/grml/grml_2008.11.iso /dev/sdb1
 
-Install specified ISOs on device /dev/sdb1.
+Install specified ISO on device /dev/sdb1.
 
   # grml2usb /home/grml/grml_2008.11.iso /home/grml/grml_small_2008.11.iso /dev/sdb1
 
 Install specified ISOs on device /dev/sdb1 for multibooting ISOs.
 Note: boot "grml" as usual, for booting grml-small use "grml-small on the
-bootprompt, for grml64 use "grml64" and so on...
+bootprompt, for grml64 use "grml64" and so on... The *first* specified ISO is
+the one being the default (when just pressing enter or waiting until the timeout
+is reached).
 
   # grml2usb --fat16 --mbr /home/grml/grml_2008.11.iso /dev/sdb1
 
index b0de9e5..c2de631 100755 (executable)
@@ -14,16 +14,17 @@ TODO
 ----
 
 * install memtest, dos, grub,... to /boot/addons/
-* implement missing options (--kernel, --initrd, --uninstall,...)
+* copy grml files to /grml/
+* implement missing options (--grub, --kernel, --initrd, --squashfs, --uninstall)
 * code improvements:
-  - improve error handling :)
-  - get rid of all TODOs in code :)
+  - improve error handling wherever possible :)
+  - get rid of all TODOs in code
   - use 'with open("...", "w") as f: ... f.write("...")'
-  - simplify functions/code as much as possible -> audit
-* validate partition schema/layout: is the partition schema ok and the bootable flag set?
+  - simplify functions/code as much as possible (move stuff to further functions) -> audit
+* validate partition schema/layout: is the partition schema ok and the bootable flag set? (--validate?)
 * implement logic for storing information about copied files -> register every file in a set()
 * the last line in bootsplash (boot.msg) should mention all installed grml flavours
-* graphical version? :)
+* graphical version? any volunteers? :)
 """
 
 from __future__ import with_statement
@@ -53,33 +54,33 @@ and root access."
 parser = OptionParser(usage=usage)
 parser.add_option("--bootoptions", dest="bootoptions",
                   action="store", type="string",
-                  help="use specified bootoptions as defaut")
+                  help="use specified bootoptions as default")
 parser.add_option("--bootloader-only", dest="bootloaderonly", action="store_true",
-                  help="do not copy files only but just install a bootloader")
+                  help="do not copy files but just install a bootloader")
 parser.add_option("--copy-only", dest="copyonly", action="store_true",
-                  help="copy files only and do not install bootloader")
+                  help="copy files only but do not install bootloader")
 parser.add_option("--dry-run", dest="dryrun", action="store_true",
-                  help="do not actually execute any commands")
+                  help="avoid executing commands")
 parser.add_option("--fat16", dest="fat16", action="store_true",
                   help="format specified partition with FAT16")
 parser.add_option("--force", dest="force", action="store_true",
                   help="force any actions requiring manual interaction")
 parser.add_option("--grub", dest="grub", action="store_true",
-                  help="install grub bootloader instead of syslinux")
+                  help="install grub bootloader instead of syslinux [TODO]")
 parser.add_option("--initrd", dest="initrd", action="store", type="string",
-                  help="install specified initrd instead of the default")
+                  help="install specified initrd instead of the default [TODO]")
 parser.add_option("--kernel", dest="kernel", action="store", type="string",
-                  help="install specified kernel instead of the default")
+                  help="install specified kernel instead of the default [TODO]")
 parser.add_option("--lilo", dest="lilo",  action="store", type="string",
                   help="lilo executable to be used for installing MBR")
 parser.add_option("--mbr", dest="mbr", action="store_true",
                   help="install master boot record (MBR) on the device")
 parser.add_option("--quiet", dest="quiet", action="store_true",
-                  help="do not output anything than errors on console")
+                  help="do not output anything but just errors on console")
 parser.add_option("--squashfs", dest="squashfs", action="store", type="string",
-                  help="install specified squashfs file instead of the default")
+                  help="install specified squashfs file instead of the default [TODO]")
 parser.add_option("--uninstall", dest="uninstall", action="store_true",
-                  help="remove grml ISO files")
+                  help="remove grml ISO files from specified device [TODO]")
 parser.add_option("--verbose", dest="verbose", action="store_true",
                   help="enable verbose mode")
 parser.add_option("-v", "--version", dest="version", action="store_true",
@@ -576,34 +577,34 @@ def copy_grml_files(grml_flavour, iso_mount, target):
     if options.dryrun:
         logging.info("Would copy files to %s", iso_mount)
     elif not options.bootloaderonly:
-           logging.info("Copying files. This might take a while....")
+        logging.info("Copying files. This might take a while....")
 
-           squashfs = search_file(grml_flavour + '.squashfs', iso_mount)
-           squashfs_target = target + '/live/'
-           execute(mkdir, squashfs_target)
+        squashfs = search_file(grml_flavour + '.squashfs', iso_mount)
+        squashfs_target = target + '/live/'
+        execute(mkdir, squashfs_target)
 
-           # use install(1) for now to make sure we can write the files afterwards as normal user as well
-           logging.debug("cp %s %s" % (squashfs, target + '/live/' + grml_flavour + '.squashfs'))
-           proc = subprocess.Popen(["install", "--mode=664", squashfs, squashfs_target + grml_flavour + ".squashfs"])
-           proc.wait()
+        # use install(1) for now to make sure we can write the files afterwards as normal user as well
+        logging.debug("cp %s %s" % (squashfs, target + '/live/' + grml_flavour + '.squashfs'))
+        proc = subprocess.Popen(["install", "--mode=664", squashfs, squashfs_target + grml_flavour + ".squashfs"])
+        proc.wait()
 
-           filesystem_module = search_file('filesystem.module', iso_mount)
-           logging.debug("cp %s %s" % (filesystem_module, squashfs_target + grml_flavour + '.module'))
-           proc = subprocess.Popen(["install", "--mode=664", filesystem_module, squashfs_target + grml_flavour + '.module'])
-           proc.wait()
+        filesystem_module = search_file('filesystem.module', iso_mount)
+        logging.debug("cp %s %s" % (filesystem_module, squashfs_target + grml_flavour + '.module'))
+        proc = subprocess.Popen(["install", "--mode=664", filesystem_module, squashfs_target + grml_flavour + '.module'])
+        proc.wait()
 
-           release_target = target + '/boot/release/' + grml_flavour
-           execute(mkdir, release_target)
+        release_target = target + '/boot/release/' + grml_flavour
+        execute(mkdir, release_target)
 
-           kernel = search_file('linux26', iso_mount)
-           logging.debug("cp %s %s" % (kernel, release_target + '/linux26'))
-           proc = subprocess.Popen(["install", "--mode=664", kernel, release_target + '/linux26'])
-           proc.wait()
+        kernel = search_file('linux26', iso_mount)
+        logging.debug("cp %s %s" % (kernel, release_target + '/linux26'))
+        proc = subprocess.Popen(["install", "--mode=664", kernel, release_target + '/linux26'])
+        proc.wait()
 
-           initrd = search_file('initrd.gz', iso_mount)
-           logging.debug("cp %s %s" % (initrd, release_target + '/initrd.gz'))
-           proc = subprocess.Popen(["install", "--mode=664", initrd, release_target + '/initrd.gz'])
-           proc.wait()
+        initrd = search_file('initrd.gz', iso_mount)
+        logging.debug("cp %s %s" % (initrd, release_target + '/initrd.gz'))
+        proc = subprocess.Popen(["install", "--mode=664", initrd, release_target + '/initrd.gz'])
+        proc.wait()
 
     if not options.copyonly:
         syslinux_target = target + '/boot/syslinux/'
@@ -821,7 +822,7 @@ def main():
     isos = args[0:len(args) - 1]
 
     # make sure we can replace old grml2usb script and warn user when using old way of life:
-    if device.startswith("/mnt/external") or device.startswith("/mnt/usb"):
+    if device.startswith("/mnt/external") or device.startswith("/mnt/usb") and not options.force:
         print "Warning: the semantics of grml2usb has changed."
         print "Instead of using grml2usb /path/to/iso %s you might" % device
         print "want to use grml2usb /path/to/iso /dev/... instead."
@@ -840,10 +841,18 @@ def main():
             sys.exit(1)
 
     # make sure we have mkfs.vfat available
-    if options.fat16:
+    if options.fat16 and not options.force:
         if not which("mkfs.vfat") and not options.copyonly and not options.dryrun:
             logging.critical('Sorry, mkfs.vfat not available. Exiting.')
-            logging.critical('Please install dosfstools.')
+            logging.critical('Please make sure to install dosfstools.')
+            sys.exit(1)
+
+        # make sure the user is aware of what he is doing
+        f = raw_input("Are you sure you want to format the device with a fat16 filesystem? y/N ")
+        if f == "y" or f == "Y":
+            logging.info("Note: you can skip this question using the option --force")
+            mkfs_fat16(device)
+        else:
             sys.exit(1)
 
     # check for vfat filesystem