Fix arguments

This commit is contained in:
Dimitris Zlatanidis 2015-06-13 03:52:26 +03:00
parent 2e2a23ba66
commit 4af641b7f5
7 changed files with 49 additions and 48 deletions

View file

@ -80,7 +80,7 @@ Optional arguments:
only packages installed on the
system.
-c, --check, [repository] --upgrade, Check, view and install updated
--skip=[] --resolve-off packages from repositories.
--skip=[] --resolve--off packages from repositories.
-s, --sync, [repository] [package...], Sync packages. Install packages
--resolve-off directly from remote repositories
with all dependencies.

View file

@ -44,7 +44,7 @@ class Dependencies(object):
"""
Build all dependencies of a package
"""
if self.meta.rsl_deps in ["on", "ON"] and resolve:
if self.meta.rsl_deps in ["on", "ON"] and resolve != "--resolve-off":
try:
sys.setrecursionlimit(10000)
dependencies = []

View file

@ -40,7 +40,7 @@ def repo_data(PACKAGES_TXT, step, repo, resolve):
rname, rlocation, rsize, runsize) = ([] for i in range(8))
index, toolbar_width = 0, 100
for line in PACKAGES_TXT.splitlines():
if _meta_.rsl_deps in ["on", "ON"] and resolve:
if _meta_.rsl_deps in ["on", "ON"] and resolve != "--resolve-off":
index += 1
toolbar_width = status(index, toolbar_width, step)
if line.startswith("PACKAGE NAME:"):

View file

@ -85,7 +85,8 @@ class BinaryInstall(object):
self.packages = self.clear_masters()
(self.dwn, self.install, self.comp_sum,
self.uncomp_sum) = self.store(self.packages)
if self.meta.rsl_deps in ["on", "ON"] and self.resolve:
if (self.meta.rsl_deps in ["on", "ON"] and
self.resolve != "--resolve-off"):
Msg().done()
if self.install:
print("\nThe following packages will be automatically "
@ -206,7 +207,8 @@ class BinaryInstall(object):
Return package dependencies
"""
requires = []
if self.meta.rsl_deps in ["on", "ON"] and self.resolve:
if (self.meta.rsl_deps in ["on", "ON"] and
self.resolve != "--resolve-off"):
Msg().resolving()
for dep in self.packages:
dependencies = []

View file

@ -181,11 +181,11 @@ class ArgParse(object):
def pkg_upgrade(self):
"""Check and upgrade packages by repository
"""
skip, resolve = "", True
skip = resolve = ""
options = ["-c", "--check"]
flag = ["--upgrade", "--skip=", "--resolve-off"]
if flag[2] in self.args:
resolve = False
resolve = flag[2]
index = self.args.index(flag[2])
del self.args[index]
if (len(self.args) == 4 and self.args[0] in options and
@ -216,20 +216,19 @@ class ArgParse(object):
def pkg_install(self):
"""Install packages by repository
"""
packages = self.args[2:]
options = ["-s", "--sync"]
flag = ["--resolve-off"]
resolve = True
if self.args[-1] == flag[0]:
resolve = False
flag = ""
flags = ["--resolve-off"]
if self.args[-1] in flags:
flag = self.args[-1]
if len(self.args) >= 3 and self.args[0] in options:
if (self.args[1] in self.meta.repositories and
self.args[1] not in ["sbo"]):
BinaryInstall(packages, self.args[1], resolve).start(
BinaryInstall(self.args[2:], self.args[1], flag).start(
if_upgrade=False)
elif (self.args[1] == "sbo" and
self.args[1] in self.meta.repositories):
SBoInstall(packages, resolve).start(if_upgrade=False)
SBoInstall(self.args[2:], flag).start(if_upgrade=False)
else:
usage(self.args[1])
else:
@ -238,11 +237,10 @@ class ArgParse(object):
def pkg_tracking(self):
"""Tracking package dependencies
"""
packages = self.args[2]
options = ["-t", "--tracking"]
if (len(self.args) == 3 and self.args[0] in options and
self.args[1] in self.meta.repositories):
track_dep(packages, self.args[1])
track_dep(self.args[2], self.args[1])
elif (len(self.args) > 1 and self.args[0] in options and
self.args[1] not in self.meta.repositories):
usage(self.args[1])
@ -252,18 +250,19 @@ class ArgParse(object):
def sbo_network(self):
"""View slackbuilds packages
"""
packages = self.args[1]
options = ["-n", "--network"]
if (len(self.args) == 2 and self.args[0] in options and
if (len(self.args) == 3 and self.args[0] in options and
"sbo" in self.meta.repositories):
SBoNetwork(packages).view()
SBoNetwork(self.args[1]).view()
elif (len(self.args) == 2 and self.args[0] in options and
"sbo" in self.meta.repositories):
SBoNetwork(self.args[1]).view()
else:
usage("")
def pkg_blacklist(self):
"""Manage blacklist packages
"""
packages = self.args[1:]
blacklist = BlackList()
options = ["-b", "--blacklist"]
flag = ["--add", "--remove"]
@ -273,27 +272,26 @@ class ArgParse(object):
blacklist.listed()
elif (len(self.args) > 2 and self.args[0] in options and
self.args[-1] == flag[0]):
blacklist.add(packages)
blacklist.add(self.args[1:])
elif (len(self.args) > 2 and self.args[0] in options and
self.args[-1] == flag[1]):
blacklist.remove(packages)
blacklist.remove(self.args[1:])
else:
usage("")
def pkg_queue(self):
"""Manage packages in queue
"""
packages = self.args[1:]
queue = QueuePkgs()
options = ["-q", "--queue"]
flag = ["--add", "--remove"]
command = ["list", "build", "install", "build-install"]
if (len(self.args) > 2 and self.args[0] in options and
self.args[-1] == flag[0]):
queue.add(packages)
queue.add(self.args[1:])
elif (len(self.args) > 2 and self.args[0] in options and
self.args[-1] == flag[1]):
queue.remove(packages)
queue.remove(self.args[1:])
elif (len(self.args) == 2 and self.args[0] in options and
self.args[1] == command[0]):
queue.listed()
@ -327,10 +325,10 @@ class ArgParse(object):
"--priority",
"--tagfile"
]
if self.args[1] in flags:
flag = self.args[1]
packages = self.args[2:]
if len(self.args) > 1 and self.args[0] in options:
if self.args[1] in flags:
flag = self.args[1]
packages = self.args[2:]
PackageManager(packages).install(flag)
else:
usage("")
@ -347,10 +345,10 @@ class ArgParse(object):
"--reinstall",
"--verbose"
]
if self.args[1] in flags:
flag = self.args[1]
packages = self.args[2:]
if len(self.args) > 1 and self.args[0] in options:
if self.args[1] in flags:
flag = self.args[1]
packages = self.args[2:]
PackageManager(packages).upgrade(flag)
else:
usage("")
@ -368,13 +366,13 @@ class ArgParse(object):
"-copy",
"-keep"
]
if self.args[-1] == additional_options[0]:
extra = additional_options[0]
packages = self.args[1:-1]
if self.args[1] in flags:
flag = self.args[1]
packages = self.args[2:]
if len(self.args) > 1 and self.args[0] in options:
if self.args[-1] == additional_options[0]:
extra = additional_options[0]
packages = self.args[1:-1]
if self.args[1] in flags:
flag = self.args[1]
packages = self.args[2:]
PackageManager(packages).remove(flag, extra)
else:
usage("")
@ -392,18 +390,17 @@ class ArgParse(object):
def pkg_desc(self):
"""Print slack-desc by repository
"""
packages = self.args[2]
options = ["-p", "--print"]
flag = ["--color="]
colors = ["red", "green", "yellow", "cyan", "grey"]
if (len(self.args) == 3 and self.args[0] in options and
self.args[1] in self.meta.repositories):
PkgDesc(packages, self.args[1], "").view()
PkgDesc(self.args[2], self.args[1], "").view()
elif (len(self.args) == 4 and self.args[0] in options and
self.args[3].startswith(flag[0])):
tag = self.args[3][len(flag[0]):]
if self.args[1] in self.meta.repositories and tag in colors:
PkgDesc(packages, self.args[1], tag).view()
PkgDesc(self.args[2], self.args[1], tag).view()
else:
usage("")
elif (len(self.args) > 1 and self.args[0] in options and

View file

@ -33,8 +33,8 @@ from greps import SBoGrep
class Requires(object):
def __init__(self, resolve):
self.resolve = resolve
def __init__(self, flag):
self.flag = flag
self.meta = _meta_
self.dep_results = []
@ -42,7 +42,7 @@ class Requires(object):
"""
Build all dependencies of a package
"""
if self.meta.rsl_deps in ["on", "ON"] and self.resolve:
if self.meta.rsl_deps in ["on", "ON"] and self.flag != "--resolve-off":
try:
sys.setrecursionlimit(10000)
dependencies = []

View file

@ -48,9 +48,9 @@ from search import sbo_search_pkg
class SBoInstall(object):
def __init__(self, slackbuilds, resolve):
def __init__(self, slackbuilds, flag):
self.slackbuilds = slackbuilds
self.resolve = resolve
self.flag = flag
self.meta = _meta_
self.build_folder = self.meta.build_path
self.unst = ["UNSUPPORTED", "UNTESTED"]
@ -74,7 +74,7 @@ class SBoInstall(object):
self.index += 1
self.toolbar_width = status(self.index, self.toolbar_width, 4)
if sbo_search_pkg(_sbo):
sbo_deps = Requires(self.resolve).sbo(_sbo)
sbo_deps = Requires(self.flag).sbo(_sbo)
self.deps += sbo_deps
self.deps_dict[_sbo] = self.one_for_all(sbo_deps)
self.package_found.append(_sbo)
@ -86,11 +86,13 @@ class SBoInstall(object):
self.master_packages, mas_src = self.sbo_version_source(
self.package_found)
Msg().done()
if self.meta.rsl_deps in ["on", "ON"] and self.resolve:
if (self.meta.rsl_deps in ["on", "ON"] and
self.flag != "--resolve-off"):
Msg().resolving()
self.dependencies, dep_src = self.sbo_version_source(
self.one_for_all(self.deps))
if self.meta.rsl_deps in ["on", "ON"] and self.resolve:
if (self.meta.rsl_deps in ["on", "ON"] and
self.flag != "--resolve-off"):
Msg().done()
self.clear_masters()
if self.package_found: