updated for version 1.9.8

This commit is contained in:
Dimitris Zlatanidis 2014-10-07 20:28:36 +03:00
parent 031421a975
commit eaf5799577
15 changed files with 262 additions and 196 deletions

View file

@ -1,3 +1,8 @@
Version 1.9.8
07-10-2014
[Updated] - Source code update.
Version 1.9.7
06-10-2014

View file

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

View file

@ -7,9 +7,9 @@
Latest Release:
- Version: 1.9.6
- Version: 1.9.8
- `Package <https://sourceforge.net/projects/slpkg/files/slpkg/binary/>`_
- `Source <https://github.com/dslackw/slpkg/archive/v1.9.6.tar.gz>`_
- `Source <https://github.com/dslackw/slpkg/archive/v1.9.8.tar.gz>`_
- `CHANGELOG <https://github.com/dslackw/slpkg/blob/master/CHANGELOG>`_
.. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/logo.png
@ -96,8 +96,8 @@ Untar the archive and run install.sh script:
.. code-block:: bash
$ tar xvf slpkg-1.9.6.tar.gz
$ cd slpkg-1.9.6
$ tar xvf slpkg-1.9.8.tar.gz
$ cd slpkg-1.9.8
$ ./install.sh
Using `pip <https://pip.pypa.io/en/latest/>`_ :

View file

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

View file

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

View file

@ -26,17 +26,17 @@ import getpass
from colors import *
from messages import s_user
from blacklist import BlackList
from version import prog_version
from __metadata__ import path, __version__
from blacklist import BlackList
from pkg.manager import PackageManager
from pkg.build import build_package
from pkg.manager import PackageManager
from sbo.check import sbo_check
from sbo.views import sbo_network
from sbo.tracking import track_dep
from sbo.slackbuild import sbo_build
from sbo.dependency import pkg_tracking
from slack.patches import patches
from slack.install import install
@ -123,7 +123,7 @@ def main():
else:
for opt in usage: print(opt)
elif len(args) == 2 and args[0] == "-t":
pkg_tracking(args[1])
track_dep(args[1])
elif len(args) == 2 and args[0] == "-n":
sbo_network(args[1])
elif len(args) == 2 and args[0] == "-b" and args[1] == "--list":

View file

@ -34,7 +34,7 @@ from checksum import md5sum
from __metadata__ import log_path
from messages import pkg_not_found, template
from sbo.greps import sbo_checksum_pkg
from sbo.greps import SBoGrep
def build_package(script, sources, path):
@ -66,7 +66,7 @@ def build_package(script, sources, path):
for src in sources:
# fix build sources with spaces
src = src.replace("%20", " ")
sbo_md5 = sbo_checksum_pkg(prgnam)
sbo_md5 = SBoGrep(prgnam).checksum()
md5 = md5sum(src)
if sbo_md5 != md5:
template(78)

View file

@ -34,10 +34,10 @@ from downloader import Download
from messages import template, build_FAILED
from __metadata__ import tmp, pkg_path, build_path, sp
from greps import SBoGrep
from search import sbo_search_pkg
from download import sbo_slackbuild_dwn
from dependency import sbo_dependencies_pkg
from greps import sbo_source_dwn, sbo_version_pkg
def sbo_check():
@ -49,17 +49,27 @@ def sbo_check():
but install the package with maximum build tag if find the
some version in /tmp directory.
'''
done = "{0}Done{1}\n".format(GREY, ENDC)
reading_lists = "{0}Reading package lists ...{1}".format(GREY, ENDC)
sys.stdout.write(reading_lists)
sys.stdout.flush()
init = initialization()
arches = ["-x86_64-", "-i486-", "-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))
try:
done = "{0}Done{1}\n".format(GREY, ENDC)
reading_lists = "{0}Reading package lists ...{1}".format(GREY, ENDC)
sys.stdout.write(reading_lists)
sys.stdout.flush()
init = initialization()
arches = ["-x86_64-", "-i486-", "-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))
for pkg in os.listdir(pkg_path):
if pkg.endswith("_SBo"):
sbo_list.append(pkg)
@ -84,7 +94,7 @@ def sbo_check():
# search packages if exists in the repository
# and it gets to avoidable modified packages
# from the user with the tag _SBo
sbo_package = ("{0}-{1}".format(name, sbo_version_pkg(name)))
sbo_package = ("{0}-{1}".format(name, SBoGrep(name).version()))
if sbo_package > package:
upg_name.append(name)
sys.stdout.write(done)
@ -120,7 +130,7 @@ def sbo_check():
# In the end lest a check of the packages that are on the list
# are already installed.
for pkg in dependencies_list:
ver = sbo_version_pkg(pkg)
ver = SBoGrep(pkg).version()
prgnam = ("{0}-{1}".format(pkg, ver))
pkg_version = ver # if package not installed
# take version from repository
@ -180,7 +190,7 @@ def sbo_check():
prgnam = ("{0}-{1}".format(name, version))
sbo_url = sbo_search_pkg(name)
sbo_dwn = sbo_slackbuild_dwn(sbo_url)
src_dwn = sbo_source_dwn(name).split()
src_dwn = SBoGrep(name).source().split()
script = sbo_dwn.split("/")[-1] # keep file from script link
Download(build_path, sbo_dwn).start()
sources = []

View file

@ -24,15 +24,10 @@
import sys
from colors import *
from init import initialization
from blacklist import BlackList
from __metadata__ import pkg_path, sp
from messages import pkg_not_found, template
from pkg.find import find_package
from greps import SBoGrep
from search import sbo_search_pkg
from greps import sbo_requires_pkg
dep_results = []
@ -46,7 +41,7 @@ def sbo_dependencies_pkg(name):
blacklist = BlackList().packages()
sbo_url = sbo_search_pkg(name)
if sbo_url:
requires = sbo_requires_pkg(name)
requires = SBoGrep(name).requires()
for req in requires:
# avoid to add %README% as dependency and
# if require in blacklist
@ -63,51 +58,3 @@ def sbo_dependencies_pkg(name):
except KeyboardInterrupt:
print # new line at exit
sys.exit()
def pkg_tracking(name):
'''
View tree of dependencies and also
highlight packages with color green
if allready installed and color red
if not installed.
'''
done = "{0}Done{1}\n".format(GREY, ENDC)
reading_lists = "{0}Reading package lists ...{1}".format(GREY, ENDC)
sys.stdout.write(reading_lists)
sys.stdout.flush()
init = initialization()
dependencies_list = sbo_dependencies_pkg(name)
if dependencies_list is not None:
sys.stdout.write(done)
print # new line at start
requires, dependencies = [], []
# Create one list for all packages
for pkg in dependencies_list:
requires += pkg
requires.reverse()
# Remove double dependencies
for duplicate in requires:
if duplicate not in dependencies:
dependencies.append(duplicate)
if dependencies == []:
dependencies = ["No dependencies"]
pkg_len = len(name) + 24
template(pkg_len)
print("| Package {0}{1}{2} dependencies :".format(CYAN, name, ENDC))
template(pkg_len)
print("\\")
print(" +---{0}[ Tree of dependencies ]{1}".format(YELLOW, ENDC))
index = int()
for pkg in dependencies:
index += 1
if find_package(pkg + sp, pkg_path):
print(" |")
print(" {0}{1}: {2}{3}{4}".format("+--", index, GREEN, pkg, ENDC))
else:
print(" |")
print(" {0}{1}: {2}{3}{4}".format("+--", index, RED, pkg, ENDC))
print # new line at end
else:
sys.stdout.write(done)
message = "From slackbuilds.org"
pkg_not_found("\n", name, message, "\n")

View file

@ -29,102 +29,104 @@ from __metadata__ import arch, lib_path
from search import sbo_search_pkg
def sbo_source_dwn(name):
class SBoGrep(object):
'''
Grab sources downloads links
Class data grab
'''
if arch == "x86_64":
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if arch == "x86_64":
if line.startswith("SLACKBUILD NAME: "):
def __init__(self, name):
self.name = name
arch64 = "x86_64"
self.line_name = "SLACKBUILD NAME: "
self.line_down = "SLACKBUILD DOWNLOAD: "
self.line_down_64 = "SLACKBUILD DOWNLOAD_{0}: ".format(arch64)
self.line_req = "SLACKBUILD REQUIRES: "
self.line_ver = "SLACKBUILD VERSION: "
self.line_md5 = "SLACKBUILD MD5SUM: "
self.line_md5_64 = "SLACKBUILD MD5SUM_{0}".format(arch64)
self.line_des = "SLACKBUILD SHORT DESCRIPTION: "
self.sbo_txt = lib_path + "sbo_repo/SLACKBUILDS.TXT"
def source(self):
'''
Grab sources downloads links
'''
if arch == "x86_64":
with open(self.sbo_txt, "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if line.startswith(self.line_name):
sbo_name = line[17:].strip()
if line.startswith("SLACKBUILD DOWNLOAD_x86_64: "):
if sbo_name == name:
if line.startswith(self.line_down_64):
if sbo_name == self.name:
if line[28:].strip():
SLACKBUILDS_TXT.close()
return line[28:].strip()
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if line.startswith("SLACKBUILD NAME: "):
sbo_name = line[17:].strip()
if line.startswith("SLACKBUILD DOWNLOAD: "):
if sbo_name == name:
SLACKBUILDS_TXT.close()
return line[21:].strip()
def sbo_requires_pkg(name):
'''
Grab package requirements
'''
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if line.startswith("SLACKBUILD NAME: "):
sbo_name = line[17:].strip()
if line.startswith("SLACKBUILD REQUIRES: "):
if sbo_name == name:
SLACKBUILDS_TXT.close()
return line[21:].strip().split()
def sbo_build_tag(sbo_url, name):
# This feature is not yet used
# because the program is doing heavy on search.
# Looking for the best option to be able to use
# the BUILD tag
'''
Grab .SlackBuild BUILD tag
'''
read_info = url_read(sbo_url + name + ".SlackBuild")
for line in read_info.splitlines():
if line.startswith("BUILD=${BUILD:"):
return line[15:-1].strip().split()
def sbo_version_pkg(name):
'''
Grab package verion
'''
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if line.startswith("SLACKBUILD NAME: "):
sbo_name = line[17:].strip()
if line.startswith("SLACKBUILD VERSION: "):
if sbo_name == name:
SLACKBUILDS_TXT.close()
return line[20:].strip()
def sbo_checksum_pkg(name):
'''
Grab checksum string
'''
if arch == "x86_64":
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r") as SLACKBUILDS_TXT:
with open(self.sbo_txt, "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if arch == "x86_64":
if line.startswith("SLACKBUILD NAME: "):
if line.startswith(self.line_name):
sbo_name = line[17:].strip()
if line.startswith(self.line_down):
if sbo_name == self.name:
SLACKBUILDS_TXT.close()
return line[21:].strip()
def requires(self):
'''
Grab package requirements
'''
with open(self.sbo_txt, "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if line.startswith(self.line_name):
sbo_name = line[17:].strip()
if line.startswith(self.line_req):
if sbo_name == self.name:
SLACKBUILDS_TXT.close()
return line[21:].strip().split()
def version(self):
'''
Grab package version
'''
with open(self.sbo_txt, "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if line.startswith(self.line_name):
sbo_name = line[17:].strip()
if line.startswith(self.line_ver):
if sbo_name == self.name:
SLACKBUILDS_TXT.close()
return line[20:].strip()
def checksum(self):
'''
Grab checksum string
'''
if arch == "x86_64":
with open(self.sbo_txt, "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if line.startswith(self.line_name):
sbo_name = line[17:].strip()
if line.startswith("SLACKBUILD MD5SUM_x86_64: "):
if sbo_name == name:
if line.startswith(self.line_md5_64):
if sbo_name == self.name:
if line[26:].strip():
SLACKBUILDS_TXT.close()
return line[26:].strip()
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if line.startswith("SLACKBUILD NAME: "):
sbo_name = line[17:].strip()
if line.startswith("SLACKBUILD MD5SUM: "):
if sbo_name == name:
SLACKBUILDS_TXT.close()
return line[19:].strip()
with open(self.sbo_txt, "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if line.startswith(self.line_name):
sbo_name = line[17:].strip()
if line.startswith(self.line_md5):
if sbo_name == self.name:
SLACKBUILDS_TXT.close()
return line[19:].strip()
def sbo_description_pkg(name):
'''
Grab package verion
'''
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if line.startswith("SLACKBUILD NAME: "):
sbo_name = line[17:].strip()
if line.startswith("SLACKBUILD SHORT DESCRIPTION: "):
if sbo_name == name:
SLACKBUILDS_TXT.close()
return line[31:].strip()
def description(self):
'''
Grab package verion
'''
with open(self.sbo_txt, "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT:
if line.startswith(self.line_name):
sbo_name = line[17:].strip()
if line.startswith(self.line_des):
if sbo_name == self.name:
SLACKBUILDS_TXT.close()
return line[31:].strip()

View file

@ -36,10 +36,10 @@ from pkg.find import find_package
from pkg.build import build_package
from pkg.manager import PackageManager
from greps import SBoGrep
from search import sbo_search_pkg
from download import sbo_slackbuild_dwn
from dependency import sbo_dependencies_pkg
from greps import sbo_source_dwn, sbo_version_pkg
def sbo_build(name):
@ -48,14 +48,21 @@ def sbo_build(name):
with all dependencies if version is greater than
that established.
'''
sbo_ver, pkg_arch, installs, upgraded, \
versions, requires, dependencies = ([] for i in range(7))
PKG_COLOR = DEP_COLOR = ARCH_COLOR = str()
done = "{0}Done{1}\n".format(GREY, ENDC)
reading_lists = "{0}Reading package lists ...{1}".format(GREY, ENDC)
sys.stdout.write(reading_lists)
sys.stdout.flush()
init = initialization()
[
sbo_ver,
pkg_arch,
installs,
upgraded,
versions,
requires,
dependencies
] = ([] for i in range(7))
PKG_COLOR = DEP_COLOR = ARCH_COLOR = str()
dependencies_list = sbo_dependencies_pkg(name)
try:
if dependencies_list is not None or sbo_search_pkg(name) is not None:
@ -74,9 +81,9 @@ def sbo_build(name):
# Create two lists one for package version and one
# for package arch.
for pkg in dependencies:
version = sbo_version_pkg(pkg)
version = SBoGrep(pkg).version()
sbo_ver.append(version)
src = sbo_source_dwn(pkg)
src = SBoGrep(pkg).source()
pkg_arch.append(select_arch(src))
sbo_pkg = ("{0}-{1}".format(pkg, version))
if find_package(sbo_pkg, pkg_path):
@ -139,7 +146,7 @@ def sbo_build(name):
# before proceed to install
UNST = ["UNSUPPORTED", "UNTESTED"]
if src in UNST:
print("\n{0}The package {1}{2}\n".format(RED, src, ENDC))
print("{0}The package {1}{2}\n".format(RED, src, ENDC))
read = ""
# exit if all packages already installed
elif pkg_sum == len(dependencies):
@ -161,7 +168,7 @@ def sbo_build(name):
else:
sbo_url = sbo_search_pkg(pkg)
sbo_link = sbo_slackbuild_dwn(sbo_url)
src_link = sbo_source_dwn(pkg).split()
src_link = SBoGrep(pkg).source().split()
script = sbo_link.split("/")[-1] # get file from script
Download(build_path, sbo_link).start()
sources = []
@ -236,8 +243,8 @@ def sbo_build(name):
sys.stdout.flush()
toolbar_width += 6
sbo_matching.append(sbo_name)
sbo_ver.append(sbo_version_pkg(sbo_name))
src = sbo_source_dwn(sbo_name)
sbo_ver.append(SBoGrep(sbo_name).version())
src = SBoGrep(sbo_name).source()
pkg_arch.append(select_arch(src))
SLACKBUILDS_TXT.close()
sys.stdout.write(done)

81
slpkg/sbo/tracking.py Executable file
View file

@ -0,0 +1,81 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# tracking.py file is part of slpkg.
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Utility for easy management packages in Slackware
# https://github.com/dslackw/slpkg
# Slpkg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
from colors import *
from messages import template
from init import initialization
from __metadata__ import pkg_path, sp
from dependency import sbo_dependencies_pkg
from pkg.find import find_package
def track_dep(name):
'''
View tree of dependencies and also
highlight packages with color green
if allready installed and color red
if not installed.
'''
done = "{0}Done{1}\n".format(GREY, ENDC)
reading_lists = "{0}Reading package lists ...{1}".format(GREY, ENDC)
sys.stdout.write(reading_lists)
sys.stdout.flush()
init = initialization()
dependencies_list = sbo_dependencies_pkg(name)
if dependencies_list is not None:
sys.stdout.write(done)
requires, dependencies = [], []
# Create one list for all packages
for pkg in dependencies_list:
requires += pkg
requires.reverse()
# Remove double dependencies
for duplicate in requires:
if duplicate not in dependencies:
dependencies.append(duplicate)
if dependencies == []:
dependencies = ["No dependencies"]
pkg_len = len(name) + 24
print # new line at start
template(pkg_len)
print("| Package {0}{1}{2} dependencies :".format(CYAN, name, ENDC))
template(pkg_len)
print("\\")
print(" +---{0}[ Tree of dependencies ]{1}".format(YELLOW, ENDC))
index = int()
for pkg in dependencies:
index += 1
if find_package(pkg + sp, pkg_path):
print(" |")
print(" {0}{1}: {2}{3}{4}".format("+--", index, GREEN, pkg, ENDC))
else:
print(" |")
print(" {0}{1}: {2}{3}{4}".format("+--", index, RED, pkg, ENDC))
print # new line at end
else:
sys.stdout.write(done)
print("\nNo package was found to match\n")

View file

@ -29,7 +29,7 @@ from colors import *
from init import initialization
from downloader import Download
from __metadata__ import tmp, build_path, pkg_path, sp
from messages import (pkg_not_found, pkg_found, view_sbo,
from messages import (pkg_found, view_sbo,
template, build_FAILED)
from pkg.build import build_package
@ -37,7 +37,7 @@ from pkg.find import find_package
from pkg.manager import PackageManager
from read import *
from greps import *
from greps import SBoGrep
from search import sbo_search_pkg
from download import sbo_slackbuild_dwn
@ -54,10 +54,10 @@ def sbo_network(name):
init = initialization()
sbo_url = sbo_search_pkg(name)
if sbo_url:
sbo_desc = sbo_description_pkg(name)[len(name) + 2:-1]
sbo_req = sbo_requires_pkg(name)
sbo_desc = SBoGrep(name).description()[len(name) + 2:-1]
sbo_req = SBoGrep(name).requires()
sbo_dwn = sbo_slackbuild_dwn(sbo_url)
source_dwn = sbo_source_dwn(name).split()
source_dwn = SBoGrep(name).source().split()
sys.stdout.write(done)
view_sbo(name, sbo_url, sbo_desc, sbo_dwn.split("/")[-1], \
", ".join([src.split("/")[-1] for src in source_dwn]), \
@ -110,7 +110,7 @@ def sbo_network(name):
sys.exit()
if not os.path.exists(build_path):
os.mkdir(build_path)
sbo_version = sbo_version_pkg(name)
sbo_version = SBoGrep(name).version()
prgnam = ("{0}-{1}".format(name, sbo_version))
if find_package(prgnam + sp, pkg_path) == []:
sources = []
@ -145,5 +145,4 @@ def sbo_network(name):
break
else:
sys.stdout.write (done)
message = "From slackbuilds.org"
pkg_not_found("\n", name, message, "\n")
print("\nNo package was found to match\n")

View file

@ -44,13 +44,20 @@ def install(slack_pkg, version):
Install packages from official Slackware distribution
'''
try:
pkg_sum = uni_sum = upg_sum = int()
comp_sum, uncomp_sum, names, dwn_list, comp_size, \
uncomp_size, install_all, package_name, \
package_location = ([] for i in range(9))
done = "{0}Done{1}\n".format(GREY, ENDC)
reading_lists = "{0}Reading package lists ...{1}".format(GREY, ENDC)
[
comp_sum,
uncomp_sum,
names, dwn_list,
comp_size,
uncomp_size,
install_all,
package_name,
package_location
] = ([] for i in range(9))
arch = COLOR = str()
pkg_sum = uni_sum = upg_sum = int()
# create directories if not exists
tmp_path = slpkg_tmp + "packages/"
if not os.path.exists(slpkg_tmp):

View file

@ -45,11 +45,19 @@ def patches(version):
Install new patches from official Slackware mirrors
'''
try:
slack_arch = str()
comp_sum, uncomp_sum, dwn_patches, comp_size, uncomp_size, \
upgrade_all, package_name, package_location = ([] for i in range(8))
done = "{0}Done{1}\n".format(GREY, ENDC)
reading_lists = "{0}Reading package lists ...{1}".format(GREY, ENDC)
[
comp_sum,
uncomp_sum,
dwn_patches,
comp_size,
uncomp_size,
upgrade_all,
package_name,
package_location
] = ([] for i in range(8))
slack_arch = str()
patch_path = slpkg_tmp + "patches/"
if not os.path.exists(slpkg_tmp):
os.mkdir(slpkg_tmp)