+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/'
+ target_grml_version_file = search_file('grml-version', grml_target)
+ if target_grml_version_file:
+ iso_grml_version_file = search_file('grml-version', iso_mount)
+ if not iso_grml_version_file:
+ logging.warn("Warning: %s could not be found - can not install it", iso_grml_version_file)
+ return False
+ try:
+ target_file = open(target_grml_version_file, 'a+')
+ target_flavours = [ get_flavour(l) for l in target_file.readlines() ]
+
+ iso_file = open(iso_grml_version_file, 'r')
+ iso_lines = iso_file.readlines()
+ for line in iso_lines:
+ if not get_flavour(line) in target_flavours:
+ target_file.write(line)
+ except IOError:
+ logging.warn("Warning: Could not write file")
+ finally:
+ target_file.close()
+ iso_file.close()
+ return True
+ else:
+ return False
+