예제 #1
0
    def build_efi_image(self, distro_path):
        hostEfiArchitecture = getHostEfiArchitecture()
        if hostEfiArchitecture == "":
            return None

        # TODO - also 32-bit installs (haven't tested this)

        modules = "part_gpt part_msdos ntfs ntfscomp hfsplus fat ext2 chain boot configfile linux " \
                "multiboot iso9660 gfxmenu gfxterm loadenv efi_gop efi_uga loadbios fixvideo png " \
                "loopback search minicmd cat cpuid appleldr elf usb videotest " \
                "halt help ls reboot echo test normal sleep memdisk tar font video_fb video " \
                "gettext true video_bochs video_cirrus multiboot2 acpi gfxterm_background gfxterm_menu"

        rootPath = join(distro_path, "root")
        bootPath = join(distro_path, "boot")
        efiPath = join(distro_path, "EFI/BOOT")
        arch = getGuestEfiArchitecture(rootPath)

        grubEfiName = "bootx64"
        if arch != "x86_64":
            arch = "i386"
            grubEfiName = "bootia32"

        try:
            # Clean up old stuff and prepare for a new EFI image
            if not exists(efiPath):
                makedirs(efiPath)
            silent_remove(join(bootPath, "efi"))
            silent_remove(join(bootPath, "boot/memdisk"))
            silent_remove(join(bootPath, "boot/grub/x86_64-efi"))
            silent_remove(join(bootPath, "boot/grub/i386-efi"))
            silent_remove(join(bootPath, "boot/grub/efi.img"))
            silent_remove(join(bootPath, "boot/grub/loopback.cfg"))

            # Create embedded.cfg
            cont = """search --file --set=root /MD5SUMS
if [ -e ($root)/boot/grub/grub.cfg ]; then
  set prefix=($root)/boot/grub
  configfile $prefix/grub.cfg
else
  echo "Could not find /boot/grub/grub.cfg!"
fi
"""
            with open('embedded.cfg', 'w') as f:
                f.write(cont)

            # Create the .efi image with the embedded.cfg file
            # Prefix is needed but can be left empty: it is set in embedded.cfg
            self.ec.run("grub-mkimage "
                        "--prefix '' "
                        "--config 'embedded.cfg' "
                        "-O {}-efi "
                        "-o '{}/{}.efi' "
                        "{}".format(arch, efiPath, grubEfiName, modules))

            print((">> Finished building EFI files"))
            return None

        except Exception as detail:
            return detail
예제 #2
0
 def download_offline_packages(self, path):
     rootPath = "%s/root" % path
     arch = getGuestEfiArchitecture(rootPath)
     de = EditDistro(path)
     script = "offline.sh"
     scriptSource = join(self.scriptDir, "files/{}".format(script))
     scriptTarget = join(rootPath, script)
     offlineSource = join(rootPath, "offline")
     offlineTarget = join(rootPath, "../boot/offline")
     if exists(scriptSource):
         try:
             copy(scriptSource, scriptTarget)
             self.ec.run("chmod a+x '%s'" % scriptTarget)
             # Run the script
             de.openTerminal("/bin/bash {} {}".format(script, arch))
             # Remove script
             silent_remove(scriptTarget)
             # Move offline directory to boot directory
             if exists(offlineSource):
                 print(("%s exists" % offlineSource))
                 if exists(offlineTarget):
                     print((">> Remove %s" % offlineTarget))
                     silent_remove(offlineTarget)
                 print((">> Move %s to %s" % (offlineSource, offlineTarget)))
                 move(offlineSource, offlineTarget)
             else:
                 print((">> Cannot find: %s" % offlineSource))
         except Exception as detail:
             self.showError("Error: getting offline packages", detail, self.window)
     else:
         print((">> Cannot find: %s" % scriptSource))
예제 #3
0
    def build_efi_image(self, distro_path):
        hostEfiArchitecture = getHostEfiArchitecture()
        if hostEfiArchitecture == "":
            return None

        # TODO - also 32-bit installs (haven't tested this)

        modules = "part_gpt part_msdos ntfs ntfscomp hfsplus fat ext2 chain boot configfile linux " \
                "multiboot iso9660 gfxmenu gfxterm loadenv efi_gop efi_uga loadbios fixvideo png " \
                "loopback search minicmd cat cpuid appleldr elf usb videotest " \
                "halt help ls reboot echo test normal sleep memdisk tar font video_fb video " \
                "gettext true video_bochs video_cirrus multiboot2 acpi gfxterm_background gfxterm_menu"

        rootPath = join(distro_path, "root")
        bootPath = join(distro_path, "boot")
        efiPath = join(distro_path, "EFI/BOOT")
        arch = getGuestEfiArchitecture(rootPath)

        grubEfiName = "bootx64"
        if arch != "x86_64":
            arch = "i386"
            grubEfiName = "bootia32"

        try:
            # Clean up old stuff and prepare for a new EFI image
            if not exists(efiPath):
                makedirs(efiPath)
            silent_remove(join(bootPath, "efi"))
            silent_remove(join(bootPath, "boot/memdisk"))
            silent_remove(join(bootPath, "boot/grub/x86_64-efi"))
            silent_remove(join(bootPath, "boot/grub/i386-efi"))
            silent_remove(join(bootPath, "boot/grub/efi.img"))
            silent_remove(join(bootPath, "boot/grub/loopback.cfg"))

            # Create embedded.cfg
            cont = """search --file --set=root /.trail
if [ -e ($root)/boot/grub/grub.cfg ]; then
  set prefix=($root)/boot/grub
  configfile $prefix/grub.cfg
else
  echo "Could not find /boot/grub/grub.cfg!"
fi
"""
            with open('embedded.cfg', 'w') as f:
                f.write(cont)

            # Create the .efi image with the embedded.cfg file
            self.ec.run("grub-mkimage "
                        "--config=embedded.cfg "
                        "-O {}-efi "
                        "-o '{}/{}.efi' "
                        "{}".format(arch, efiPath, grubEfiName, modules))

            print((">> Finished building EFI files"))
            return None

        except Exception as detail:
            return detail
예제 #4
0
    def build_efi_files(self):

        # TODO - also 32-bit installs (haven't tested this)

        modules = "part_gpt part_msdos ntfs ntfscomp hfsplus fat ext2 normal chain boot configfile linux " \
                "multiboot iso9660 gfxmenu gfxterm loadenv efi_gop efi_uga loadbios fixvideo png " \
                "ext2 ntfscomp loopback search minicmd cat cpuid appleldr elf usb videotest " \
                "halt help ls reboot echo test normal sleep memdisk tar font video_fb video " \
                "gettext true  video_bochs video_cirrus multiboot2 acpi gfxterm_background gfxterm_menu"

        selected = self.tvHandlerDistros.getToggledValues(toggleColNr=0, valueColNr=2)
        for path in selected:
            rootPath = "%s/root" % path
            bootPath = "{}/boot".format(path)
            arch = functions.getGuestEfiArchitecture(rootPath)

            grubEfiName = "bootx64"
            efiName = "x64"
            if arch != "x86_64":
                arch = "i386"
                grubEfiName = "bootia32"
                efiName = "ia32"

            try:
                if not exists("{}/efi/boot".format(bootPath)):
                    makedirs("{}/efi/boot".format(bootPath))

                self.ec.run("efi-image {}/~tmp {}-efi {}".format(bootPath, arch, efiName))
                if exists("{}/~tmp/efi.img".format(bootPath) and
                   exists("{}/~tmp/boot/grub/{}-efi".format(bootPath, arch))):
                    self.ec.run("rm -r {}/boot/grub/{}-efi".format(bootPath, arch))
                    self.ec.run("mv -vf {}/~tmp/boot/grub/{}-efi {}/boot/grub/".format(bootPath, arch, bootPath))
                    self.ec.run("mv -vf {}/~tmp/efi.img {}/boot/grub/".format(bootPath, bootPath))
                    self.ec.run("rm -r {}/~tmp".format(bootPath))

                self.ec.run("grub-mkimage -O {}-efi -d /usr/lib/grub/{}-efi "
                            "-o {}/efi/boot/{}.efi "
                            "-p \"/boot/grub\" {}".format(arch, arch, bootPath, grubEfiName, modules))

                print((">> Finished building EFI files"))

            except Exception as detail:
                self.showError("Error: build EFI files", detail, self.window)
예제 #5
0
 def download_offline_packages(self):
     selected = self.tvHandlerDistros.getToggledValues(toggleColNr=0,
                                                       valueColNr=2)
     for path in selected:
         rootPath = "%s/root" % path
         arch = getGuestEfiArchitecture(rootPath)
         de = EditDistro(path)
         script = "offline.sh"
         scriptSource = join(self.scriptDir, "files/{}".format(script))
         scriptTarget = join(rootPath, script)
         offlineSource = join(rootPath, "offline")
         offlineTarget = join(rootPath, "../boot/offline")
         if exists(scriptSource):
             try:
                 copy(scriptSource, scriptTarget)
                 self.ec.run("chmod a+x '%s'" % scriptTarget)
                 # Run the script
                 de.openTerminal("/bin/bash {} {}".format(script, arch))
                 # Remove script
                 silent_remove(scriptTarget)
                 # Move offline directory to boot directory
                 if exists(offlineSource):
                     print(("%s exists" % offlineSource))
                     if exists(offlineTarget):
                         print((">> Remove %s" % offlineTarget))
                         silent_remove(offlineTarget)
                     print((">> Move %s to %s" %
                            (offlineSource, offlineTarget)))
                     move(offlineSource, offlineTarget)
                 else:
                     print((">> Cannot find: %s" % offlineSource))
             except Exception as detail:
                 self.showError("Error: getting offline packages", detail,
                                self.window)
         else:
             print((">> Cannot find: %s" % scriptSource))