summaryrefslogtreecommitdiffstats
path: root/.bin/dot-pkgs
diff options
context:
space:
mode:
Diffstat (limited to '.bin/dot-pkgs')
-rwxr-xr-x.bin/dot-pkgs76
1 files changed, 76 insertions, 0 deletions
diff --git a/.bin/dot-pkgs b/.bin/dot-pkgs
new file mode 100755
index 0000000..f5c80ee
--- /dev/null
+++ b/.bin/dot-pkgs
@@ -0,0 +1,76 @@
+#!/usr/bin/env python3
+
+import subprocess
+import os
+
+ENV = {
+ 'path': f'{os.environ["HOME"]}/.cache/dot-pkgs',
+ 'bin_path': f'{os.environ["HOME"]}/.local/bin'
+}
+
+PKGS = [
+ {
+ 'src': 'git://git.suckless.org/dwm',
+ 'path': f'{ENV["path"]}/dwm',
+ 'bin': 'dwm',
+ 'type': 'git'
+ },
+ {
+ 'src': 'git://git.suckless.org/st',
+ 'path': f'{ENV["path"]}/st',
+ 'bin': 'st',
+ 'type': 'git'
+ },
+ {
+ 'src': 'git@st0dev1:_suckless/dwm',
+ 'path': f'{os.environ["HOME"]}/git.rgoncalves.se/_suckless/dwm',
+ 'bin': 'st',
+ 'type': 'git'
+ },
+ {
+ 'src': '',
+ 'type': ''
+ }
+]
+
+
+def copy_executable_file(src, dst):
+ pass
+
+
+def merge_mappings(pkgs, env):
+ """
+ Merge two dict in the first one.
+ """
+ for index, pkg in enumerate(pkgs):
+ pkgs[index] = {**env, **pkg}
+
+
+def handle_git(pkg):
+ """
+ Clone and update git repo.
+ """
+ commands = [
+ ['git', 'clone', pkg['src'], pkg['path']],
+ ['git', 'pull']
+ ]
+
+ for command in commands:
+ subprocess.run(command, cwd=pkg['path'])
+
+
+def handle_make(pkg):
+ subprocess.run(['make'], cwd=pkg['path'])
+
+
+def main():
+ merge_mappings(PKGS, ENV)
+
+ for pkg in [pkg for pkg in PKGS if pkg['type'] == 'git']:
+ os.makedirs(pkg['path'], exist_ok=True)
+ handle_git(pkg)
+ handle_make(pkg)
+
+
+if __name__ == '__main__':
+ main()
remember that computers suck.