From a28ed01fde0ffb023aa527d9d57dbfb2e5b1eda0 Mon Sep 17 00:00:00 2001 From: Jack Foltz Date: Sat, 8 Dec 2018 19:01:28 -0500 Subject: [PATCH] Rename configure to deploy and add wip import/export stuff --- lib/configure.py | 35 ------------------------------ lib/deploy.py | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 35 deletions(-) delete mode 100644 lib/configure.py create mode 100644 lib/deploy.py diff --git a/lib/configure.py b/lib/configure.py deleted file mode 100644 index 524fcb3..0000000 --- a/lib/configure.py +++ /dev/null @@ -1,35 +0,0 @@ -import os -from pathlib import Path -import lib.pacman as pacman -from lib.package import Package - -installed_packages = pacman.get_installed() - -def install(package): - if not package.install or not package.source: - return - if package.source == 'core' and package.name not in installed_packages: - res = pacman.install(package.name) - - -def copy_config(package): - if not package.copy_config or not package.config: - return - -def run_script(package): - if not package.run_script or not package.script: - return - -def enable_units(package): - if not package.enable_units or not package.userunits: - return - -def configure(package): - if not package.enabled: - return - #print(vars(package)) - install(package) - copy_config(package) - run_script(package) - enable_units(package) - diff --git a/lib/deploy.py b/lib/deploy.py new file mode 100644 index 0000000..4fd0935 --- /dev/null +++ b/lib/deploy.py @@ -0,0 +1,66 @@ +import os +import distutils +from pathlib import Path +import lib.pacman as pacman +from lib.package import Package + +installed_packages = pacman.get_installed() + +def copy(source, dest): + print(source, '->', dest) + if source.is_dir(): + pass#distutils.dir_util.copy_tree(source.absolute(), dest.absolute()) + else: + pass#distutils.file_util.copy_file(source.absolute(), dest.absolute()) + +def import_item(path): + copy(Path('~') / path, Path('./lain') / path) + +def export_item(path): + copy(Path('./lain') / path, Path('~') / path) + +def install(package): + if not package.install or not package.source: + return + if package.source == 'core' and package.name not in installed_packages: + res = pacman.install(package.name) + + +def export_config(package): + if not package.export_config or not package.config: + return + + export_item(package.config) + +def import_config(package): + if not package.config: + return + + import_item(package.config) + +def run_script(package): + if not package.run_script or not package.script: + return + +def export_units(package): + if not package.export_units or not package.userunits: + return + + for unit in package.userunits: + export_item(unit) + +def import_units(package): + if not package.userunits: + return + + for unit in package.userunits: + import_item(unit) + +def deploy(package): + if not package.enabled: + return + install(package) + export_config(package) + run_script(package) + export_units(package) +