summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-01-02 20:09:10 +0000
committerdavidovski <david@davidovski.xyz>2022-01-02 20:09:10 +0000
commit16375135a0a840e9dba6f397f458acd2389cb67b (patch)
tree2adb08680a25ee81c1241edc88ab62da1d367fae /src
parent8ced2d5ec3fe54477704434ffd45ab2a431efc5e (diff)
added postinstall
Diffstat (limited to 'src')
-rw-r--r--src/verbs/install.py25
-rw-r--r--src/verbs/update.py2
2 files changed, 21 insertions, 6 deletions
diff --git a/src/verbs/install.py b/src/verbs/install.py
index 929f8c4..c21487d 100644
--- a/src/verbs/install.py
+++ b/src/verbs/install.py
@@ -219,12 +219,15 @@ def is_installed(package_name, config, root="/"):
return False
def install_package(package_name, package_path, package_info,
- repo, source_url, key,
- config, root="/"):
+ repo, source_url, key, post_install,
+ config, verbose=False, root="/"):
# TODO loading bar here
files = util.extract_tar(package_path, root)
+ if post_install:
+ run_post_install(config, verbose=verbose, root=root)
save_installed_info(package_name, package_info, files, repo, source_url, key, config, root=root)
+
def save_installed_info(package_name, package_info,
@@ -260,7 +263,7 @@ def save_installed_info(package_name, package_info,
pass
-def install_single(package, options, config, verbose=False, unsafe=False):
+def install_single(package, options, config, post_install=True, verbose=False, unsafe=False):
checksum, sources, repo = find_package(package, config["repos"],
config["dir"]["packages"], config["sources"])
@@ -275,8 +278,20 @@ def install_single(package, options, config, verbose=False, unsafe=False):
verbose=verbose, skip_verification=unsafe)
files = install_package(package, package_path, info,
- repo, sources[source], key,
- config, root=options["r"])
+ repo, sources[source], key, post_install,
+ config, verbose=verbose, root=options["r"])
+
+def run_post_install(config, verbose=False, root="/"):
+ installed_dir = util.add_path(root, config["dir"]["postinstall"])
+ if os.path.exists(installed_dir):
+ files = os.listdir(installed_dir)
+ for file in files:
+ command = f"sh {util.add_path(installed_dir, file)}"
+ run = os.popen(command)
+ if verbose:
+ print(run.read())
+ os.remove(command)
+
def install(args, options, config):
if not options["l"]:
diff --git a/src/verbs/update.py b/src/verbs/update.py
index 1cba192..4348637 100644
--- a/src/verbs/update.py
+++ b/src/verbs/update.py
@@ -50,7 +50,7 @@ def update(args, options, config):
if util.ask_confirmation(colors.BLUE + "Continue?", no_confirm=options["y"]):
for package in updates:
- install_single(package, options, config, verbose=v, unsafe=options["u"])
+ install_single(package, options, config, verbose=v, post_install=False, unsafe=options["u"])
util.fill_line(f"Updated {package}", colors.BG_CYAN + colors.LIGHT_BLACK, end="\n")
else:
print(colors.LIGHT_RED + "Nothing to do")