mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-02-01 07:57:26 +01:00
updated for version 1.9.8
This commit is contained in:
parent
a5bb698e36
commit
ac6ad56731
32 changed files with 604 additions and 473 deletions
|
@ -1,3 +1,8 @@
|
|||
Version 1.9.8
|
||||
07-10-2014
|
||||
|
||||
[Updated] - Source code update.
|
||||
|
||||
Version 1.9.7
|
||||
06-10-2014
|
||||
|
||||
|
|
2
PKG-INFO
2
PKG-INFO
|
@ -1,6 +1,6 @@
|
|||
Metadata-Version: 1.1
|
||||
Name: slpkg
|
||||
Version: 1.9.7
|
||||
Version: 1.9.8
|
||||
Author: dslackw
|
||||
Author-email: d zlatanidis at gmail com
|
||||
Maintainer: dslackw
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
Latest Release:
|
||||
|
||||
- Version: 1.9.7
|
||||
- Version: 1.9.8
|
||||
- `Package <https://sourceforge.net/projects/slpkg/files/slpkg/binary/>`_
|
||||
- `Source <https://github.com/dslackw/slpkg/archive/v1.9.7.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.7.tar.gz
|
||||
$ cd slpkg-1.9.7
|
||||
$ tar xvf slpkg-1.9.8.tar.gz
|
||||
$ cd slpkg-1.9.8
|
||||
$ ./install.sh
|
||||
|
||||
Using `pip <https://pip.pypa.io/en/latest/>`_ :
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
PRGNAM=slpkg
|
||||
VERSION=${VERSION:-1.9.7}
|
||||
VERSION=${VERSION:-1.9.8}
|
||||
TAG=${TAG:-_dsw}
|
||||
|
||||
cd ..
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
PRGNAM=slpkg
|
||||
VERSION=${VERSION:-1.9.7}
|
||||
VERSION=${VERSION:-1.9.8}
|
||||
BUILD=${BUILD:-1}
|
||||
TAG=${TAG:-_dsw}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
PRGNAM="slpkg"
|
||||
VERSION="1.9.7"
|
||||
VERSION="1.9.8"
|
||||
HOMEPAGE="https://github.com/dslackw/slpkg"
|
||||
DOWNLOAD="https://github.com/dslackw/slpkg/archive/v1.9.7.tar.gz"
|
||||
DOWNLOAD="https://github.com/dslackw/slpkg/archive/v1.9.8.tar.gz"
|
||||
MD5SUM=""
|
||||
DOWNLOAD_x86_64=""
|
||||
MD5SUM_x86_64=""
|
||||
|
|
|
@ -26,7 +26,7 @@ import subprocess
|
|||
|
||||
__all__ = "slpkg"
|
||||
__author__ = "dslackw"
|
||||
__version_info__ = (1, 9, 7)
|
||||
__version_info__ = (1, 9, 8)
|
||||
__version__ = "{0}.{1}.{2}".format(*__version_info__)
|
||||
__license__ = "GNU General Public License v3 (GPLv3)"
|
||||
__email__ = "d.zlatanidis@gmail.com"
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
import os
|
||||
from __metadata__ import bls_path
|
||||
|
||||
|
||||
class BlackList(object):
|
||||
'''
|
||||
Blacklist class to add, remove or listed packages
|
||||
|
@ -115,7 +116,7 @@ class BlackList(object):
|
|||
print(pkg)
|
||||
black_conf.write(pkg + "\n")
|
||||
exit = 1
|
||||
black_conf.close()
|
||||
black_conf.close()
|
||||
if exit == 1:
|
||||
print # new line at exit
|
||||
|
||||
|
|
|
@ -22,14 +22,29 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
from colors import *
|
||||
|
||||
def download(path, url):
|
||||
'''
|
||||
Download files usign wget.
|
||||
Check if file exist or file is broken.
|
||||
'''
|
||||
print("\n{0}[ Download ] -->{1} {2}\n".format(GREEN, ENDC, url.split("/")[-1]))
|
||||
subprocess.call("wget -N --directory-prefix={0} {1}".format(path, url), shell=True)
|
||||
|
||||
class Download(object):
|
||||
|
||||
def __init__(self, path, url):
|
||||
self.path = path
|
||||
self.url = url
|
||||
self.file_name = self.url.split("/")[-1]
|
||||
|
||||
def start(self):
|
||||
'''
|
||||
Download files usign wget.
|
||||
Check if file already download the skip or continue
|
||||
download if before stoped.
|
||||
'''
|
||||
print("\n{0}[ Download ] -->{1} {2}\n".format(GREEN, ENDC, self.file_name))
|
||||
try:
|
||||
subprocess.call("wget -c -N --directory-prefix={0} {1}".format(
|
||||
self.path, self.url), shell=True)
|
||||
except KeyboardInterrupt:
|
||||
print # new line at cancel
|
||||
sys.exit()
|
||||
|
|
|
@ -25,23 +25,29 @@ import os
|
|||
import sys
|
||||
import urllib2
|
||||
|
||||
def server_file_size(url):
|
||||
'''
|
||||
Returns the size of remote files
|
||||
'''
|
||||
try:
|
||||
tar = urllib2.urlopen(url)
|
||||
meta = tar.info()
|
||||
return int(meta.getheaders("Content-Length")[0])
|
||||
except (urllib2.URLError, IndexError):
|
||||
print("\nError: connection refused\n")
|
||||
sys.exit()
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
||||
def local_file_size(registry):
|
||||
'''
|
||||
Returns the size of local files
|
||||
'''
|
||||
return os.path.getsize(registry)
|
||||
class FileSize(object):
|
||||
|
||||
def __init__(self, registry):
|
||||
self.registry = registry
|
||||
|
||||
def server(self):
|
||||
'''
|
||||
Returns the size of remote files
|
||||
'''
|
||||
try:
|
||||
tar = urllib2.urlopen(self.registry)
|
||||
meta = tar.info()
|
||||
return int(meta.getheaders("Content-Length")[0])
|
||||
except (urllib2.URLError, IndexError):
|
||||
print("\nError: connection refused\n")
|
||||
sys.exit()
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
||||
def local(self):
|
||||
'''
|
||||
Returns the size of local files
|
||||
'''
|
||||
return os.path.getsize(self.registry)
|
||||
|
|
|
@ -25,13 +25,14 @@ import os
|
|||
import sys
|
||||
import getpass
|
||||
|
||||
from file_size import *
|
||||
from messages import s_user
|
||||
from url_read import url_read
|
||||
from __metadata__ import log_path, lib_path
|
||||
from file_size import server_file_size, local_file_size
|
||||
|
||||
from slack.slack_version import slack_ver
|
||||
|
||||
|
||||
def initialization():
|
||||
'''
|
||||
Slpkg initialization, creating directories and SLACKBUILDS.TXT in
|
||||
|
@ -76,8 +77,8 @@ def initialization():
|
|||
log.close()
|
||||
print("File ChangeLog.txt created in {0}".format(sbo_log))
|
||||
# We take the size of ChangeLog.txt from the server and locally
|
||||
server = server_file_size(sbo_url + "ChangeLog.txt")
|
||||
local = local_file_size(sbo_log + "ChangeLog.txt")
|
||||
server = FileSize(sbo_url + "ChangeLog.txt").server()
|
||||
local = FileSize(sbo_log + "ChangeLog.txt").local()
|
||||
# If the two files differ in size delete and replaced with new
|
||||
if server != local:
|
||||
os.remove("{0}{1}".format(sbo_lib, "SLACKBUILDS.TXT"))
|
||||
|
|
|
@ -21,21 +21,22 @@
|
|||
# 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
|
||||
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 *
|
||||
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
|
||||
|
@ -92,7 +93,7 @@ def main():
|
|||
elif len(args) == 2 and args[0] == "-l":
|
||||
sbo_list = ["all", "sbo", "slack", "noarch"]
|
||||
if args[1] in sbo_list:
|
||||
pkg_list(args[1])
|
||||
PackageManager(None).list(args[1])
|
||||
else:
|
||||
for opt in usage: print(opt)
|
||||
elif len(args) == 3 and args[0] == "-c":
|
||||
|
@ -122,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":
|
||||
|
@ -132,17 +133,17 @@ def main():
|
|||
elif len(args) > 2 and args[0] == "-b" and args[-1] == "--remove":
|
||||
BlackList().remove(args[1:-1])
|
||||
elif len(args) > 1 and args[0] == "-i":
|
||||
pkg_install(args[1:])
|
||||
PackageManager(args[1:]).install()
|
||||
elif len(args) > 1 and args[0] == "-u":
|
||||
pkg_upgrade(args[1:])
|
||||
PackageManager(args[1:]).upgrade()
|
||||
elif len(args) > 1 and args[0] == "-o":
|
||||
pkg_reinstall(args[1:])
|
||||
PackageManager(args[1:]).reinstall()
|
||||
elif len(args) > 1 and args[0] == "-r":
|
||||
pkg_remove(args[1:])
|
||||
PackageManager(args[1:]).remove()
|
||||
elif len(args) > 1 and args[0] == "-f":
|
||||
pkg_find(args[1:])
|
||||
PackageManager(args[1:]).find()
|
||||
elif len(args) > 1 and args[0] == "-d":
|
||||
pkg_display(args[1:])
|
||||
PackageManager(args[1:]).display()
|
||||
else:
|
||||
for opt in usage: print(opt)
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ import sys
|
|||
from colors import *
|
||||
from __metadata__ import __all__
|
||||
|
||||
|
||||
def pkg_not_found(bol, pkg, message, eol):
|
||||
'''
|
||||
Print message when package not found
|
||||
|
@ -63,7 +64,7 @@ def build_FAILED(sbo_url, prgnam):
|
|||
|
||||
def template(max):
|
||||
'''
|
||||
Print view template
|
||||
Print template
|
||||
'''
|
||||
print("+" + "=" * max)
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@ from slpkg.checksum import md5sum
|
|||
from slpkg.__metadata__ import log_path
|
||||
from slpkg.messages import pkg_not_found, template
|
||||
|
||||
from slpkg.sbo.greps import sbo_checksum_pkg
|
||||
from slpkg.sbo.greps import SBoGrep
|
||||
|
||||
|
||||
def build_package(script, sources, path):
|
||||
'''
|
||||
|
@ -65,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)
|
||||
|
|
|
@ -27,6 +27,7 @@ from slpkg.blacklist import BlackList
|
|||
|
||||
from slpkg.slack.splitting import split_package
|
||||
|
||||
|
||||
def find_package(find_pkg, directory):
|
||||
'''
|
||||
Find packages
|
||||
|
|
|
@ -32,212 +32,232 @@ from slpkg.__metadata__ import pkg_path, sp, log_path
|
|||
|
||||
from find import find_package
|
||||
|
||||
def pkg_install(binary):
|
||||
'''
|
||||
Install Slackware binary packages
|
||||
'''
|
||||
for pkg in binary:
|
||||
try:
|
||||
print(subprocess.check_output("installpkg {0}".format(pkg), shell=True))
|
||||
print("Completed!\n")
|
||||
except subprocess.CalledProcessError:
|
||||
message = "Can't install"
|
||||
if len(binary) > 1:
|
||||
bol = eol = str()
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
pkg_not_found(bol, pkg, message, eol)
|
||||
|
||||
def pkg_upgrade(binary):
|
||||
class PackageManager(object):
|
||||
'''
|
||||
Upgrade Slackware binary packages
|
||||
'''
|
||||
for pkg in binary:
|
||||
try:
|
||||
print(subprocess.check_output("upgradepkg --install-new {0}".format(pkg),
|
||||
shell=True))
|
||||
print("Completed!\n")
|
||||
except subprocess.CalledProcessError:
|
||||
message = "Can't upgrade"
|
||||
if len(binary) > 1:
|
||||
bol = eol = str()
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
pkg_not_found(bol, pkg, message, eol)
|
||||
|
||||
def pkg_reinstall(binary):
|
||||
'''
|
||||
Reinstall Slackware binary packages
|
||||
'''
|
||||
for pkg in binary:
|
||||
try:
|
||||
print(subprocess.check_output("upgradepkg --reinstall {0}".format(pkg),
|
||||
shell=True))
|
||||
print("Completed!\n")
|
||||
except subprocess.CalledProcessError:
|
||||
message = "Can't reinstall"
|
||||
if len(binary) > 1:
|
||||
bol = eol = str()
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
pkg_not_found(bol, pkg, message, eol)
|
||||
Package manager class for install, upgrade,
|
||||
reinstall, remove, find and display packages.
|
||||
'''
|
||||
def __init__(self, binary):
|
||||
self.binary = binary
|
||||
|
||||
def pkg_remove(binary):
|
||||
'''
|
||||
Remove Slackware binary packages
|
||||
'''
|
||||
dep_path = log_path + "dep/"
|
||||
removed, dependencies, \
|
||||
rmv_list, rmv_dependencies = ([] for i in range(4))
|
||||
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
||||
CYAN, ", ".join(binary), ENDC))
|
||||
for pkg in binary:
|
||||
pkgs = find_package(pkg + sp, pkg_path)
|
||||
if pkgs:
|
||||
print(RED + "[ delete ] --> " + ENDC + "\n ".join(pkgs))
|
||||
removed.append(pkg)
|
||||
def install(self):
|
||||
'''
|
||||
Install Slackware binary packages
|
||||
'''
|
||||
for pkg in self.binary:
|
||||
try:
|
||||
print(subprocess.check_output("installpkg {0}".format(
|
||||
pkg), shell=True))
|
||||
print("Completed!\n")
|
||||
except subprocess.CalledProcessError:
|
||||
message = "Can't install"
|
||||
if len(self.binary) > 1:
|
||||
bol = eol = str()
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
pkg_not_found(bol, pkg, message, eol)
|
||||
|
||||
def upgrade(self):
|
||||
'''
|
||||
Upgrade Slackware binary packages
|
||||
'''
|
||||
for pkg in self.binary:
|
||||
try:
|
||||
print(subprocess.check_output("upgradepkg --install-new {0}".format(
|
||||
pkg), shell=True))
|
||||
print("Completed!\n")
|
||||
except subprocess.CalledProcessError:
|
||||
message = "Can't upgrade"
|
||||
if len(self.binary) > 1:
|
||||
bol = eol = str()
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
pkg_not_found(bol, pkg, message, eol)
|
||||
|
||||
def reinstall(self):
|
||||
'''
|
||||
Reinstall Slackware binary packages
|
||||
'''
|
||||
for pkg in self.binary:
|
||||
try:
|
||||
print(subprocess.check_output("upgradepkg --reinstall {0}".format(
|
||||
pkg), shell=True))
|
||||
print("Completed!\n")
|
||||
except subprocess.CalledProcessError:
|
||||
message = "Can't reinstall"
|
||||
if len(self.binary) > 1:
|
||||
bol = eol = str()
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
pkg_not_found(bol, pkg, message, eol)
|
||||
|
||||
def remove(self):
|
||||
'''
|
||||
Remove Slackware binary packages
|
||||
'''
|
||||
dep_path = log_path + "dep/"
|
||||
[
|
||||
removed,
|
||||
dependencies,
|
||||
rmv_list,
|
||||
rmv_dependencies
|
||||
] = ([] for i in range(4))
|
||||
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
||||
CYAN, ", ".join(self.binary), ENDC))
|
||||
for pkg in self.binary:
|
||||
pkgs = find_package(pkg + sp, pkg_path)
|
||||
if pkgs:
|
||||
print(RED + "[ delete ] --> " + ENDC + "\n ".join(pkgs))
|
||||
removed.append(pkg)
|
||||
else:
|
||||
message = "Can't remove"
|
||||
pkg_not_found("", pkg, message, "")
|
||||
if removed == []:
|
||||
print # new line at end
|
||||
else:
|
||||
message = "Can't remove"
|
||||
pkg_not_found("", pkg, message, "")
|
||||
if removed == []:
|
||||
print # new line at end
|
||||
else:
|
||||
msg = "package"
|
||||
if len(removed) > 1:
|
||||
msg = msg + "s"
|
||||
msg = "package"
|
||||
if len(removed) > 1:
|
||||
msg = msg + "s"
|
||||
try:
|
||||
remove_pkg = raw_input("\nAre you sure to remove {0} {1} [Y/n]? ".format(
|
||||
str(len(removed)), msg))
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
if remove_pkg == "y" or remove_pkg == "Y":
|
||||
for rmv in removed:
|
||||
# If package build and install with 'slpkg -s sbo <package>'
|
||||
# then look log file for dependencies in /var/log/slpkg/dep,
|
||||
# read and remove all else remove only the package.
|
||||
if os.path.isfile(dep_path + rmv):
|
||||
with open(dep_path + rmv, "r") as f:
|
||||
dependencies = f.read().split()
|
||||
f.close()
|
||||
print # new line at start
|
||||
template(78)
|
||||
print("| Found dependencies for package {0}:".format(rmv))
|
||||
template(78)
|
||||
# Prints dependecies before removed except master package
|
||||
# because referred as master package
|
||||
for dep in dependencies[:-1]:
|
||||
print("| {0}{1}{2}".format(RED, dep, ENDC))
|
||||
template(78)
|
||||
try:
|
||||
remove_dep = raw_input(
|
||||
"\nRemove dependencies (maybe used by other packages) [Y/n]? ")
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
if remove_dep == "y" or remove_dep == "Y":
|
||||
for dep in dependencies:
|
||||
if find_package(dep + sp, pkg_path):
|
||||
print(subprocess.check_output("removepkg {0}".format(
|
||||
dep), shell=True))
|
||||
rmv_list.append(dep)
|
||||
os.remove(dep_path + rmv)
|
||||
rmv_dependencies += dependencies[:-1]
|
||||
else:
|
||||
if find_package(rmv + sp, pkg_path):
|
||||
print(subprocess.check_output("removepkg {0}".format(
|
||||
rmv), shell=True))
|
||||
rmv_list.append(rmv)
|
||||
f.close()
|
||||
os.remove(dep_path + rmv)
|
||||
else:
|
||||
if find_package(rmv + sp, pkg_path):
|
||||
print(subprocess.check_output("removepkg {0}".format(
|
||||
rmv), shell=True))
|
||||
rmv_list.append(rmv)
|
||||
# Prints all removed packages
|
||||
if len(rmv_list) > 1:
|
||||
template(78)
|
||||
print("| Total {0} packages removed".format(len(rmv_list)))
|
||||
template(78)
|
||||
for pkg in rmv_list:
|
||||
if find_package(pkg + sp, pkg_path) == []:
|
||||
print("| Package {0} removed".format(pkg))
|
||||
else:
|
||||
print("| Package {0} not found".format(pkg))
|
||||
template(78)
|
||||
print # new line at end
|
||||
|
||||
def find(self):
|
||||
'''
|
||||
Find installed Slackware packages
|
||||
'''
|
||||
self.binary = "".join(self.binary)
|
||||
matching = size = int()
|
||||
print("\nInstalled packages with name begin matching [ {0}{1}{2} ]\n".format(
|
||||
CYAN, self.binary, ENDC))
|
||||
for match in find_package(self.binary, pkg_path):
|
||||
if self.binary in match:
|
||||
matching += 1
|
||||
print("[ {0}installed{1} ] - {2}".format(
|
||||
GREEN, ENDC, match))
|
||||
with open(pkg_path + match, "r") as f:
|
||||
data = f.read()
|
||||
f.close()
|
||||
for line in data.splitlines():
|
||||
if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
|
||||
if "M" in line[26:]:
|
||||
size += float(line[26:-1]) * 1024
|
||||
else:
|
||||
size += float(line[26:-1])
|
||||
break
|
||||
if matching == 0:
|
||||
message = "Can't find"
|
||||
pkg_not_found("", self.binary, message, "\n")
|
||||
else:
|
||||
print("\n{0}Total found {1} matching packages.{2}".format(
|
||||
GREY, matching, ENDC))
|
||||
unit = "Kb"
|
||||
if size > 1024:
|
||||
unit = "Mb"
|
||||
size = (size / 1024)
|
||||
print("{0}Size of installed packages {1} {2}.{3}\n".format(
|
||||
GREY, round(size, 2), unit, ENDC))
|
||||
|
||||
def display(self):
|
||||
'''
|
||||
Print the Slackware packages contents
|
||||
'''
|
||||
for pkg in self.binary:
|
||||
if find_package(pkg + sp, pkg_path):
|
||||
print(subprocess.check_output("cat {0}{1}".format(pkg_path,
|
||||
" /var/log/packages/".join(find_package(
|
||||
pkg + sp, pkg_path))), shell=True))
|
||||
else:
|
||||
message = "Can't dislpay"
|
||||
if len(self.binary) > 1:
|
||||
bol = eol = str()
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
pkg_not_found(bol, pkg, message, eol)
|
||||
|
||||
def list(self, pattern):
|
||||
'''
|
||||
List with the installed packages
|
||||
'''
|
||||
try:
|
||||
remove_pkg = raw_input("\nAre you sure to remove {0} {1} [Y/n]? ".format(
|
||||
str(len(removed)), msg))
|
||||
if "sbo" in pattern:
|
||||
search = "_SBo"
|
||||
elif "slack" in pattern:
|
||||
search = "_slack"
|
||||
elif "noarch" in pattern:
|
||||
search = "-noarch-"
|
||||
elif "all" in pattern:
|
||||
search = ""
|
||||
index, page = 0, 50
|
||||
for pkg in find_package("", pkg_path):
|
||||
if search in pkg:
|
||||
index += 1
|
||||
print("{0}{1}:{2} {3}".format(GREY, index, ENDC, pkg))
|
||||
if index == page:
|
||||
key = raw_input("\nPress [ {0}Enter{1} ] >> Next page ".format(
|
||||
CYAN, ENDC))
|
||||
page += 50
|
||||
print # new line at end
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
if remove_pkg == "y" or remove_pkg == "Y":
|
||||
for rmv in removed:
|
||||
# If package build and install with 'slpkg -s sbo <package>'
|
||||
# then look log file for dependencies in /var/log/slpkg/dep,
|
||||
# read and remove all else remove only the package.
|
||||
if os.path.isfile(dep_path + rmv):
|
||||
with open(dep_path + rmv, "r") as f:
|
||||
dependencies = f.read().split()
|
||||
f.close()
|
||||
print # new line at start
|
||||
template(78)
|
||||
print("| Found dependencies for package {0}:".format(rmv))
|
||||
template(78)
|
||||
# Prints dependecies before removed except master package
|
||||
# because referred as master package
|
||||
for dep in dependencies[:-1]:
|
||||
print("| {0}{1}{2}".format(RED, dep, ENDC))
|
||||
template(78)
|
||||
try:
|
||||
remove_dep = raw_input(
|
||||
"\nRemove dependencies (maybe used by other packages) [Y/n]? ")
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
if remove_dep == "y" or remove_dep == "Y":
|
||||
for dep in dependencies:
|
||||
if find_package(dep + sp, pkg_path):
|
||||
print(subprocess.check_output("removepkg {0}".format(dep), shell=True))
|
||||
rmv_list.append(dep)
|
||||
os.remove(dep_path + rmv)
|
||||
rmv_dependencies += dependencies[:-1]
|
||||
else:
|
||||
if find_package(rmv + sp, pkg_path):
|
||||
print(subprocess.check_output("removepkg {0}".format(rmv), shell=True))
|
||||
rmv_list.append(rmv)
|
||||
f.close()
|
||||
os.remove(dep_path + rmv)
|
||||
else:
|
||||
if find_package(rmv + sp, pkg_path):
|
||||
print(subprocess.check_output("removepkg {0}".format(rmv), shell=True))
|
||||
rmv_list.append(rmv)
|
||||
# Prints all removed packages
|
||||
if len(rmv_list) > 1:
|
||||
template(78)
|
||||
print("| Total {0} packages removed".format(len(rmv_list)))
|
||||
template(78)
|
||||
for pkg in rmv_list:
|
||||
if find_package(pkg + sp, pkg_path) == []:
|
||||
print("| Package {0} removed".format(pkg))
|
||||
else:
|
||||
print("| Package {0} not found".format(pkg))
|
||||
template(78)
|
||||
print # new line at end
|
||||
|
||||
def pkg_find(binary):
|
||||
'''
|
||||
Find installed Slackware packages
|
||||
'''
|
||||
binary = "".join(binary)
|
||||
matching = size = int()
|
||||
print("\nInstalled packages with name begin matching [ {0}{1}{2} ]\n".format(
|
||||
CYAN, binary, ENDC))
|
||||
for match in find_package(binary, pkg_path):
|
||||
if binary in match:
|
||||
matching += 1
|
||||
print("[ {0}installed{1} ] - {2}".format(
|
||||
GREEN, ENDC, match))
|
||||
with open(pkg_path + match, "r") as f:
|
||||
data = f.read()
|
||||
f.close()
|
||||
for line in data.splitlines():
|
||||
if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
|
||||
if "M" in line[26:]:
|
||||
size += float(line[26:-1]) * 1024
|
||||
else:
|
||||
size += float(line[26:-1])
|
||||
break
|
||||
if matching == 0:
|
||||
print("No package was found to match\n")
|
||||
else:
|
||||
print("\n{0}Total found {1} matching packages.{2}".format(GREY, matching, ENDC))
|
||||
unit = "Kb"
|
||||
if size > 1024:
|
||||
unit = "Mb"
|
||||
size = (size / 1024)
|
||||
print("{0}Size of installed packages {1} {2}.{3}\n".format(
|
||||
GREY, round(size, 2), unit, ENDC))
|
||||
|
||||
def pkg_display(binary):
|
||||
'''
|
||||
Print the Slackware packages contents
|
||||
'''
|
||||
for pkg in binary:
|
||||
if find_package(pkg + sp, pkg_path):
|
||||
print(subprocess.check_output("cat {0}{1}".format(pkg_path,
|
||||
" /var/log/packages/".join(find_package(pkg +sp, pkg_path))), shell=True))
|
||||
else:
|
||||
message = "Can't dislpay"
|
||||
if len(binary) > 1:
|
||||
bol = eol = str()
|
||||
else:
|
||||
bol = eol = "\n"
|
||||
pkg_not_found(bol, pkg, message, eol)
|
||||
|
||||
def pkg_list(pattern):
|
||||
'''
|
||||
List with the installed packages
|
||||
'''
|
||||
try:
|
||||
if "sbo" in pattern:
|
||||
search = "_SBo"
|
||||
elif "slack" in pattern:
|
||||
search = "_slack"
|
||||
elif "noarch" in pattern:
|
||||
search = "-noarch-"
|
||||
elif "all" in pattern:
|
||||
search = ""
|
||||
index, page = 0, 50
|
||||
for pkg in find_package("", pkg_path):
|
||||
if search in pkg:
|
||||
index += 1
|
||||
print("{0}{1}:{2} {3}".format(GREY, index, ENDC, pkg))
|
||||
if index == page:
|
||||
key = raw_input("\nPress [ {0}Enter{1} ] >> Next page ".format(
|
||||
CYAN, ENDC))
|
||||
page += 50
|
||||
print # new line at end
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
|
|
@ -26,18 +26,19 @@ import sys
|
|||
|
||||
from slpkg.pkg.find import find_package
|
||||
from slpkg.pkg.build import build_package
|
||||
from slpkg.pkg.manager import pkg_upgrade
|
||||
from slpkg.pkg.manager import PackageManager
|
||||
|
||||
from slpkg.colors import *
|
||||
from slpkg.init import initialization
|
||||
from slpkg.downloader import download
|
||||
from slpkg.downloader import Download
|
||||
from slpkg.messages import template, build_FAILED
|
||||
from slpkg.__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():
|
||||
'''
|
||||
|
@ -48,17 +49,27 @@ def sbo_check():
|
|||
but install the package with maximum build tag if find the
|
||||
some version in /tmp directory.
|
||||
'''
|
||||
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))
|
||||
|
||||
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:
|
||||
for pkg in os.listdir(pkg_path):
|
||||
if pkg.endswith("_SBo"):
|
||||
sbo_list.append(pkg)
|
||||
|
@ -83,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)
|
||||
|
@ -119,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
|
||||
|
@ -179,12 +190,12 @@ 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)
|
||||
Download(build_path, sbo_dwn).start()
|
||||
sources = []
|
||||
for src in src_dwn:
|
||||
download(build_path, src)
|
||||
Download(build_path, src).start()
|
||||
sources.append(src.split("/")[-1]) # keep file from source link
|
||||
build_package(script, sources, build_path)
|
||||
# Searches the package name and version in /tmp to install.
|
||||
|
@ -206,7 +217,7 @@ def sbo_check():
|
|||
# Use this list to pick out what
|
||||
# packages will be installed
|
||||
installed.append(name)
|
||||
pkg_upgrade(binary)
|
||||
PackageManager(binary).upgrade()
|
||||
if len(pkg_for_upg) > 1:
|
||||
template(78)
|
||||
print("| Total {0} {1} upgraded and {2} {3} installed".format(
|
||||
|
|
|
@ -24,15 +24,11 @@
|
|||
import sys
|
||||
|
||||
from slpkg.colors import *
|
||||
from slpkg.init import initialization
|
||||
from slpkg.blacklist import BlackList
|
||||
from slpkg.__metadata__ import pkg_path, sp
|
||||
from slpkg.messages import pkg_not_found, template
|
||||
|
||||
from slpkg.pkg.find import find_package
|
||||
|
||||
from greps import SBoGrep
|
||||
from search import sbo_search_pkg
|
||||
from greps import sbo_requires_pkg
|
||||
|
||||
|
||||
dep_results = []
|
||||
|
||||
|
@ -45,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
|
||||
|
@ -62,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")
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
def sbo_slackbuild_dwn(sbo_url):
|
||||
'''
|
||||
Create download slackbuild tar.gz archive
|
||||
|
|
|
@ -28,102 +28,105 @@ from slpkg.__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()
|
||||
|
||||
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()
|
||||
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 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()
|
||||
|
|
|
@ -25,6 +25,7 @@ import os
|
|||
|
||||
from slpkg.url_read import url_read
|
||||
|
||||
|
||||
def read_readme(sbo_url, sbo_readme):
|
||||
'''
|
||||
Read SlackBuild README file
|
||||
|
|
|
@ -30,6 +30,7 @@ from slpkg.blacklist import BlackList
|
|||
|
||||
from slpkg.slack.slack_version import slack_ver
|
||||
|
||||
|
||||
def sbo_search_pkg(name):
|
||||
'''
|
||||
Search for package path from SLACKBUILDS.TXT file
|
||||
|
|
|
@ -26,20 +26,21 @@ import sys
|
|||
|
||||
from slpkg.colors import *
|
||||
from slpkg.init import initialization
|
||||
from slpkg.downloader import download
|
||||
from slpkg.downloader import Download
|
||||
from slpkg.__metadata__ import (tmp, pkg_path, build_path,
|
||||
log_path, lib_path, sp)
|
||||
from slpkg.messages import (pkg_not_found, pkg_found, template,
|
||||
build_FAILED, sbo_packages_view)
|
||||
log_path, lib_path, sp)
|
||||
from slpkg.messages import (pkg_found, template, build_FAILED,
|
||||
pkg_not_found, sbo_packages_view)
|
||||
|
||||
from slpkg.pkg.find import find_package
|
||||
from slpkg.pkg.build import build_package
|
||||
from slpkg.pkg.manager import pkg_upgrade
|
||||
from slpkg.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):
|
||||
'''
|
||||
|
@ -47,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:
|
||||
|
@ -73,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):
|
||||
|
@ -138,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):
|
||||
|
@ -160,13 +168,13 @@ 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)
|
||||
Download(build_path, sbo_link).start()
|
||||
sources = []
|
||||
for src in src_link:
|
||||
sources.append(src.split("/")[-1]) # get file from source
|
||||
download(build_path, src)
|
||||
Download(build_path, src).start()
|
||||
build_package(script, sources, build_path)
|
||||
# Searches the package name and version in /tmp to install.
|
||||
# If find two or more packages e.g. to build tag
|
||||
|
@ -187,7 +195,7 @@ def sbo_build(name):
|
|||
else:
|
||||
print("{0}[ Installing ] --> {1}{2}".format(
|
||||
GREEN, ENDC, pkg))
|
||||
pkg_upgrade(binary)
|
||||
PackageManager(binary).upgrade()
|
||||
installs.append(pkg)
|
||||
versions.append(ver)
|
||||
# Reference list with packages installed
|
||||
|
@ -235,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)
|
||||
|
@ -270,7 +278,8 @@ def sbo_build(name):
|
|||
print("{0} installed {1} and {2} uninstalled {3}.{4}\n".format(
|
||||
ins, ins_msg, uns, uns_msg, ENDC))
|
||||
else:
|
||||
print("\nNo package was found to match\n")
|
||||
message = "No matching"
|
||||
pkg_not_found("\n", name, message, "\n")
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
|
81
slpkg/sbo/tracking.py
Executable file
81
slpkg/sbo/tracking.py
Executable 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 slpkg.colors import *
|
||||
from slpkg.messages import template
|
||||
from slpkg.init import initialization
|
||||
from slpkg.__metadata__ import pkg_path, sp
|
||||
|
||||
from dependency import sbo_dependencies_pkg
|
||||
|
||||
from slpkg.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")
|
|
@ -27,20 +27,21 @@ import pydoc
|
|||
|
||||
from slpkg.colors import *
|
||||
from slpkg.init import initialization
|
||||
from slpkg.downloader import download
|
||||
from slpkg.downloader import Download
|
||||
from slpkg.__metadata__ import tmp, build_path, pkg_path, sp
|
||||
from slpkg.messages import (pkg_not_found, pkg_found, view_sbo,
|
||||
from slpkg.messages import (pkg_found, view_sbo, pkg_not_found,
|
||||
template, build_FAILED)
|
||||
|
||||
from slpkg.pkg.build import build_package
|
||||
from slpkg.pkg.find import find_package
|
||||
from slpkg.pkg.manager import pkg_upgrade
|
||||
from slpkg.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
|
||||
|
||||
|
||||
def sbo_network(name):
|
||||
'''
|
||||
View SlackBuild package, read or install them
|
||||
|
@ -53,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]), \
|
||||
|
@ -75,9 +76,9 @@ def sbo_network(name):
|
|||
break
|
||||
if read == "D" or read == "d":
|
||||
path = ""
|
||||
download(path, sbo_dwn)
|
||||
Download(path, sbo_dwn).start()
|
||||
for src in source_dwn:
|
||||
download(path, src)
|
||||
Download(path, src).start()
|
||||
break
|
||||
elif read == "R" or read == "r":
|
||||
readme = "README"
|
||||
|
@ -97,9 +98,9 @@ def sbo_network(name):
|
|||
sources = []
|
||||
os.chdir(build_path)
|
||||
script = sbo_dwn.split("/")[-1] # get file from script link
|
||||
download(build_path, sbo_dwn)
|
||||
Download(build_path, sbo_dwn).start()
|
||||
for src in source_dwn:
|
||||
download(build_path, src)
|
||||
Download(build_path, src).start()
|
||||
sources.append(src.split("/")[-1]) # get file from source link
|
||||
build_package(script, sources, build_path)
|
||||
break
|
||||
|
@ -109,15 +110,15 @@ 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 = []
|
||||
os.chdir(build_path)
|
||||
download(build_path, sbo_dwn)
|
||||
Download(build_path, sbo_dwn).start()
|
||||
script = sbo_dwn.split("/")[-1] # get file from script link
|
||||
for src in source_dwn:
|
||||
download(build_path, src)
|
||||
Download(build_path, src).start()
|
||||
sources.append(src.split("/")[-1]) # get file from source link
|
||||
build_package(script, sources, build_path)
|
||||
# Searches the package name and version in /tmp to install.
|
||||
|
@ -133,7 +134,7 @@ def sbo_network(name):
|
|||
build_FAILED(sbo_url, prgnam)
|
||||
sys.exit()
|
||||
print("{0}[ Installing ] --> {1} {2}".format(GREEN, ENDC, name))
|
||||
pkg_upgrade(binary)
|
||||
PackageManager(binary).upgrade()
|
||||
break
|
||||
else:
|
||||
template(78)
|
||||
|
@ -143,6 +144,6 @@ def sbo_network(name):
|
|||
else:
|
||||
break
|
||||
else:
|
||||
sys.stdout.write (done)
|
||||
message = "From slackbuilds.org"
|
||||
sys.stdout.write(done)
|
||||
message = "Can't view"
|
||||
pkg_not_found("\n", name, message, "\n")
|
||||
|
|
|
@ -27,29 +27,37 @@ import time
|
|||
|
||||
from slpkg.colors import *
|
||||
from slpkg.url_read import url_read
|
||||
from slpkg.downloader import download
|
||||
from slpkg.downloader import Download
|
||||
from slpkg.blacklist import BlackList
|
||||
from slpkg.messages import pkg_not_found, template
|
||||
from slpkg.__metadata__ import slpkg_tmp, pkg_path, slack_archs
|
||||
|
||||
from slpkg.pkg.find import find_package
|
||||
from slpkg.pkg.manager import pkg_upgrade, pkg_reinstall
|
||||
from slpkg.pkg.manager import PackageManager
|
||||
|
||||
from mirrors import mirrors
|
||||
from splitting import split_package
|
||||
|
||||
|
||||
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):
|
||||
|
@ -150,21 +158,22 @@ def install(slack_pkg, version):
|
|||
read = raw_input("\nWould you like to install [Y/n]? ")
|
||||
if read == "Y" or read == "y":
|
||||
for dwn in dwn_list:
|
||||
download(tmp_path, dwn)
|
||||
download(tmp_path, dwn + ".asc")
|
||||
Download(tmp_path, dwn).start()
|
||||
Download(tmp_path, dwn + ".asc").start()
|
||||
for install, name in zip(install_all, names):
|
||||
package = ((tmp_path + install).split())
|
||||
if os.path.isfile(pkg_path + install[:-4]):
|
||||
print("{0}[ reinstalling ] --> {1}{2}".format(
|
||||
GREEN, ENDC, install))
|
||||
pkg_reinstall((tmp_path + install).split())
|
||||
PackageManager(package).reinstall()
|
||||
elif find_package(name + "-", pkg_path):
|
||||
print("{0}[ upgrading ] --> {1}{2}".format(
|
||||
GREEN, ENDC, install))
|
||||
pkg_upgrade((tmp_path + install).split())
|
||||
PackageManager(package).upgrade()
|
||||
else:
|
||||
print("{0}[ installing ] --> {1}{2}".format(
|
||||
GREEN, ENDC, install))
|
||||
pkg_upgrade((tmp_path + install).split())
|
||||
PackageManager(package).upgrade()
|
||||
read = raw_input("Removal downloaded packages [Y/n]? ")
|
||||
if read == "Y" or read == "y":
|
||||
for remove in install_all:
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
from slpkg.__metadata__ import arch
|
||||
from slack_version import slack_ver
|
||||
|
||||
|
||||
def mirrors(name, location, version):
|
||||
'''
|
||||
Select Slackware official mirror packages
|
||||
|
|
|
@ -29,26 +29,35 @@ import subprocess
|
|||
from slpkg.colors import *
|
||||
from slpkg.url_read import url_read
|
||||
from slpkg.messages import template
|
||||
from slpkg.downloader import download
|
||||
from slpkg.downloader import Download
|
||||
from slpkg.blacklist import BlackList
|
||||
from slpkg.__metadata__ import pkg_path, slpkg_tmp
|
||||
|
||||
from slpkg.pkg.manager import pkg_upgrade
|
||||
from slpkg.pkg.manager import PackageManager
|
||||
|
||||
from mirrors import mirrors
|
||||
from splitting import split_package
|
||||
from slack_version import slack_ver
|
||||
|
||||
|
||||
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)
|
||||
|
@ -156,11 +165,11 @@ def patches(version):
|
|||
read = raw_input("\nWould you like to upgrade [Y/n]? ")
|
||||
if read == "Y" or read == "y":
|
||||
for dwn in dwn_patches:
|
||||
download(patch_path, dwn)
|
||||
download(patch_path, dwn + ".asc")
|
||||
Download(patch_path, dwn).start()
|
||||
Download(patch_path, dwn + ".asc").start()
|
||||
for pkg in upgrade_all:
|
||||
print("{0}[ upgrading ] --> {1}{2}".format(GREEN, ENDC, pkg[:-4]))
|
||||
pkg_upgrade((patch_path + pkg).split())
|
||||
PackageManager((patch_path + pkg).split()).upgrade()
|
||||
for kernel in upgrade_all:
|
||||
if "kernel" in kernel:
|
||||
print("The kernel has been upgraded, reinstall `lilo` ...")
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
import re
|
||||
|
||||
|
||||
def slack_ver():
|
||||
'''
|
||||
Open file and read Slackware version
|
||||
|
|
|
@ -25,6 +25,7 @@ from slpkg.__metadata__ import slack_archs
|
|||
|
||||
from slack_version import slack_ver
|
||||
|
||||
|
||||
def split_package(package):
|
||||
'''
|
||||
Split package in name, version
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
import sys
|
||||
import urllib2
|
||||
|
||||
|
||||
def url_read(link):
|
||||
'''
|
||||
Open url and read
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
from __metadata__ import __version__, __license__, __email__
|
||||
|
||||
|
||||
def prog_version():
|
||||
'''
|
||||
Print version, license and email
|
||||
|
|
Loading…
Add table
Reference in a new issue