Пример #1
0
 def listDevices(self):
     """Return a list of device descriptions.
     Each device description is a list of strings:
         [device (/dev/sda, etc.),
          size (including unit),
          device type/name]
     """
     devices = []
     op = self.xcall("get-devices")
     for line in op.splitlines():
         # In virtualbox with a fresh virtual disk, we can get this:
         # "Error: /dev/sda: unrecognised disk label:"
         em = line.split(":")
         if (em[0].strip() == "Error" and (em[2].strip() ==
                 "unrecognised disk label")):
             dev = em[1].strip()
             if popupWarning(_("Error scanning devices:\n %s\n"
                     "Your disk (%s) seems to be empty and unformatted. "
                     "Shall I prepare it for use (create an msdos "
                     "partition table on it)?")
                     % (line, dev)):
                 op = self.xcall("make-parttable %s" % dev)
                 if op:
                     popupError(_("Couldn't create partition table:\n %s"))
                 else:
                     return self.listDevices()
             return []
         devices.append(line.rstrip(';').split(':'))
     return devices
Пример #2
0
    def getDevices(self):
        ld = install.listDevices()
        # Note that if one of these has mounted partitions it will not be
        # available for automatic partitioning, and should thus not be
        # included in the list used for automatic installation
        mounts = install.getmounts().splitlines()
        i = 0
        if ld:
            for d, s, n in ld:
                i += 1
                # Determine devices which have mounted partitions
                dstring = "%16s  (%10s : %s)" % (d, s, n)
                dm = False
                for m in mounts:
                    if m.startswith(d):
                        dm = True
                        i -= 1
                        break
                if dm:
                    self.addLabel('***' + dstring, align='left')
                else:
                    self.addOption(d, dstring, (i == 1))
            self.addOption('manual', _("Manual partitioning"), (i == 0))

        else:
            popupError(_("No disk(-like) devices were found,"
                    " so Arch Linux can not be installed on this machine"))
            mainWindow.exit()
Пример #3
0
 def tidyup(self):
     for p in self.processes:
         os.kill(p.pid, signal.SIGKILL)
         p.wait()
     tu = self.xcall("tidyup")
     if tu:
         popupError(tu, _("Tidying up failed,"
                 " there may still be devices mounted"))
     shutil.rmtree("/tmp/larchin", True)
Пример #4
0
def errorTrap(type, value, tb):
    etext = "".join(traceback.format_exception(type, value, tb))
    popupError(etext, _("This error could not be handled."))
    if initialized:
        try:
            install.tidyup()
        except:
            pass
    quit()
Пример #5
0
 def get_config(self, item, trap=True):
     f = "/tmp/larchin/%s" % item
     if os.path.isfile(f):
         fh = open(f, "r")
         value = fh.read()
         fh.close()
     elif trap:
         popupError(_("Configuration item not found: %s") % item)
         mainWindow.exit()
     else:
         value = None
     return value
Пример #6
0
    def select(self, stagename):
        i = 0
        for r in self.liststore:
            if (r[0] == stagename):
                self.selection.select_path(i)
                return
            i += 1

        if (stagename == '/'):
            mainWindow.exit()
        else:
            popupError(_("Attempt to select non-existent stage: %s") %
                    stagename, "BUG")
Пример #7
0
    def set_rootpw(self, pw):
        if (pw == ''):
            # Passwordless login
            pwcrypt = ''
        else:
            # Normal MD5 password
            salt = '$1$'
            for i in range(8):
                salt += random.choice("./0123456789abcdefghijklmnopqrstuvwxyz"
                        "ABCDEFGHIJKLMNOPQRSTUVWXYZ")
            pwcrypt = crypt.crypt(pw, salt)

        self.remount()
        op = self.xcall("setpw root '%s'" % pwcrypt)
        self.unmount()
        if op:
            popupError(op, _("Couldn't set root password:"))
            return False
        return True
Пример #8
0
 def getbootinfo(self):
     """Retrieves kernel file name and a list of initramfs files from
     the boot directory of the newly installed system.
     """
     self.remount()
     kernel = None
     inits = []
     for line in self.xcall("get-bootinfo").splitlines():
         if line.startswith('+++'):
             kernel = line.split()[1]
         else:
             inits.append(line)
     self.unmount()
     if not kernel:
         popupError(inits[0], _("GRUB problem"))
         return None
     if not inits:
         popupError(_("No initramfs found"), _("GRUB problem"))
         return None
     return (kernel, inits)
Пример #9
0
 def tidyup(self):
     tu = self.xcall("tidyup")
     if tu:
         dialogs.popupError(tu, _("Tidying up failed,"
                 " there may still be devices mounted"))
     shutil.rmtree("/tmp/larchin", True)
Пример #10
0
import __builtin__
def tr(s):
    return s
__builtin__._ = tr

import traceback
initialized = False

sys.excepthook = errorTrap

transfer = False
if (len(sys.argv) == 1):
    target = None
elif (len(sys.argv) == 2):
    target = sys.argv[1]
else:
    popupError(_("Usage:\n"
        "          larchin.py \t\t\t\t # local installation\n"
        "          larchin.py target-address \t # remote installation\n"),
        _("Bad arguments"))
    quit()

__builtin__.basePath = basedir
__builtin__.stages = {}
__builtin__.mainWindow = Larchin()
__builtin__.install = installClass(target)
initialized = True
mainWindow.goto('welcome')
mainWindow.mainLoop()
Пример #11
0
import traceback
initialized = False

sys.excepthook = errorTrap

transfer = False
if (len(sys.argv) == 1):
    target = None
elif (len(sys.argv) == 2):
    target = sys.argv[1]
elif ((len(sys.argv) == 3) and (sys.argv[1] == '-t')):
    target = sys.argv[2]
    transfer = True
else:
    popupError(_("Usage:\n"
        "          larchin.py \t\t\t\t\t # local installation\n"
        "          larchin.py [-t] target-address \t # remote installation\n"
        "\n              The '-t' option causes the installation scripts\n"
        "              to be copied to the remote machine."),
        _("Bad arguments"))
    quit()

__builtin__.basePath = basedir
__builtin__.stages = {}
__builtin__.mainWindow = Larchin()
__builtin__.install = installClass(target, transfer)
initialized = True
mainWindow.goto('welcome')
mainWindow.mainLoop()