Added feature rebuild and reinstall

This commit is contained in:
Dimitris Zlatanidis 2016-10-10 16:35:29 +03:00
parent 28147fb5d8
commit 611cfd683e
5 changed files with 31 additions and 12 deletions

View file

@ -41,7 +41,8 @@ Usage: slpkg [COMMANDS|OPTIONS] {repository|package...}
[-l [repository], --index, --installed, --name]
[-c [repository], --upgrade, --skip=[...], --resolve-off,
--checklist]
[-s [repository] [package...], --resolve-off, --download-only,
[-s [repository] [package...], --rebuild, --reinstall,
--resolve-off, --download-only,
--directory-prefix=[dir],
--case-ins]
[-t [repository] [package], --check-deps, --graph=[type],
@ -230,6 +231,10 @@ dependencies of the package.
.PP
Additional options:
.PP
\fB--rebuild\fP : Rebuild packages from sbo repository.
.PP
\fB--reinstall\fP : Reinstall binary packages from repositories.
.PP
\fB--resolve-off\fP : Switch off automatic resolve dependencies.
.PP
\fB--download-only\fP : Download packages without install.

View file

@ -114,8 +114,9 @@ Optional arguments:
--checklist install with all dependencies.
-s | --sync, [repository] [package...], Sync packages. Install packages
--resolve-off, --download-only, directly from remote repositories
--directory-prefix=[dir], with all dependencies.
--rebuild, --reinstall, directly from remote repositories
--resolve-off, --download-only, with all dependencies.
--directory-prefix=[dir],
--case-ins
-t | --tracking, [repository] [package], Tracking package dependencies and
@ -194,7 +195,8 @@ def usage(repo):
[-l [repository], --index, --installed, --name]
[-c [repository], --upgrade, --skip=[...], --resolve-off,
--checklist]
[-s [repository] [package...], --resolve-off, --download-only,
[-s [repository] [package...], --rebuild, --reinstall,
--resolve-off, --download-only,
--directory-prefix=[dir],
--case-ins]
[-t [repository] [package], --check-deps, --graph=[type],

View file

@ -133,7 +133,8 @@ class BinaryInstall(object):
self.not_downgrade(inst) is True):
continue
if (not os.path.isfile(self.meta.pkg_path + inst[:-4]) or
"--download-only" in self.flag):
"--download-only" in self.flag or
"--reinstall" in self.flag):
Download(self.tmp_path, dwn.split(), self.repo).start()
else:
self.msg.template(78)
@ -160,7 +161,8 @@ class BinaryInstall(object):
if (os.path.isfile(self.meta.pkg_path + inst[:-4]) and
"--download-only" not in self.flag):
count_inst += 1
if count_inst == len(self.dep_install + self.install):
if (count_inst == len(self.dep_install + self.install) and
"--reinstall" not in self.flag):
raise SystemExit()
def case_insensitive(self):
@ -209,6 +211,9 @@ class BinaryInstall(object):
print("[ {0}upgrading{1} ] --> {2}".format(
self.meta.color["YELLOW"], self.meta.color["ENDC"], inst))
upgraded.append(pkg_ver)
if "--reinstall" in self.flag:
PackageManager(package).upgrade("--reinstall")
else:
PackageManager(package).upgrade("--install-new")
else:
print("[ {0}installing{1} ] --> {2}".format(
@ -218,7 +223,7 @@ class BinaryInstall(object):
return [installs, upgraded]
def not_downgrade(self, package):
"""Don't downgrade packages if sbo version is lower than
"""Don't downgrade packages if repository version is lower than
installed"""
name = split_package(package)[0]
rep_ver = split_package(package)[1]

View file

@ -342,7 +342,9 @@ class ArgParse(object):
"--resolve-off",
"--download-only",
"--directory-prefix=",
"--case-ins"
"--case-ins",
"--rebuild",
"--reinstall"
]
for arg in self.args:
if arg.startswith(additional_options[2]):

View file

@ -177,7 +177,7 @@ class SBoInstall(object):
"""Continue to install ?
"""
if (self.count_uni > 0 or self.count_upg > 0 or
"--download-only" in self.flag):
"--download-only" in self.flag or "--rebuild" in self.flag):
if self.master_packages and self.msg.answer() in ["y", "Y"]:
installs, upgraded = self.build_install()
if "--download-only" in self.flag:
@ -316,7 +316,8 @@ class SBoInstall(object):
pkg = "-".join(prgnam.split("-")[:-1])
installed = "".join(find_package(prgnam, self.meta.pkg_path))
src_link = SBoGrep(pkg).source().split()
if installed and "--download-only" not in self.flag:
if (installed and "--download-only" not in self.flag and
"--rebuild" not in self.flag):
self.msg.template(78)
self.msg.pkg_found(prgnam)
self.msg.template(78)
@ -350,6 +351,10 @@ class SBoInstall(object):
self.meta.color["GREEN"],
self.meta.color["ENDC"], prgnam))
installs.append(prgnam)
if ("--rebuild" in self.flag and
GetFromInstalled(pkg).name() == pkg):
PackageManager(binary).upgrade(flag="--reinstall")
else:
PackageManager(binary).upgrade(flag="--install-new")
return installs, upgraded