Updated queues

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2022-05-12 20:02:52 +03:00
parent ba8193b90a
commit 6255a13030

View file

@ -82,16 +82,17 @@ class QueuePkgs(Utils):
def listed(self): def listed(self):
"""Print packages from queue """Print packages from queue
""" """
print("Packages in the queue:\n") print("Packages in the queue:")
for pkg in self.packages(): for pkg in self.packages():
print(f"{self.green}{pkg}{self.endc}") print(f"{self.green}{pkg}{self.endc}")
print()
def add(self, pkgs): def add(self, pkgs):
"""Add packages in queue if not exist """Add packages in queue if not exist
""" """
queue_list = list(self.packages()) queue_list = list(self.packages())
pkgs = list(OrderedDict.fromkeys(pkgs)) pkgs = list(OrderedDict.fromkeys(pkgs))
print("Add packages in the queue:\n") print("Add packages in the queue:")
with open(self.queue_list, "a") as queue: with open(self.queue_list, "a") as queue:
for pkg in pkgs: for pkg in pkgs:
find = sbo_search_pkg(pkg) find = sbo_search_pkg(pkg)
@ -100,24 +101,30 @@ class QueuePkgs(Utils):
queue.write(pkg + "\n") queue.write(pkg + "\n")
else: else:
print(f"{self.red}{pkg}{self.endc}") print(f"{self.red}{pkg}{self.endc}")
print()
def remove(self, pkgs): def remove(self, pkgs):
"""Remove packages from queue """Remove packages from queue
""" """
print("Remove packages from the queue:\n") print("Remove packages from the queue:")
with open(self.queue_list, "w") as queue: with open(self.queue_list, "w") as queue:
for line in self.queued.splitlines(): for line in self.queued.splitlines():
if line not in pkgs: if line not in pkgs:
queue.write(line + "\n") queue.write(line + "\n")
else: else:
print(f"{self.red}{line}{self.endc}") print(f"{self.red}{line}{self.endc}")
print()
def build(self): def build(self):
"""Build packages from queue """Build packages from queue
""" """
sources = []
packages = list(self.packages()) packages = list(self.packages())
if packages: if packages:
for pkg in packages: for pkg in packages:
if pkg not in SBoGrep(pkg).names():
raise SystemExit(f"\nPackage '{pkg}' was not found in "
f"the SBo repository\n")
if not os.path.exists(self.meta.build_path): if not os.path.exists(self.meta.build_path):
os.mkdir(self.meta.build_path) os.mkdir(self.meta.build_path)
if not os.path.exists(self._SOURCES): if not os.path.exists(self._SOURCES):
@ -125,7 +132,6 @@ class QueuePkgs(Utils):
sbo_url = sbo_search_pkg(pkg) sbo_url = sbo_search_pkg(pkg)
sbo_dwn = SBoLink(sbo_url).tar_gz() sbo_dwn = SBoLink(sbo_url).tar_gz()
source_dwn = SBoGrep(pkg).source().split() source_dwn = SBoGrep(pkg).source().split()
sources = []
os.chdir(self.meta.build_path) os.chdir(self.meta.build_path)
script = sbo_dwn.split("/")[-1] script = sbo_dwn.split("/")[-1]
Download(self.meta.build_path, sbo_dwn.split(), Download(self.meta.build_path, sbo_dwn.split(),