Loop-mount ISO with read-only option
[grml2usb.git] / grml2usb
index 3fbf2c7..7bb2670 100755 (executable)
--- a/grml2usb
+++ b/grml2usb
@@ -1205,7 +1205,7 @@ def copy_grml_files(iso_mount, target):
     for myfile in copy_files:
         grml_file = search_file(myfile, iso_mount)
         if grml_file is None:
-            logging.warn("Warning: myfile %s could not be found - can not install it", myfile)
+            logging.warn("Warning: file %s could not be found - can not install it", myfile)
         else:
             exec_rsync(grml_file, grml_target + myfile)
 
@@ -1215,7 +1215,7 @@ def copy_grml_files(iso_mount, target):
     for myfile in 'index.html', 'style.css':
         grml_file = search_file(myfile, iso_mount)
         if grml_file is None:
-            logging.warn("Warning: myfile %s could not be found - can not install it")
+            logging.warn("Warning: file %s could not be found - can not install it", myfile)
         else:
             exec_rsync(grml_file, grml_web_target + myfile)
 
@@ -1225,21 +1225,23 @@ def copy_grml_files(iso_mount, target):
     for myfile in 'button.png', 'favicon.png', 'linux.jpg', 'logo.png':
         grml_file = search_file(myfile, iso_mount)
         if grml_file is None:
-            logging.warn("Warning: myfile %s could not be found - can not install it")
+            logging.warn("Warning: file %s could not be found - can not install it", myfile)
         else:
             exec_rsync(grml_file, grml_webimg_target + myfile)
 
 
-def handle_addon_copy(filename, dst, iso_mount):
+def handle_addon_copy(filename, dst, iso_mount, ignore_errors=False):
     """handle copy of optional addons
 
     @filename: filename of the addon
     @dst: destination directory
     @iso_mount: location of the iso mount
+    @ignore_errors: don't report missing files
     """
     file_location = search_file(filename, iso_mount)
     if file_location is None:
-        logging.warn("Warning: %s not found (that's fine if you don't need it)",  filename)
+        if not ignore_errors:
+            logging.warn("Warning: %s not found (that's fine if you don't need it)",  filename)
     else:
         exec_rsync(file_location, dst)
 
@@ -1280,7 +1282,7 @@ def copy_addons(iso_mount, target):
     handle_addon_copy('memtest', addons, iso_mount)
 
     # gpxe.lkrn: got replaced by ipxe
-    handle_addon_copy('gpxe.lkrn', addons, iso_mount)
+    handle_addon_copy('gpxe.lkrn', addons, iso_mount, ignore_errors=True)
 
     # ipxe.lkrn
     handle_addon_copy('ipxe.lkrn', addons, iso_mount)
@@ -1882,7 +1884,7 @@ def install(image, device):
         register_tmpfile(iso_mountpoint)
         remove_image_mountpoint = True
         try:
-            mount(image, iso_mountpoint, ["-o", "loop", "-t", "iso9660"])
+            mount(image, iso_mountpoint, ["-o", "loop,ro", "-t", "iso9660"])
         except CriticalException, error:
             logging.critical("Fatal: %s", error)
             sys.exit(1)