updated for version 1.8.8

This commit is contained in:
Dimitris Zlatanidis 2014-09-22 00:47:08 +03:00
parent 7e2dfd1d53
commit 4e50b5454a
18 changed files with 192 additions and 233 deletions

View file

@ -1,3 +1,10 @@
Version 1.8.8
22-08-2014
[Updated] - Fix Alignment viewing packages
- Fix build time
[Feature] - Added search dependencies from local SLACKBUILDS.TXT file
Version 1.8.7 Version 1.8.7
19-09-2014 19-09-2014

View file

@ -1,6 +1,6 @@
Metadata-Version: 1.1 Metadata-Version: 1.1
Name: slpkg Name: slpkg
Version: 1.8.7 Version: 1.8.8
Author: dslackw Author: dslackw
Author-email: d zlatanidis at gmail com Author-email: d zlatanidis at gmail com
Maintainer: dslackw Maintainer: dslackw

View file

@ -7,9 +7,9 @@
Latest Release: Latest Release:
- Version: 1.8.7 - Version: 1.8.8
- `Package <https://sourceforge.net/projects/slpkg/files/slpkg/binary/>`_ - `Package <https://sourceforge.net/projects/slpkg/files/slpkg/binary/>`_
- `Source <https://github.com/dslackw/slpkg/archive/v1.8.7.tar.gz>`_ - `Source <https://github.com/dslackw/slpkg/archive/v1.8.8.tar.gz>`_
- `CHANGELOG <https://github.com/dslackw/slpkg/blob/master/CHANGELOG>`_ - `CHANGELOG <https://github.com/dslackw/slpkg/blob/master/CHANGELOG>`_
.. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/logo.png .. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/logo.png
@ -98,8 +98,8 @@ Untar the archive and run install.sh script:
.. code-block:: bash .. code-block:: bash
$ tar xvf slpkg-1.8.7.tar.gz $ tar xvf slpkg-1.8.8.tar.gz
$ cd slpkg-1.8.7 $ cd slpkg-1.8.8
$ ./install.sh $ ./install.sh
Using `pip <https://pip.pypa.io/en/latest/>`_ : Using `pip <https://pip.pypa.io/en/latest/>`_ :
@ -195,12 +195,12 @@ download and install:
Reading package lists.............................. Done Reading package lists.............................. Done
+============================================================================== +==============================================================================
| Package Version Arch Build Repos Size | Package Version Arch Build Repos Size
+============================================================================== +==============================================================================
Installing: Installing:
mozilla-firefox 24.1.0esr x86_64 1 Slack 23524 K mozilla-firefox 24.1.0esr x86_64 1 Slack 23524 K
mozilla-nss 3.15.2 x86_64 2 Slack 1592 K mozilla-nss 3.15.2 x86_64 2 Slack 1592 K
mozilla-thunderbird 24.1.0 x86_64 1 Slack 24208 K mozilla-thunderbird 24.1.0 x86_64 1 Slack 24208 K
Installing summary Installing summary
=============================================================================== ===============================================================================
@ -274,12 +274,12 @@ Check if your distribution is up to date from `Slackware official mirrors
These packages need upgrading: These packages need upgrading:
+============================================================================== +==============================================================================
| Package Version Arch Build Repos Size | Package Version Arch Build Repos Size
+============================================================================== +==============================================================================
Upgrading: Upgrading:
dhcpcd 6.0.5 x86_64 3 Slack 92 K dhcpcd 6.0.5 x86_64 3 Slack 92 K
samba 4.1.11 x86_64 1 Slack 9928 K samba 4.1.11 x86_64 1 Slack 9928 K
xscreensaver 5.29 x86_64 1 Slack 3896 K xscreensaver 5.29 x86_64 1 Slack 3896 K
Installing summary Installing summary
=============================================================================== ===============================================================================

View file

@ -21,7 +21,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PRGNAM=slpkg PRGNAM=slpkg
VERSION=${VERSION:-1.8.7} VERSION=${VERSION:-1.8.8}
TAG=${TAG:-_dsw} TAG=${TAG:-_dsw}
cd .. cd ..

View file

@ -33,9 +33,9 @@ except ImportError:
from distutils.core import setup from distutils.core import setup
setup( setup(
name='slpkg', name="slpkg",
packages=['slpkg', 'slpkg/sbo', 'slpkg/pkg', 'slpkg/slack'], packages=["slpkg", "slpkg/sbo", "slpkg/pkg", "slpkg/slack"],
scripts=['bin/slpkg'], scripts=["bin/slpkg"],
version=__version__, version=__version__,
description="Python tool to manage Slackware packages", description="Python tool to manage Slackware packages",
keywords=["slackware", "slpkg", "upgrade", "install", "remove", keywords=["slackware", "slpkg", "upgrade", "install", "remove",
@ -61,11 +61,11 @@ setup(
long_description=open("README.rst").read() long_description=open("README.rst").read()
) )
if 'install' in sys.argv: if "install" in sys.argv:
man_path = "/usr/man/man8/" man_path = "/usr/man/man8/"
os.system("mkdir -p {}".format(man_path)) os.system("mkdir -p {}".format(man_path))
if os.path.exists(man_path): if os.path.exists(man_path):
print("Installing man pages") print("Installing man pages")
man_page = "man/slpkg.8" man_page = "man/slpkg.8"
shutil.copy2(man_page, man_path) shutil.copy2(man_page, man_path)
os.chmod(man_path, int('444', 8)) os.chmod(man_path, int("444", 8))

View file

@ -23,7 +23,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PRGNAM=slpkg PRGNAM=slpkg
VERSION=${VERSION:-1.8.7} VERSION=${VERSION:-1.8.8}
BUILD=${BUILD:-1} BUILD=${BUILD:-1}
TAG=${TAG:-_dsw} TAG=${TAG:-_dsw}

View file

@ -1,7 +1,7 @@
PRGNAM="slpkg" PRGNAM="slpkg"
VERSION="1.8.7" VERSION="1.8.8"
HOMEPAGE="https://github.com/dslackw/slpkg" HOMEPAGE="https://github.com/dslackw/slpkg"
DOWNLOAD="https://github.com/dslackw/slpkg/archive/v1.8.7.tar.gz" DOWNLOAD="https://github.com/dslackw/slpkg/archive/v1.8.8.tar.gz"
MD5SUM="" MD5SUM=""
DOWNLOAD_x86_64="" DOWNLOAD_x86_64=""
MD5SUM_x86_64="" MD5SUM_x86_64=""

View file

@ -26,7 +26,7 @@ import subprocess
__all__ = "slpkg" __all__ = "slpkg"
__author__ = "dslackw" __author__ = "dslackw"
__version_info__ = (1, 8, 7) __version_info__ = (1, 8, 8)
__version__ = "{0}.{1}.{2}".format(*__version_info__) __version__ = "{0}.{1}.{2}".format(*__version_info__)
__license__ = "GNU General Public License v3 (GPLv3)" __license__ = "GNU General Public License v3 (GPLv3)"
__email__ = "d.zlatanidis@gmail.com" __email__ = "d.zlatanidis@gmail.com"

View file

@ -104,13 +104,13 @@ def build_package(script, sources, path):
end_time = time.time() end_time = time.time()
diff_time = round(end_time - start_time, 2) diff_time = round(end_time - start_time, 2)
# calculate build time per package # calculate build time per package
if diff_time <= 60: if diff_time <= 59.99:
sum_time = str(diff_time) + " Sec" sum_time = str(diff_time) + " Sec"
elif diff_time > 60: elif diff_time > 59.99 and diff_time <= 3599.99:
sum_time = round(diff_time / 60, 2) sum_time = round(diff_time / 60, 2)
sum_time_list = re.findall(r"\d+", str(sum_time)) sum_time_list = re.findall(r"\d+", str(sum_time))
sum_time = ("{0} Min {1} Sec".format(sum_time_list[0], sum_time_list[1])) sum_time = ("{0} Min {1} Sec".format(sum_time_list[0], sum_time_list[1]))
elif diff_time > 3600: elif diff_time > 3599.99:
sum_time = round(diff_time / 3600, 2) sum_time = round(diff_time / 3600, 2)
sum_time_list = re.findall(r"\d+", str(sum_time)) sum_time_list = re.findall(r"\d+", str(sum_time))
sum_time = ("{0} Hours {1} Min".format(sum_time_list[0], sum_time_list[1])) sum_time = ("{0} Hours {1} Min".format(sum_time_list[0], sum_time_list[1]))

View file

@ -41,9 +41,9 @@ def pkg_install(binary):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
message = "Can't install" message = "Can't install"
if len(binary) > 1: if len(binary) > 1:
bol, eol = "", "" bol = eol = str()
else: else:
bol, eol = "\n", "\n" bol = eol = "\n"
pkg_not_found(bol, pkg, message, eol) pkg_not_found(bol, pkg, message, eol)
def pkg_upgrade(binary): def pkg_upgrade(binary):
@ -57,9 +57,9 @@ def pkg_upgrade(binary):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
message = "Can't upgrade" message = "Can't upgrade"
if len(binary) > 1: if len(binary) > 1:
bol, eol = "", "" bol = eol = str()
else: else:
bol, eol = "\n", "\n" bol = eol = "\n"
pkg_not_found(bol, pkg, message, eol) pkg_not_found(bol, pkg, message, eol)
def pkg_reinstall(binary): def pkg_reinstall(binary):
@ -73,9 +73,9 @@ def pkg_reinstall(binary):
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
message = "Can't reinstall" message = "Can't reinstall"
if len(binary) > 1: if len(binary) > 1:
bol, eol = "", "" bol = eol = str()
else: else:
bol, eol = "\n", "\n" bol = eol = "\n"
pkg_not_found(bol, pkg, message, eol) pkg_not_found(bol, pkg, message, eol)
def pkg_remove(binary): def pkg_remove(binary):
@ -83,8 +83,8 @@ def pkg_remove(binary):
Remove Slackware binary packages Remove Slackware binary packages
''' '''
dep_path = log_path + "dep/" dep_path = log_path + "dep/"
removed, dependencies = [], [] removed, dependencies, \
rmv_list, rmv_dependencies = [], [] rmv_list, rmv_dependencies = ([] for i in range(4))
print("\nPackages with name matching [ {0}{1}{2} ]\n".format( print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
colors.CYAN, ", ".join(binary), colors.ENDC)) colors.CYAN, ", ".join(binary), colors.ENDC))
for pkg in binary: for pkg in binary:
@ -109,11 +109,9 @@ def pkg_remove(binary):
sys.exit() sys.exit()
if remove_pkg == "y" or remove_pkg == "Y": if remove_pkg == "y" or remove_pkg == "Y":
for rmv in removed: for rmv in removed:
''' # If package build and install with 'slpkg -s sbo <package>'
If package build and install with 'slpkg -s sbo <package>' # then look log file for dependencies in /var/log/slpkg/dep,
then look log file for dependencies in /var/log/slpkg/dep, # read and remove all else remove only the package.
read and remove all else remove only the package.
'''
if os.path.isfile(dep_path + rmv): if os.path.isfile(dep_path + rmv):
f = open(dep_path + rmv, "r") f = open(dep_path + rmv, "r")
dependencies = f.read().split() dependencies = f.read().split()
@ -122,15 +120,14 @@ def pkg_remove(binary):
template(78) template(78)
print("| Found dependencies for package {0}:".format(rmv)) print("| Found dependencies for package {0}:".format(rmv))
template(78) template(78)
''' # Prints dependecies before removed except master package
Prints dependecies before removed except master package # because referred as master package
because referred as master package
'''
for dep in dependencies[:-1]: for dep in dependencies[:-1]:
print("| " + dep) print("| " + dep)
template(78) template(78)
try: try:
remove_dep = raw_input("\nRemove dependencies (maybe used by other packages) [Y/n]? ") remove_dep = raw_input(
"\nRemove dependencies (maybe used by other packages) [Y/n]? ")
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print # new line at exit
sys.exit() sys.exit()
@ -151,9 +148,7 @@ def pkg_remove(binary):
if find_package(rmv + sp, pkg_path): if find_package(rmv + sp, pkg_path):
print subprocess.check_output("removepkg {0}".format(rmv), shell=True) print subprocess.check_output("removepkg {0}".format(rmv), shell=True)
rmv_list.append(rmv) rmv_list.append(rmv)
''' # Prints all removed packages
Prints all removed packages
'''
if len(rmv_list) > 1: if len(rmv_list) > 1:
template(78) template(78)
print("| Total {0} packages removed".format(len(rmv_list))) print("| Total {0} packages removed".format(len(rmv_list)))
@ -170,7 +165,7 @@ def pkg_find(binary):
''' '''
Find installed Slackware packages Find installed Slackware packages
''' '''
matching, size = 0, 0 matching = size = int()
print("\nInstalled packages with name matching [ {0}{1}{2} ]\n".format( print("\nInstalled packages with name matching [ {0}{1}{2} ]\n".format(
colors.CYAN, binary, colors.ENDC)) colors.CYAN, binary, colors.ENDC))
for match in sorted(os.listdir(pkg_path)): for match in sorted(os.listdir(pkg_path)):
@ -205,13 +200,13 @@ def pkg_display(binary):
for pkg in binary: for pkg in binary:
if find_package(pkg + sp, pkg_path): if find_package(pkg + sp, pkg_path):
print subprocess.check_output("cat {0}{1}".format(pkg_path, print subprocess.check_output("cat {0}{1}".format(pkg_path,
" /var/log/packages/".join(find_package(pkg +sp, pkg_path))), shell=True) " /var/log/packages/".join(find_package(pkg +sp, pkg_path))), shell=True)
else: else:
message = "Can't dislpay" message = "Can't dislpay"
if len(binary) > 1: if len(binary) > 1:
bol, eol = "", "" bol = eol = str()
else: else:
bol, eol = "\n", "\n" bol = eol = "\n"
pkg_not_found(bol, pkg, message, eol) pkg_not_found(bol, pkg, message, eol)
def pkg_list(pattern): def pkg_list(pattern):

View file

@ -54,10 +54,16 @@ def sbo_check():
colors.GREY, colors.ENDC)) colors.GREY, colors.ENDC))
sys.stdout.flush() sys.stdout.flush()
initialization() initialization()
index, toolbar_width = 0, 3 arches = [
dependencies, dependencies_list = [], [] "-x86_64-",
requires, upgrade, installed, sbo_list = [], [], [], [] "-i486-",
upg_name, pkg_for_upg, upg_ver, upg_arch = [], [], [], [] "-arm-",
"-noarch-"
]
index, toolbar_width = int(), 3
dependencies, dependencies_list, \
requires, upgrade, installed, sbo_list, \
upg_name, pkg_for_upg, upg_ver, upg_arch = ([] for i in range(10))
GREEN, RED, ENDC = colors.GREEN, colors.RED, colors.ENDC GREEN, RED, ENDC = colors.GREEN, colors.RED, colors.ENDC
for pkg in os.listdir(pkg_path): for pkg in os.listdir(pkg_path):
if pkg.endswith("_SBo"): if pkg.endswith("_SBo"):
@ -69,16 +75,11 @@ def sbo_check():
sys.stdout.write("{0}.{1}".format(colors.GREY, ENDC)) sys.stdout.write("{0}.{1}".format(colors.GREY, ENDC))
sys.stdout.flush() sys.stdout.flush()
toolbar_width += 4 toolbar_width += 4
if "-x86_64-" in pkg: for _arch in arches:
arch = "x86_64" if _arch in pkg:
elif "-i486-" in pkg: arch = _arch[1:-1]
arch = "i486" else:
elif "-arm-" in pkg: arch = os.uname()[4]
arch = "arm"
elif "-noarch-" in pkg:
arch = "noarch"
else:
arch = os.uname()[4]
package = pkg[:-(len(arch) + len("_SBo") + 3)] package = pkg[:-(len(arch) + len("_SBo") + 3)]
pkg_version = get_file(package, "-")[1:] pkg_version = get_file(package, "-")[1:]
name = package[:-(len(pkg_version) + 1)] name = package[:-(len(pkg_version) + 1)]
@ -94,43 +95,33 @@ def sbo_check():
sys.stdout.write("{0}Resolving dependencies ...{1}".format( sys.stdout.write("{0}Resolving dependencies ...{1}".format(
colors.GREY, ENDC)) colors.GREY, ENDC))
sys.stdout.flush() sys.stdout.flush()
''' # Of the packages found to need upgrading,
Of the packages found to need upgrading, # stored in a series such as reading from the
stored in a series such as reading from the # file .info.
file .info.
'''
for upg in upg_name: for upg in upg_name:
dependencies = sbo_dependencies_pkg(upg) dependencies = sbo_dependencies_pkg(upg)
''' # Because there are dependencies that depend on other
Because there are dependencies that depend on other # dependencies are created lists into other lists.
dependencies are created lists into other lists. # Thus creating this loop create one-dimensional list.
Thus creating this loop create one-dimensional list.
'''
for dep in dependencies: for dep in dependencies:
requires += dep requires += dep
requires.reverse() # Inverting the list brings the requires.reverse() # Inverting the list brings the
# dependencies in order to be installed. # dependencies in order to be installed.
''' # Many packages use the same dependencies, in this loop
Many packages use the same dependencies, in this loop # creates a new list by removing duplicate dependencies but
creates a new list by removing duplicate dependencies but # without spoiling the line must be installed.
without spoiling the line must be installed.
'''
for duplicate in requires: for duplicate in requires:
if duplicate not in dependencies_list: if duplicate not in dependencies_list:
dependencies_list.append(duplicate) dependencies_list.append(duplicate)
''' # Last and after the list is created with the correct number
Last and after the list is created with the correct number # of dependencies that must be installed, and add the particular
of dependencies that must be installed, and add the particular # packages that need to be upgraded if they are not already on
packages that need to be upgraded if they are not already on # the list in end to list.
the list in end to list.
'''
for upg in upg_name: for upg in upg_name:
if upg not in dependencies_list: if upg not in dependencies_list:
dependencies_list.append(upg) dependencies_list.append(upg)
''' # In the end lest a check of the packages that are on the list
In the end lest a check of the packages that are on the list # are already installed.
are already installed.
'''
for pkg in dependencies_list: for pkg in dependencies_list:
ver = sbo_version_pkg(pkg) ver = sbo_version_pkg(pkg)
prgnam = ("{0}-{1}".format(pkg, ver)) prgnam = ("{0}-{1}".format(pkg, ver))
@ -142,16 +133,11 @@ def sbo_check():
# search if packages installed # search if packages installed
# if yes grab package name, # if yes grab package name,
# version and arch # version and arch
if "-x86_64-" in sbo: for _arch in arches:
arch = "x86_64" if _arch in pkg:
elif "-i486-" in sbo: arch = _arch[1:-1]
arch = "i486" else:
elif "-arm-" in sbo: arch = os.uname()[4]
arch = "arm"
elif "-noarch-" in sbo:
arch = "noarch"
else:
arch = os.uname()[4]
name = sbo[:-(len(arch) + len("_SBo") + 3)] name = sbo[:-(len(arch) + len("_SBo") + 3)]
pkg_version = get_file(name, "-")[1:] pkg_version = get_file(name, "-")[1:]
upgrade.append(pkg) upgrade.append(pkg)
@ -162,10 +148,11 @@ def sbo_check():
if pkg_for_upg: if pkg_for_upg:
print("\nThese packages need upgrading:\n") print("\nThese packages need upgrading:\n")
template(78) template(78)
print "| Package", " " * 27, "New version", " " * 5, "Arch", " " * 7, "Repository" print("{0}{1}{2}{3}{4}{5}{6}".format("| Package", " " * 30, "New version", \
" " * 6 , "Arch", " " * 9, "Repository"))
template(78) template(78)
print("Upgrading:") print("Upgrading:")
count_upgraded, count_installed = 0, 0 count_upgraded = count_installed = int()
for upg, ver, arch in zip(pkg_for_upg, upg_ver, upg_arch): for upg, ver, arch in zip(pkg_for_upg, upg_ver, upg_arch):
if find_package(upg[:-len(ver)], pkg_path): if find_package(upg[:-len(ver)], pkg_path):
COLOR = colors.YELLOW COLOR = colors.YELLOW
@ -173,8 +160,9 @@ def sbo_check():
else: else:
COLOR = colors.RED COLOR = colors.RED
count_installed += 1 count_installed += 1
print " " , COLOR + upg + ENDC, " " * (34-len(upg)), GREEN + ver + ENDC, \ print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(COLOR, upg, ENDC, \
" " * (16-len(ver)), arch, " " * (11-len(arch)), "SBo" " " * (38-len(upg)), GREEN, ver, ENDC, \
" " * (17-len(ver)), arch, " " * (13-len(arch)), "SBo"))
msg_upg = "package" msg_upg = "package"
msg_ins = msg_upg msg_ins = msg_upg
if count_upgraded > 1: if count_upgraded > 1:
@ -203,11 +191,9 @@ def sbo_check():
subprocess.call("wget -N {0}".format(src), shell=True) subprocess.call("wget -N {0}".format(src), shell=True)
sources.append(get_file(src, "/")) sources.append(get_file(src, "/"))
build_package(script, sources, build_path) build_package(script, sources, build_path)
''' # Searches the package name and version in /tmp to install.
Searches the package name and version in /tmp to install. # If find two or more packages e.g. to build tag
If find two or more packages e.g. to build tag # 2 or 3 will fit most.
2 or 3 will fit most.
'''
binary_list = [] binary_list = []
for search in find_package(prgnam, tmp): for search in find_package(prgnam, tmp):
if "_SBo" in search: if "_SBo" in search:

View file

@ -43,8 +43,9 @@ def sbo_dependencies_pkg(name):
dependencies = [] dependencies = []
sbo_url = sbo_search_pkg(name) sbo_url = sbo_search_pkg(name)
if sbo_url: if sbo_url:
requires = sbo_requires_pkg(sbo_url, name) requires = sbo_requires_pkg(name)
for req in requires: for req in requires:
# avoid to add %README% as dependency
if "%README%" not in req: if "%README%" not in req:
dependencies.append(req) dependencies.append(req)
if dependencies: if dependencies:
@ -77,15 +78,11 @@ def pkg_tracking(name):
sys.stdout.write("{0}Done{1}\n".format(colors.GREY, colors.ENDC)) sys.stdout.write("{0}Done{1}\n".format(colors.GREY, colors.ENDC))
print # new line at start print # new line at start
requires, dependencies = [], [] requires, dependencies = [], []
''' # Create one list for all packages
Create one list for all packages
'''
for pkg in dependencies_list: for pkg in dependencies_list:
requires += pkg requires += pkg
requires.reverse() requires.reverse()
''' # Remove double dependencies
Remove double dependencies
'''
for duplicate in requires: for duplicate in requires:
if duplicate not in dependencies: if duplicate not in dependencies:
dependencies.append(duplicate) dependencies.append(duplicate)
@ -97,7 +94,7 @@ def pkg_tracking(name):
template(pkg_len) template(pkg_len)
print("\\") print("\\")
print(" +---{0}[ Tree of dependencies ]{1}".format(YELLOW, ENDC)) print(" +---{0}[ Tree of dependencies ]{1}".format(YELLOW, ENDC))
index = 0 index = int()
for pkg in dependencies: for pkg in dependencies:
index += 1 index += 1
if find_package(pkg + sp, pkg_path): if find_package(pkg + sp, pkg_path):

View file

@ -48,14 +48,16 @@ def sbo_source_dwn(name):
if sbo_name == name: if sbo_name == name:
return line[21:].strip() return line[21:].strip()
def sbo_requires_pkg(sbo_url, name): def sbo_requires_pkg(name):
''' '''
Grab package requirements Grab package requirements
''' '''
read_info = url_read(sbo_url + name + ".info") for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"):
for line in read_info.splitlines(): if line.startswith("SLACKBUILD NAME: "):
if line.startswith("REQUIRES=\""): sbo_name = line[17:].strip()
return line[10:-1].strip().split() if line.startswith("SLACKBUILD REQUIRES: "):
if sbo_name == name:
return line[21:].strip().split()
def sbo_build_tag(sbo_url, name): def sbo_build_tag(sbo_url, name):
# This feature is not yet used # This feature is not yet used

View file

@ -48,10 +48,8 @@ def initialization():
if not os.path.exists(sbo_lib): if not os.path.exists(sbo_lib):
os.mkdir(sbo_lib) os.mkdir(sbo_lib)
sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(slack_ver())) sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(slack_ver()))
''' # Read SLACKBUILDS.TXT from slackbuilds.org and write in /var/lib/slpkg/sbo_repo/
Read SLACKBUILDS.TXT from slackbuilds.org and write in /var/lib/slpkg/sbo_repo/ # directory if not exist
directory if not exist
'''
if not os.path.isfile(sbo_lib + "SLACKBUILDS.TXT"): if not os.path.isfile(sbo_lib + "SLACKBUILDS.TXT"):
print("\nslpkg ...initialization") print("\nslpkg ...initialization")
sys.stdout.write("SLACKBUILDS.TXT read ...") sys.stdout.write("SLACKBUILDS.TXT read ...")
@ -63,10 +61,8 @@ def initialization():
sbo.write(SLACKBUILDS_TXT) sbo.write(SLACKBUILDS_TXT)
sbo.close() sbo.close()
print("File SLACKBUILDS.TXT created in {0}".format(sbo_lib)) print("File SLACKBUILDS.TXT created in {0}".format(sbo_lib))
''' # Read ChangeLog.txt from slackbuilds.org and write in /var/log/slpkg/sbo/
Read ChangeLog.txt from slackbuilds.org and write in /var/log/slpkg/sbo/ # directory if not exist
directory if not exist
'''
if not os.path.isfile(sbo_log + "ChangeLog.txt"): if not os.path.isfile(sbo_log + "ChangeLog.txt"):
print("\nslpkg initialization") print("\nslpkg initialization")
sys.stdout.write("ChangeLog.txt read ...") sys.stdout.write("ChangeLog.txt read ...")
@ -78,14 +74,10 @@ def initialization():
log.write(ChangeLog_txt) log.write(ChangeLog_txt)
log.close() log.close()
print("File ChangeLog.txt created in {0}".format(sbo_log)) print("File ChangeLog.txt created in {0}".format(sbo_log))
''' # We take the size of ChangeLog.txt from the server and locally
We take the size of ChangeLog.txt from the server and locally
'''
server = int(''.join(server_file_size(sbo_url + "ChangeLog.txt"))) server = int(''.join(server_file_size(sbo_url + "ChangeLog.txt")))
local = int(local_file_size(sbo_log + "ChangeLog.txt")) local = int(local_file_size(sbo_log + "ChangeLog.txt"))
''' # If the two files differ in size delete and replaced with new
If the two files differ in size delete and replaced with new
'''
if server != local: if server != local:
os.remove("{0}{1}".format(sbo_lib, "SLACKBUILDS.TXT")) os.remove("{0}{1}".format(sbo_lib, "SLACKBUILDS.TXT"))
os.remove("{0}{1}".format(sbo_log, "ChangeLog.txt")) os.remove("{0}{1}".format(sbo_log, "ChangeLog.txt"))

View file

@ -52,34 +52,25 @@ def sbo_build(name):
dependencies_list = sbo_dependencies_pkg(name) dependencies_list = sbo_dependencies_pkg(name)
try: try:
if dependencies_list is not None: if dependencies_list is not None:
pkg_sum, count_upgraded, count_installed = 0, 0, 0 pkg_sum = count_upgraded = count_installed = int()
arch = os.uname()[4] sbo_ver, pkg_arch, installs, upgraded, \
sbo_ver, pkg_arch = [], [] versions, requires, dependencies = ([] for i in range(7))
installs, upgraded, versions = [], [], [] PKG_COLOR = DEP_COLOR = ARCH_COLOR = str()
requires, dependencies = [], []
PKG_COLOR, DEP_COLOR, ARCH_COLOR = "", "", ""
ENDC = colors.ENDC ENDC = colors.ENDC
''' arch = os.uname()[4]
Insert master package in list to # Insert master package in list to
install it after dependencies # install it after dependencies
'''
requires.append(name) requires.append(name)
''' # Create one list for all packages
Create one list for all packages
'''
for pkg in dependencies_list: for pkg in dependencies_list:
requires += pkg requires += pkg
requires.reverse() requires.reverse()
''' # Remove double dependencies
Remove double dependencies
'''
for duplicate in requires: for duplicate in requires:
if duplicate not in dependencies: if duplicate not in dependencies:
dependencies.append(duplicate) dependencies.append(duplicate)
''' # Create two lists one for package version and one
Create two lists one for package version and one # for package arch.
for package arch.
'''
for pkg in dependencies: for pkg in dependencies:
version = sbo_version_pkg(pkg) version = sbo_version_pkg(pkg)
sbo_ver.append(version) sbo_ver.append(version)
@ -90,10 +81,8 @@ def sbo_build(name):
pkg_arch.append("i486") pkg_arch.append("i486")
elif "arm" in arch: elif "arm" in arch:
pkg_arch.append("arm") pkg_arch.append("arm")
''' # Looks if sources unsupported or untested
Looks if sources unsupported or untested # from arch
from arch
'''
if "UNSUPPORTED" in src: if "UNSUPPORTED" in src:
pkg_arch.append("UNSUPPORTED") pkg_arch.append("UNSUPPORTED")
elif "UNTESTED" in src: elif "UNTESTED" in src:
@ -103,12 +92,10 @@ def sbo_build(name):
pkg_sum += 1 pkg_sum += 1
sys.stdout.write("{0}Done{1}\n".format( sys.stdout.write("{0}Done{1}\n".format(
colors.GREY, ENDC)) colors.GREY, ENDC))
''' # Tag with color green if package already installed,
Tag with color green if package already installed, # color yellow for packages to upgrade and color red
color yellow for packages to upgrade and color red # if not installed. Also if package arch is UNSUPPORTED
if not installed. Also if package arch is UNSUPPORTED # tag with color red and if UNTESTED with color yellow.
tag with color red and if UNTESTED with color yellow.
'''
master_pkg = ("{0}-{1}".format(name, sbo_ver[-1])) master_pkg = ("{0}-{1}".format(name, sbo_ver[-1]))
if find_package(master_pkg, pkg_path): if find_package(master_pkg, pkg_path):
PKG_COLOR = colors.GREEN PKG_COLOR = colors.GREEN
@ -125,13 +112,14 @@ def sbo_build(name):
print("\nThe following packages will be automatically installed or upgraded") print("\nThe following packages will be automatically installed or upgraded")
print("with new version:\n") print("with new version:\n")
template(78) template(78)
print "| Package", " " * 31, "Version", " " * 7, "Arch", " " * 5, "Repository" print("{0}{1}{2}{3}{4}{5}{6}".format("| Package", " " * 30, "Version", \
" " * 10, "Arch", " " * 9, "Repository"))
template(78) template(78)
print("Installing:") print("Installing:")
print " " , PKG_COLOR + name + ENDC, \ print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(PKG_COLOR, name, ENDC, \
" " * (38-len(name)), sbo_ver[-1], \ " " * (38-len(name)), sbo_ver[-1], \
" " * (14-len(sbo_ver[-1])), ARCH_COLOR + pkg_arch[-1] + ENDC, \ " " * (17-len(sbo_ver[-1])), ARCH_COLOR, pkg_arch[-1], ENDC, \
" " * (9-len(pkg_arch[-1])), "SBo" " " * (13-len(pkg_arch[-1])), "SBo"))
print("Installing for dependencies:") print("Installing for dependencies:")
ARCH_COLOR = "" # reset arch color for dependencies packages ARCH_COLOR = "" # reset arch color for dependencies packages
for dep, ver, dep_arch in zip(dependencies[:-1], sbo_ver[:-1], pkg_arch[:-1]): for dep, ver, dep_arch in zip(dependencies[:-1], sbo_ver[:-1], pkg_arch[:-1]):
@ -148,10 +136,10 @@ def sbo_build(name):
ARCH_COLOR = colors.RED ARCH_COLOR = colors.RED
elif "UNTESTED" in dep_arch: elif "UNTESTED" in dep_arch:
ARCH_COLOR = colors.YELLOW ARCH_COLOR = colors.YELLOW
print " " , DEP_COLOR + dep + ENDC, \ print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(DEP_COLOR, dep, ENDC, \
" " * (38-len(dep)), ver, \ " " * (38-len(dep)), ver, \
" " * (14-len(ver)), ARCH_COLOR + dep_arch + ENDC, \ " " * (17-len(ver)), ARCH_COLOR, dep_arch, ENDC, \
" " * (9-len(dep_arch)), "SBo" " " * (13-len(dep_arch)), "SBo"))
msg_ins = "package" msg_ins = "package"
msg_upg = msg_ins msg_upg = msg_ins
if count_installed > 1: if count_installed > 1:
@ -164,10 +152,8 @@ def sbo_build(name):
print("{0} {1} will be installed, {2} allready installed and {3} {4}".format( print("{0} {1} will be installed, {2} allready installed and {3} {4}".format(
count_installed, msg_ins, pkg_sum, count_upgraded, msg_upg)) count_installed, msg_ins, pkg_sum, count_upgraded, msg_upg))
print("will be upgraded.\n") print("will be upgraded.\n")
''' # Check if package supported or tested by arch
Check if package supported or tested by arch # before proceed to install
before proceed to install
'''
UNST = ["UNSUPPORTED", "UNTESTED"] UNST = ["UNSUPPORTED", "UNTESTED"]
if src in UNST: if src in UNST:
print("\n{0}The package {1}{2}\n".format(colors.RED, src, ENDC)) print("\n{0}The package {1}{2}\n".format(colors.RED, src, ENDC))
@ -200,11 +186,9 @@ def sbo_build(name):
subprocess.call("wget -N {0}".format(src), shell=True) subprocess.call("wget -N {0}".format(src), shell=True)
sources.append(get_file(src, "/")) sources.append(get_file(src, "/"))
build_package(script, sources, build_path) build_package(script, sources, build_path)
''' # Searches the package name and version in /tmp to install.
Searches the package name and version in /tmp to install. # If find two or more packages e.g. to build tag
If find two or more packages e.g. to build tag # 2 or 3 will fit most.
2 or 3 will fit most.
'''
binary_list = [] binary_list = []
for search in find_package(prgnam, tmp): for search in find_package(prgnam, tmp):
if "_SBo" in search: if "_SBo" in search:
@ -225,10 +209,8 @@ def sbo_build(name):
print("Complete!\n") print("Complete!\n")
installs.append(pkg) installs.append(pkg)
versions.append(ver) versions.append(ver)
''' # Reference list with packages installed
Reference list with packages installed # and upgraded.
and upgraded.
'''
if len(installs) > 1: if len(installs) > 1:
template(78) template(78)
print("| Total {0} {1} installed and {2} {3} upgraded".format( print("| Total {0} {1} installed and {2} {3} upgraded".format(
@ -244,10 +226,8 @@ def sbo_build(name):
else: else:
print("| Package {0} NOT installed".format(installed)) print("| Package {0} NOT installed".format(installed))
template(78) template(78)
''' # Write dependencies in a log file
Write dependencies in a log file # into directory `/var/log/slpkg/dep/`
into directory `/var/log/slpkg/dep/`
'''
if find_package(name + sp, pkg_path): if find_package(name + sp, pkg_path):
dep_path = log_path + "dep/" dep_path = log_path + "dep/"
if not os.path.exists(dep_path): if not os.path.exists(dep_path):

View file

@ -52,18 +52,16 @@ def sbo_network(name):
initialization() initialization()
sbo_url = sbo_search_pkg(name) sbo_url = sbo_search_pkg(name)
if sbo_url: if sbo_url:
sbo_req = sbo_requires_pkg(sbo_url, name) sbo_req = sbo_requires_pkg(name)
sbo_dwn = sbo_slackbuild_dwn(sbo_url) sbo_dwn = sbo_slackbuild_dwn(sbo_url)
source_dwn = sbo_source_dwn(name).split() source_dwn = sbo_source_dwn(name).split()
sys.stdout.write ("{0}Done{1}\n".format(colors.GREY, colors.ENDC)) sys.stdout.write("{0}Done{1}\n".format(colors.GREY, colors.ENDC))
view_sbo(name, sbo_url, get_file(sbo_dwn, "/"), \ view_sbo(name, sbo_url, get_file(sbo_dwn, "/"), \
", ".join([get_file(src, "/") for src in source_dwn]), \ ", ".join([get_file(src, "/") for src in source_dwn]), \
sbo_req) sbo_req)
''' # Check if package supported by arch
Check if package supported by arch # before proceed to install
before proceed to install FAULT = str()
'''
FAULT = ""
UNST = ["UNSUPPORTED", "UNTESTED"] UNST = ["UNSUPPORTED", "UNTESTED"]
if "".join(source_dwn) in UNST: if "".join(source_dwn) in UNST:
FAULT = "".join(source_dwn) FAULT = "".join(source_dwn)
@ -130,11 +128,9 @@ def sbo_network(name):
subprocess.call("wget -N {0}".format(src), shell=True) subprocess.call("wget -N {0}".format(src), shell=True)
sources.append(get_file(src, "/")) sources.append(get_file(src, "/"))
build_package(script, sources, build_path) build_package(script, sources, build_path)
''' # Searches the package name and version in /tmp to install.
Searches the package name and version in /tmp to install. # If find two or more packages e.g. to build tag
If find two or more packages e.g. to build tag # 2 or 3 will fit most.
2 or 3 will fit most.
'''
binary_list = [] binary_list = []
for search in find_package(prgnam, tmp): for search in find_package(prgnam, tmp):
if "_SBo" in search: if "_SBo" in search:

View file

@ -43,11 +43,12 @@ def install(slack_pkg):
Install packages from official Slackware distribution Install packages from official Slackware distribution
''' '''
try: try:
pkg_sum, uni_sum, upg_sum = 0, 0, 0 pkg_sum = uni_sum = upg_sum = int()
comp_sum, uncomp_sum = [], [] comp_sum, uncomp_sum, names, dwn_list, comp_size, \
names, dwn_list, comp_size, uncomp_size = [], [], [], [] uncomp_size, install_all, package_name, \
install_all, package_name, package_location = [], [], [] package_location = ([] for i in range(9))
arch, COLOR, ENDC = "", "", colors.ENDC arch = COLOR = str()
ENDC = colors.ENDC
# create directories if not exist # create directories if not exist
tmp_path = slpkg_tmp + "packages/" tmp_path = slpkg_tmp + "packages/"
if not os.path.exists(slpkg_tmp): if not os.path.exists(slpkg_tmp):
@ -87,8 +88,9 @@ def install(slack_pkg):
sys.stdout.write("{0}Done{1}\n\n".format(colors.GREY, ENDC)) sys.stdout.write("{0}Done{1}\n\n".format(colors.GREY, ENDC))
if install_all: if install_all:
template(78) template(78)
print "| Package", " " * 17, "Version", " " * 8, "Arch", " " * 3, \ print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
"Build", " ", "Repos", " ", "Size" "| Package", " " * 17, "Version", " " * 12, "Arch", " " * 4, \
"Build", " " * 2, "Repos", " " * 10, "Size"))
template(78) template(78)
print("Installing:") print("Installing:")
for pkg, comp in zip(install_all, comp_sum): for pkg, comp in zip(install_all, comp_sum):
@ -110,13 +112,14 @@ def install(slack_pkg):
else: else:
COLOR = colors.RED COLOR = colors.RED
uni_sum += 1 uni_sum += 1
print " " , COLOR + name + ENDC, \ print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11:>12}{12}".format(
" " * (24-len(name)), ver, \ COLOR, name, ENDC, \
" " * (15-len(ver)), arch, \ " " * (25-len(name)), ver, \
" " * (7-len(arch)), build, \ " " * (19-len(ver)), arch, \
" " * (6-len(build)), "Slack", \ " " * (8-len(arch)), build, \
" " , comp, " " * (3-len(comp)), "K" " " * (7-len(build)), "Slack", \
comp_unit, uncomp_unit = "Mb", "Mb" comp, " K"))
comp_unit = uncomp_unit = "Mb"
compressed = round((sum(map(float, comp_sum)) / 1024), 2) compressed = round((sum(map(float, comp_sum)) / 1024), 2)
uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2) uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2)
if compressed < 1: if compressed < 1:

View file

@ -42,12 +42,11 @@ def patches():
Install new patches from official Slackware mirrors Install new patches from official Slackware mirrors
''' '''
try: try:
comp_sum, uncomp_sum = [], [] slack_arch = str()
dwn_patches, comp_size, uncomp_size = [], [], [] comp_sum, uncomp_sum, dwn_patches, comp_size, uncomp_size, \
upgrade_all, package_name, package_location = [], [], [] upgrade_all, package_name, package_location = ([] for i in range(8))
GREEN, RED, ENDC = colors.GREEN, colors.RED, colors.ENDC GREEN, RED, ENDC = colors.GREEN, colors.RED, colors.ENDC
patch_path = slpkg_tmp + "patches/" patch_path = slpkg_tmp + "patches/"
slack_arch = ""
if not os.path.exists(slpkg_tmp): if not os.path.exists(slpkg_tmp):
os.mkdir(slpkg_tmp) os.mkdir(slpkg_tmp)
if not os.path.exists(patch_path): if not os.path.exists(patch_path):
@ -81,8 +80,9 @@ def patches():
if upgrade_all: if upgrade_all:
print("\nThese packages need upgrading:\n") print("\nThese packages need upgrading:\n")
template(78) template(78)
print "| Package", " " * 17, "Version", " " * 8, "Arch", " " * 3, \ print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
"Build", " ", "Repos", " ", "Size" "| Package", " " * 17, "Version", " " * 12, "Arch", " " * 4, \
"Build", " " * 2, "Repos", " " * 10, "Size"))
template(78) template(78)
print("Upgrading:") print("Upgrading:")
for upgrade, size in zip(upgrade_all, comp_sum): for upgrade, size in zip(upgrade_all, comp_sum):
@ -92,20 +92,21 @@ def patches():
if "_slack" in upgrade: if "_slack" in upgrade:
slack = "_slack" + slack_ver() slack = "_slack" + slack_ver()
else: else:
slack = "" slack = str()
upg = upgrade[:-(len(slack) + 4)] upg = upgrade[:-(len(slack) + 4)]
build = get_file(upg, "-").replace("-", "") build = get_file(upg, "-").replace("-", "")
upg_ver = upg[:-(len(arch) + len(build))] upg_ver = upg[:-(len(arch) + len(build))]
ver = get_file(upg_ver, "-").replace("-", "") ver = get_file(upg_ver, "-").replace("-", "")
name = upg_ver[:-(len(ver) + 1)] name = upg_ver[:-(len(ver) + 1)]
arch = arch[1:-1] arch = arch[1:-1]
print " " , GREEN + name + ENDC, \ print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11:>12}{12}".format(
" " * (24-len(name)), ver, \ GREEN, name, ENDC, \
" " * (15-len(ver)), arch, \ " " * (25-len(name)), ver, \
" " * (7-len(arch)), build, \ " " * (19-len(ver)), arch, \
" " * (6-len(build)), "Slack", \ " " * (8-len(arch)), build, \
" " , size, " " * (3-len(size)), "K" " " * (7-len(build)), "Slack", \
comp_unit, uncomp_unit = "Mb", "Mb" size, " K"))
comp_unit = uncomp_unit = "Mb"
compressed = round((sum(map(float, comp_sum)) / 1024), 2) compressed = round((sum(map(float, comp_sum)) / 1024), 2)
uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2) uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2)
if compressed < 1: if compressed < 1: