mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-02-10 20:48:40 +01:00
Merge functions into class
This commit is contained in:
parent
109cdbe5dc
commit
a908cf0c37
4 changed files with 13 additions and 29 deletions
|
@ -173,14 +173,6 @@ class BinaryInstall(object):
|
||||||
PackageManager(package).upgrade("--install-new")
|
PackageManager(package).upgrade("--install-new")
|
||||||
return [installs, upgraded]
|
return [installs, upgraded]
|
||||||
|
|
||||||
def find_installed(self, pkg):
|
|
||||||
"""Return installed package name
|
|
||||||
"""
|
|
||||||
find = find_package(pkg + "-", self.meta.pkg_path)
|
|
||||||
if find:
|
|
||||||
return split_package(find[0])[0]
|
|
||||||
return ""
|
|
||||||
|
|
||||||
def checksums(self, install):
|
def checksums(self, install):
|
||||||
"""
|
"""
|
||||||
Checksums before install
|
Checksums before install
|
||||||
|
@ -217,7 +209,7 @@ class BinaryInstall(object):
|
||||||
if find_package(pkg[:-4], self.meta.pkg_path):
|
if find_package(pkg[:-4], self.meta.pkg_path):
|
||||||
pkg_sum += 1
|
pkg_sum += 1
|
||||||
COLOR = self.meta.color["GREEN"]
|
COLOR = self.meta.color["GREEN"]
|
||||||
elif pkg_repo[0] == self.find_installed(pkg_repo[0]):
|
elif pkg_repo[0] == GetFromInstalled(pkg_repo[0]).name():
|
||||||
COLOR = self.meta.color["YELLOW"]
|
COLOR = self.meta.color["YELLOW"]
|
||||||
upg_sum += 1
|
upg_sum += 1
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -37,7 +37,7 @@ class GetFromInstalled(object):
|
||||||
self.meta = _meta_
|
self.meta = _meta_
|
||||||
|
|
||||||
def version(self):
|
def version(self):
|
||||||
"""Get version from installed packages
|
"""Return version from installed packages
|
||||||
"""
|
"""
|
||||||
find = find_package(self.package + self.meta.sp, _meta_.pkg_path)
|
find = find_package(self.package + self.meta.sp, _meta_.pkg_path)
|
||||||
if find:
|
if find:
|
||||||
|
@ -45,3 +45,11 @@ class GetFromInstalled(object):
|
||||||
if self.package == name:
|
if self.package == name:
|
||||||
return self.meta.sp + split_package(find[0])[1]
|
return self.meta.sp + split_package(find[0])[1]
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
def name(self):
|
||||||
|
"""Return installed package name
|
||||||
|
"""
|
||||||
|
find = find_package(self.package + self.meta.sp, self.meta.pkg_path)
|
||||||
|
if find:
|
||||||
|
return split_package(find[0])[0]
|
||||||
|
return ""
|
||||||
|
|
|
@ -224,7 +224,7 @@ class SBoInstall(object):
|
||||||
"""
|
"""
|
||||||
# split sbo name with version and get name
|
# split sbo name with version and get name
|
||||||
sbo_name = "-".join(sbo.split("-")[:-1])
|
sbo_name = "-".join(sbo.split("-")[:-1])
|
||||||
find = self.find_installed(sbo_name)
|
find = GetFromInstalled(sbo_name).name()
|
||||||
if find_package(sbo, self.meta.pkg_path):
|
if find_package(sbo, self.meta.pkg_path):
|
||||||
paint = self.meta.color["GREEN"]
|
paint = self.meta.color["GREEN"]
|
||||||
count_ins += 1
|
count_ins += 1
|
||||||
|
@ -265,14 +265,6 @@ class SBoInstall(object):
|
||||||
binary.append(search)
|
binary.append(search)
|
||||||
return binary
|
return binary
|
||||||
|
|
||||||
def find_installed(self, pkg):
|
|
||||||
"""Return installed package name
|
|
||||||
"""
|
|
||||||
find = find_package(pkg + "-", self.meta.pkg_path)
|
|
||||||
if find:
|
|
||||||
return split_package(find[0])[0]
|
|
||||||
return ""
|
|
||||||
|
|
||||||
def build_install(self):
|
def build_install(self):
|
||||||
"""Searches the package name and version in /tmp to
|
"""Searches the package name and version in /tmp to
|
||||||
install. If find two or more packages e.g. to build
|
install. If find two or more packages e.g. to build
|
||||||
|
@ -313,7 +305,7 @@ class SBoInstall(object):
|
||||||
except ValueError:
|
except ValueError:
|
||||||
Msg().build_FAILED(sbo_url, prgnam)
|
Msg().build_FAILED(sbo_url, prgnam)
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
find = self.find_installed(pkg)
|
find = GetFromInstalled(pkg).name()
|
||||||
if find == pkg:
|
if find == pkg:
|
||||||
print("[ {0}Upgrading{1} ] --> {2}".format(
|
print("[ {0}Upgrading{1} ] --> {2}".format(
|
||||||
self.meta.color["YELLOW"],
|
self.meta.color["YELLOW"],
|
||||||
|
|
|
@ -160,7 +160,7 @@ class Patches(object):
|
||||||
for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)):
|
for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)):
|
||||||
pkg_repo = split_package(upg[:-4])
|
pkg_repo = split_package(upg[:-4])
|
||||||
color = self.meta.color["RED"]
|
color = self.meta.color["RED"]
|
||||||
pkg_inst = self.find_installed(pkg_repo[0])
|
pkg_inst = GetFromInstalled(pkg_repo[0]).name()
|
||||||
if pkg_repo[0] == pkg_inst:
|
if pkg_repo[0] == pkg_inst:
|
||||||
color = self.meta.color["YELLOW"]
|
color = self.meta.color["YELLOW"]
|
||||||
ver = GetFromInstalled(pkg_repo[0]).version()
|
ver = GetFromInstalled(pkg_repo[0]).version()
|
||||||
|
@ -172,14 +172,6 @@ class Patches(object):
|
||||||
" " * (7-len(pkg_repo[3])), "Slack",
|
" " * (7-len(pkg_repo[3])), "Slack",
|
||||||
size, " K")).rstrip()
|
size, " K")).rstrip()
|
||||||
|
|
||||||
def find_installed(self, pkg):
|
|
||||||
"""Return installed package name
|
|
||||||
"""
|
|
||||||
find = find_package(pkg + "-", self.meta.pkg_path)
|
|
||||||
if find:
|
|
||||||
return split_package(find[0])[0]
|
|
||||||
return ""
|
|
||||||
|
|
||||||
def upgrade(self):
|
def upgrade(self):
|
||||||
"""
|
"""
|
||||||
Upgrade packages
|
Upgrade packages
|
||||||
|
|
Loading…
Add table
Reference in a new issue