summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2021-12-07 23:02:43 +0000
committerdavidovski <david@davidovski.xyz>2021-12-07 23:02:43 +0000
commit075149bb1c92e3dc5df9fd07feebe60a3c8e4fef (patch)
treed9a97bc49b96657629045b29c989610208d54da0
parent7887f4d828c0ec15b209afc49f2671e368cb2c70 (diff)
fixed issues with getting most popular package
-rwxr-xr-xinstall-system.sh4
-rw-r--r--src/util.py7
-rw-r--r--src/verbs/install.py13
-rw-r--r--src/verbs/sync.py11
-rw-r--r--xipkg.conf2
5 files changed, 28 insertions, 9 deletions
diff --git a/install-system.sh b/install-system.sh
index 892e1e5..af25ffa 100755
--- a/install-system.sh
+++ b/install-system.sh
@@ -18,7 +18,9 @@ ln -s usr/lib lib
ln -s usr/lib lib64
ln -s usr/lib usr/lib64
+ln -s usr/local usr
+
xi sync
xi -nyl --root . install $(ls /var/lib/xipkg/packages/core)
-
+xi -nyl --root . install xipkg
diff --git a/src/util.py b/src/util.py
index fcc58f4..c84d7a3 100644
--- a/src/util.py
+++ b/src/util.py
@@ -10,7 +10,12 @@ DEFAULT_BAR_COLOR = colors.BLACK + colors.BG_CYAN
DEFAULT_BAR_COLOR_RESET = colors.BG_BLACK + colors.CYAN
def extract_tar(package_path, destination):
- os.system(f"tar -h --no-overwrite-dir -xf {package_path} -C {destination}")
+ cmd = f"tar -h --no-overwrite-dir -xvf {package_path} -C {destination}"
+
+ os.popen(cmd).read()
+ with tarfile.open(package_path) as tar:
+ return "\n".join(["".join(m.name[1:]) for m in tar.getmembers() if not m.isdir()])
+
def add_path(*argv):
a = argv[0]
diff --git a/src/verbs/install.py b/src/verbs/install.py
index 2e63dd4..7b6fd7d 100644
--- a/src/verbs/install.py
+++ b/src/verbs/install.py
@@ -230,12 +230,11 @@ def install_package(package_name, package_path, package_info,
# TODO loading bar here
files = util.extract_tar(package_path, root)
- save_installed_info(package_name, package_info, repo, source_url, key, config, root=root)
- # untar and move into root
- # then add entry in the config["dir"]["installed"]
+ save_installed_info(package_name, package_info, files, repo, source_url, key, config, root=root)
+
def save_installed_info(package_name, package_info,
- repo, source_url, key,
+ files, repo, source_url, key,
config, root=""):
installed_dir = util.add_path(root, config["dir"]["installed"], package_name)
util.mkdir(installed_dir)
@@ -261,6 +260,10 @@ def save_installed_info(package_name, package_info,
file.write(f"URL={package_url}\n")
file.write(f"REPO={repo}\n")
+ files_file = util.add_path(installed_dir, "files")
+ with open(files_file, "w") as file:
+ file.write(files)
+
pass
def install_single(package, options, config, verbose=False, unsafe=False):
@@ -277,7 +280,7 @@ def install_single(package, options, config, verbose=False, unsafe=False):
info, package, config,
verbose=verbose, skip_verification=unsafe)
- install_package(package, package_path, info,
+ files = install_package(package, package_path, info,
repo, sources[source], key,
config, root=options["r"])
diff --git a/src/verbs/sync.py b/src/verbs/sync.py
index 38a8a39..07ed2ec 100644
--- a/src/verbs/sync.py
+++ b/src/verbs/sync.py
@@ -47,7 +47,16 @@ def validate_package(package, versions, repo, verbose=False):
popularity[checksum] = 0
popularity[checksum] += 1
- most_popular = sorted(popularity)[-1]
+ most_popular = ""
+ p_count = -1
+ for p,c in popularity.items():
+ if c > p_count:
+ most_popular = p
+ p_count = c
+
+ if verbose:
+ ##print(package, ":", popularity)
+ print(most_popular)
sources = [v[1] for v in versions if v[0] == most_popular]
# change the packages dict to list all the sources
diff --git a/xipkg.conf b/xipkg.conf
index 6eb1a1d..01488e3 100644
--- a/xipkg.conf
+++ b/xipkg.conf
@@ -3,7 +3,7 @@
include /etc/xipkg.d/default.conf
sources {
- localhost http://localhost:8089/repo/
+ localhost http://localhost:8089/repo/ # this is for testing
davidovski https://xi.davidovski.xyz/repo/
codeberg https://xi.codeberg.page/repo/
ftp https://xilinux.ftp.sh/repo/