+
+ # TODO
+ # * provide alternative search_file() if file information is stored in a config.ini file?
+ # * catch "install: .. No space left on device" & CO
+ # * abstract copy logic to make the code shorter and get rid of spaghetti ;)
+
+ 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)
+
+ # 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'))
+ execute(subprocess.Popen, ["install", "--mode=664", squashfs, squashfs_target + grml_flavour + ".squashfs"])
+
+ filesystem_module = search_file('filesystem.module', iso_mount)
+ logging.debug("cp %s %s" % (filesystem_module, squashfs_target + grml_flavour + '.module'))
+ execute(subprocess.Popen, ["install", "--mode=664", filesystem_module, squashfs_target + grml_flavour + '.module'])
+
+ 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'))
+ execute(subprocess.Popen, ["install", "--mode=664", kernel, release_target + '/linux26'])
+
+ initrd = search_file('initrd.gz', iso_mount)
+ logging.debug("cp %s %s" % (initrd, release_target + '/initrd.gz'))
+ execute(subprocess.Popen, ["install", "--mode=664", initrd, release_target + '/initrd.gz'])
+
+ if not options.copyonly:
+ isolinux_target = target + '/boot/isolinux/'
+ execute(mkdir, isolinux_target)
+
+ logo = search_file('logo.16', iso_mount)
+ logging.debug("cp %s %s" % logo, isolinux_target + 'logo.16')
+ execute(subprocess.Popen, ["install", "--mode=664", logo, isolinux_target + 'logo.16'])
+
+ for ffile in 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'f10':
+ bootsplash = search_file(ffile, iso_mount)
+ logging.debug("cp %s %s" % (bootsplash, isolinux_target + ffile))
+ execute(subprocess.Popen, ["install", "--mode=664", bootsplash, isolinux_target + ffile])
+
+ grub_target = target + '/boot/grub/'
+ execute(mkdir, grub_target)
+
+ logging.debug("cp grub/splash.xpm.gz %s" % grub_target + 'splash.xpm.gz')
+ execute(subprocess.Popen, ["install", "--mode=664", 'grub/splash.xpm.gz', grub_target + 'splash.xpm.gz'])
+
+ logging.debug("cp grub/stage2_eltorito to %s" % grub_target + 'stage2_eltorito')
+ execute(subprocess.Popen, ["install", "--mode=664", 'grub/stage2_eltorito', grub_target + 'stage2_eltorito'])
+
+ logging.debug("Generating grub configuration %s" % grub_target + 'menu.lst')
+ if not dry_run:
+ #with open("...", "w") as f:
+ #f.write("bla bla bal")
+ grub_config_file = open(grub_target + 'menu.lst', 'w')
+ grub_config_file.write(generate_grub_config(grml_flavour))
+ grub_config_file.close( )
+
+ syslinux_target = target + '/boot/isolinux/'
+ execute(mkdir, syslinux_target)
+
+ logging.debug("Generating syslinux configuration %s" % syslinux_target + 'syslinux.cfg')
+ if not dry_run:
+ syslinux_config_file = open(syslinux_target + 'syslinux.cfg', 'w')
+ syslinux_config_file.write(generate_syslinux_config(grml_flavour))
+ syslinux_config_file.close( )
+
+ logging.debug("Generating isolinux/syslinux splash %s" % syslinux_target + 'boot.msg')
+ if not dry_run:
+ isolinux_splash = open(syslinux_target + 'boot.msg', 'w')
+ isolinux_splash.write(generate_isolinux_splash(grml_flavour))
+ isolinux_splash.close( )