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))
 def on_btnLocalize_clicked(self, widget):
     # Set locale
     selected = self.tvHandlerDistros.getToggledValues(toggleColNr=0, valueColNr=2)
     for path in selected:
         rootPath = "%s/root" % path
         de = EditDistro(path)
         script = "setlocale.sh"
         scriptSource = join(self.scriptDir, "files/{}".format(script))
         scriptTarget = join(rootPath, script)
         if exists(scriptSource):
             copy(scriptSource, scriptTarget)
             self.ec.run("chmod a+x '%s'" % scriptTarget)
             de.openTerminal("/bin/bash %s" % script)
             silent_remove(scriptTarget)
         
         # Copy Grub locale files to ISO boot directory and configure grub.cfg
         grub_path = "%s/boot/boot/grub/" % path
         grubcfg_path = "%s/grub.cfg" % grub_path
         locale_path = "%s/root/boot/grub/locale" % path
         default_path = "%s/root/etc/default" % path
         locale = self.ec.run("grep -oP '(?<=LANG=).*?(?=\.)' %s/locale" % default_path)[0]
         if exists(locale_path) and \
            exists(grubcfg_path) and \
            locale:
             self.ec.run("cp -rf %s %s" % (locale_path, grub_path))
             self.ec.run("sed -i 's/set lang=.*/set lang=%s/' %s" % (locale, grubcfg_path))
示例#3
0
 def on_btnLocalize_clicked(self, widget):
     # Set locale
     selected = self.tvHandlerDistros.getToggledValues(toggleColNr=0, valueColNr=2)
     for path in selected:
         rootPath = "%s/root" % path
         de = EditDistro(path)
         script = "setlocale.sh"
         scriptSource = join(self.scriptDir, "files/{}".format(script))
         scriptTarget = join(rootPath, script)
         if exists(scriptSource):
             copy(scriptSource, scriptTarget)
             self.ec.run("chmod a+x %s" % scriptTarget)
             de.openTerminal("/bin/bash %s" % script)
             remove(scriptTarget)
 def on_btnEdit_clicked(self, widget):
     selected = self.tvHandlerDistros.getToggledValues(toggleColNr=0, valueColNr=2)
     for path in selected:
         de = EditDistro(path)
         services = []
         if exists(join(path, 'root/etc/apache2/apache2.conf')):
             services.append("apache2")
         if exists(join(path, 'root/etc/mysql/debian.cnf')):
             services.append("mysql")
         if services:
             msg = "If you need to update packages that depend on these services,\n" \
                   "you will need to manually start them:\n"
             for service in services:
                 msg += "\nservice %s start" % service
             msg += "\n\nWhen done:\n"
             for service in services:
                 msg += "\nservice %s stop" % service
             self.showInfo(_("Services detected"), msg, self.window)
             repaintGui()
         de.openTerminal()
    def on_btnUpgrade_clicked(self, widget):
        selected = self.tvHandlerDistros.getToggledValues(toggleColNr=0, valueColNr=2)
        upgraded = False
        for path in selected:
            upgraded = True
            rootPath = "%s/root" % path
            force = get_apt_force(rootPath)
            de = EditDistro(path)
            de.openTerminal("apt-get update")
            if exists(join(rootPath, 'etc/apache2/apache2.conf')):
                de.openTerminal("service apache2 start")
            if exists(join(rootPath, 'etc/mysql/debian.cnf')):
                de.openTerminal("service mysql start")
            de.openTerminal("apt-get -y %s -o Dpkg::Options::=\"--force-confnew\" dist-upgrade" % force)
            if exists(join(rootPath, 'etc/apache2/apache2.conf')):
                de.openTerminal("service apache2 stop")
            if exists(join(rootPath, 'etc/mysql/debian.cnf')):
                de.openTerminal("service mysql stop")

            # Cleanup old kernel and headers
            script = "rmoldkernel.sh"
            scriptSource = join(self.scriptDir, "files/{}".format(script))
            scriptTarget = join(rootPath, script)
            if exists(scriptSource):
                copy(scriptSource, scriptTarget)
                self.ec.run("chmod a+x '%s'" % scriptTarget)
                de.openTerminal("/bin/bash %s" % script)
                silent_remove(scriptTarget)

            # Download offline packages
            print(">> Start downloading offline packages")
            self.download_offline_packages(path)

        if upgraded and exists("/usr/bin/aplay") and exists(self.doneWav):
            self.ec.run("/usr/bin/aplay '%s'" % self.doneWav, False)