mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-26 09:58:31 +01:00
align to PEP8 style
This commit is contained in:
parent
b215018bc3
commit
21340c8cf2
28 changed files with 468 additions and 387 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -5,3 +5,4 @@ __pycache__
|
|||
.pipy
|
||||
*.egg-info/
|
||||
/slpkg_Build
|
||||
.ropeproject/
|
||||
|
|
|
@ -38,4 +38,3 @@ from slpkg import main
|
|||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
|
2
setup.py
2
setup.py
|
@ -40,7 +40,7 @@ setup(
|
|||
version=__version__,
|
||||
description="Python tool to manage Slackware packages",
|
||||
keywords=["slackware", "slpkg", "upgrade", "install", "remove",
|
||||
"view", "slackpkg", "tool", "build"],
|
||||
"view", "slackpkg", "tool", "build"],
|
||||
author=__author__,
|
||||
author_email=__email__,
|
||||
url="https://github.com/dslackw/slpkg",
|
||||
|
|
|
@ -23,11 +23,12 @@
|
|||
|
||||
import os
|
||||
|
||||
from colors import *
|
||||
from colors import RED, GREEN, ENDC
|
||||
from __metadata__ import bls_path
|
||||
|
||||
|
||||
class BlackList(object):
|
||||
|
||||
'''
|
||||
Blacklist class to add, remove or listed packages
|
||||
in blacklist file.
|
||||
|
@ -38,37 +39,37 @@ class BlackList(object):
|
|||
create it by default.
|
||||
'''
|
||||
blacklist_conf = [
|
||||
"# This is the blacklist file. Each package listed here may not be\n",
|
||||
"# installed be upgraded be find or deleted.\n",
|
||||
"# NOTE: The settings here affect all repositories.\n",
|
||||
"#\n",
|
||||
"# An example syntax is as follows:\n",
|
||||
"# add a package from SBo repository:\n",
|
||||
"# brasero\n",
|
||||
"#\n",
|
||||
"# Add package from slackware repository:\n",
|
||||
"# example add package 'wicd-1.7.2.4-x86_64-4.txz':\n",
|
||||
"# wicd\n",
|
||||
"#\n",
|
||||
"# Sometimes the automatic kernel update creates problems because you\n",
|
||||
"# may need to file intervention 'lilo'. The slpkg automatically detects\n",
|
||||
"# if the core has been upgraded and running 'lilo'. If you want to avoid\n",
|
||||
"# any problems uncomment the lines below.\n",
|
||||
"#\n",
|
||||
"# kernel-firmware\n",
|
||||
"# kernel-generic\n",
|
||||
"# kernel-generic-smp\n",
|
||||
"# kernel-headers\n",
|
||||
"# kernel-huge\n",
|
||||
"# kernel-huge-smp\n",
|
||||
"# kernel-modules\n",
|
||||
"# kernel-modules-smp\n",
|
||||
"# kernel-source\n"
|
||||
"#\n",
|
||||
"#\n",
|
||||
"# aaa_elflibs can't be updated.\n",
|
||||
"aaa_elflibs\n"
|
||||
]
|
||||
"# This is the blacklist file. Each package listed here may not be\n",
|
||||
"# installed be upgraded be find or deleted.\n",
|
||||
"# NOTE: The settings here affect all repositories.\n",
|
||||
"#\n",
|
||||
"# An example syntax is as follows:\n",
|
||||
"# add a package from SBo repository:\n",
|
||||
"# brasero\n",
|
||||
"#\n",
|
||||
"# Add package from slackware repository:\n",
|
||||
"# example add package 'wicd-1.7.2.4-x86_64-4.txz':\n",
|
||||
"# wicd\n",
|
||||
"#\n",
|
||||
"# Sometimes the automatic kernel update creates problems because you\n",
|
||||
"# may need to file intervention 'lilo'. The slpkg automatically detects\n",
|
||||
"# if the core has been upgraded and running 'lilo'. If you want to avoid\n",
|
||||
"# any problems uncomment the lines below.\n",
|
||||
"#\n",
|
||||
"# kernel-firmware\n",
|
||||
"# kernel-generic\n",
|
||||
"# kernel-generic-smp\n",
|
||||
"# kernel-headers\n",
|
||||
"# kernel-huge\n",
|
||||
"# kernel-huge-smp\n",
|
||||
"# kernel-modules\n",
|
||||
"# kernel-modules-smp\n",
|
||||
"# kernel-source\n"
|
||||
"#\n",
|
||||
"#\n",
|
||||
"# aaa_elflibs can't be updated.\n",
|
||||
"aaa_elflibs\n"
|
||||
]
|
||||
self.blackfile = bls_path + "blacklist"
|
||||
if not os.path.exists(bls_path):
|
||||
os.mkdir(bls_path)
|
||||
|
@ -103,7 +104,7 @@ class BlackList(object):
|
|||
print("{0}{1}{2}".format(GREEN, black, ENDC))
|
||||
exit = 1
|
||||
if exit == 1:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
|
||||
def add(self, pkgs):
|
||||
'''
|
||||
|
@ -121,7 +122,7 @@ class BlackList(object):
|
|||
exit = 1
|
||||
black_conf.close()
|
||||
if exit == 1:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
|
||||
def remove(self, pkgs):
|
||||
'''
|
||||
|
@ -129,7 +130,6 @@ class BlackList(object):
|
|||
'''
|
||||
exit = 0
|
||||
print("\nRemove packages from blacklist:\n")
|
||||
|
||||
with open(self.blackfile, "r") as black_conf:
|
||||
lines = black_conf.read()
|
||||
black_conf.close()
|
||||
|
@ -142,4 +142,4 @@ class BlackList(object):
|
|||
exit = 1
|
||||
black_conf.close()
|
||||
if exit == 1:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
import hashlib
|
||||
|
||||
|
||||
def md5sum(source):
|
||||
'''
|
||||
Calculate the md5 checksum
|
||||
|
|
|
@ -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/>.
|
||||
|
||||
|
||||
'''
|
||||
Foreground colors
|
||||
'''
|
||||
|
|
|
@ -21,11 +21,10 @@
|
|||
# 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 os
|
||||
import sys
|
||||
import subprocess
|
||||
|
||||
from colors import *
|
||||
from colors import GREEN, ENDC
|
||||
|
||||
|
||||
class Download(object):
|
||||
|
@ -41,10 +40,11 @@ class Download(object):
|
|||
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))
|
||||
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
|
||||
print # new line at cancel
|
||||
sys.exit()
|
||||
|
|
|
@ -43,7 +43,7 @@ class FileSize(object):
|
|||
print("\nError: connection refused\n")
|
||||
sys.exit()
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
print # new line at cancle
|
||||
sys.exit()
|
||||
|
||||
def local(self):
|
||||
|
|
|
@ -23,10 +23,8 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
import getpass
|
||||
|
||||
from file_size import *
|
||||
from messages import s_user
|
||||
from file_size import FileSize
|
||||
from url_read import url_read
|
||||
from __metadata__ import log_path, lib_path
|
||||
|
||||
|
@ -53,14 +51,15 @@ def initialization():
|
|||
if not os.path.exists(pkg_que):
|
||||
os.mkdir(pkg_que)
|
||||
sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(slack_ver()))
|
||||
# Read SLACKBUILDS.TXT from slackbuilds.org and write in /var/lib/slpkg/sbo_repo/
|
||||
# directory if not exist
|
||||
# Read SLACKBUILDS.TXT from slackbuilds.org and write in
|
||||
# /var/lib/slpkg/sbo_repo directory if not exist
|
||||
if not os.path.isfile(sbo_lib + "SLACKBUILDS.TXT"):
|
||||
print("\nslpkg ...initialization")
|
||||
sys.stdout.write("SLACKBUILDS.TXT read ...")
|
||||
sys.stdout.flush()
|
||||
SLACKBUILDS_TXT = url_read((
|
||||
"http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format(slack_ver())))
|
||||
"http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format(
|
||||
slack_ver())))
|
||||
sys.stdout.write("Done\n")
|
||||
with open("{0}SLACKBUILDS.TXT".format(sbo_lib), "w") as sbo:
|
||||
sbo.write(SLACKBUILDS_TXT)
|
||||
|
@ -73,7 +72,8 @@ def initialization():
|
|||
sys.stdout.write("ChangeLog.txt read ...")
|
||||
sys.stdout.flush()
|
||||
ChangeLog_txt = url_read((
|
||||
"http://slackbuilds.org/slackbuilds/{0}/ChangeLog.txt".format(slack_ver())))
|
||||
"http://slackbuilds.org/slackbuilds/{0}/ChangeLog.txt".format(
|
||||
slack_ver())))
|
||||
sys.stdout.write("Done\n")
|
||||
with open("{0}ChangeLog.txt".format(sbo_log), "w") as log:
|
||||
log.write(ChangeLog_txt)
|
||||
|
@ -91,9 +91,11 @@ def initialization():
|
|||
sys.stdout.write("Files re-created ...")
|
||||
sys.stdout.flush()
|
||||
SLACKBUILDS_TXT = url_read((
|
||||
"http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format(slack_ver())))
|
||||
"http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format(
|
||||
slack_ver())))
|
||||
ChangeLog_txt = url_read((
|
||||
"http://slackbuilds.org/slackbuilds/{0}/ChangeLog.txt".format(slack_ver())))
|
||||
"http://slackbuilds.org/slackbuilds/{0}/ChangeLog.txt".format(
|
||||
slack_ver())))
|
||||
with open("{0}SLACKBUILDS.TXT".format(sbo_lib), "w") as sbo:
|
||||
sbo.write(SLACKBUILDS_TXT)
|
||||
sbo.close()
|
||||
|
|
107
slpkg/main.py
107
slpkg/main.py
|
@ -24,7 +24,6 @@
|
|||
import sys
|
||||
import getpass
|
||||
|
||||
from colors import *
|
||||
from queue import QueuePkgs
|
||||
from messages import s_user
|
||||
from blacklist import BlackList
|
||||
|
@ -44,56 +43,61 @@ from slack.install import install
|
|||
|
||||
|
||||
def main():
|
||||
|
||||
# root privileges required
|
||||
s_user(getpass.getuser())
|
||||
arguments = [
|
||||
"slpkg - version {0}\n".format(__version__),
|
||||
"Utility for easy management packages in Slackware\n",
|
||||
"Optional arguments:",
|
||||
" -h, --help show this help message and exit",
|
||||
" -v, --version print version and exit",
|
||||
" -a, script [source...] auto build packages",
|
||||
" -b, --list, [package...] --add, --remove add, remove packages in blacklist",
|
||||
" -q, --list, [package...] --add, --remove add, remove packages in queue",
|
||||
" --build, --install, --build-install build or install from queue",
|
||||
" -l, all, sbo, slack, noarch list of installed packages",
|
||||
" -c, <repository> --upgrade --current check for updated packages",
|
||||
" -s, <repository> <package> --current download, build & install",
|
||||
" -f, <package> find installed packages",
|
||||
" -t, <package> tracking dependencies from SBo",
|
||||
" -n, <package> view packages from SBo",
|
||||
" -i, [package...] install binary packages",
|
||||
" -u, [package...] upgrade binary packages",
|
||||
" -o, [package...] reinstall binary packages",
|
||||
" -r, [package...] remove binary packages",
|
||||
" -d, [package...] display the contents\n",
|
||||
"Repositories:",
|
||||
" SlackBuilds = sbo",
|
||||
" Slackware = slack '--current'\n",
|
||||
]
|
||||
"slpkg - version {0}\n".format(__version__),
|
||||
"Utility for easy management packages in Slackware\n",
|
||||
"Optional arguments:",
|
||||
" -h, --help show this help message and exit",
|
||||
" -v, --version print version and exit",
|
||||
" -a, script [source...] auto build packages",
|
||||
" -b, --list, [package...] --add, --remove add, remove packages in blacklist",
|
||||
" -q, --list, [package...] --add, --remove add, remove packages in queue",
|
||||
" --build, --install, --build-install build or install from queue",
|
||||
" -l, all, sbo, slack, noarch list of installed packages",
|
||||
" -c, <repository> --upgrade --current check for updated packages",
|
||||
" -s, <repository> <package> --current download, build & install",
|
||||
" -f, <package> find installed packages",
|
||||
" -t, <package> tracking dependencies from SBo",
|
||||
" -n, <package> view packages from SBo",
|
||||
" -i, [package...] install binary packages",
|
||||
" -u, [package...] upgrade binary packages",
|
||||
" -o, [package...] reinstall binary packages",
|
||||
" -r, [package...] remove binary packages",
|
||||
" -d, [package...] display the contents\n",
|
||||
"Repositories:",
|
||||
" SlackBuilds = sbo",
|
||||
" Slackware = slack '--current'\n",
|
||||
]
|
||||
usage = [
|
||||
"slpkg - version {0}\n".format(__version__),
|
||||
"Usage: slpkg [-h] [-v] [-a script [sources...]]",
|
||||
" [-b --list, [...] --add, --remove]",
|
||||
" [-q --list, [...] --add, --remove]",
|
||||
" [-q --build, --install, --build-install]",
|
||||
" [-l all, sbo, slack, noarch]",
|
||||
" [-c <repository> --upgrade --current]",
|
||||
" [-s <repository> <package> --current]",
|
||||
" [-f] [-t] [-n] [-i [...]] [-u [...]]",
|
||||
" [-o [...]] [-r [...]] [-d [...]]\n",
|
||||
"For more information try 'slpkg --help'\n"
|
||||
]
|
||||
"slpkg - version {0}\n".format(__version__),
|
||||
"Usage: slpkg [-h] [-v] [-a script [sources...]]",
|
||||
" [-b --list, [...] --add, --remove]",
|
||||
" [-q --list, [...] --add, --remove]",
|
||||
" [-q --build, --install, --build-install]",
|
||||
" [-l all, sbo, slack, noarch]",
|
||||
" [-c <repository> --upgrade --current]",
|
||||
" [-s <repository> <package> --current]",
|
||||
" [-f] [-t] [-n] [-i [...]] [-u [...]]",
|
||||
" [-o [...]] [-r [...]] [-d [...]]\n",
|
||||
"For more information try 'slpkg --help'\n"
|
||||
]
|
||||
args = sys.argv
|
||||
args.pop(0)
|
||||
repository = ["sbo", "slack"]
|
||||
blacklist = BlackList()
|
||||
queue = QueuePkgs()
|
||||
if len(args) == 0:
|
||||
for opt in usage: print(opt)
|
||||
elif len(args) == 1 and args[0] == "-h" or args[0] == "--help" and args[1:] == []:
|
||||
for opt in arguments: print(opt)
|
||||
elif len(args) == 1 and args[0] == "-v" or args[0] == "--version" and args[1:] == []:
|
||||
for opt in usage:
|
||||
print(opt)
|
||||
elif (len(args) == 1 and args[0] == "-h" or
|
||||
args[0] == "--help" and args[1:] == []):
|
||||
for opt in arguments:
|
||||
print(opt)
|
||||
elif (len(args) == 1 and args[0] == "-v" or
|
||||
args[0] == "--version" and args[1:] == []):
|
||||
prog_version()
|
||||
elif len(args) == 3 and args[0] == "-a":
|
||||
build_package(args[1], args[2:], path)
|
||||
|
@ -102,7 +106,8 @@ def main():
|
|||
if args[1] in sbo_list:
|
||||
PackageManager(None).list(args[1])
|
||||
else:
|
||||
for opt in usage: print(opt)
|
||||
for opt in usage:
|
||||
print(opt)
|
||||
elif len(args) == 3 and args[0] == "-c":
|
||||
if args[1] == repository[0] and args[2] == "--upgrade":
|
||||
sbo_check()
|
||||
|
@ -110,13 +115,15 @@ def main():
|
|||
version = "stable"
|
||||
patches(version)
|
||||
else:
|
||||
for opt in usage: print(opt)
|
||||
for opt in usage:
|
||||
print(opt)
|
||||
elif len(args) == 4 and args[0] == "-c":
|
||||
if args[1] == repository[1] and args[3] == "--current":
|
||||
version = "current"
|
||||
patches(version)
|
||||
else:
|
||||
for opt in usage: print(opt)
|
||||
for opt in usage:
|
||||
print(opt)
|
||||
elif len(args) == 3 and args[0] == "-s":
|
||||
if args[1] == repository[0]:
|
||||
sbo_build(args[2])
|
||||
|
@ -128,7 +135,8 @@ def main():
|
|||
version = "current"
|
||||
install(args[2], version)
|
||||
else:
|
||||
for opt in usage: print(opt)
|
||||
for opt in usage:
|
||||
print(opt)
|
||||
elif len(args) == 2 and args[0] == "-t":
|
||||
track_dep(args[1])
|
||||
elif len(args) == 2 and args[0] == "-n":
|
||||
|
@ -145,11 +153,11 @@ def main():
|
|||
queue.add(args[1:-1])
|
||||
elif len(args) > 2 and args[0] == "-q" and args[-1] == "--remove":
|
||||
queue.remove(args[1:-1])
|
||||
elif len(args) == 2 and args[0] =="-q" and args[1] == "--build":
|
||||
elif len(args) == 2 and args[0] == "-q" and args[1] == "--build":
|
||||
queue.build()
|
||||
elif len(args) == 2 and args[0] =="-q" and args[1] == "--install":
|
||||
elif len(args) == 2 and args[0] == "-q" and args[1] == "--install":
|
||||
queue.install()
|
||||
elif len(args) == 2 and args[0] =="-q" and args[1] == "--build-install":
|
||||
elif len(args) == 2 and args[0] == "-q" and args[1] == "--build-install":
|
||||
queue.build()
|
||||
queue.install()
|
||||
elif len(args) > 1 and args[0] == "-i":
|
||||
|
@ -165,7 +173,8 @@ def main():
|
|||
elif len(args) > 1 and args[0] == "-d":
|
||||
PackageManager(args[1:]).display()
|
||||
else:
|
||||
for opt in usage: print(opt)
|
||||
for opt in usage:
|
||||
print(opt)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -22,8 +22,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import sys
|
||||
from colors import *
|
||||
from __metadata__ import __all__
|
||||
from colors import RED, GREEN, CYAN, YELLOW, ENDC
|
||||
|
||||
|
||||
def pkg_not_found(bol, pkg, message, eol):
|
||||
|
@ -32,18 +31,21 @@ def pkg_not_found(bol, pkg, message, eol):
|
|||
'''
|
||||
print("{0}No such package {1}: {2}{3}".format(bol, pkg, message, eol))
|
||||
|
||||
|
||||
def pkg_found(pkg, version):
|
||||
'''
|
||||
Print message when package found
|
||||
'''
|
||||
print("| Package {0}-{1} is already installed".format(pkg, version))
|
||||
|
||||
|
||||
def pkg_installed(pkg):
|
||||
'''
|
||||
Print message when package installed
|
||||
'''
|
||||
print("| Package {0} installed".format(pkg))
|
||||
|
||||
|
||||
def s_user(user):
|
||||
'''
|
||||
Check for root user
|
||||
|
@ -52,15 +54,17 @@ def s_user(user):
|
|||
print("\nslpkg: error: must have root privileges\n")
|
||||
sys.exit()
|
||||
|
||||
|
||||
def build_FAILED(sbo_url, prgnam):
|
||||
template(78)
|
||||
print("| Build package {0} [ {1}FAILED{2} ]".format(prgnam, RED, ENDC))
|
||||
template(78)
|
||||
print("| See log file in {0}/var/log/slpkg/sbo/build_logs{1} directory or read README file:".format(
|
||||
CYAN, ENDC))
|
||||
print("| See log file in {0}/var/log/slpkg/sbo/build_logs{1} directory or \
|
||||
read README file:".format(CYAN, ENDC))
|
||||
print("| {0}{1}".format(sbo_url, "README"))
|
||||
template(78)
|
||||
print # new line at end
|
||||
print # new line at end
|
||||
|
||||
|
||||
def template(max):
|
||||
'''
|
||||
|
@ -68,32 +72,35 @@ def template(max):
|
|||
'''
|
||||
print("+" + "=" * max)
|
||||
|
||||
|
||||
def view_sbo(pkg, sbo_url, sbo_desc, sbo_dwn, source_dwn, sbo_req):
|
||||
print # new line at start
|
||||
print # new line at start
|
||||
template(78)
|
||||
print("| {0}Package {1}{2}{3} --> {4}".format(GREEN,
|
||||
CYAN, pkg, GREEN, ENDC + sbo_url))
|
||||
print("| {0}Package {1}{2}{3} --> {4}".format(GREEN, CYAN, pkg, GREEN,
|
||||
ENDC + sbo_url))
|
||||
template(78)
|
||||
print("| {0}Description : {1}{2}".format(GREEN, ENDC, sbo_desc))
|
||||
print("| {0}SlackBuild : {1}{2}".format(GREEN, ENDC, sbo_dwn))
|
||||
print("| {0}Sources : {1}{2}".format(GREEN, ENDC, source_dwn))
|
||||
print("| {0}Requirements : {1}{2}".format(YELLOW, ENDC,
|
||||
", ".join(sbo_req)))
|
||||
print("| {0}Requirements : {1}{2}".format(YELLOW, ENDC, ", ".join(sbo_req)))
|
||||
template(78)
|
||||
print(" {0}R{1}EADME View the README file".format(RED, ENDC))
|
||||
print(" {0}S{1}lackBuild View the SlackBuild file".format(RED, ENDC))
|
||||
print(" {0}S{1}lackBuild View the SlackBuild file".format(
|
||||
RED, ENDC))
|
||||
print(" In{0}f{1}o View the Info file".format(RED, ENDC))
|
||||
print(" {0}D{1}ownload Download this package".format(RED, ENDC))
|
||||
print(" {0}B{1}uild Download and build".format(RED, ENDC))
|
||||
print(" {0}I{1}nstall Download/Build/Install".format(RED, ENDC))
|
||||
print(" {0}I{1}nstall Download/Build/Install".format(
|
||||
RED, ENDC))
|
||||
print(" {0}Q{1}uit Quit\n".format(RED, ENDC))
|
||||
|
||||
|
||||
def sbo_packages_view(PKG_COLOR, package, version, ARCH_COLOR, arch):
|
||||
'''
|
||||
View slackbuild packages with version and arch
|
||||
'''
|
||||
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(PKG_COLOR, package, ENDC, \
|
||||
" " * (38-len(package)), version, \
|
||||
" " * (17-len(version)), ARCH_COLOR, arch, ENDC, \
|
||||
" " * (13-len(arch)), "SBo"))
|
||||
|
||||
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
|
||||
PKG_COLOR, package, ENDC,
|
||||
" " * (38-len(package)), version,
|
||||
" " * (17-len(version)), ARCH_COLOR, arch, ENDC,
|
||||
" " * (13-len(arch)), "SBo"))
|
||||
|
|
|
@ -29,9 +29,9 @@ import shutil
|
|||
import tarfile
|
||||
import subprocess
|
||||
|
||||
from colors import *
|
||||
from checksum import md5sum
|
||||
from __metadata__ import log_path
|
||||
from colors import RED, GREEN, ENDC
|
||||
from messages import pkg_not_found, template
|
||||
|
||||
from sbo.greps import SBoGrep
|
||||
|
@ -43,7 +43,7 @@ def build_package(script, sources, path):
|
|||
file in path /var/log/slpkg/sbo/build_logs/.
|
||||
Also check md5sum calculates.
|
||||
'''
|
||||
prgnam = script.replace(".tar.gz", "")
|
||||
prgnam = script[:-7] # remove .tar.gz
|
||||
log_file = ("build_{0}_log".format(prgnam))
|
||||
sbo_logs = log_path + "sbo/"
|
||||
build_logs = sbo_logs + "build_logs/"
|
||||
|
@ -86,11 +86,12 @@ def build_package(script, sources, path):
|
|||
print("| MD5SUM check for {0} [ {1}PASSED{2} ]".format(
|
||||
src, GREEN, ENDC))
|
||||
template(78)
|
||||
print # new line after pass checksum
|
||||
shutil.copy2(src, prgnam)
|
||||
print # new line after pass checksum
|
||||
shutil.copy2(src, prgnam)
|
||||
os.chdir(path + prgnam)
|
||||
subprocess.call("chmod +x {0}.SlackBuild".format(prgnam), shell=True)
|
||||
with open(build_logs + log_file, "w") as log: # write headers to log file
|
||||
# write headers to log file
|
||||
with open(build_logs + log_file, "w") as log:
|
||||
log.write(log_line)
|
||||
log.write("File : " + log_file + "\n")
|
||||
log.write("Path : " + build_logs + "\n")
|
||||
|
@ -99,8 +100,8 @@ def build_package(script, sources, path):
|
|||
log.write(log_line)
|
||||
log.close()
|
||||
subprocess.Popen("./{0}.SlackBuild 2>&1 | tee -a {1}{2}".format(
|
||||
prgnam, build_logs, log_file), \
|
||||
shell=True, stdout=sys.stdout).communicate()
|
||||
prgnam, build_logs, log_file),
|
||||
shell=True, stdout=sys.stdout).communicate()
|
||||
end_log_time = time.strftime("%H:%M:%S")
|
||||
end_time = time.time()
|
||||
diff_time = round(end_time - start_time, 2)
|
||||
|
@ -110,13 +111,16 @@ def build_package(script, sources, path):
|
|||
elif diff_time > 59.99 and diff_time <= 3599.99:
|
||||
sum_time = round(diff_time / 60, 2)
|
||||
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 > 3599.99:
|
||||
sum_time = round(diff_time / 3600, 2)
|
||||
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]))
|
||||
with open(build_logs + log_file, "a") as log: # append END tag to a log file
|
||||
log.seek(2) # EOF
|
||||
sum_time = ("{0} Hours {1} Min".format(sum_time_list[0],
|
||||
sum_time_list[1]))
|
||||
# append END tag to a log file
|
||||
with open(build_logs + log_file, "a") as log:
|
||||
log.seek(2)
|
||||
log.write(log_line)
|
||||
log.write("Time : " + end_log_time + "\n")
|
||||
log.write("Total build time : {0}\n".format(sum_time))
|
||||
|
@ -124,10 +128,11 @@ def build_package(script, sources, path):
|
|||
log.write(log_line)
|
||||
log.close()
|
||||
os.chdir(path)
|
||||
print("Total build time for package {0} : {1}\n".format(prgnam, sum_time))
|
||||
print("Total build time for package {0} : {1}\n".format(prgnam,
|
||||
sum_time))
|
||||
except (OSError, IOError):
|
||||
message = "Wrong file"
|
||||
pkg_not_found("\n", prgnam, message, "\n")
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
|
|
@ -35,6 +35,7 @@ def find_package(find_pkg, directory):
|
|||
pkgs = []
|
||||
blacklist = BlackList().packages()
|
||||
for pkg in sorted(os.listdir(directory)):
|
||||
if pkg.startswith(find_pkg) and split_package(pkg + ".???")[0] not in blacklist:
|
||||
name = split_package(pkg + ".???")[0]
|
||||
if pkg.startswith(find_pkg) and name not in blacklist:
|
||||
pkgs.append(pkg)
|
||||
return pkgs
|
||||
|
|
|
@ -25,9 +25,8 @@ import os
|
|||
import sys
|
||||
import subprocess
|
||||
|
||||
from colors import *
|
||||
from blacklist import BlackList
|
||||
from messages import pkg_not_found, template
|
||||
from colors import RED, GREEN, CYAN, GREY, ENDC
|
||||
from __metadata__ import pkg_path, sp, log_path
|
||||
|
||||
from find import find_package
|
||||
|
@ -81,8 +80,9 @@ class PackageManager(object):
|
|||
'''
|
||||
for pkg in self.binary:
|
||||
try:
|
||||
print(subprocess.check_output("upgradepkg --reinstall {0}".format(
|
||||
pkg), shell=True))
|
||||
print(
|
||||
subprocess.check_output("upgradepkg --reinstall {0}".format(
|
||||
pkg), shell=True))
|
||||
print("Completed!\n")
|
||||
except subprocess.CalledProcessError:
|
||||
message = "Can't reinstall"
|
||||
|
@ -108,22 +108,25 @@ class PackageManager(object):
|
|||
for pkg in self.binary:
|
||||
pkgs = find_package(pkg + sp, pkg_path)
|
||||
if pkgs:
|
||||
print(RED + "[ delete ] --> " + ENDC + "\n ".join(pkgs))
|
||||
print("{0}[ delete ]{1} --> {2}".format(RED, ENDC,
|
||||
"\n ".join(pkgs)))
|
||||
|
||||
removed.append(pkg)
|
||||
else:
|
||||
message = "Can't remove"
|
||||
pkg_not_found("", pkg, message, "")
|
||||
if removed == []:
|
||||
print # new line at end
|
||||
print # new line at end
|
||||
else:
|
||||
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))
|
||||
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
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
if remove_pkg == "y" or remove_pkg == "Y":
|
||||
for rmv in removed:
|
||||
|
@ -134,40 +137,45 @@ class PackageManager(object):
|
|||
with open(dep_path + rmv, "r") as f:
|
||||
dependencies = f.read().split()
|
||||
f.close()
|
||||
print # new line at start
|
||||
print # new line at start
|
||||
template(78)
|
||||
print("| Found dependencies for package {0}:".format(rmv))
|
||||
print("| Found dependencies for package {0}:".format(
|
||||
rmv))
|
||||
template(78)
|
||||
# Prints dependecies before removed except master package
|
||||
# because referred as master package
|
||||
# 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]? ")
|
||||
"\nRemove dependencies (maybe used by other packages) [Y/n]? ")
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
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))
|
||||
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))
|
||||
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))
|
||||
print(subprocess.check_output(
|
||||
"removepkg {0}".format(rmv),
|
||||
shell=True))
|
||||
rmv_list.append(rmv)
|
||||
# Prints all removed packages
|
||||
if len(rmv_list) > 1:
|
||||
|
@ -180,7 +188,7 @@ class PackageManager(object):
|
|||
else:
|
||||
print("| Package {0} not found".format(pkg))
|
||||
template(78)
|
||||
print # new line at end
|
||||
print # new line at end
|
||||
|
||||
def find(self):
|
||||
'''
|
||||
|
@ -188,23 +196,23 @@ class PackageManager(object):
|
|||
'''
|
||||
self.binary = "".join(self.binary)
|
||||
matching = size = int()
|
||||
print("\nInstalled packages with name begin matching [ {0}{1}{2} ]\n".format(
|
||||
print("\nPackages with matching name [ {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:]:
|
||||
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:
|
||||
else:
|
||||
size += float(line[26:-1])
|
||||
break
|
||||
break
|
||||
if matching == 0:
|
||||
message = "Can't find"
|
||||
pkg_not_found("", self.binary, message, "\n")
|
||||
|
@ -223,10 +231,12 @@ class PackageManager(object):
|
|||
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))
|
||||
find = find_package(pkg + sp, pkg_path)
|
||||
if find:
|
||||
with open(pkg_path + "".join(find), "r") as package:
|
||||
for line in package:
|
||||
print(line).strip()
|
||||
print # new line per file
|
||||
else:
|
||||
message = "Can't dislpay"
|
||||
if len(self.binary) > 1:
|
||||
|
@ -254,10 +264,11 @@ class PackageManager(object):
|
|||
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))
|
||||
print # new line at start
|
||||
raw_input("Press [ {0}Enter{1} ] >> Next page ".format(
|
||||
CYAN, ENDC))
|
||||
page += 50
|
||||
print # new line at end
|
||||
print # new line at end
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
|
|
@ -22,10 +22,9 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from colors import *
|
||||
from downloader import Download
|
||||
from colors import GREEN, RED, ENDC
|
||||
from __metadata__ import lib_path, build_path, tmp
|
||||
|
||||
from sbo.greps import SBoGrep
|
||||
|
@ -43,10 +42,10 @@ class QueuePkgs(object):
|
|||
'''
|
||||
def __init__(self):
|
||||
queue_file = [
|
||||
"# In this file you can create a list of\n",
|
||||
"# packages you want to build or install.\n",
|
||||
"#\n"
|
||||
]
|
||||
"# In this file you can create a list of\n",
|
||||
"# packages you want to build or install.\n",
|
||||
"#\n"
|
||||
]
|
||||
self.queue = lib_path + "queue/"
|
||||
self.queue_list = self.queue + "queue_list"
|
||||
if not os.path.exists(lib_path):
|
||||
|
@ -84,7 +83,7 @@ class QueuePkgs(object):
|
|||
print("{0}{1}{2}".format(GREEN, pkg, ENDC))
|
||||
exit = 1
|
||||
if exit == 1:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
|
||||
def add(self, pkgs):
|
||||
'''
|
||||
|
@ -106,7 +105,7 @@ class QueuePkgs(object):
|
|||
exit = 1
|
||||
queue.close()
|
||||
if exit == 1:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
|
||||
def remove(self, pkgs):
|
||||
'''
|
||||
|
@ -117,7 +116,8 @@ class QueuePkgs(object):
|
|||
with open(self.queue_list, "r") as queue:
|
||||
lines = queue.read()
|
||||
queue.close()
|
||||
if pkgs == ["all"]: pkgs = self.packages()
|
||||
if pkgs == ["all"]:
|
||||
pkgs = self.packages()
|
||||
with open(self.queue_list, "w") as queue:
|
||||
for line in lines.splitlines():
|
||||
if line not in pkgs:
|
||||
|
@ -127,7 +127,7 @@ class QueuePkgs(object):
|
|||
exit = 1
|
||||
queue.close()
|
||||
if exit == 1:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
|
||||
def build(self):
|
||||
'''
|
||||
|
@ -143,11 +143,11 @@ class QueuePkgs(object):
|
|||
source_dwn = SBoGrep(pkg).source().split()
|
||||
sources = []
|
||||
os.chdir(build_path)
|
||||
script = sbo_dwn.split("/")[-1] # get file from script link
|
||||
script = sbo_dwn.split("/")[-1]
|
||||
Download(build_path, sbo_dwn).start()
|
||||
for src in source_dwn:
|
||||
Download(build_path, src).start()
|
||||
sources.append(src.split("/")[-1]) # get file from source link
|
||||
sources.append(src.split("/")[-1])
|
||||
build_package(script, sources, build_path)
|
||||
else:
|
||||
print("\nPackages not found in the queue for building\n")
|
||||
|
@ -155,7 +155,8 @@ class QueuePkgs(object):
|
|||
def install(self):
|
||||
packages = self.packages()
|
||||
if packages:
|
||||
print # new line at start
|
||||
# new line at start
|
||||
print
|
||||
for pkg in packages:
|
||||
# check if package exist in repository
|
||||
find = find_package(pkg, tmp)
|
||||
|
@ -163,7 +164,6 @@ class QueuePkgs(object):
|
|||
find = max(find)
|
||||
except ValueError:
|
||||
print("Package '{0}' not found in /tmp\n".format(pkg))
|
||||
pass
|
||||
if pkg in find:
|
||||
binary = "{0}{1}".format(tmp, find)
|
||||
PackageManager(binary.split()).install()
|
||||
|
|
|
@ -28,10 +28,10 @@ from pkg.find import find_package
|
|||
from pkg.build import build_package
|
||||
from pkg.manager import PackageManager
|
||||
|
||||
from colors import *
|
||||
from init import initialization
|
||||
from downloader import Download
|
||||
from messages import template, build_FAILED
|
||||
from colors import RED, GREEN, GREY, YELLOW, ENDC
|
||||
from __metadata__ import tmp, pkg_path, build_path, sp
|
||||
|
||||
from greps import SBoGrep
|
||||
|
@ -54,7 +54,7 @@ def sbo_check():
|
|||
reading_lists = "{0}Reading package lists ...{1}".format(GREY, ENDC)
|
||||
sys.stdout.write(reading_lists)
|
||||
sys.stdout.flush()
|
||||
init = initialization()
|
||||
initialization()
|
||||
arches = ["-x86_64-", "-i486-", "-arm-", "-noarch-"]
|
||||
index, toolbar_width = int(), 3
|
||||
[
|
||||
|
@ -94,7 +94,8 @@ 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, SBoGrep(name).version()))
|
||||
sbo_package = ("{0}-{1}".format(name,
|
||||
SBoGrep(name).version()))
|
||||
if sbo_package > package:
|
||||
upg_name.append(name)
|
||||
sys.stdout.write(done)
|
||||
|
@ -112,8 +113,9 @@ def sbo_check():
|
|||
# Thus creating this loop create one-dimensional list.
|
||||
for dep in dependencies:
|
||||
requires += dep
|
||||
requires.reverse() # Inverting the list brings the
|
||||
# dependencies in order to be installed.
|
||||
# Inverting the list brings the
|
||||
# dependencies in order to be installed.
|
||||
requires.reverse()
|
||||
# Many packages use the same dependencies, in this loop
|
||||
# creates a new list by removing duplicate dependencies but
|
||||
# without spoiling the line must be installed.
|
||||
|
@ -132,14 +134,16 @@ def sbo_check():
|
|||
for pkg in dependencies_list:
|
||||
ver = SBoGrep(pkg).version()
|
||||
prgnam = ("{0}-{1}".format(pkg, ver))
|
||||
pkg_version = ver # if package not installed
|
||||
# take version from repository
|
||||
# if package not installed
|
||||
# take version from repository
|
||||
pkg_version = ver
|
||||
arch = os.uname()[4]
|
||||
if arch.startswith("i") and arch.endswith("86"):
|
||||
arch = "i486"
|
||||
if find_package(prgnam, pkg_path) == []:
|
||||
for sbo in os.listdir(pkg_path):
|
||||
if sbo.startswith(pkg + sp) and sbo.endswith("_SBo"):
|
||||
if (sbo.startswith(pkg + sp) and
|
||||
sbo.endswith("_SBo")):
|
||||
# search if packages installed
|
||||
# if yes grab package name,
|
||||
# version and arch
|
||||
|
@ -156,8 +160,9 @@ def sbo_check():
|
|||
if pkg_for_upg:
|
||||
print("\nThese packages need upgrading:\n")
|
||||
template(78)
|
||||
print("{0}{1}{2}{3}{4}{5}{6}".format("| Package", " " * 30, "New version", \
|
||||
" " * 6 , "Arch", " " * 9, "Repository"))
|
||||
print("{0}{1}{2}{3}{4}{5}{6}".format(
|
||||
"| Package", " " * 30, "New version", " " * 6,
|
||||
"Arch", " " * 9, "Repository"))
|
||||
template(78)
|
||||
print("Upgrading:")
|
||||
count_upgraded = count_installed = int()
|
||||
|
@ -168,9 +173,10 @@ def sbo_check():
|
|||
else:
|
||||
COLOR = RED
|
||||
count_installed += 1
|
||||
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(COLOR, upg, ENDC, \
|
||||
" " * (38-len(upg)), GREEN, ver, ENDC, \
|
||||
" " * (17-len(ver)), arch, " " * (13-len(arch)), "SBo"))
|
||||
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
|
||||
COLOR, upg, ENDC, " " * (38-len(upg)), GREEN,
|
||||
ver, ENDC, " " * (17-len(ver)), arch,
|
||||
" " * (13-len(arch)), "SBo"))
|
||||
msg_upg = "package"
|
||||
msg_ins = msg_upg
|
||||
if count_upgraded > 1:
|
||||
|
@ -180,7 +186,8 @@ def sbo_check():
|
|||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print("{0}Total {1} {2} will be upgraded and {3} {4} will be installed.{5}\n".format(
|
||||
GREY, count_upgraded, msg_upg, count_installed, msg_ins, ENDC))
|
||||
GREY, count_upgraded, msg_upg,
|
||||
count_installed, msg_ins, ENDC))
|
||||
read = raw_input("Would you like to upgrade [Y/n]? ")
|
||||
if read == "Y" or read == "y":
|
||||
if not os.path.exists(build_path):
|
||||
|
@ -191,15 +198,16 @@ def sbo_check():
|
|||
sbo_url = sbo_search_pkg(name)
|
||||
sbo_dwn = sbo_slackbuild_dwn(sbo_url)
|
||||
src_dwn = SBoGrep(name).source().split()
|
||||
script = sbo_dwn.split("/")[-1] # keep file from script link
|
||||
script = sbo_dwn.split("/")[-1]
|
||||
Download(build_path, sbo_dwn).start()
|
||||
sources = []
|
||||
for src in src_dwn:
|
||||
Download(build_path, src).start()
|
||||
sources.append(src.split("/")[-1]) # keep file from source link
|
||||
# keep file from source link
|
||||
sources.append(src.split("/")[-1])
|
||||
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
|
||||
# Searches the package name and version in /tmp to
|
||||
# install.If find two or more packages e.g. to build tag
|
||||
# 2 or 3 will fit most.
|
||||
binary_list = []
|
||||
for search in find_package(prgnam, tmp):
|
||||
|
@ -211,9 +219,11 @@ def sbo_check():
|
|||
build_FAILED(sbo_url, prgnam)
|
||||
sys.exit()
|
||||
if find_package(name + sp, pkg_path):
|
||||
print("{0}[ Upgrading ] --> {1}{2}".format(GREEN, ENDC, name))
|
||||
print("{0}[ Upgrading ] --> {1}{2}".format(
|
||||
GREEN, ENDC, name))
|
||||
else:
|
||||
print("{0}[ Installing ] --> {1}{2}".format(GREEN, ENDC, name))
|
||||
print("{0}[ Installing ] --> {1}{2}".format(
|
||||
GREEN, ENDC, name))
|
||||
# Use this list to pick out what
|
||||
# packages will be installed
|
||||
installed.append(name)
|
||||
|
@ -221,7 +231,7 @@ def sbo_check():
|
|||
if len(pkg_for_upg) > 1:
|
||||
template(78)
|
||||
print("| Total {0} {1} upgraded and {2} {3} installed".format(
|
||||
count_upgraded, msg_upg, count_installed, msg_ins))
|
||||
count_upgraded, msg_upg, count_installed, msg_ins))
|
||||
template(78)
|
||||
for pkg, upg, ver in zip(pkg_for_upg, upgrade, upg_ver):
|
||||
upgraded = ("{0}-{1}".format(upg, ver))
|
||||
|
@ -233,10 +243,11 @@ def sbo_check():
|
|||
pkg, upg, ver))
|
||||
template(78)
|
||||
else:
|
||||
print("\nTotal {0} SBo packages are up to date\n".format(len(sbo_list)))
|
||||
print("\nTotal {0} SBo packages are up to date\n".format(
|
||||
len(sbo_list)))
|
||||
else:
|
||||
sys.stdout.write(done)
|
||||
print("\nNo SBo packages found\n")
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
|
||||
import sys
|
||||
|
||||
from colors import *
|
||||
from colors import GREY, ENDC
|
||||
from blacklist import BlackList
|
||||
|
||||
from greps import SBoGrep
|
||||
|
@ -32,6 +32,7 @@ from search import sbo_search_pkg
|
|||
|
||||
dep_results = []
|
||||
|
||||
|
||||
def sbo_dependencies_pkg(name):
|
||||
'''
|
||||
Build all dependencies of a package
|
||||
|
@ -56,5 +57,5 @@ def sbo_dependencies_pkg(name):
|
|||
sbo_dependencies_pkg(dep)
|
||||
return dep_results
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
|
|
@ -21,13 +21,8 @@
|
|||
# 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 os
|
||||
|
||||
from url_read import url_read
|
||||
from __metadata__ import arch, lib_path
|
||||
|
||||
from search import sbo_search_pkg
|
||||
|
||||
|
||||
class SBoGrep(object):
|
||||
'''
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
# 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 os
|
||||
|
||||
from url_read import url_read
|
||||
|
||||
|
||||
|
@ -32,6 +30,7 @@ def read_readme(sbo_url, sbo_readme):
|
|||
'''
|
||||
return url_read(sbo_url + sbo_readme)
|
||||
|
||||
|
||||
def read_info_slackbuild(sbo_url, name, sbo_file):
|
||||
'''
|
||||
Read info and SlackBuild file
|
||||
|
|
|
@ -21,8 +21,6 @@
|
|||
# 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 os
|
||||
import re
|
||||
import sys
|
||||
|
||||
from __metadata__ import lib_path
|
||||
|
@ -37,14 +35,17 @@ def sbo_search_pkg(name):
|
|||
'''
|
||||
try:
|
||||
blacklist = BlackList().packages()
|
||||
sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(slack_ver()))
|
||||
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r") as SLACKBUILDS_TXT:
|
||||
sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(
|
||||
slack_ver()))
|
||||
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT",
|
||||
"r") as SLACKBUILDS_TXT:
|
||||
for line in SLACKBUILDS_TXT:
|
||||
if line.startswith("SLACKBUILD LOCATION"):
|
||||
sbo_name = (line[23:].split("/")[-1].replace("\n", "")).strip()
|
||||
sbo_name = (line[23:].split("/")[-1].replace("\n",
|
||||
"")).strip()
|
||||
if name == sbo_name and name not in blacklist:
|
||||
SLACKBUILDS_TXT.close()
|
||||
return (sbo_url + line[23:].strip() + "/")
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
|
|
@ -24,13 +24,14 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
from colors import *
|
||||
from init import initialization
|
||||
from downloader import Download
|
||||
from __metadata__ import (tmp, pkg_path, build_path,
|
||||
log_path, lib_path, sp)
|
||||
log_path, lib_path, sp)
|
||||
from colors import RED, GREEN, GREY, YELLOW, CYAN, ENDC
|
||||
from messages import (pkg_found, template, build_FAILED,
|
||||
pkg_not_found, sbo_packages_view)
|
||||
pkg_not_found, sbo_packages_view)
|
||||
|
||||
|
||||
from pkg.find import find_package
|
||||
from pkg.build import build_package
|
||||
|
@ -52,7 +53,7 @@ def sbo_build(name):
|
|||
reading_lists = "{0}Reading package lists ...{1}".format(GREY, ENDC)
|
||||
sys.stdout.write(reading_lists)
|
||||
sys.stdout.flush()
|
||||
init = initialization()
|
||||
initialization()
|
||||
[
|
||||
sbo_ver,
|
||||
pkg_arch,
|
||||
|
@ -109,14 +110,17 @@ def sbo_build(name):
|
|||
print("\nThe following packages will be automatically installed or upgraded")
|
||||
print("with new version:\n")
|
||||
template(78)
|
||||
print("{0}{1}{2}{3}{4}{5}{6}".format("| Package", " " * 30, "Version", \
|
||||
" " * 10, "Arch", " " * 9, "Repository"))
|
||||
print("{0}{1}{2}{3}{4}{5}{6}".format(
|
||||
"| Package", " " * 30, "Version",
|
||||
" " * 10, "Arch", " " * 9, "Repository"))
|
||||
template(78)
|
||||
print("Installing:")
|
||||
sbo_packages_view(PKG_COLOR, name, sbo_ver[-1], ARCH_COLOR, pkg_arch[-1])
|
||||
sbo_packages_view(PKG_COLOR, name, sbo_ver[-1], ARCH_COLOR,
|
||||
pkg_arch[-1])
|
||||
print("Installing for dependencies:")
|
||||
ARCH_COLOR = "" # reset arch color for dependencies packages
|
||||
for dep, ver, dep_arch in zip(dependencies[:-1], sbo_ver[:-1], pkg_arch[:-1]):
|
||||
ARCH_COLOR = "" # reset arch color for dependencies packages
|
||||
for dep, ver, dep_arch in zip(dependencies[:-1], sbo_ver[:-1],
|
||||
pkg_arch[:-1]):
|
||||
dep_pkg = ("{0}-{1}".format(dep, ver))
|
||||
if find_package(dep_pkg, pkg_path):
|
||||
DEP_COLOR = GREEN
|
||||
|
@ -169,16 +173,17 @@ def sbo_build(name):
|
|||
sbo_url = sbo_search_pkg(pkg)
|
||||
sbo_link = sbo_slackbuild_dwn(sbo_url)
|
||||
src_link = SBoGrep(pkg).source().split()
|
||||
script = sbo_link.split("/")[-1] # get file from script
|
||||
script = sbo_link.split("/")[-1]
|
||||
Download(build_path, sbo_link).start()
|
||||
sources = []
|
||||
for src in src_link:
|
||||
sources.append(src.split("/")[-1]) # get file from source
|
||||
# get file from source
|
||||
sources.append(src.split("/")[-1])
|
||||
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
|
||||
# 2 or 3 will fit most.
|
||||
# Searches the package name and version in /tmp to
|
||||
# install. If find two or more packages e.g. to build
|
||||
# tag 2 or 3 will fit most.
|
||||
binary_list = []
|
||||
for search in find_package(prgnam, tmp):
|
||||
if "_SBo" in search:
|
||||
|
@ -209,11 +214,14 @@ def sbo_build(name):
|
|||
installed = ("{0}-{1}".format(pkg, ver))
|
||||
if find_package(installed, pkg_path):
|
||||
if pkg in upgraded:
|
||||
print("| Package {0} upgraded successfully".format(installed))
|
||||
print("| Package {0} upgraded successfully".format(
|
||||
installed))
|
||||
else:
|
||||
print("| Package {0} installed successfully".format(installed))
|
||||
print("| Package {0} installed successfully".format(
|
||||
installed))
|
||||
else:
|
||||
print("| Package {0} NOT installed".format(installed))
|
||||
print("| Package {0} NOT installed".format(
|
||||
installed))
|
||||
template(78)
|
||||
# Write dependencies in a log file
|
||||
# into directory `/var/log/slpkg/dep/`
|
||||
|
@ -232,7 +240,8 @@ def sbo_build(name):
|
|||
ins = uns = int()
|
||||
sbo_matching = []
|
||||
index, toolbar_width = int(), 3
|
||||
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r") as SLACKBUILDS_TXT:
|
||||
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()
|
||||
|
@ -252,8 +261,9 @@ def sbo_build(name):
|
|||
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
||||
CYAN, name, ENDC))
|
||||
template(78)
|
||||
print("{0}{1}{2}{3}{4}{5}{6}".format("| Package", " " * 30, "Version", \
|
||||
" " * 10, "Arch", " " * 9, "Repository"))
|
||||
print("{0}{1}{2}{3}{4}{5}{6}".format(
|
||||
"| Package", " " * 30, "Version",
|
||||
" " * 10, "Arch", " " * 9, "Repository"))
|
||||
template(78)
|
||||
print("Matching:")
|
||||
ARCH_COLOR = str()
|
||||
|
@ -281,9 +291,10 @@ def sbo_build(name):
|
|||
message = "No matching"
|
||||
pkg_not_found("\n", name, message, "\n")
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
||||
|
||||
def select_arch(src):
|
||||
'''
|
||||
Looks if sources unsupported or untested
|
||||
|
|
|
@ -23,10 +23,10 @@
|
|||
|
||||
import sys
|
||||
|
||||
from colors import *
|
||||
from messages import template
|
||||
from init import initialization
|
||||
from __metadata__ import pkg_path, sp
|
||||
from colors import RED, GREEN, GREY, YELLOW, CYAN, ENDC
|
||||
|
||||
from dependency import sbo_dependencies_pkg
|
||||
|
||||
|
@ -44,7 +44,7 @@ def track_dep(name):
|
|||
reading_lists = "{0}Reading package lists ...{1}".format(GREY, ENDC)
|
||||
sys.stdout.write(reading_lists)
|
||||
sys.stdout.flush()
|
||||
init = initialization()
|
||||
initialization()
|
||||
dependencies_list = sbo_dependencies_pkg(name)
|
||||
if dependencies_list is not None:
|
||||
sys.stdout.write(done)
|
||||
|
@ -60,7 +60,7 @@ def track_dep(name):
|
|||
if dependencies == []:
|
||||
dependencies = ["No dependencies"]
|
||||
pkg_len = len(name) + 24
|
||||
print # new line at start
|
||||
print # new line at start
|
||||
template(pkg_len)
|
||||
print("| Package {0}{1}{2} dependencies :".format(CYAN, name, ENDC))
|
||||
template(pkg_len)
|
||||
|
@ -71,11 +71,12 @@ def track_dep(name):
|
|||
index += 1
|
||||
if find_package(pkg + sp, pkg_path):
|
||||
print(" |")
|
||||
print(" {0}{1}: {2}{3}{4}".format("+--", index, GREEN, pkg, ENDC))
|
||||
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
|
||||
print # new line at end
|
||||
else:
|
||||
sys.stdout.write(done)
|
||||
print("\nNo package was found to match\n")
|
||||
|
|
|
@ -25,21 +25,21 @@ import os
|
|||
import sys
|
||||
import pydoc
|
||||
|
||||
from colors import *
|
||||
from colors import RED, GREEN, GREY, ENDC
|
||||
from init import initialization
|
||||
from downloader import Download
|
||||
from __metadata__ import tmp, build_path, pkg_path, sp
|
||||
from messages import (pkg_found, view_sbo, pkg_not_found,
|
||||
template, build_FAILED)
|
||||
template, build_FAILED)
|
||||
|
||||
from pkg.build import build_package
|
||||
from pkg.find import find_package
|
||||
from pkg.manager import PackageManager
|
||||
|
||||
from read import *
|
||||
from greps import SBoGrep
|
||||
from search import sbo_search_pkg
|
||||
from download import sbo_slackbuild_dwn
|
||||
from read import read_readme, read_info_slackbuild
|
||||
|
||||
|
||||
def sbo_network(name):
|
||||
|
@ -51,7 +51,7 @@ def sbo_network(name):
|
|||
reading_lists = "{0}Reading package lists ...{1}".format(GREY, ENDC)
|
||||
sys.stdout.write(reading_lists)
|
||||
sys.stdout.flush()
|
||||
init = initialization()
|
||||
initialization()
|
||||
sbo_url = sbo_search_pkg(name)
|
||||
if sbo_url:
|
||||
sbo_desc = SBoGrep(name).description()[len(name) + 2:-1]
|
||||
|
@ -59,8 +59,8 @@ def sbo_network(name):
|
|||
sbo_dwn = sbo_slackbuild_dwn(sbo_url)
|
||||
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]), \
|
||||
view_sbo(name, sbo_url, sbo_desc, sbo_dwn.split("/")[-1],
|
||||
", ".join([src.split("/")[-1] for src in source_dwn]),
|
||||
sbo_req)
|
||||
# Check if package supported by arch
|
||||
# before proceed to install
|
||||
|
@ -72,7 +72,7 @@ def sbo_network(name):
|
|||
try:
|
||||
read = raw_input(" {0}Choose an option: {1}".format(GREY, ENDC))
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
break
|
||||
if read == "D" or read == "d":
|
||||
path = ""
|
||||
|
@ -97,11 +97,11 @@ def sbo_network(name):
|
|||
os.mkdir(build_path)
|
||||
sources = []
|
||||
os.chdir(build_path)
|
||||
script = sbo_dwn.split("/")[-1] # get file from script link
|
||||
script = sbo_dwn.split("/")[-1]
|
||||
Download(build_path, sbo_dwn).start()
|
||||
for src in source_dwn:
|
||||
Download(build_path, src).start()
|
||||
sources.append(src.split("/")[-1]) # get file from source link
|
||||
sources.append(src.split("/")[-1])
|
||||
build_package(script, sources, build_path)
|
||||
break
|
||||
elif read == "I" or read == "i":
|
||||
|
@ -116,11 +116,11 @@ def sbo_network(name):
|
|||
sources = []
|
||||
os.chdir(build_path)
|
||||
Download(build_path, sbo_dwn).start()
|
||||
script = sbo_dwn.split("/")[-1] # get file from script link
|
||||
script = sbo_dwn.split("/")[-1]
|
||||
for src in source_dwn:
|
||||
Download(build_path, src).start()
|
||||
sources.append(src.split("/")[-1]) # get file from source link
|
||||
build_package(script, sources, build_path)
|
||||
sources.append(src.split("/")[-1])
|
||||
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
|
||||
# 2 or 3 will fit most.
|
||||
|
@ -133,7 +133,8 @@ def sbo_network(name):
|
|||
except ValueError:
|
||||
build_FAILED(sbo_url, prgnam)
|
||||
sys.exit()
|
||||
print("{0}[ Installing ] --> {1} {2}".format(GREEN, ENDC, name))
|
||||
print("{0}[ Installing ] --> {1} {2}".format(GREEN, ENDC,
|
||||
name))
|
||||
PackageManager(binary).upgrade()
|
||||
break
|
||||
else:
|
||||
|
|
|
@ -25,12 +25,12 @@ import os
|
|||
import sys
|
||||
import time
|
||||
|
||||
from colors import *
|
||||
from url_read import url_read
|
||||
from downloader import Download
|
||||
from blacklist import BlackList
|
||||
from messages import pkg_not_found, template
|
||||
from __metadata__ import slpkg_tmp, pkg_path, slack_archs
|
||||
from __metadata__ import slpkg_tmp, pkg_path
|
||||
from colors import RED, GREEN, CYAN, YELLOW, GREY, ENDC
|
||||
|
||||
from pkg.find import find_package
|
||||
from pkg.manager import PackageManager
|
||||
|
@ -49,7 +49,8 @@ def install(slack_pkg, version):
|
|||
[
|
||||
comp_sum,
|
||||
uncomp_sum,
|
||||
names, dwn_list,
|
||||
names,
|
||||
dwn_list,
|
||||
comp_size,
|
||||
uncomp_size,
|
||||
install_all,
|
||||
|
@ -89,9 +90,11 @@ def install(slack_pkg, version):
|
|||
comp_size.append(line[28:-2].strip())
|
||||
if line.startswith("PACKAGE SIZE (uncompressed): "):
|
||||
uncomp_size.append(line[30:-2].strip())
|
||||
for loc, name, comp, uncomp in zip(package_location, package_name, comp_size, uncomp_size):
|
||||
for loc, name, comp, uncomp in zip(package_location, package_name,
|
||||
comp_size, uncomp_size):
|
||||
if slack_pkg in name and slack_pkg not in blacklist:
|
||||
dwn_list.append("{0}{1}/{2}".format(mirrors("","", version), loc, name))
|
||||
dwn_list.append("{0}{1}/{2}".format(mirrors("", "", version),
|
||||
loc, name))
|
||||
install_all.append(name)
|
||||
comp_sum.append(comp)
|
||||
uncomp_sum.append(uncomp)
|
||||
|
@ -99,8 +102,12 @@ def install(slack_pkg, version):
|
|||
if install_all:
|
||||
template(78)
|
||||
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
|
||||
"| Package", " " * 17, "Version", " " * 12, "Arch", " " * 4, \
|
||||
"Build", " " * 2, "Repos", " " * 10, "Size"))
|
||||
"| Package", " " * 17,
|
||||
"Version", " " * 12,
|
||||
"Arch", " " * 4,
|
||||
"Build", " " * 2,
|
||||
"Repos", " " * 10,
|
||||
"Size"))
|
||||
template(78)
|
||||
print("Installing:")
|
||||
for pkg, comp in zip(install_all, comp_sum):
|
||||
|
@ -120,12 +127,12 @@ def install(slack_pkg, version):
|
|||
COLOR = RED
|
||||
uni_sum += 1
|
||||
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11:>12}{12}".format(
|
||||
COLOR, name, ENDC, \
|
||||
" " * (25-len(name)), ver, \
|
||||
" " * (19-len(ver)), arch, \
|
||||
" " * (8-len(arch)), build, \
|
||||
" " * (7-len(build)), "Slack", \
|
||||
comp, " K"))
|
||||
COLOR, name, ENDC,
|
||||
" " * (25-len(name)), ver,
|
||||
" " * (19-len(ver)), arch,
|
||||
" " * (8-len(arch)), build,
|
||||
" " * (7-len(build)), "Slack",
|
||||
comp, " K"))
|
||||
comp_unit = uncomp_unit = "Mb"
|
||||
compressed = round((sum(map(float, comp_sum)) / 1024), 2)
|
||||
uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2)
|
||||
|
@ -151,8 +158,9 @@ def install(slack_pkg, version):
|
|||
print("=" * 79)
|
||||
print("{0}Total {1} {2}.".format(GREY, len(install_all), msg_pkg))
|
||||
print("{0} {1} will be installed, {2} will be upgraded and {3} will be resettled.".format(
|
||||
uni_sum, msg_2_pkg, upg_sum, pkg_sum))
|
||||
print("Need to get {0} {1} of archives.".format(compressed, comp_unit))
|
||||
uni_sum, msg_2_pkg, upg_sum, pkg_sum))
|
||||
print("Need to get {0} {1} of archives.".format(compressed,
|
||||
comp_unit))
|
||||
print("After this process, {0} {1} of additional disk space will be used.{2}".format(
|
||||
uncompressed, uncomp_unit, ENDC))
|
||||
read = raw_input("\nWould you like to install [Y/n]? ")
|
||||
|
@ -182,12 +190,14 @@ def install(slack_pkg, version):
|
|||
if os.listdir(tmp_path) == []:
|
||||
print("Packages removed")
|
||||
else:
|
||||
print("\nThere are packages in directory {0}\n".format(tmp_path))
|
||||
print("\nThere are packages in directory {0}\n".format(
|
||||
tmp_path))
|
||||
else:
|
||||
print("\nThere are packages in directory {0}\n".format(tmp_path))
|
||||
print("\nThere are packages in directory {0}\n".format(
|
||||
tmp_path))
|
||||
else:
|
||||
message = "No matching"
|
||||
pkg_not_found("\n", slack_pkg, message, "\n")
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
|
|
@ -26,7 +26,7 @@ import sys
|
|||
import time
|
||||
import subprocess
|
||||
|
||||
from colors import *
|
||||
from colors import GREEN, GREY, YELLOW, ENDC
|
||||
from url_read import url_read
|
||||
from messages import template
|
||||
from downloader import Download
|
||||
|
@ -63,7 +63,7 @@ def patches(version):
|
|||
os.mkdir(slpkg_tmp)
|
||||
if not os.path.exists(patch_path):
|
||||
os.mkdir(patch_path)
|
||||
sys.stdout.write (reading_lists)
|
||||
sys.stdout.write(reading_lists)
|
||||
sys.stdout.flush()
|
||||
blacklist = BlackList().packages()
|
||||
if version == "stable":
|
||||
|
@ -81,38 +81,41 @@ def patches(version):
|
|||
toolbar_width += step
|
||||
time.sleep(0.05)
|
||||
if line.startswith("PACKAGE NAME"):
|
||||
package_name.append(line[15:].strip())
|
||||
package_name.append(line[15:].strip())
|
||||
if line.startswith("PACKAGE LOCATION"):
|
||||
package_location.append(line[21:].strip())
|
||||
package_location.append(line[21:].strip())
|
||||
if line.startswith("PACKAGE SIZE (compressed): "):
|
||||
comp_size.append(line[28:-2].strip())
|
||||
if line.startswith("PACKAGE SIZE (uncompressed): "):
|
||||
uncomp_size.append(line[30:-2].strip())
|
||||
if version == "stable": # stables versions upgrade
|
||||
for loc, name, comp, uncomp in zip(package_location, package_name, \
|
||||
if version == "stable": # stables versions upgrade
|
||||
for loc, name, comp, uncomp in zip(package_location, package_name,
|
||||
comp_size, uncomp_size):
|
||||
if not os.path.isfile(pkg_path + name[:-4]) and split_package(
|
||||
name)[0] not in blacklist:
|
||||
dwn_patches.append("{0}{1}/{2}".format(mirrors("","", version), loc, name))
|
||||
if (not os.path.isfile(pkg_path + name[:-4]) and split_package(
|
||||
name)[0] not in blacklist):
|
||||
dwn_patches.append("{0}{1}/{2}".format(
|
||||
mirrors("", "", version), loc, name))
|
||||
comp_sum.append(comp)
|
||||
uncomp_sum.append(uncomp)
|
||||
upgrade_all.append(name)
|
||||
else: # current version upgrade
|
||||
else: # current version upgrade
|
||||
installed = []
|
||||
# get all installed packages and store the package name.
|
||||
for pkg in os.listdir(pkg_path):
|
||||
installed.append(split_package(pkg + ".???")[0])
|
||||
for loc, name, comp, uncomp in zip(package_location, package_name, \
|
||||
for loc, name, comp, uncomp in zip(package_location, package_name,
|
||||
comp_size, uncomp_size):
|
||||
# If the package from the current repository is installed
|
||||
# (check with the name) but not is in the path (check with all package
|
||||
# like 'apr-1.5.0-x86_64-1') then add to list for upgrade.
|
||||
# etc. 'apr' in list 'installed' ?? if yes 'apr-1.5.0-x86_64-1' exist
|
||||
# in /var/log/packages ?? if no add to upgrade.
|
||||
# (check with the name) but not is in the path (check with
|
||||
# all package like 'apr-1.5.0-x86_64-1') then add to list for
|
||||
# upgrade.
|
||||
# etc. 'apr' in list 'installed' ?? if yes 'apr-1.5.0-x86_64-1'
|
||||
# exist in /var/log/packages ?? if no add to upgrade.
|
||||
if split_package(name)[0] in installed:
|
||||
if not os.path.isfile(pkg_path + name[:-4]) and split_package(
|
||||
name)[0] not in blacklist:
|
||||
dwn_patches.append("{0}{1}/{2}".format(mirrors("","", version), loc, name))
|
||||
if (not os.path.isfile(pkg_path + name[:-4]) and
|
||||
split_package(name)[0] not in blacklist):
|
||||
dwn_patches.append("{0}{1}/{2}".format(
|
||||
mirrors("", "", version), loc, name))
|
||||
comp_sum.append(comp)
|
||||
uncomp_sum.append(uncomp)
|
||||
upgrade_all.append(name)
|
||||
|
@ -121,8 +124,12 @@ def patches(version):
|
|||
print("\nThese packages need upgrading:\n")
|
||||
template(78)
|
||||
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
|
||||
"| Package", " " * 17, "Version", " " * 12, "Arch", " " * 4, \
|
||||
"Build", " " * 2, "Repos", " " * 10, "Size"))
|
||||
"| Package", " " * 17,
|
||||
"Version", " " * 12,
|
||||
"Arch", " " * 4,
|
||||
"Build", " " * 2,
|
||||
"Repos", " " * 10,
|
||||
"Size"))
|
||||
template(78)
|
||||
print("Upgrading:")
|
||||
for upgrade, size in zip(upgrade_all, comp_sum):
|
||||
|
@ -132,12 +139,12 @@ def patches(version):
|
|||
arch = pkg_split[2]
|
||||
build = pkg_split[3]
|
||||
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11:>12}{12}".format(
|
||||
YELLOW, name, ENDC, \
|
||||
" " * (25-len(name)), ver, \
|
||||
" " * (19-len(ver)), arch, \
|
||||
" " * (8-len(arch)), build, \
|
||||
" " * (7-len(build)), "Slack", \
|
||||
size, " K"))
|
||||
YELLOW, name, ENDC,
|
||||
" " * (25-len(name)), ver,
|
||||
" " * (19-len(ver)), arch,
|
||||
" " * (8-len(arch)), build,
|
||||
" " * (7-len(build)), "Slack",
|
||||
size, " K"))
|
||||
comp_unit = uncomp_unit = "Mb"
|
||||
compressed = round((sum(map(float, comp_sum)) / 1024), 2)
|
||||
uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2)
|
||||
|
@ -158,8 +165,11 @@ def patches(version):
|
|||
msg_pkg = msg_pkg + "s"
|
||||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print("{0}Total {1} {2} will be upgraded.".format(GREY, len(upgrade_all), msg_pkg))
|
||||
print("Need to get {0} {1} of archives.".format(compressed, comp_unit))
|
||||
print("{0}Total {1} {2} will be upgraded.".format(GREY,
|
||||
len(upgrade_all),
|
||||
msg_pkg))
|
||||
print("Need to get {0} {1} of archives.".format(compressed,
|
||||
comp_unit))
|
||||
print("After this process, {0} {1} of additional disk space will be used.{2}".format(
|
||||
uncompressed, uncomp_unit, ENDC))
|
||||
read = raw_input("\nWould you like to upgrade [Y/n]? ")
|
||||
|
@ -168,7 +178,8 @@ def patches(version):
|
|||
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]))
|
||||
print("{0}[ upgrading ] --> {1}{2}".format(GREEN, ENDC,
|
||||
pkg[:-4]))
|
||||
PackageManager((patch_path + pkg).split()).upgrade()
|
||||
for kernel in upgrade_all:
|
||||
if "kernel" in kernel:
|
||||
|
@ -183,14 +194,17 @@ def patches(version):
|
|||
if os.listdir(patch_path) == []:
|
||||
print("Packages removed")
|
||||
else:
|
||||
print("\nThere are packages in direcrory {0}\n".format(patch_path))
|
||||
print("\nThere are packages in direcrory {0}\n".format(
|
||||
patch_path))
|
||||
else:
|
||||
print("\nThere are packages in directory {0}\n".format(patch_path))
|
||||
print("\nThere are packages in directory {0}\n".format(
|
||||
patch_path))
|
||||
else:
|
||||
if os.uname()[4] == "x86_64":
|
||||
slack_arch = 64
|
||||
print("\nSlackware{0} '{1}' v{2} distribution is up to date\n".format(
|
||||
slack_arch, version, slack_ver()))
|
||||
print(
|
||||
"\nSlackware{0} '{1}' v{2} distribution is up to date\n".format(
|
||||
slack_arch, version, slack_ver()))
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
|
|
@ -36,5 +36,5 @@ def url_read(link):
|
|||
print ("\nslpkg: error: connection refused\n")
|
||||
sys.exit()
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
|
Loading…
Reference in a new issue