+def update_grml_versions(iso_mount, target):
+ """Update the grml version file on a cd
+ Returns true if version was updated successfully,
+ False if grml-version does not exist yet on the mountpoint
+
+ @iso_mount: string of the iso mount point
+ @target: path of the target mount point
+ """
+ grml_target = target + '/grml/'
+ new_grml_version = search_file('grml-version', grml_target)
+ if new_grml_version:
+ orig_grml_version = search_file('grml-version', iso_mount)
+ if not orig_grml_version:
+ logging.warn("Warning: %s could not be found - can not install it", orig_grml_version)
+ return False
+ try:
+ new_file = open(new_grml_version, 'a+')
+ new_flavours = [ get_flavour(l) for l in new_file.readlines() ]
+
+ old_file = open(orig_grml_version, 'r')
+ old_lines = old_file.readlines()
+ for line in old_lines:
+ if not get_flavour(line) in new_flavours:
+ new_file.write(line)
+ except IOError:
+ logging.warn("Warning: Could not write file")
+ finally:
+ new_file.close()
+ old_file.close()
+ return True
+ else:
+ return False
+