def install_basic_arch():
    ### Nicer formatting for pacstrap
    sed_inplace("/etc/pacman.conf", "#Color", "Color")
    sed_inplace("/etc/pacman.conf", "#TotalDownload", "TotalDownload")

    ### Update mirrorlist
    print(" >> Updating mirror list")
    try:
        run('reflector --latest 100 --sort rate --protocol https --save /etc/pacman.d/mirrorlist'
            )
    except CalledProcessError as error:
        print('Updating package mirrorlist failed with message: ',
              error.output)

    print(" >> Going to install arch base packages")
    try:
        run('pacstrap /mnt ' + ' '.join(basics))
    except CalledProcessError as error:
        print('Error installing base packages. Message: ', error.output)

    print(" >> Installed arch base packages")

    ### Nicer formatting for pacstrap on installed system
    sed_inplace("/mnt/etc/pacman.conf", "#Color", "Color")
    sed_inplace("/mnt/etc/pacman.conf", "#TotalDownload", "TotalDownload")
def install_package_manager(install_user_name):
    print(' >> Going to install package manager')

    # Copy install files to fake install user home directory
    copy2(
        'arch-installer/package_manager/installPackageManager.sh',
        '/mnt/home/{}/'.format(install_user_name))

    # Install aura and AUR packages
    run('arch-chroot /mnt sudo -u {0} sh /home/{0}/installPackageManager.sh'.format(install_user_name))

    print(' >> Installed package manager')
Ejemplo n.º 3
0
def set_keymap_gui(keymap_gui, internationalisation=False):
    # Set the keymap
    sed_inplace('arch-installer/20-keyboard.conf', '<LAYOUT>', keymap_gui)

    # If internationalisation is chosen, add the option
    if internationalisation:
        sed_inplace('arch-installer/20-keyboard.conf', '<INTL>',
                    'Option          \"XkbVariant\" \"altgr-intl\"')
    else:
        sed_inplace('arch-installer/20-keyboard.conf', '<INTL>', '')

    # Finally copy file over
    run("mkdir -p /mnt/etc/X11/xorg.conf.d/")
    copy2('arch-installer/20-keyboard.conf', '/mnt/etc/X11/xorg.conf.d/')
def get_gpu_vendor():
    from pyscripts.utilities import run
    from pyscripts.utilities import check_output
    from subprocess import CalledProcessError

    run("update-pciids")
    vendors = ['VirtualBox Graphics Adapter', 'nvidia', 'intel', 'amd' ]

    for vendor in vendors:
        try:
            output = check_output("lspci | grep -i 'vga.*"+vendor+"\|3d.*"+vendor+"\|2d.*"+vendor+"'")
            if vendor == 'VirtualBox Graphics Adapter':
                return 'vbox'
            else:
                return vendor
        except CalledProcessError:
            pass

    return "default"
def get_gpu_vendor():
    from pyscripts.utilities import run
    from pyscripts.utilities import check_output
    from subprocess import CalledProcessError

    run("update-pciids")
    vendors = ['VirtualBox Graphics Adapter', 'nvidia', 'intel', 'amd']

    for vendor in vendors:
        try:
            output = check_output("lspci | grep -i 'vga.*" + vendor +
                                  "\|3d.*" + vendor + "\|2d.*" + vendor + "'")
            if vendor == 'VirtualBox Graphics Adapter':
                return 'vbox'
            else:
                return vendor
        except CalledProcessError:
            pass

    return "default"
Ejemplo n.º 6
0
def configure_users(user_input):
    ### Add user
    username = user_input['username']
    run("arch-chroot /mnt useradd -m -G wheel -s /bin/bash "+username)

    ### Get user password
    success = False
    while not success:
        try:
            print(" >> Please type in a password for "+username+":")
            run("arch-chroot /mnt passwd "+username)
            success = True
        except subprocess.CalledProcessError as error:
            print(' >> It seems you did not type in matching passwords. Error-message: ', error.output)

    ### Get root password
    success = False
    while not success:
        try:
            print(" >> Please type in a password for root user:"******"arch-chroot /mnt passwd")
            success = True
        except subprocess.CalledProcessError as error:
            print(' >> It seems you did not type in matching passwords. Error-message: ', error.output)

    ### Place the user into the sudoers list
    sed_inplace("/mnt/etc/sudoers", "# %wheel ALL=\(ALL\) ALL", "%wheel ALL=(ALL) ALL")
Ejemplo n.º 7
0
def configure_desktop(user_input):
    if user_input['desktop'] == 'KDE plasma':

        print(" >> Activating Desktop (sddm)")
        try:
            run("arch-chroot /mnt sddm --example-config > /mnt/etc/sddm.conf")
            sed_inplace("/mnt/etc/sddm.conf", "^Current=.*", "Current=breeze")
            sed_inplace("/mnt/etc/sddm.conf", "CursorTheme=",
                        "CursorTheme=breeze-dark")
            sed_inplace("/mnt/etc/sddm.conf", "Numlock=none", "Numlock=on")
            run("arch-chroot /mnt systemctl enable sddm")
        except CalledProcessError as error:
            print('Enabling sddm failed with message: ', error.output)

        print(" >> Copying Desktop and Shell theme files")
        #if not os.path.exists("/mnt/etc/skel/.config/gtk-3.0"):
        #    os.makedirs("/mnt/etc/skel/.config/gtk-3.0")
        #if not os.path.exists("mkdir -p /mnt/etc/skel/.local/share/konsole/"):
        #    os.makedirs("mkdir -p /mnt/etc/skel/.local/share/konsole/")

        #copytree("arch-installer/configuration_desktop", "/mnt/etc/skel/")
        try:
            run('cp -a arch-installer/configuration_desktop/. /mnt/etc/skel/')
        except CalledProcessError as error:
            print(
                'Error installing default user desktop configurations with message: ',
                error.output)
Ejemplo n.º 8
0
def configure_desktop(user_input):
    if user_input['desktop'] == 'KDE plasma':

        print(" >> Configuring KDE desktop (sddm)")
        try:
            run("arch-chroot /mnt sddm --example-config > /mnt/etc/sddm.conf")
            sed_inplace("/mnt/etc/sddm.conf", "^Current=.*", "Current=breeze")
            sed_inplace("/mnt/etc/sddm.conf", "CursorTheme=", "CursorTheme=breeze-dark")
            sed_inplace("/mnt/etc/sddm.conf", "Numlock=none", "Numlock=on")
        except CalledProcessError as error:
            print('Configuring KDE desktop (sddm) failed with message: ', error.output)

        print(" >> Copying KDE Desktop and Shell theme files")
        #if not os.path.exists("/mnt/etc/skel/.config/gtk-3.0"):
        #    os.makedirs("/mnt/etc/skel/.config/gtk-3.0")
        #if not os.path.exists("mkdir -p /mnt/etc/skel/.local/share/konsole/"):
        #    os.makedirs("mkdir -p /mnt/etc/skel/.local/share/konsole/")

        #copytree("arch-installer/configuration_desktop", "/mnt/etc/skel/")
        try:
            run('cp -a arch-installer/configuration_desktop/. /mnt/etc/skel/')
        except CalledProcessError as error:
            print('Error installing default user desktop configurations with message: ', error.output)
        #copy2("arch-installer/configuration_desktop/.config/kdeglobals", "/mnt/etc/skel/.config/")
        #copy2("arch-installer/configuration_desktop/.config/konsolerc", "/mnt/etc/skel/.config/")
        #copy2("arch-installer/configuration_desktop/.config/yakuakerc", "/mnt/etc/skel/.config/")
        #copy2("arch-installer/configuration_desktop/.config/kcminputrc", "/mnt/etc/skel/.config/")
        #copy2("arch-installer/configuration_desktop/.local/share/konsole/Default.profile", "/mnt/etc/skel/.local/share/konsole/")
        #copy2("arch-installer/configuration_desktop/.local/share/konsole/Dark Breeze.colorscheme", "/mnt/etc/skel/.local/share/konsole/")
        #copy2("arch-installer/configuration_desktop/.gtkrc-2.0", "/mnt/etc/skel/")
        #copy2("arch-installer/configuration_desktop/.config/gtk-3.0/settings.ini", "/mnt/etc/locale.conf/")

    elif user_input['desktop'] == 'Cinnamon':

        print(" >> Configuring Cinnamon desktop (gdm)")
        try:
            pass
        except CalledProcessError as error:
            print('Configuring Cinnamon desktop (gdm) failed with message: ', error.output)
Ejemplo n.º 9
0
def configure_bootloader():
    # Call to generate most default files and folder necessary for boot
    try:
        run("arch-chroot /mnt bootctl --path=/boot install")
    except CalledProcessError as error:
        print('Unable to install bootloader. Is UEFI activated on your machine?',
              ' Error message: ', error.output)

    # Get the part_uuid of the Linux partition
    try:
        linux_partition_uuid = check_output("blkid -L Arch")
        linux_partition_partuuid = check_output(
            "blkid -s PARTUUID -o value "
            + linux_partition_uuid)
    except CalledProcessError as error:
        print('Unable to figure out PARTUUID of your Linux partition. Is it really called `Arch`?',
              ' Error message: ', error.output)

    # Write configuration to boot from the previously
    # found Linux partition
    arch_bootloader_conf = (
        "title Arch Linux\n"
        "linux /vmlinuz-linux\n"
        "initrd /initramfs-linux.img\n"
        "options quiet splash loglevel=3 udev.log-priority=3 vga=current root=PARTUUID="
        + linux_partition_partuuid + " rw")

    with open("/mnt/boot/loader/entries/arch.conf", "w") as file:
        file.write(arch_bootloader_conf)

    # Set the previous configuration as the default to boot
    default_bootloader_conf = (
        "default arch\n"
        "timeout 0\n"
        "editor  0")

    with open("/mnt/boot/loader/loader.conf", "w") as file:
        file.write(default_bootloader_conf)
Ejemplo n.º 10
0
def setup_languages(user_input):
    keyboard = user_input['keyboard layout']
    language = user_input['language']
    has_gui = user_input['desktop'] == 'KDE plasma'

    print(" >> Setting language and keyboard layout")
    if language == 'english (reasonable)':
        set_locale('en_DK.UTF-8', 'en_GB.UTF-8')
    elif language == 'english (US)':
        set_locale('en_US.UTF-8', 'en_US.UTF-8')

    if keyboard == 'DE - Deutschland':
        set_keymap('de-latin1')
        if has_gui:
            set_keymap_gui('de')

    elif keyboard == 'DE - Schweiz':
        set_keymap('sg-latin1')
        if has_gui:
            set_keymap_gui('ch')

    if keyboard == 'EN - US':
        set_keymap('us')
        if has_gui:
            set_keymap_gui('us', True)

    if keyboard == 'EN - GB':
        set_keymap('gb')
        if has_gui:
            set_keymap_gui('gb', True)

    try:
        print(" >> Generating locale")
        run("arch-chroot /mnt locale-gen")
    except CalledProcessError as error:
        print('Unable to generate locale on /mnt...', ' Error message: ',
              error.output)
Ejemplo n.º 11
0
def setup_languages(user_input):
    keyboard = user_input['keyboard layout']
    language = user_input['language']
    has_gui = user_input['desktop'] == 'KDE plasma'

    print(" >> Setting language and keyboard layout")
    if language == 'english (reasonable)':
        set_locale('en_DK.UTF-8', 'en_GB.UTF-8')
    elif language == 'english (US)':
        set_locale('en_US.UTF-8', 'en_US.UTF-8')

    if keyboard == 'DE - Deutschland':
        set_keymap('de-latin1')
        if has_gui:
            set_keymap_gui('de')

    elif keyboard == 'DE - Schweiz':
        set_keymap('sg-latin1')
        if has_gui:
            set_keymap_gui('ch')

    if keyboard == 'EN - US':
        set_keymap('us')
        if has_gui:
            set_keymap_gui('us', True)

    if keyboard == 'EN - GB':
        set_keymap('gb')
        if has_gui:
            set_keymap_gui('gb', True)

    try:
        print(" >> Generating locale")
        run("arch-chroot /mnt locale-gen")
    except CalledProcessError as error:
        print('Unable to generate locale on /mnt...',
              ' Error message: ', error.output)
Ejemplo n.º 12
0
def configure_bootloader():
    # Call to generate most default files and folder necessary for boot
    try:
        run("arch-chroot /mnt bootctl --path=/boot install")
    except CalledProcessError as error:
        print(
            'Unable to install bootloader. Is UEFI activated on your machine?',
            ' Error message: ', error.output)

    # Get the part_uuid of the Linux partition
    try:
        linux_partition_uuid = check_output("blkid -L Arch")
        linux_partition_partuuid = check_output("blkid -s PARTUUID -o value " +
                                                linux_partition_uuid)
    except CalledProcessError as error:
        print(
            'Unable to figure out PARTUUID of your Linux partition. Is it really called `Arch`?',
            ' Error message: ', error.output)

    # Write configuration to boot from the previously
    # found Linux partition
    arch_bootloader_conf = (
        "title Arch Linux\n"
        "linux /vmlinuz-linux\n"
        "initrd /initramfs-linux.img\n"
        "options quiet splash loglevel=3 udev.log-priority=3 vga=current root=PARTUUID="
        + linux_partition_partuuid + " rw")

    with open("/mnt/boot/loader/entries/arch.conf", "w") as file:
        file.write(arch_bootloader_conf)

    # Set the previous configuration as the default to boot
    default_bootloader_conf = ("default arch\n" "timeout 0\n" "editor  0")

    with open("/mnt/boot/loader/loader.conf", "w") as file:
        file.write(default_bootloader_conf)
Ejemplo n.º 13
0
def install_basic_arch():
    ### Nicer formatting for pacstrap
    sed_inplace("/etc/pacman.conf", "#Color", "Color")
    sed_inplace("/etc/pacman.conf", "#TotalDownload", "TotalDownload")
    ### Enable Multilib
    with open("/etc/pacman.conf", "a") as file:
        file.write("[multilib]\nInclude = /etc/pacman.d/mirrorlist")

    ### Update mirrorlist
    print(" >> Updating mirror list")
    try:
        run('reflector --latest 100 --sort rate --protocol https --save /etc/pacman.d/mirrorlist')
    except CalledProcessError as error:
        print('Updating package mirrorlist failed with message: ', error.output)

    ### Update system and keyring
    print(" >> Updating system and keyring")
    try:
        run('pacman -Sy --noconfirm')
        run('pacman -S archlinux-keyring --noconfirm')
    except CalledProcessError as error:
        print('Updating system and keyring failed with message: ', error.output)

    ### Install base packages
    print(" >> Going to install arch base packages")
    try:
        run('pacstrap /mnt '+ ' '.join(basics))
    except CalledProcessError as error:
        print('Error installing base packages. Message: ', error.output)

    print(" >> Installed arch base packages")

    ### Nicer formatting for pacstrap on installed system
    sed_inplace("/mnt/etc/pacman.conf", "#Color", "Color")
    sed_inplace("/mnt/etc/pacman.conf", "#TotalDownload", "TotalDownload")
    ### Enable Multilib on installed system
    with open("/mnt/etc/pacman.conf", "a") as file:
        file.write("[multilib]\nInclude = /etc/pacman.d/mirrorlist")
Ejemplo n.º 14
0
def configure_aur():
    print(" >> Going to install AUR packages")

    # Create fake install user
    run("arch-chroot /mnt useradd -m installer")
    open('/mnt/etc/sudoers', 'a').write('installer ALL=(ALL) NOPASSWD: ALL\n')

    # Copy install files to fake install user home directory
    copy2("arch-installer/aur-packages/aurPackageList.txt",
          "/mnt/home/installer/")
    copy2("arch-installer/aur-packages/installAurPackages.py",
          "/mnt/home/installer/")

    # Install aura and AUR packages
    run("arch-chroot /mnt sudo -u installer python /home/installer/installAurPackages.py"
        )

    # Remove fake install user,
    run("arch-chroot /mnt userdel installer")
    sed_inplace('/mnt/etc/sudoers', 'installer ALL=\(ALL\) NOPASSWD: ALL', '')
    run("rm -rf /mnt/home/installer")

    print(" >> Installed AUR packages")
Ejemplo n.º 15
0
def setup_timezone(user_input):
    print(' >> Setting Timezone')
    try:
        if user_input['timezone'] == 'Deutschland':
            run('arch-chroot /mnt ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime')
        if user_input['timezone'] == 'Schweiz':
            run('arch-chroot /mnt ln -sf /usr/share/zoneinfo/Europe/Zurich /etc/localtime')
    except CalledProcessError as error:
        print('Unable to set timezone',
            ' Error message: ', error.output)

    print(' >> Setting system clock')
    try:
        run('arch-chroot /mnt hwclock --systohc')
    except CalledProcessError as error:
        print('Unable to set system clock...',
            ' Error message: ', error.output)
Ejemplo n.º 16
0
def setup_timezone(user_input):
    print(' >> Setting Timezone')
    try:
        if user_input['timezone'] == 'Deutschland':
            run('arch-chroot /mnt ln -sf /usr/share/zoneinfo/Europe/Berlin /etc/localtime'
                )
        if user_input['timezone'] == 'Schweiz':
            run('arch-chroot /mnt ln -sf /usr/share/zoneinfo/Europe/Zurich /etc/localtime'
                )
    except CalledProcessError as error:
        print('Unable to set timezone', ' Error message: ', error.output)

    print(' >> Setting system clock')
    try:
        run('arch-chroot /mnt hwclock --systohc')
    except CalledProcessError as error:
        print('Unable to set system clock...', ' Error message: ',
              error.output)
Ejemplo n.º 17
0
def get_user_input(detected_hardware):
    user_input = {}

    # First ask for keyboard layout
    user_input['keyboard layout'] = ask_choice(
        'Please choose your keyboard-layout:',
        ['DE - Deutschland', 'DE - Schweiz', 'EN - US', 'EN - GB'],
        multiple_choice=False)

    # And set it immediately for the current installation so that the
    # user can enter his user name etc correctly
    try:
        if user_input['keyboard layout'] == 'DE - Deutschland':
            run("loadkeys de-latin1")
            run("set -x LANG \'en_DK.UTF-8\'")
            run("set -x LC_ALL \'en_DK.UTF-8\'")

        elif user_input['keyboard layout'] == 'DE - Schweiz':
            run("loadkeys sg-latin1")
            run("set -x LANG \'en_DK.UTF-8\'")
            run("set -x LC_ALL \'en_DK.UTF-8\'")

        elif user_input['keyboard layout'] == 'EN - GB':
            run("loadkeys uk")
            run("set -x LANG \'en_US.UTF-8\'")
            run("set -x LC_ALL \'en_US.UTF-8\'")

    except CalledProcessError as error:
        print('Unable to set keyboard to requested model: ' + error.output)

    user_input['username'] = ask_for_input(
        'Please choose your username. '
        'If you do not specify a username, no user will be created for you:',
        restricted_character_set=True,
        not_empty=False)
    user_input['hostname'] = ask_for_input(
        'Please choose a hostname (device name):',
        restricted_character_set=True)
    user_input['system type'] = ask_choice(
        'Please choose your kind of system:', ['desktop', 'server'],
        multiple_choice=False)
    if user_input['system type'] == 'desktop':
        user_input['packages'] = ask_choice(
            'Please choose your set of packages:',
            ['full', 'developer', 'office', 'media', 'minimal'])
    else:
        user_input['packages'] = ask_choice(
            'Please choose your set of packages:',
            ['full', 'developer', 'media', 'minimal'])

    user_input['desktop'] = ask_choice(
        'Please choose your desktop environment:', ['none', 'KDE plasma'],
        multiple_choice=False)
    # TODO: Check CPU driver
    # TODO: First check GPU automatically, then ask if it is correct, offer
    # options otherwise

    gpu_is_correct = ask_choice(
        'The following GPU vendor was auto-detected: `' +
        detected_hardware['gpu'] + '`. Is this correct?', ['Yes', 'No'],
        multiple_choice=False)

    if gpu_is_correct == 'Yes':
        user_input['graphics driver'] = detected_hardware['gpu']
    else:
        user_input['graphics driver'] = ask_choice(
            'Please choose your graphics driver manually:',
            ['default', 'intel', 'nVidia', 'AMD', 'vbox'],
            multiple_choice=False)

    user_input['language'] = ask_choice(
        'Please choose your language and locale settings.'
        'You have the choice between english with reasonable locale settings and english US:',
        ['english (reasonable)', 'english (US)'],
        multiple_choice=False)

    # TODO: timezones
    user_input['timezone'] = ask_choice('Please choose your timezone:',
                                        ['Deutschland', 'Schweiz'],
                                        multiple_choice=False)

    return user_input
Ejemplo n.º 18
0
def install_packages(user_input, install_user_name):

    print(" >> Packages Installation...")
    print("    Your package choices: ", user_input)

    ### All the packages

    misc_packages = ['vim',
                     'vim-supertab',
                     'vim-jedi',
                     'zsh',
                     'powerline-fonts',
                     'p7zip',
                     'unrar',
                     'fortune-mod',
                     'reflector',
                     'tree',
                     'openssh',
                     'networkmanager',
                     'htop',
                     'tmux']
    packages = {
        'minimal': {
            'desktop' : [],
            'server'  : ['docker']},
        'developer': defaultdict(lambda:
                                 ['cmake',
                                  'boost',
                                  'eigen',
                                  'opencl-headers',
                                  'ocl-icd',
                                  'openmpi',
                                  'hdf5-cpp-fortran',
                                  'python2-pip',
                                  'python-pip',
                                  'ipython',
                                  'python-h5py',
                                  'python-scipy',
                                  'python-matplotlib',
                                  'python-pillow',
                                  'python-pylint',
                                  'autopep8',
                                  'doxygen',
                                  'clinfo']),
        'office': defaultdict(lambda:
                              ['texlive-most',
                               'texlive-lang']),
        'media': {
            'desktop' : ['gnuplot',
                         'graphviz',
                         'ffmpeg'],
            'server'  : ['gnuplot',
                         'graphviz',
                         'ffmpeg']
        }
    }

    desktop_distros = {
        "KDE plasma": ['xorg-server',
                       'xorg-apps',
                       'yakuake',
                       'plasma-meta',
                       'kde-applications'],
        "Gnome": ['gnome',
                  'gnome-extra',
                  'gdm'],
        "Cinnamon": ['cinnamon',
                     'gdm'],
        "Deepin": ['deepin',
                   'deepin-extra',
                   'lightdm'],
        "Budgie": ['budgie-desktop',
                   'gnome',
                   'gdm']
    }

    gui_packages = {
        'minimal': {
            'desktop': ['qtox',
                        'xclip',
                        'yakuake-skin-breeze-thin-dark'],
            'server': ['yakuake-skin-breeze-thin-dark']},
        'developer': defaultdict(lambda: ['xterm', 'visual-studio-code']),
        'office': defaultdict(lambda:
                              ['texstudio',
                               'libreoffice-fresh']),
        'media': {
            'desktop': ['teamspeak3',
                        'gimp',
                        'inkscape',
                        'blender',
                        'handbrake',
                        'vlc',
                        'skypeforlinux-bin',
                        'nextcloud-client',
                        'steam'],
            'server': ['vlc',
                       'steam']}
    }

    graphics_driver_packages = {
        'default': ['mesa', 'mesa-libgl', 'xf86-video-vesa', 'opencl-mesa'],
        'intel':   ['mesa', 'mesa-libgl', 'xf86-video-intel', 'opencl-mesa'],
        'nvidia':  ['nvidia', 'nvidia-libgl', 'opencl-nvidia'],
        'amd':     ['mesa', 'mesa-libgl', 'xf86-video-vesa', 'opencl-mesa'],
        'vbox':    ['virtualbox-guest-modules-arch', 'virtualbox-guest-utils', 'opencl-mesa']}

    server_docker_images = {
        'minimal':   ['nginx'],
        'developer': ['gitlab'],
        'office':    [],
        'media':     ['teamspeak', 'nextcloud']}


    ### Generate the package list
    package_list = misc_packages
    package_list += graphics_driver_packages[user_input['graphics driver']]
    #   Add non-minimal packages to list
    if 'full' in user_input['packages']:
        for _, value in packages.items():
            package_list += value[user_input['system type']]

        if user_input['desktop'] != 'none':
            package_list += desktop_distros[user_input['desktop']]
            for _, value in gui_packages.items():
                package_list += value[user_input['system type']]
    else:
        for package_type in set(['minimal'] + user_input['packages']):
            package_list += packages[package_type][user_input['system type']]

            if user_input['desktop'] != 'none':
                package_list += desktop_distros[user_input['desktop']]
                package_list += gui_packages[package_type][user_input['system type']]

    ### Generate docker image list
    server_docker_list = []
    #   Add non-minimal images to list
    if 'full' in user_input['packages']:
        for _, value in server_docker_images.items():
            server_docker_list += value
    else:
        for package_type in set(['minimal'] + user_input['packages']):
            server_docker_list += server_docker_images[package_type]

    ### Parallel makepkg
    print(" >> Setting `makepkg` parallel")
    sed_inplace(
        '/etc/makepkg.conf',
        '#MAKEFLAGS="-j2"',
        'MAKEFLAGS="-j$(nproc)"')
    sed_inplace(
        '/mnt/etc/makepkg.conf',
        '#MAKEFLAGS="-j2"',
        'MAKEFLAGS="-j$(nproc)"')
    print(" >> Gave `makepkg` the flag `-j2`")


    ### Install packages using pacaur
    print(" >> Going to install user packages")
    with tempfile.NamedTemporaryFile(mode='w', suffix='.txt', dir='/mnt') as package_file:
        package_string = " ".join(package_list)
        package_file.write(package_string)
        package_file.flush()
        try:
            run('arch-chroot /mnt sudo -u {} pacaur -S --noconfirm --noedit `cat {}`'.format(install_user_name, package_file.name))
        except CalledProcessError as error:
            print('Error installing packages. Message: ', error.output)
    print(" >> Installed user packages")

    ### Pull docker images
    if user_input['system type'] == 'server':
        print(" >> Going to pull docker images")
        try:
            for image in server_docker_list:
                run('arch-chroot /mnt sudo -u {} systemctl start docker'.format(install_user_name))
                run('arch-chroot /mnt sudo -u {} docker pull {}'.format(install_user_name, image))
        except CalledProcessError as error:
            print('Error pulling docker images. Message: ', error.output)
        print(" >> Pulled docker images")


    print(" >> Packages Installation... done")
Ejemplo n.º 19
0
def create_and_mount():
    print(" >> Fetching partitions from labels 'Arch' and 'EFI'")
    try:
        device = check_output("blkid -L Arch").strip()
        bootdevice = check_output("blkid -L EFI").strip()
    except CalledProcessError as error:
        print(
            'Unable to figure out linux and boot partition. You need to label the linux partition `Arch`'
            ' and the boot partition `EFI` for auto-detection to work.',
            ' Error message: ', error.output)

    print(" >> Mounting 'Arch' partition (" + device + ") on /mnt")
    try:
        run("yes | mkfs.ext4 -L Arch " + device)
        run("mount " + device + " /mnt")
    except CalledProcessError as error:
        print("Unable to mount 'Arch' partition on /mnt .", ' Error message: ',
              error.output)

    print(" >> Mounting 'EFI' boot partition (" + bootdevice +
          ") on /mnt/boot")
    try:
        run("mkdir -p /mnt/boot")
        run("yes | mkfs.fat -F32 " + bootdevice)
        run("fatlabel " + bootdevice + " EFI")
        run("mount " + bootdevice + " /mnt/boot")
    except CalledProcessError as error:
        print("Unable to mount 'EFI' partition on /mnt/boot .",
              ' Error message: ', error.output)
Ejemplo n.º 20
0
def install_packages(user_input, install_user_name):
    ### Setup Package List
    print(" >> Creating package list")
    print(" Your choices: ", user_input)

    sed_inplace('/etc/makepkg.conf', '#MAKEFLAGS="-j2"',
                'MAKEFLAGS="-j$(nproc)"')
    sed_inplace('/mnt/etc/makepkg.conf', '#MAKEFLAGS="-j2"',
                'MAKEFLAGS="-j$(nproc)"')

    misc_packages = [
        'vim', 'vim-supertab', 'vim-jedi', 'zsh', 'powerline-fonts', 'p7zip',
        'unrar', 'fortune-mod', 'reflector', 'tree'
    ]
    packages = {
        'minimal': {
            'desktop': [],
            'server': ['openssh']
        },
        'developer':
        defaultdict(lambda: [
            'cmake', 'boost', 'eigen', 'opencl-headers', 'ocl-icd', 'openmpi',
            'hdf5-cpp-fortran', 'python2-pip', 'python-pip', 'ipython',
            'python-h5py', 'python-scipy', 'python-matplotlib',
            'python-pillow', 'python-pylint', 'autopep8', 'doxygen', 'clinfo'
        ]),
        'office':
        defaultdict(lambda: ['texlive-most', 'texlive-lang']),
        'media': {
            'desktop': ['gnuplot', 'graphviz', 'ffmpeg'],
            'server': ['gnuplot', 'graphviz', 'ffmpeg', 'teamspeak3-server']
        }
    }

    desktop_distros = {
        "KDE plasma": [
            'xorg-server', 'xorg-apps', 'yakuake', 'plasma-meta',
            'kde-applications'
        ]
    }

    gui_packages = {
        'minimal': {
            'desktop': ['qtox', 'xclip', 'yakuake-skin-breeze-thin-dark'],
            'server': ['yakuake-skin-breeze-thin-dark']
        },
        'developer': defaultdict(lambda: ['xterm', 'visual-studio-code']),
        'office': defaultdict(lambda: ['texstudio', 'libreoffice-fresh']),
        'media': {
            'desktop': [
                'teamspeak3', 'gimp', 'inkscape', 'blender', 'handbrake',
                'vlc', 'skypeforlinux-bin', 'nextcloud-client'
            ],
            'server': ['vlc', 'nextcloud']
        }
    }

    graphics_driver_packages = {
        'default': ['mesa', 'mesa-libgl', 'xf86-video-vesa', 'opencl-mesa'],
        'intel': ['mesa', 'mesa-libgl', 'xf86-video-intel', 'opencl-mesa'],
        'nvidia': ['nvidia', 'nvidia-libgl', 'opencl-nvidia'],
        'amd': ['mesa', 'mesa-libgl', 'xf86-video-vesa', 'opencl-mesa'],
        'vbox': [
            'virtualbox-guest-modules-arch', 'virtualbox-guest-utils',
            'opencl-mesa'
        ]
    }

    package_list = misc_packages
    package_list += graphics_driver_packages[user_input['graphics driver']]

    if 'full' in user_input['packages']:
        for _, value in packages.items():
            package_list += value[user_input['system type']]

        if user_input['desktop'] != 'none':
            package_list += desktop_distros[user_input['desktop']]
            for _, value in gui_packages.items():
                package_list += value[user_input['system type']]

    else:
        for package_type in set(['minimal'] + user_input['packages']):
            package_list += packages[package_type][user_input['system type']]

            if user_input['desktop'] != 'none':
                package_list += desktop_distros[user_input['desktop']]
                package_list += gui_packages[package_type][
                    user_input['system type']]

    package_string = " ".join(package_list)

    print(" >> Going to install user packages")
    with tempfile.NamedTemporaryFile(mode='w', suffix='.txt',
                                     dir='/mnt') as package_file:
        package_file.write(package_string)
        package_file.flush()
        try:
            run('arch-chroot /mnt sudo -u {} pacaur -S --noconfirm --noedit `cat {}`'
                .format(install_user_name, package_file.name))
        except CalledProcessError as error:
            print('Error installing packages. Message: ', error.output)

    print(" >> Installed user packages")
Ejemplo n.º 21
0
def autostart_add_services(user_input):
    print(" >> Adding services to autostart")
    try:
        # networking
        run('arch-chroot /mnt systemctl enable dhcpcd')
        run('arch-chroot /mnt systemctl enable NetworkManager')
        # ssh daemon
        run("arch-chroot /mnt systemctl enable sshd")
        # desktop daemon
        #       kde
        if user_input['desktop'] == 'KDE plasma':
            run("arch-chroot /mnt systemctl enable sddm")
        #       gnome
        elif user_input['desktop'] == 'Gnome':
            run("arch-chroot /mnt systemctl enable gdm")
        #       cinnamon
        elif user_input['desktop'] == 'Cinnamon':
            run("arch-chroot /mnt systemctl enable gdm")
        #       deepin
        elif user_input['desktop'] == 'Deepin':
            run("arch-chroot /mnt systemctl enable lightdm")
        #       budgie
        elif user_input['desktop'] == 'Budgie':
            run("arch-chroot /mnt systemctl enable gdm")
        # server docker service
        if user_input['system type'] == 'server':
            run("arch-chroot /mnt systemctl enable docker")
    except CalledProcessError as error:
        print('Adding services to autostart failed with message: ', error.output)
Ejemplo n.º 22
0
def generate_fstab():
    try:
        run("genfstab -pU /mnt >> /mnt/etc/fstab")
    except CalledProcessError as error:
        print('Unable to generate /mnt/etc/fstab...',
                ' Error message: ', error.output)
Ejemplo n.º 23
0
def configure_ssh():
    print(" >> Enabling sshd")
    try:
        run("arch-chroot /mnt systemctl enable sshd")
    except CalledProcessError as error:
        print('Enabling sshd failed with message: ', error.output)
Ejemplo n.º 24
0
def generate_fstab():
    try:
        run("genfstab -pU /mnt >> /mnt/etc/fstab")
    except CalledProcessError as error:
        print('Unable to generate /mnt/etc/fstab...', ' Error message: ',
              error.output)
Ejemplo n.º 25
0
def configure_shell():
    ### Place yakuake into autostart
    print(" >> Adding yakuake to autostart")
    run("mkdir -p /mnt/etc/skel/.config/autostart-scripts/")
    run("chmod +x arch-installer/autostart/yakuake.sh")
    copy2("arch-installer/autostart/yakuake.sh",
          "/mnt/etc/skel/.config/autostart-scripts/")

    ### Install zsh and configure
    print(" >> Installing zsh with prezto")

    ### Clone the Prezto files
    run("git clone --recursive https://github.com/sorin-ionescu/prezto.git /mnt/etc/skel/.zprezto"
        )

    ### Set correct theme
    # sed -i "s|theme '<replace>'|theme '$USER_ZSH_THEME'|g" arch-installer/configuration_zsh/zpreztorc

    ### Copy them into the user's folder
    run("zsh arch-installer/configuration_zsh/zsh_setup_configs.sh")

    ### Copy prompt theme and .zpreztorc over
    copy2("arch-installer/configuration_zsh/zshrc", "/mnt/etc/skel/.zshrc")
    copy2("arch-installer/configuration_zsh/zpreztorc",
          "/mnt/etc/skel/.zpreztorc")
    copy2("arch-installer/configuration_zsh/prompt_plasmon_setup",
          "/mnt/etc/skel/.zprezto/modules/prompt/functions/")

    ### Add powerline fonts to display prezto symbols
    print(" >> Installing powerline fonts")
    run("git clone https://github.com/powerline/fonts")
    run("export HOME='/mnt/etc/skel' && zsh ./fonts/install.sh")

    ### Copy Vim-config
    copy2("arch-installer/configuration_zsh/.vimrc", "/mnt/etc/skel/")

    ### Change the default shell
    print(" >> Changing default shell to zsh")
    sed_inplace("/mnt/etc/default/useradd", "SHELL=/bin/bash",
                "SHELL=/bin/zsh")
Ejemplo n.º 26
0
def configure_network():
    print(" >> Enabling dhcpd")
    try:
        run('arch-chroot /mnt systemctl enable dhcpcd')
    except CalledProcessError as error:
        print('Enabling dhcpd failed with message: ', error.output)