From f6f5875892e4ec6978323026b5f7819ddce1bb83 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Thu, 20 Aug 2020 19:47:39 +0000 Subject: Added a unattended installer. Fixed list_profiles() to not include .py ending in the profile name, it's already in the ['path'] defintion. Renamed desktop.py to awesome.py as it more accurately describes what's being installed. desktop should be reserved to a default desktop environment that's more new-user-friendly. --- archinstall/lib/profiles.py | 4 ++-- examples/minimal.py | 2 +- examples/unattended.py | 19 +++++++++++++++---- profiles/52-54-00-12-34-56.py | 2 +- profiles/awesome.py | 27 +++++++++++++++++++++++++++ profiles/desktop.py | 27 --------------------------- 6 files changed, 46 insertions(+), 35 deletions(-) create mode 100644 profiles/awesome.py delete mode 100644 profiles/desktop.py diff --git a/archinstall/lib/profiles.py b/archinstall/lib/profiles.py index b63a26c4..2ed367b9 100644 --- a/archinstall/lib/profiles.py +++ b/archinstall/lib/profiles.py @@ -26,7 +26,7 @@ def list_profiles(base='./profiles/', filter_irrelevant_macs=True): tailored = False if os.path.splitext(file)[1] == '.py': if len(mac := re.findall('(([a-zA-z0-9]{2}[-:]){5}([a-zA-z0-9]{2}))', file)): - if filter_irrelevant_macs and mac[0][0] not in local_macs:: + if filter_irrelevant_macs and mac[0][0] not in local_macs: continue tailored = True @@ -36,7 +36,7 @@ def list_profiles(base='./profiles/', filter_irrelevant_macs=True): if first_line[0] == '#': description = first_line[1:].strip() - cache[file] = {'path' : os.path.join(root, file), 'description' : description, 'tailored' : tailored} + cache[file[:-2]] = {'path' : os.path.join(root, file), 'description' : description, 'tailored' : tailored} break return cache diff --git a/examples/minimal.py b/examples/minimal.py index 203fa94e..c0ccfe20 100644 --- a/examples/minimal.py +++ b/examples/minimal.py @@ -24,7 +24,7 @@ with archinstall.Filesystem(harddrive, archinstall.GPT) as fs: installation.add_bootloader() installation.add_additional_packages(['nano', 'wget', 'git']) - installation.install_profile('workstation') + installation.install_profile('awesome') installation.user_create('anton', 'test') installation.user_set_pw('root', 'toor') diff --git a/examples/unattended.py b/examples/unattended.py index 7dfa58c1..b0ef0b7b 100644 --- a/examples/unattended.py +++ b/examples/unattended.py @@ -1,6 +1,17 @@ import archinstall +import time -for profile in archinstall.list_profiles(): - # Tailored means it's a match for this machine. - if profile['tailored']: - print('Selecting profile to be installed:', profile) \ No newline at end of file +for name, info in archinstall.list_profiles().items(): + # Tailored means it's a match for this machine + # based on it's MAC address (or some other criteria + # that fits the requirements for this machine specifically). + if info['tailored']: + print(f'Found a tailored profile for this machine called: "{name}".') + print(f'Starting install in:') + for i in range(10, 0, -1): + print(f'{i}...') + time.sleep(1) + + profile = archinstall.Profile(None, info['path']) + profile.install() + break \ No newline at end of file diff --git a/profiles/52-54-00-12-34-56.py b/profiles/52-54-00-12-34-56.py index 4c487938..6a3639c7 100644 --- a/profiles/52-54-00-12-34-56.py +++ b/profiles/52-54-00-12-34-56.py @@ -24,7 +24,7 @@ with archinstall.Filesystem(harddrive, archinstall.GPT) as fs: installation.add_bootloader() installation.add_additional_packages(['nano', 'wget', 'git']) - installation.install_profile('workstation') + installation.install_profile('awesome') installation.user_create('anton', 'test') installation.user_set_pw('root', 'toor') diff --git a/profiles/awesome.py b/profiles/awesome.py new file mode 100644 index 00000000..67e4fd25 --- /dev/null +++ b/profiles/awesome.py @@ -0,0 +1,27 @@ +# A desktop environemtn using "Awesome" window manager. + +import archinstall + +arguments = { + 'keyboard_layout' : 'sv-latin1', + "editor" : "nano", + "mediaplayer" : "lollypop gstreamer gst-plugins-good gnome-keyring", + "filebrowser" : "nemo gpicview-gtk3", + "webbrowser" : "chromium", + "window_manager" : "awesome", + "virtulization" : "qemu ovmf", + "utils" : "openssh sshfs git htop pkgfile scrot dhclient wget smbclient cifs-utils libu2f-host", + "audio" : "pulseaudio pulseaudio-alsa pavucontrol" +} + +installation.add_additional_packages("{webbrowser} {utils} {mediaplayer} {window_manager} {virtulization} {filebrowser} {editor}".format(**arguments)) + +with open(f'{installation.mountpoint}/etc/X11/xinit/xinitrc', 'a') as X11: + X11.write('setxkbmap se\n') + +with open(f'{installation.mountpoint}/etc/vconsole.conf', 'a') as vconsole: + vconsole.write('KEYMAP={keyboard_layout}\n'.format(**arguments)) + vconsole.write('FONT=lat9w-16\n') + +awesome = archinstall.Application(installation, 'awesome') +awesome.install() \ No newline at end of file diff --git a/profiles/desktop.py b/profiles/desktop.py deleted file mode 100644 index 67e4fd25..00000000 --- a/profiles/desktop.py +++ /dev/null @@ -1,27 +0,0 @@ -# A desktop environemtn using "Awesome" window manager. - -import archinstall - -arguments = { - 'keyboard_layout' : 'sv-latin1', - "editor" : "nano", - "mediaplayer" : "lollypop gstreamer gst-plugins-good gnome-keyring", - "filebrowser" : "nemo gpicview-gtk3", - "webbrowser" : "chromium", - "window_manager" : "awesome", - "virtulization" : "qemu ovmf", - "utils" : "openssh sshfs git htop pkgfile scrot dhclient wget smbclient cifs-utils libu2f-host", - "audio" : "pulseaudio pulseaudio-alsa pavucontrol" -} - -installation.add_additional_packages("{webbrowser} {utils} {mediaplayer} {window_manager} {virtulization} {filebrowser} {editor}".format(**arguments)) - -with open(f'{installation.mountpoint}/etc/X11/xinit/xinitrc', 'a') as X11: - X11.write('setxkbmap se\n') - -with open(f'{installation.mountpoint}/etc/vconsole.conf', 'a') as vconsole: - vconsole.write('KEYMAP={keyboard_layout}\n'.format(**arguments)) - vconsole.write('FONT=lat9w-16\n') - -awesome = archinstall.Application(installation, 'awesome') -awesome.install() \ No newline at end of file -- cgit v1.2.3-70-g09d2