From 0c235c929c04d0d9268b8afd211bba0abd36ad04 Mon Sep 17 00:00:00 2001 From: demostanis Date: Fri, 23 Oct 2020 11:50:25 +0200 Subject: Added sums to PKGBUILD --- PKGBUILD/python-archinstall/PKGBUILD | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/PKGBUILD/python-archinstall/PKGBUILD b/PKGBUILD/python-archinstall/PKGBUILD index 6fa0f044..50ae9ac9 100644 --- a/PKGBUILD/python-archinstall/PKGBUILD +++ b/PKGBUILD/python-archinstall/PKGBUILD @@ -1,26 +1,34 @@ -# Maintainer: Anton Hvornum anton@hvornum.se -# Contributor: Anton Hvornum anton@hvornum.se +# Maintainer: Anton Hvornum +# Contributor: demostanis worlds + pkgname="python-archinstall" pkgver="2.0.5" pkgdesc="Installs ${pkgname} as a python library." pkgrel=1 url="https://github.com/Torxed/archinstall" +source=("${pkgname}-v${pkgver}-x86_64.tar.gz::https://github.com/Torxed/archinstall/archive/v$pkgver.tar.gz") license=('GPLv3') provides=("${pkgname}") -md5sums=('SKIP') arch=('x86_64') -source=("${pkgname}-v${pkgver}-x86_64.tar.gz::https://github.com/Torxed/archinstall/archive/v$pkgver.tar.gz") depends=('python>=3.8') -optdepends=('pyttsx3: Adds text-to-speach support for log/screen output.') +makedepends=('python-setuptools') +optdepends=('pyttsx3: Adds text-to-speech support for log/screen output.') +md5sums=('a23ec87d901d9dc28a8a36dd7427200f') build() { cd "archinstall-${pkgver}" - python3 setup.py build + python setup.py build } package() { cd "archinstall-${pkgver}" - python setup.py install --prefix=/usr --root="${pkgdir}" --optimize=1 + python setup.py install \ + --prefix=/usr \ + --root="${pkgdir}" \ + --optimize=1 } + +# vim:ft=sh + -- cgit v1.2.3-70-g09d2 From 4ef2a60e6a93739672c64ce8f08775493bb48186 Mon Sep 17 00:00:00 2001 From: demostanis Date: Fri, 23 Oct 2020 11:55:36 +0200 Subject: Added one single sh file to run archinstall --- PKGBUILD/archinstall/PKGBUILD | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/PKGBUILD/archinstall/PKGBUILD b/PKGBUILD/archinstall/PKGBUILD index 40c80c3b..b8435b33 100644 --- a/PKGBUILD/archinstall/PKGBUILD +++ b/PKGBUILD/archinstall/PKGBUILD @@ -7,27 +7,20 @@ pkgrel=1 url="https://github.com/Torxed/archinstall" license=('GPLv3') provides=("${pkgname}") -md5sums=('SKIP') arch=('x86_64') source=("${pkgname}-v${pkgver}-x86_64.tar.gz::https://github.com/Torxed/archinstall/archive/v$pkgver.tar.gz") depends=('python-archinstall') +md5sums=('a23ec87d901d9dc28a8a36dd7427200f') package() { mkdir -p "${pkgdir}/usr/bin" # Install a guided profile - echo '#!/bin/bash' > "${pkgdir}/usr/bin/archinstall-guided" - echo 'python -m archinstall guided' >> "${pkgdir}/usr/bin/archinstall-guided" + cat - > "${pkgdir}/usr/bin/archinstall" < "${pkgdir}/usr/bin/archinstall-minimal" - echo 'python -m archinstall minimal' >> "${pkgdir}/usr/bin/archinstall-minimal" +python -m archinstall $@ +EOF - # Install a unattended profile (safely aborts if no machine specific instructions are found) - #echo '#!/bin/bash' > "${pkgdir}/usr/bin/archinstall-unattended" - #echo 'python -m archinstall unattended' >> "${pkgdir}/usr/bin/archinstall-unattended" - - chmod +x "${pkgdir}/usr/bin/archinstall-guided" - chmod +x "${pkgdir}/usr/bin/archinstall-minimal" - #chmod +x "${pkgdir}/usr/bin/archinstall-unattended" + chmod +x "${pkgdir}/usr/bin/archinstall" } -- cgit v1.2.3-70-g09d2 From 7f72c0fd93eae201c6b802d3c5059e51d8c8d4b1 Mon Sep 17 00:00:00 2001 From: demostanis Date: Fri, 23 Oct 2020 12:02:06 +0200 Subject: Add vim line --- PKGBUILD/archinstall/PKGBUILD | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/PKGBUILD/archinstall/PKGBUILD b/PKGBUILD/archinstall/PKGBUILD index b8435b33..897db3fc 100644 --- a/PKGBUILD/archinstall/PKGBUILD +++ b/PKGBUILD/archinstall/PKGBUILD @@ -1,5 +1,5 @@ -# Maintainer: Anton Hvornum anton@hvornum.se -# Contributor: Anton Hvornum anton@hvornum.se +# Maintainer: Anton Hvornum +# Contributor: demostanis worlds pkgname="archinstall" pkgver="2.0.5" pkgdesc="Installs launcher scripts for archinstall" @@ -24,3 +24,6 @@ EOF chmod +x "${pkgdir}/usr/bin/archinstall" } + +# vim:ft=sh + -- cgit v1.2.3-70-g09d2 From 434cf7122174e15b166449ec531d4c18d064368c Mon Sep 17 00:00:00 2001 From: demostanis Date: Fri, 23 Oct 2020 15:44:02 +0200 Subject: Add support for remote profiles --- archinstall/__main__.py | 58 ++++++++++++++++++++++++++++++------------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/archinstall/__main__.py b/archinstall/__main__.py index fe4a3732..744d2a5d 100644 --- a/archinstall/__main__.py +++ b/archinstall/__main__.py @@ -1,5 +1,6 @@ +from urllib.parse import urlparse import archinstall, sys, os, glob -import importlib.util +import urllib.request # TODO: Learn the dark arts of argparse... # (I summon thee dark spawn of cPython) @@ -19,28 +20,41 @@ def find_examples(): return {os.path.basename(path): path for path in glob.glob(f'{examples}/*.py')} +def find(url): + parsed_url = urlparse(url) + if not parsed_url.scheme: + examples = find_examples() + if f"{url}.py" in examples: + return open(examples[f"{url}.py"]).read() + try: + return open(url, 'r').read() + except FileNotFoundError: + return ProfileNotFound(f"File {url} does not exist") + elif parsed_url.scheme in ('https', 'http'): + return urllib.request.urlopen(url).read().decode('utf-8') + else: + return ProfileNotFound(f"Cannot handle scheme {parsed_url.scheme}") + def run_as_a_module(): - """ - Since we're running this as a 'python -m archinstall' module OR - a nuitka3 compiled version of the project. - This function and the file __main__ acts as a entry point. - """ - if len(sys.argv) == 1: sys.argv.append('guided') - - profile = sys.argv[1] - library = find_examples() - - if f'{profile}.py' not in library: - raise ProfileNotFound(f'Could not locate {profile}.py among the example files.') - - # Import and execute the chosen `.py`: - spec = importlib.util.spec_from_file_location( - library[f"{profile}.py"], - library[f"{profile}.py"] - ) - imported_path = importlib.util.module_from_spec(spec) - spec.loader.exec_module(imported_path) - sys.modules[library[f'{profile}.py']] = imported_path + """ + Since we're running this as a 'python -m archinstall' module OR + a nuitka3 compiled version of the project. + This function and the file __main__ acts as a entry point. + """ + if len(sys.argv) == 1: sys.argv.append('guided') + + try: + profile = find(sys.argv[1]) + print(profile) + except ProfileNotFound as err: + print(f"Couldn't find file: {err}") + sys.exit(1) + + try: + exec(profile) # Is this is very safe? + except Exception as err: + print(f"Failed to run profile... {err}") + sys.exit(1) # Should prompt for another profile path instead if __name__ == '__main__': run_as_a_module() -- cgit v1.2.3-70-g09d2 From d018ae98a1178ca3105e68cf7a25df32ece12398 Mon Sep 17 00:00:00 2001 From: demostanis Date: Fri, 23 Oct 2020 15:49:03 +0200 Subject: Remove useless log --- archinstall/__main__.py | 1 - 1 file changed, 1 deletion(-) diff --git a/archinstall/__main__.py b/archinstall/__main__.py index 744d2a5d..d2ef22cb 100644 --- a/archinstall/__main__.py +++ b/archinstall/__main__.py @@ -45,7 +45,6 @@ def run_as_a_module(): try: profile = find(sys.argv[1]) - print(profile) except ProfileNotFound as err: print(f"Couldn't find file: {err}") sys.exit(1) -- cgit v1.2.3-70-g09d2 From 5d2b11e60fa244c1f8af78d4238848f45a4c0d2c Mon Sep 17 00:00:00 2001 From: demostanis Date: Fri, 23 Oct 2020 15:53:31 +0200 Subject: Ran autopep8 --- archinstall/__main__.py | 73 +++++++++++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/archinstall/__main__.py b/archinstall/__main__.py index d2ef22cb..de7cf994 100644 --- a/archinstall/__main__.py +++ b/archinstall/__main__.py @@ -1,59 +1,68 @@ from urllib.parse import urlparse -import archinstall, sys, os, glob +import archinstall +import sys +import os +import glob import urllib.request # TODO: Learn the dark arts of argparse... # (I summon thee dark spawn of cPython) + class ProfileNotFound(BaseException): - pass + pass + def find_examples(): - """ - Used to locate the examples, bundled with the module or executable. + """ + Used to locate the examples, bundled with the module or executable. - :return: {'guided.py' : './examples/guided.py', '' : ''} - :rtype: dict - """ - cwd = os.path.abspath(f'{os.path.dirname(__file__)}') - examples = f"{cwd}/examples" + :return: {'guided.py' : './examples/guided.py', '' : ''} + :rtype: dict + """ + cwd = os.path.abspath(f'{os.path.dirname(__file__)}') + examples = f"{cwd}/examples" + + return {os.path.basename(path): path for path in glob.glob(f'{examples}/*.py')} - return {os.path.basename(path): path for path in glob.glob(f'{examples}/*.py')} def find(url): parsed_url = urlparse(url) if not parsed_url.scheme: examples = find_examples() if f"{url}.py" in examples: - return open(examples[f"{url}.py"]).read() + return open(examples[f"{url}.py"]).read() try: - return open(url, 'r').read() + return open(url, 'r').read() except FileNotFoundError: - return ProfileNotFound(f"File {url} does not exist") + return ProfileNotFound(f"File {url} does not exist") elif parsed_url.scheme in ('https', 'http'): return urllib.request.urlopen(url).read().decode('utf-8') else: return ProfileNotFound(f"Cannot handle scheme {parsed_url.scheme}") + def run_as_a_module(): - """ - Since we're running this as a 'python -m archinstall' module OR - a nuitka3 compiled version of the project. - This function and the file __main__ acts as a entry point. - """ - if len(sys.argv) == 1: sys.argv.append('guided') - - try: - profile = find(sys.argv[1]) - except ProfileNotFound as err: - print(f"Couldn't find file: {err}") - sys.exit(1) - - try: - exec(profile) # Is this is very safe? - except Exception as err: - print(f"Failed to run profile... {err}") - sys.exit(1) # Should prompt for another profile path instead + """ + Since we're running this as a 'python -m archinstall' module OR + a nuitka3 compiled version of the project. + This function and the file __main__ acts as a entry point. + """ + if len(sys.argv) == 1: + sys.argv.append('guided') + + try: + profile = find(sys.argv[1]) + except ProfileNotFound as err: + print(f"Couldn't find file: {err}") + sys.exit(1) + + try: + exec(profile) # Is this is very safe? + except Exception as err: + print(f"Failed to run profile... {err}") + sys.exit(1) # Should prompt for another profile path instead + if __name__ == '__main__': - run_as_a_module() + run_as_a_module() -- cgit v1.2.3-70-g09d2 From 57eef46f953574799e01b389e9f665f058bbd42d Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Sun, 1 Nov 2020 23:01:41 +0000 Subject: Fix for issue #59 Relative paths work great for running as a script. But break when running as a module since there is no `src/` folder to mention. This should clear that up as the `src/` now lives under wherever the python package was installed. --- archinstall/__main__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/archinstall/__main__.py b/archinstall/__main__.py index fe4a3732..48d8a5ce 100644 --- a/archinstall/__main__.py +++ b/archinstall/__main__.py @@ -33,6 +33,10 @@ def run_as_a_module(): if f'{profile}.py' not in library: raise ProfileNotFound(f'Could not locate {profile}.py among the example files.') + # Swap the working dir, otherwise certain relative lookups won't work within archinstall. + # Mainly to avoid https://github.com/Torxed/archinstall/issues/59 + os.chdir(os.path.abspath(os.path.dirname(__file__))) + # Import and execute the chosen `.py`: spec = importlib.util.spec_from_file_location( library[f"{profile}.py"], -- cgit v1.2.3-70-g09d2 From 8f7cc1280eed461e28d9a3273da103142c59c18c Mon Sep 17 00:00:00 2001 From: demostanis Date: Mon, 2 Nov 2020 18:30:43 +0100 Subject: Replaced spaces with tabs --- archinstall/__main__.py | 82 ++++++++++++++++++++++++------------------------- 1 file changed, 41 insertions(+), 41 deletions(-) diff --git a/archinstall/__main__.py b/archinstall/__main__.py index de7cf994..be3d4e66 100644 --- a/archinstall/__main__.py +++ b/archinstall/__main__.py @@ -6,63 +6,63 @@ import glob import urllib.request # TODO: Learn the dark arts of argparse... -# (I summon thee dark spawn of cPython) +# (I summon thee dark spawn of cPython) class ProfileNotFound(BaseException): - pass + pass def find_examples(): - """ - Used to locate the examples, bundled with the module or executable. + """ + Used to locate the examples, bundled with the module or executable. - :return: {'guided.py' : './examples/guided.py', '' : ''} - :rtype: dict - """ - cwd = os.path.abspath(f'{os.path.dirname(__file__)}') - examples = f"{cwd}/examples" + :return: {'guided.py' : './examples/guided.py', '' : ''} + :rtype: dict + """ + cwd = os.path.abspath(f'{os.path.dirname(__file__)}') + examples = f"{cwd}/examples" - return {os.path.basename(path): path for path in glob.glob(f'{examples}/*.py')} + return {os.path.basename(path): path for path in glob.glob(f'{examples}/*.py')} def find(url): - parsed_url = urlparse(url) - if not parsed_url.scheme: - examples = find_examples() - if f"{url}.py" in examples: - return open(examples[f"{url}.py"]).read() - try: - return open(url, 'r').read() - except FileNotFoundError: - return ProfileNotFound(f"File {url} does not exist") - elif parsed_url.scheme in ('https', 'http'): - return urllib.request.urlopen(url).read().decode('utf-8') - else: - return ProfileNotFound(f"Cannot handle scheme {parsed_url.scheme}") + parsed_url = urlparse(url) + if not parsed_url.scheme: + examples = find_examples() + if f"{url}.py" in examples: + return open(examples[f"{url}.py"]).read() + try: + return open(url, 'r').read() + except FileNotFoundError: + return ProfileNotFound(f"File {url} does not exist") + elif parsed_url.scheme in ('https', 'http'): + return urllib.request.urlopen(url).read().decode('utf-8') + else: + return ProfileNotFound(f"Cannot handle scheme {parsed_url.scheme}") def run_as_a_module(): - """ - Since we're running this as a 'python -m archinstall' module OR - a nuitka3 compiled version of the project. - This function and the file __main__ acts as a entry point. - """ - if len(sys.argv) == 1: - sys.argv.append('guided') + """ + Since we're running this as a 'python -m archinstall' module OR + a nuitka3 compiled version of the project. + This function and the file __main__ acts as a entry point. + """ + if len(sys.argv) == 1: + sys.argv.append('guided') - try: - profile = find(sys.argv[1]) - except ProfileNotFound as err: - print(f"Couldn't find file: {err}") - sys.exit(1) + try: + profile = find(sys.argv[1]) + except ProfileNotFound as err: + print(f"Couldn't find file: {err}") + sys.exit(1) - try: - exec(profile) # Is this is very safe? - except Exception as err: - print(f"Failed to run profile... {err}") - sys.exit(1) # Should prompt for another profile path instead + try: + exec(profile) # Is this is very safe? + except Exception as err: + print(f"Failed to run profile... {err}") + sys.exit(1) # Should prompt for another profile path instead if __name__ == '__main__': - run_as_a_module() + run_as_a_module() -- cgit v1.2.3-70-g09d2 From d14f1156a01a54e63d856393687f15a28ae93f76 Mon Sep 17 00:00:00 2001 From: demostanis Date: Mon, 2 Nov 2020 18:52:10 +0100 Subject: md5 -> sha256 --- PKGBUILD/archinstall/PKGBUILD | 2 +- PKGBUILD/python-archinstall/PKGBUILD | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/PKGBUILD/archinstall/PKGBUILD b/PKGBUILD/archinstall/PKGBUILD index 897db3fc..672b8329 100644 --- a/PKGBUILD/archinstall/PKGBUILD +++ b/PKGBUILD/archinstall/PKGBUILD @@ -10,7 +10,7 @@ provides=("${pkgname}") arch=('x86_64') source=("${pkgname}-v${pkgver}-x86_64.tar.gz::https://github.com/Torxed/archinstall/archive/v$pkgver.tar.gz") depends=('python-archinstall') -md5sums=('a23ec87d901d9dc28a8a36dd7427200f') +sha256sums=('04176c096d13589b874083aecbb9b1d34e676d2b784f55e5368f4ab83ff38c2e') package() { mkdir -p "${pkgdir}/usr/bin" diff --git a/PKGBUILD/python-archinstall/PKGBUILD b/PKGBUILD/python-archinstall/PKGBUILD index 50ae9ac9..5aa0b721 100644 --- a/PKGBUILD/python-archinstall/PKGBUILD +++ b/PKGBUILD/python-archinstall/PKGBUILD @@ -13,7 +13,7 @@ arch=('x86_64') depends=('python>=3.8') makedepends=('python-setuptools') optdepends=('pyttsx3: Adds text-to-speech support for log/screen output.') -md5sums=('a23ec87d901d9dc28a8a36dd7427200f') +sha256sums=('04176c096d13589b874083aecbb9b1d34e676d2b784f55e5368f4ab83ff38c2e') build() { cd "archinstall-${pkgver}" -- cgit v1.2.3-70-g09d2