index : archinstall32 | |
Archlinux32 installer | gitolite user |
summaryrefslogtreecommitdiff |
-rw-r--r-- | README.md | 4 | ||||
-rw-r--r-- | archinstall/__init__.py | 5 | ||||
-rw-r--r-- | archinstall/__main__.py | 29 | ||||
-rw-r--r-- | archinstall/lib/general.py | 1 | ||||
-rw-r--r-- | examples/guided.py (renamed from examples/guided_installation.py) | 0 | ||||
-rw-r--r-- | examples/minimal.py (renamed from examples/main_example.py) | 0 | ||||
-rw-r--r-- | setup.py | 3 |
@@ -88,8 +88,8 @@ This installer will perform the following: # Testing -To test this, the simplest approach is to use a local image and create a loop device.<br> -This can be done by installing `pacman -S arch-install-scripts util-linux` locally and do the following: +To test this without a live ISO, the simplest approach is to use a local image and create a loop device.<br> +This can be done by installing `pacman -S arch-install-scripts util-linux` locally and doing the following: # dd if=/dev/zero of=./testimage.img bs=1G count=5 # losetup -fP ./testimage.img diff --git a/archinstall/__init__.py b/archinstall/__init__.py index a9eeb6b5..9cf7faec 100644 --- a/archinstall/__init__.py +++ b/archinstall/__init__.py @@ -4,7 +4,4 @@ from .lib.user_interaction import * from .lib.exceptions import * from .lib.installer import * from .lib.profiles import * -from .lib.luks import * - -if __name__ == '__main__': - print('Launching as a module?')
\ No newline at end of file +from .lib.luks import *
\ No newline at end of file diff --git a/archinstall/__main__.py b/archinstall/__main__.py new file mode 100644 index 00000000..bd657291 --- /dev/null +++ b/archinstall/__main__.py @@ -0,0 +1,29 @@ +import archinstall, sys, os, glob +import importlib.util + +class ProfileNotFound(BaseException): + pass + +# TODO: Learn the dark arts of argparse... +# (I summon thee dark spawn of cPython) + +def find_examples(): + 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')} + + +if __name__ == '__main__': + if len(sys.argv) == 1: sys.arv.append('guided') + + profile = sys.argv[1] + library = find_examples() + + if not f'{profile}.py' in library: + raise ProfileNotFound(f'Could not locate {profile}.py among the example files.') + + 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
\ No newline at end of file diff --git a/archinstall/lib/general.py b/archinstall/lib/general.py index 31f81413..b0de39a7 100644 --- a/archinstall/lib/general.py +++ b/archinstall/lib/general.py @@ -2,6 +2,7 @@ import os, json, hashlib, shlex, sys import time, pty from subprocess import Popen, STDOUT, PIPE, check_output from select import epoll, EPOLLIN, EPOLLHUP +from .exceptions import * def log(*args, **kwargs): string = ' '.join([str(x) for x in args]) diff --git a/examples/guided_installation.py b/examples/guided.py index c84b5e56..c84b5e56 100644 --- a/examples/guided_installation.py +++ b/examples/guided.py diff --git a/examples/main_example.py b/examples/minimal.py index 195ee60c..195ee60c 100644 --- a/examples/main_example.py +++ b/examples/minimal.py @@ -1,4 +1,4 @@ -import setuptools +import setuptools, glob with open("README.md", "r") as fh: long_description = fh.read() @@ -19,4 +19,5 @@ setuptools.setup( "Operating System :: POSIX :: Linux", ], python_requires='>=3.8', + data_files=[('examples', glob.glob('examples/*.py'))], )
\ No newline at end of file |