示例#1
0
    def _do_partition(self):
        if not partition_lib.scanned:
            self._scan()

        m = list(partition_lib.get_layout_menu())
        l = [len(x.text) for x in m]
        max_len = max(l)

        menu = []
        i = 0
        for x in m:
            menu.append(
                (str(i), x.text + ' ' * (max_len - l[i] + 2) + x.size_text))
            i += 1
        menu.append((str(len(menu)), 'Finish Partitioning'))

        res, sel = dialog.menu(
            'Edit partitions below. If not sure, ' +
            'choose an empty disk, and select ' +
            '\'Automatically Set Up This Disk\'.\n',
            choices=menu,
            no_tags=True,
            default_item=str(len(menu) - 1) if self._switch_to_finish else '0')

        self._switch_to_finish = False

        if res != dialog.OK:
            return 'back'

        sel = int(sel)
        if sel == len(menu) - 1:
            return 'next'

        menu = []
        for x in m[sel].ops:
            menu.append((x, partition_lib.get_text_for_op(x)))

        if not menu:
            dialog.msgbox('Name: ' + m[sel].text.strip(' ') + '\n' +
                          m[sel].details_atext)
            return 'again'

        res, sel2 = dialog.menu('Name: ' + m[sel].text.strip(' ') + '\n' +
                                m[sel].details_text +
                                '\n\nChoose an action:\n',
                                choices=menu,
                                no_tags=True)

        if res != dialog.OK:
            return 'again'

        if self._handle_action(m[sel].name, m[sel].size, sel2):
            self._scan()

        return 'again'
示例#2
0
 def run_once(self):
     if (dialog.msgbox('Welcome to AL Installer!\n\n' +
                       'This guide will help you install Arch Linux.',
                       width=50,
                       height=8) == dialog.OK):
         set_font_cli.run()
     return True
示例#3
0
    def _msgbox(self, text):
        if not gui.started:
            dialog.msgbox(text)
        else:
            event = threading.Event()

            def show():
                from gi.repository import Gtk
                dialog2 = Gtk.MessageDialog(
                    gui.window, Gtk.DialogFlags.DESTROY_WITH_PARENT,
                    Gtk.MessageType.INFO, Gtk.ButtonsType.CLOSE, text)
                dialog2.run()
                dialog2.destroy()
                event.set()

            gui.idle_add(show)
            event.wait()
示例#4
0
    def run_once(self):
        res = 'again'
        try:
            res = self._do_partition()
            if res == 'back':
                return False
        except (Exception, KeyboardInterrupt):
            dialog.msgbox('An error occurred:\n\n' + traceback.format_exc())
            return False

        if res == 'next':
            if partition_lib.install_target == '':
                dialog.msgbox('A main installation target must be selected.',
                              width=50,
                              height=6)
                return True
            hostname_cli.run()

        return True
    def run_once(self):
        res = dialog.yesno('We are ready to install Arch Linux.\n' +
                           'Begin installing now?',
                           width=50, height=6)
        if res != dialog.OK:
            return False

        res = self._do_install()

        if res == 0:
            dialog.msgbox('Installation completed.\n' +
                          'Your system is going to be restarted.',
                          width=50, height=6)
        else:
            dialog.msgbox('Installation failed.\n' +
                          'Your system is going to be restarted.',
                          width=50, height=6)

        ai_dialog_exec('reboot', msg='Restarting...', showcmd=False)
        sys.exit(res)
示例#6
0
def main():
    language_lib.install()

    GLib.set_prgname(gui_application.application_id)
    GLib.set_application_name(_('AL Installer'))

    enable_gui = False

    if len(sys.argv) >= 2:
        if sys.argv[1] in ['--help', '-h']:
            print(
                'Usage:\n\n' +
                '(no argument)       Run in CLI (must be run as root)\n' +
                '--gui               Run in GUI (must be run as a password-free sudoer user)\n'
                +
                '--setup-gui         Prompt and set up GUI (must be run as root)\n'
            )
            sys.exit(0)

        if sys.argv[1] == '--gui':
            enable_gui = True
            if getpass.getuser() == 'liveuser':
                cmd = 'gsettings set org.gnome.software download-updates false'
                os.system(cmd)

        elif sys.argv[1] == '--setup-gui':
            print(
                '\n\nTo use CLI instead of GUI, press Ctrl+C (once) in 3 seconds.'
            )
            try:
                time.sleep(3)
                enable_gui = True
            except KeyboardInterrupt:
                enable_gui = False

            if enable_gui:
                print('\nSetting up GUI...')

                ai_call(
                    'rm /etc/xdg/autostart/gnome-initial-setup-first-login.desktop'
                )
                ai_call('rm /etc/xdg/autostart/gnome-welcome-tour.desktop')
                ai_call(
                    'cp /usr/local/share/applications/*.desktop /etc/xdg/autostart'
                )

                ai_call('useradd -c \'Live User\' -G users,wheel -m liveuser')
                ai_call('passwd -d liveuser')

                ai_call(
                    'sed -i \'s/\\[daemon\\]/[daemon]\\nAutomaticLoginEnable='
                    + 'True\\nAutomaticLogin=liveuser/\' /etc/gdm/custom.conf')

                with open('/etc/sudoers', 'a') as f:
                    f.write('\n%wheel ALL=(ALL) ALL\n')

                ai_call('systemctl start firewalld')
                ai_call('systemctl start NetworkManager')
                ai_call('systemctl start avahi-daemon')
                ai_call('systemctl start systemd-resolved')
                ai_call('systemctl start spice-vdagentd')
                ai_call('systemctl start gdm')
                sys.exit(0)

    if enable_gui:
        gui_application.run(sys.argv)
    else:
        try:
            welcome_cli.run()
        except (Exception, KeyboardInterrupt):
            dialog.msgbox('Installation failed.\n\n' + traceback.format_exc())
示例#7
0
def main():
    language_lib.install()

    GLib.set_prgname(gui_application.application_id)
    GLib.set_application_name(_('AL Installer'))

    enable_gui = False

    if len(sys.argv) >= 2:
        if sys.argv[1] in ['--help', '-h']:
            print(
                'Usage:\n\n' +
                '(no argument)       Run in CLI (must be run as root)\n' +
                '--gui               Run in GUI (must be run as a password-free sudoer user)\n'
                +
                '--setup-gui         Prompt and set up GUI (must be run as root)\n'
            )
            sys.exit(0)

        if sys.argv[1] == '--gui':
            enable_gui = True
        elif sys.argv[1] == '--setup-gui':
            print(
                '\n\nTo use CLI instead of GUI, press Ctrl+C (once) in 3 seconds.'
            )
            try:
                time.sleep(3)
                enable_gui = True

                def handle_interrupt_immediate(signum, frame):
                    ai_call('reboot')
                    while True:
                        time.sleep(1000)

                def handle_interrupt(signum, frame):
                    signal.signal(signal.SIGINT, lambda signum, frame: None)
                    print('\nToo late.\n')
                    time.sleep(2)
                    signal.signal(signal.SIGINT, handle_interrupt_immediate)
                    ai_call('reboot')
                    while True:
                        time.sleep(1000)

                signal.signal(signal.SIGINT, handle_interrupt)
            except KeyboardInterrupt:
                enable_gui = False

            if enable_gui:
                print('\nSetting up GUI...')

                ai_call(
                    'pacman -R --noconfirm --noprogressbar gnome-initial-setup && '
                    + 'rm -f /var/log/pacman.log')

                ai_call(
                    'cp /usr/local/share/applications/*.desktop /etc/xdg/autostart'
                )

                ai_call('useradd -c \'Live User\' -G users,wheel -m liveuser')
                ai_call('passwd -d liveuser')

                ai_call(
                    'sed -i \'s/\\[daemon\\]/[daemon]\\nAutomaticLoginEnable='
                    + 'True\\nAutomaticLogin=liveuser/\' /etc/gdm/custom.conf')

                with open('/etc/sudoers', 'a') as f:
                    f.write('\n%wheel ALL=(ALL) ALL\n')

                ai_call(
                    'sudo -u liveuser dbus-launch bash -c \'' +
                    'gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-ac-type nothing && '
                    +
                    'gsettings set org.gnome.settings-daemon.plugins.power sleep-inactive-battery-type nothing && '
                    +
                    'gsettings set org.gnome.software allow-updates false && '
                    +
                    'gsettings set org.gnome.software download-updates false' +
                    '\'')

                ai_call('systemctl start firewalld')
                ai_call('systemctl start NetworkManager')
                ai_call('systemctl start avahi-daemon')
                ai_call('systemctl start systemd-resolved')
                ai_call('systemctl start spice-vdagentd')
                ai_call('systemctl start gdm')
                sys.exit(0)

    if enable_gui:
        gui_application.run(sys.argv)
    else:
        try:
            welcome_cli.run()
        except (Exception, KeyboardInterrupt):
            dialog.msgbox('Installation failed.\n\n' + traceback.format_exc())
示例#8
0
    def _handle_action(self, name, size, op):
        if op == 'autosetup':
            res, text = dialog.inputbox(
                text='Partitioning type (msdos, gpt, ...):',
                init=partition_lib.default_partitioning)
            if res != dialog.OK:
                return False
            res = dialog.yesno(text='Enable encryption?', defaultno=True)
            passphrase = ''
            if res == dialog.OK:
                res2, passphrase = dialog.passwordbox(text='Enter passphrase:',
                                                      insecure=True)
                if res2 != dialog.OK:
                    return False
                res2, passphrase2 = dialog.passwordbox(
                    text='Confirm passphrase:', insecure=True)
                if res2 != dialog.OK:
                    return False
                if passphrase2 != passphrase:
                    dialog.msgbox('Passphrases do not match.')
                    return False
            res2 = dialog.yesno(
                text='Are you sure you want to wipe this disk?')
            if res2 != dialog.OK:
                return False

            partition_lib.action(op,
                                 name,
                                 size=size,
                                 parttable=text,
                                 crypt=(res == dialog.OK),
                                 passphrase=passphrase)

            self._switch_to_finish = True

        elif op == 'parttable':
            res, text = dialog.inputbox(
                text=partition_lib.get_text_for_op(op) + '\n\n' +
                'Partitioning type (msdos, gpt, ...):',
                init=partition_lib.default_partitioning)
            if res != dialog.OK:
                return False
            res = dialog.yesno(text='Are you sure you want to wipe this disk?')
            if res != dialog.OK:
                return False

            partition_lib.action(op, name, parttable=text)

        elif op == 'part':
            info = name.split('*')
            res, lst = dialog.form(
                text=partition_lib.get_text_for_op(op) + '\n',
                elements=[('Disk', 1, 1, info[1], 1, 48, -32, 1024),
                          ('Start', 3, 1, info[2], 3, 48, 32, 1024),
                          ('End', 5, 1, info[3], 5, 48, 32, 1024),
                          ('Filesystem (ext4, linux-swap, fat32, ...)', 7, 1,
                           partition_lib.default_filesystem, 7, 48, 32, 1024)])
            if res != dialog.OK:
                return False

            partition_lib.action(op,
                                 name,
                                 start=lst[0],
                                 end=lst[1],
                                 fstype=lst[2])

        elif op == 'format':
            res, text = dialog.inputbox(
                text=partition_lib.get_text_for_op(op) + '\n\n' +
                'Filesystem type (ext4, swap, fat, ...):',
                init=partition_lib.default_filesystem)
            if res != dialog.OK:
                return False
            res = dialog.yesno(text='Are you sure?')
            if res != dialog.OK:
                return False

            partition_lib.action(op, name, fstype=text)

        elif op == 'remove':
            res = dialog.yesno(text='Are you sure?')
            if res != dialog.OK:
                return False

            partition_lib.action(op, name)

        elif op == 'cryptsetup':
            res, passphrase = dialog.passwordbox(text='Enter passphrase:',
                                                 insecure=True)
            if res != dialog.OK:
                return False

            res, passphrase2 = dialog.passwordbox(text='Confirm passphrase:',
                                                  insecure=True)
            if res != dialog.OK:
                return False
            if passphrase2 != passphrase:
                dialog.msgbox('Passphrases do not match.')
                return False

            res = dialog.yesno(text='Are you sure?')
            if res != dialog.OK:
                return False

            partition_lib.action(op, name, passphrase=passphrase)

        elif op in ['cryptopen', 'swap-cryptopen']:
            res, passphrase = dialog.passwordbox(text='Enter passphrase:',
                                                 insecure=True)
            if res != dialog.OK:
                return False

            partition_lib.action(op, name, passphrase=passphrase)

        else:
            partition_lib.action(op, name)

        return True