update support multipages

This commit is contained in:
Dimitris Zlatanidis 2015-01-16 22:55:28 +02:00
parent f797bbc9a3
commit dae0bba736
7 changed files with 50 additions and 28 deletions

View file

@ -1,3 +1,11 @@
Version 2.2.1
16-1-2015
[Feature] - Added support multipackages.
[Updated] - Fix [key error] when you enter wrong repository as default.
Version 2.2.0 Version 2.2.0
08-1-2015 08-1-2015

View file

@ -229,7 +229,7 @@ Command Line Tool Usage
.. code-block:: bash .. code-block:: bash
Utility for easy management packages in Slackware Slpkg is a user-friendly package manager for Slackware installations
Commands: Commands:
update update all package lists update update all package lists

View file

@ -157,8 +157,10 @@ all repositories.
.TP .TP
\fBslpkg\fP \fB-q\fP \fB--build\fP \fB--install\fP \fB--build-install\fP \fBslpkg\fP \fB-q\fP \fB--build\fP \fB--install\fP \fB--build-install\fP
.PP .PP
List, add, or remove sbo packages from queue. If you want to remove all the packages List, add, or remove sbo packages from queue. This argument is very useful if you want
from the list 'slpkg -q all --remove'. (these arguments only working for the sbo repository) to build and install multiple packages together. What to watch out for is the correct
order if there are dependencies. If you want to remove all the packages from the list
run '# slpkg -q all --remove'. (these arguments only working for the sbo repository)
Build or install or build and install packages are queued. Build or install or build and install packages are queued.
.SS -g , configuration file management .SS -g , configuration file management

View file

@ -59,6 +59,17 @@ default_repositories = repositories[10] = 'slacke'
default_repositories = repositories default_repositories = repositories
def remove_repositories(repositories):
'''
Remove no default repositories
'''
repos = []
for repo in repositories:
if repo in default_repositories:
repos.append(repo)
return repos
def update_repositories(repositories): def update_repositories(repositories):
''' '''
Upadate with user custom repositories Upadate with user custom repositories
@ -156,6 +167,9 @@ if os.path.isfile("/etc/slpkg/slpkg.conf"):
ktown_kde_repo = ktown_repo(repositories) ktown_kde_repo = ktown_repo(repositories)
slacke_sub_repo = slacke_repo(repositories) slacke_sub_repo = slacke_repo(repositories)
# remove no default repositories
repositories = remove_repositories(repositories)
# add custom repositories
update_repositories(repositories) update_repositories(repositories)
color = { color = {

View file

@ -24,6 +24,7 @@
import sys import sys
from slpkg.toolbar import status from slpkg.toolbar import status
from slpkg.blacklist import BlackList
from greps import Requires from greps import Requires
@ -40,13 +41,14 @@ class Dependencies(object):
try: try:
sys.setrecursionlimit(10000) sys.setrecursionlimit(10000)
dependencies = [] dependencies = []
blacklist = BlackList().packages()
requires = Requires(name, repo).get_deps() requires = Requires(name, repo).get_deps()
toolbar_width, index = 2, 0 toolbar_width, index = 2, 0
if requires: if requires:
for req in requires: for req in requires:
index += 1 index += 1
toolbar_width = status(index, toolbar_width, 1) toolbar_width = status(index, toolbar_width, 1)
if req: if req and req not in blacklist:
dependencies.append(req) dependencies.append(req)
if dependencies: if dependencies:
self.dep_results.append(dependencies) self.dep_results.append(dependencies)

View file

@ -37,16 +37,16 @@ def repo_data(PACKAGES_TXT, step, repo, version):
''' '''
(name, location, size, unsize, (name, location, size, unsize,
rname, rlocation, rsize, runsize) = ([] for i in range(8)) rname, rlocation, rsize, runsize) = ([] for i in range(8))
index, toolbar_width = 0, 700 index, toolbar_width = 0, 100
for line in PACKAGES_TXT.splitlines(): for line in PACKAGES_TXT.splitlines():
index += 1 index += 1
toolbar_width = status(index, toolbar_width, step) toolbar_width = status(index, toolbar_width, step)
if line.startswith("PACKAGE NAME"): if line.startswith("PACKAGE NAME:"):
if repo == "slackr": if repo == "slackr":
name.append(fix_slackers_pkg(line[15:])) name.append(fix_slackers_pkg(line[15:]))
else: else:
name.append(line[15:].strip()) name.append(line[15:].strip())
if line.startswith("PACKAGE LOCATION"): if line.startswith("PACKAGE LOCATION:"):
location.append(line[21:].strip()) location.append(line[21:].strip())
if line.startswith("PACKAGE SIZE (compressed):"): if line.startswith("PACKAGE SIZE (compressed):"):
size.append(line[28:-2].strip()) size.append(line[28:-2].strip())
@ -207,10 +207,10 @@ class Requires(object):
f.close() f.close()
for line in PACKAGES_TXT.splitlines(): for line in PACKAGES_TXT.splitlines():
if line.startswith("PACKAGE NAME:"): if line.startswith("PACKAGE NAME:"):
pkg_name = line[14:].strip().split('-')[0] pkg_name = line[13:].strip().split('-')[0]
if line.startswith("PACKAGE REQUIRED:"): if line.startswith("PACKAGE REQUIRED:"):
if pkg_name == self.name: if pkg_name == self.name:
if line[17:].strip(): if line[16:].strip():
return self._req_fix(line) return self._req_fix(line)
def _req_fix(self, line): def _req_fix(self, line):

View file

@ -72,7 +72,7 @@ class OthersInstall(object):
sys.stdout.write("{0}Reading package lists ...{1}".format( sys.stdout.write("{0}Reading package lists ...{1}".format(
color['GREY'], color['ENDC'])) color['GREY'], color['ENDC']))
sys.stdout.flush() sys.stdout.flush()
self.step = 700 self.step = 800 * len(packages)
if repo in default_repositories: if repo in default_repositories:
exec('self._init_{0}()'.format(self.repo)) exec('self._init_{0}()'.format(self.repo))
@ -82,6 +82,8 @@ class OthersInstall(object):
f = open(self.lib, "r") f = open(self.lib, "r")
self.PACKAGES_TXT = f.read() self.PACKAGES_TXT = f.read()
f.close() f.close()
num_lines = sum(1 for line in self.PACKAGES_TXT)
self.step = num_lines / 1000
def _init_custom(self): def _init_custom(self):
self.lib = lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo) self.lib = lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo)
@ -94,7 +96,6 @@ class OthersInstall(object):
def _init_alien(self): def _init_alien(self):
self.lib = lib_path + "alien_repo/PACKAGES.TXT" self.lib = lib_path + "alien_repo/PACKAGES.TXT"
self.mirror = Repo().alien() self.mirror = Repo().alien()
self.step = self.step * 2
def _init_slacky(self): def _init_slacky(self):
self.lib = lib_path + "slacky_repo/PACKAGES.TXT" self.lib = lib_path + "slacky_repo/PACKAGES.TXT"
@ -103,7 +104,6 @@ class OthersInstall(object):
arch = "64" arch = "64"
self.mirror = "{0}slackware{1}-{2}/".format(Repo().slacky(), arch, self.mirror = "{0}slackware{1}-{2}/".format(Repo().slacky(), arch,
slack_ver()) slack_ver())
self.step = self.step * 2
def _init_studio(self): def _init_studio(self):
self.lib = lib_path + "studio_repo/PACKAGES.TXT" self.lib = lib_path + "studio_repo/PACKAGES.TXT"
@ -112,12 +112,10 @@ class OthersInstall(object):
arch = "64" arch = "64"
self.mirror = "{0}slackware{1}-{2}/".format(Repo().studioware(), self.mirror = "{0}slackware{1}-{2}/".format(Repo().studioware(),
arch, slack_ver()) arch, slack_ver())
self.step = self.step * 2
def _init_slackr(self): def _init_slackr(self):
self.lib = lib_path + "slackr_repo/PACKAGES.TXT" self.lib = lib_path + "slackr_repo/PACKAGES.TXT"
self.mirror = Repo().slackers() self.mirror = Repo().slackers()
self.step = self.step * 2
def _init_slonly(self): def _init_slonly(self):
self.lib = lib_path + "slonly_repo/PACKAGES.TXT" self.lib = lib_path + "slonly_repo/PACKAGES.TXT"
@ -125,17 +123,14 @@ class OthersInstall(object):
if os.uname()[4] == "x86_64": if os.uname()[4] == "x86_64":
arch = "{0}-x86_64".format(slack_ver()) arch = "{0}-x86_64".format(slack_ver())
self.mirror = "{0}{1}/".format(Repo().slackonly(), arch) self.mirror = "{0}{1}/".format(Repo().slackonly(), arch)
self.step = self.step * 3
def _init_ktown(self): def _init_ktown(self):
self.lib = lib_path + "ktown_repo/PACKAGES.TXT" self.lib = lib_path + "ktown_repo/PACKAGES.TXT"
self.mirror = Repo().ktown() self.mirror = Repo().ktown()
self.step = self.step * 2
def _init_multi(self): def _init_multi(self):
self.lib = lib_path + "multi_repo/PACKAGES.TXT" self.lib = lib_path + "multi_repo/PACKAGES.TXT"
self.mirror = Repo().multi() self.mirror = Repo().multi()
self.step = self.step * 2
def _init_slacke(self): def _init_slacke(self):
arch = "" arch = ""
@ -146,7 +141,6 @@ class OthersInstall(object):
self.lib = lib_path + "slacke_repo/PACKAGES.TXT" self.lib = lib_path + "slacke_repo/PACKAGES.TXT"
self.mirror = "{0}slacke{1}/slackware{2}-{3}/".format( self.mirror = "{0}slacke{1}/slackware{2}-{3}/".format(
Repo().slacke(), slacke_sub_repo[1:-1], arch, slack_ver()) Repo().slacke(), slacke_sub_repo[1:-1], arch, slack_ver())
self.step = self.step * 2
def _init_salix(self): def _init_salix(self):
arch = "i486" arch = "i486"
@ -154,7 +148,6 @@ class OthersInstall(object):
arch = "x86_64" arch = "x86_64"
self.lib = lib_path + "salix_repo/PACKAGES.TXT" self.lib = lib_path + "salix_repo/PACKAGES.TXT"
self.mirror = "{0}{1}/{2}/".format(Repo().salix(), arch, slack_ver()) self.mirror = "{0}{1}/{2}/".format(Repo().salix(), arch, slack_ver())
self.step = self.step * 2
def _init_slackl(self): def _init_slackl(self):
arch = "i486" arch = "i486"
@ -162,17 +155,16 @@ class OthersInstall(object):
arch = "x86_64" arch = "x86_64"
self.lib = lib_path + "slackl_repo/PACKAGES.TXT" self.lib = lib_path + "slackl_repo/PACKAGES.TXT"
self.mirror = "{0}{1}/current/".format(Repo().slackel(), arch) self.mirror = "{0}{1}/current/".format(Repo().slackel(), arch)
self.step = self.step * 2
def _init_rested(self): def _init_rested(self):
self.lib = lib_path + "rested_repo/PACKAGES.TXT" self.lib = lib_path + "rested_repo/PACKAGES.TXT"
self.mirror = Repo().restricted() self.mirror = Repo().restricted()
self.step = self.step * 2
def start(self): def start(self):
''' '''
Install packages from official Slackware distribution Install packages from official Slackware distribution
''' '''
mas_sum = dep_sum = pkg_sum = [0, 0, 0]
(self.dwn, self.install, self.comp_sum, (self.dwn, self.install, self.comp_sum,
self.uncomp_sum) = self.store(self.packages) self.uncomp_sum) = self.store(self.packages)
sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC'])) sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC']))
@ -185,10 +177,14 @@ class OthersInstall(object):
if self.install: if self.install:
self.top_view() self.top_view()
print("Installing:") print("Installing:")
self.views(self.install, self.comp_sum) mas_sum = self.views(self.install, self.comp_sum)
if dependencies: if dependencies:
print("Installing for dependencies:") print("Installing for dependencies:")
self.views(self.dep_install, self.dep_comp_sum) dep_sum = self.views(self.dep_install, self.dep_comp_sum)
pkg_sum = [sum(i) for i in zip(mas_sum, dep_sum)]
unit, size = units(self.comp_sum, self.uncomp_sum)
print unit, size
def resolving_deps(self): def resolving_deps(self):
''' '''
@ -263,7 +259,7 @@ class OthersInstall(object):
for pkg in packages: for pkg in packages:
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
data[3]): data[3]):
if name.startswith(pkg + "-") and pkg not in black: if pkg in name and pkg not in black:
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name)) dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
install.append(name) install.append(name)
comp_sum.append(comp) comp_sum.append(comp)