updated for version 1.7.6

This commit is contained in:
Dimitris Zlatanidis 2014-08-26 05:10:16 +03:00
parent 043f814df1
commit fb497262d2
19 changed files with 526 additions and 507 deletions

View file

@ -1,5 +1,12 @@
Version 1.7.6
[Updated] - Bugfix IndexError '-aa' in cli argparseoptions.
Fix arch's
[Feature] - Added upgrade all SBo packages
22-08-2014 22-08-2014
Version 1.7.5.dev Version 1.7.5
[Feature] - Added report of packages will be installed the options [Feature] - Added report of packages will be installed the options
`slpkg -s sbo <package>` `slpkg -s sbo <package>`

View file

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

View file

@ -39,7 +39,7 @@ Video Tutorial
============== ==============
.. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/screenshot-1.png .. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/screenshot-1.png
:target: https://asciinema.org/a/11649 :target: https://asciinema.org/a/11457
Installation Installation
------------ ------------
@ -67,8 +67,7 @@ Command Line Tool Usage
.. code-block:: bash .. code-block:: bash
usage: slpkg [-h] [-v] [-a script [source ...]] usage: slpkg [-h] [-v] [-a script [source ...]] [-l all, sbo, slack, noarch]
[-l all, sbo, slack, noarch, other]
[-c sbo, slack [sbo, slack ...]] [-c sbo, slack [sbo, slack ...]]
[-s sbo, slack [sbo, slack ...]] [-t] [-n] [-i [...]] [-s sbo, slack [sbo, slack ...]] [-t] [-n] [-i [...]]
[-u [...]] [-o [...]] [-r [...]] [-f [...]] [-d [...]] [-u [...]] [-o [...]] [-r [...]] [-f [...]] [-d [...]]
@ -80,7 +79,7 @@ Command Line Tool Usage
-v, --verbose print version and exit -v, --verbose print version and exit
-a script [source ...] -a script [source ...]
auto build package auto build package
-l all, sbo, slack, noarch, other -l all, sbo, slack, noarch
list of installed packages list of installed packages
-c sbo, slack [sbo, slack ...] -c sbo, slack [sbo, slack ...]
check if your packages is up to date check if your packages is up to date
@ -108,16 +107,16 @@ build and install with all dependencies :
Building dependency tree...... Done Building dependency tree...... Done
The following packages will be automatically installed or upgraded with new version: The following packages will be automatically installed or upgraded with new version:
+============================================================================== +==============================================================================
| Package Version Arch Repository | Package Version Arch Repository
+============================================================================== +==============================================================================
Installing: Installing:
brasero 3.11.3 x86_64 SBo brasero 3.11.3 x86_64 SBo
Installing for dependencies: Installing for dependencies:
orc 0.4.19 x86_64 SBo orc 0.4.19 x86_64 SBo
gstreamer1 1.2.2 x86_64 SBo gstreamer1 1.2.2 x86_64 SBo
gst1-plugins-base 1.2.2 x86_64 SBo gst1-plugins-base 1.2.2 x86_64 SBo
gst1-plugins-bad 1.2.2 x86_64 SBo gst1-plugins-bad 1.2.2 x86_64 SBo
libunique 1.1.6 x86_64 SBo libunique 1.1.6 x86_64 SBo
Installing summary Installing summary
=============================================================================== ===============================================================================
@ -203,27 +202,31 @@ Check if your packages is up to date from slackbuilds.org:
.. code-block:: bash .. code-block:: bash
$ slpkg -c sbo flashplayer-plugin $ slpkg -c sbo upgrade
Reading package lists. Done Reading package lists. Done
New version is available: Thece packages need upgrading:
+============================================================================== +==============================================================================
| Package: flashplayer-plugin 11.2.202.356 --> flashplayer-plugin 11.2.202.394 | Package New version Arch Repository
+============================================================================== +==============================================================================
Upgrading:
six-1.7.1 1.7.3 x86_64 SBo
pysetuptools-3.4 3.6 x86_64 SBo
Jinja2-2.7.0 2.7.2 x86_64 SBo
pysed-0.3.0 0.3.1 x86_64 SBo
Pafy-0.3.56 0.3.58 x86_64 SBo
MarkupSafe-0.21 0.23 x86_64 SBo
pip-1.5.3 1.5.6 x86_64 SBo
colored-1.1.1 1.1.4 x86_64 SBo
Installing summary
===============================================================================
Total 8 packages will be upgraded.
Would you like to upgrade [Y/n]?
Would you like to install [Y/n]? if your distribution is up to date from `Slackware official mirrors
$ slpkg -c sbo ranger
Reading package lists. Done
Package ranger-1.6.1 is up to date
$ slpkg -c sbo termcolor
Reading package lists. Done
No such package termcolor: Not installed
Check if your distribution is up to date from `Slackware official mirrors
<http://mirrors.slackware.com/>`_ <http://mirrors.slackware.com/>`_
.. code-block:: bash .. code-block:: bash

View file

@ -15,9 +15,11 @@
.SH NAME .SH NAME
slpkg - Utility for easy management packages in Slackware slpkg - Utility for easy management packages in Slackware
.SH SYNOPSIS .SH SYNOPSIS
\fBslpkg\fP \fB-h\fP \fB-v\fP \fB-a script [source ...]\fP \fB-l all, sbo, slack, noarch, other\fP \fBusage: slpkg [-h] [-v] [-a script [source ...]] [-l all, sbo, slack, noarch]
\fB-t\fP \fB-n\fP \fB-c sbo, slack [sbo, slack ...]\fP \fB-s\ slack [sbo, slack ...] fP\fB-i [...]\fP [-c sbo, slack [sbo, slack ...]]
\fB-u [...]\fP \fB-o [...]\fP \fB-r [...]\fP \fB-f [...]\fP \fB-d [...]\fP [-s sbo, slack [sbo, slack ...]] [-t] [-n] [-i [...]]
[-u [...]] [-o [...]] [-r [...]] [-f [...]] [-d [...]]\fP
.SH DESCRIPTION .SH DESCRIPTION
\fBslpkg\fP is a terminal multitool in order to easy use Slackware packages. \fBslpkg\fP is a terminal multitool in order to easy use Slackware packages.
.PP .PP
@ -27,7 +29,7 @@ It's a quick and easy way to manage your packages in slackware to a command.
\fB-v, --verbose print version and exit\fP \fB-v, --verbose print version and exit\fP
\fB-a script [source ...]\fP \fB-a script [source ...]\fP
\fB auto build packages\fP \fB auto build packages\fP
\fB-l all, sbo, slack, noarch, other\fP \fB-l all, sbo, slack, noarch\fP
\fB list of installed packages\fP \fB list of installed packages\fP
\fB-c sbo, slack [sbo, slack ...]\fp \fB-c sbo, slack [sbo, slack ...]\fp
\fB check if your packages is up to date\fP \fB check if your packages is up to date\fP
@ -55,11 +57,11 @@ The following commands are available.
.PP .PP
With this argument, build slackware package from source quickly and easy. With this argument, build slackware package from source quickly and easy.
Support .tar.gz and .tar.bz2 slackbuilds archives. Support .tar.gz and .tar.bz2 slackbuilds archives.
.SS -l all, sbo, slack, noarch, other .SS -l all, sbo, slack, noarch
\fBslpkg\fP \fB-l\fP <\fIall\fP> <\fIsbo\fP> \fBslpkg\fP \fB-l\fP <\fIall\fP> <\fIsbo\fP>
.PP .PP
Two display options list, one for all packages and another Four display options list, sbo, slack, noarch and all packages
only for packages SBo. items that are installed on the system.
.SS -t , tracking dependencies .SS -t , tracking dependencies
\fBslpkg\fP \fB-t\fP <\fIname of package\fP> \fBslpkg\fP \fB-t\fP <\fIname of package\fP>
.PP .PP
@ -70,8 +72,8 @@ The sequence shown is that you must follow to correctly install package.
.PP .PP
With this method you can find the SBo script that interests you through With this method you can find the SBo script that interests you through
the network. (www.slackbuilds.org) the network. (www.slackbuilds.org)
.SS -c , sbo, slack [sbo, slack ...] check if your package is up to date .SS -c , sbo, slack [sbo, slack ...] check if your packages is up to date
\fBslpkg\fP \fB-c\fP <\fIsbo\fP> <\fIslack\fP> <\fIname of package\fP> \fBslpkg\fP \fB-c\fP <\fIsbo\fP> <\fIslack\fP> <\fIupgrade\fP>
.PP .PP
Check your packages from Slackware official mirrors or from Check your packages from Slackware official mirrors or from
slackbuilds.org is up to date. slackbuilds.org is up to date.
@ -94,14 +96,14 @@ Normally upgrade only upgrades packages that are already
installed on the system, and will skip any packages that do not installed on the system, and will skip any packages that do not
already have a version installed. 'Requires root privileges' already have a version installed. 'Requires root privileges'
(like slackware command upgradepkg --install-new) (like slackware command upgradepkg --install-new)
.SS -o reinstall binary package .SS -o , reinstall binary package
\fBslpkg\fP \fB-o\fP <\fIpackages.t?z\fP> \fBslpkg\fP \fB-o\fP <\fIpackages.t?z\fP>
.PP .PP
Upgradepkg usually skips packages if the exact same package Upgradepkg usually skips packages if the exact same package
(matching name, version, arch, and build number) is already (matching name, version, arch, and build number) is already
installed on the system.'Requires root privileges' (like installed on the system.'Requires root privileges' (like
slackware command upgradepkg --reinstall) slackware command upgradepkg --reinstall)
.SS -r , remove package .SS -r , remove packages
\fBslpkg\fP \fB-r\fP <\fIname of packages\fP> \fBslpkg\fP \fB-r\fP <\fIname of packages\fP>
.PP .PP
Removes a previously installed Slackware package, while writing Removes a previously installed Slackware package, while writing
@ -116,7 +118,7 @@ privileges' (like slackware command removepkg)
\fBslpkg\fP \fB-f\fP <\fIname of packages\fP> \fBslpkg\fP \fB-f\fP <\fIname of packages\fP>
.PP .PP
Find if package allready installed or not. Find if package allready installed or not.
.SS -d display contents .SS -d , display contents
\fBslpkg\fP \fB-d\fP <\fIname of packages\fP> \fBslpkg\fP \fB-d\fP <\fIname of packages\fP>
.PP .PP
Display the contents of the package with all descriptions. Display the contents of the package with all descriptions.
@ -191,15 +193,29 @@ $ \fBslpkg -s sbo brasero\fP
Package brasero-3.11.3-x86_64-1_SBo.tgz installed. Package brasero-3.11.3-x86_64-1_SBo.tgz installed.
$ \fBslpkg -c sbo flashplayer-plugin\fP $ \fBslpkg -c sbo upgrade\fP
Reading package lists. Done Reading package lists. Done
New version is available: These packages need upgrading:
+============================================================================== +==============================================================================
| Package: flashplayer-plugin 11.2.202.356 --> flashplayer-plugin 11.2.202.394 | Package New version Arch Repository
+============================================================================== +==============================================================================
Upgrading:
Would you like to install [Y/n]? six-1.7.1 1.7.3 x86_64 SBo
pysetuptools-3.4 3.6 x86_64 SBo
Jinja2-2.7.0 2.7.2 x86_64 SBo
pysed-0.3.0 0.3.1 x86_64 SBo
Pafy-0.3.56 0.3.58 x86_64 SBo
MarkupSafe-0.21 0.23 x86_64 SBo
pip-1.5.3 1.5.6 x86_64 SBo
colored-1.1.1 1.1.4 x86_64 SBo
Installing summary
===============================================================================
Total 8 packages will be upgraded.
Would you like to upgrade [Y/n]?
$ \fBslpkg -c slack upgrade\fp $ \fBslpkg -c slack upgrade\fp
Reading package lists....... Done Reading package lists....... Done

View file

@ -1,4 +1,4 @@
# Python 2.7.5 # Python 2.7.5+
# Slackware current (not supported yet) # Slackware current (not supported yet)
# Slackware # Slackware
# Slackware 64 # Slackware 64

View file

@ -26,7 +26,7 @@ import subprocess
__all__ = "slpkg" __all__ = "slpkg"
__author__ = "dslackw" __author__ = "dslackw"
__version_info__ = (1, 7, 5) __version_info__ = (1, 7, 6)
__version__ = "{0}.{1}.{2}".format(*__version_info__) __version__ = "{0}.{1}.{2}".format(*__version_info__)
__license__ = "GNU General Public License v3 (GPLv3)" __license__ = "GNU General Public License v3 (GPLv3)"
__email__ = "d.zlatanidis@gmail.com" __email__ = "d.zlatanidis@gmail.com"
@ -54,10 +54,16 @@ slpkg_tmp = tmp + "slpkg/"
pkg_path = "/var/log/packages/" pkg_path = "/var/log/packages/"
''' computer architecture ''' ''' computer architecture '''
uname = os.uname() arch = os.uname()[4]
arch = (uname[4])
''' slackbuild fietype binary packages ''' ''' slackbuild fietype binary packages '''
sbo_arch = "*" if arch == "x86_64":
sbo_tag = "?_SBo" sbo_arch = "-x86_64-"
elif arch.startswith("i") and arch.endswith("86"):
sbo_arch = "-i486-"
elif "arm" in arch:
sbo_arch = "-arm-"
build = "*"
sbo_tag = "_SBo"
sbo_filetype = ".tgz" sbo_filetype = ".tgz"

View file

@ -60,14 +60,14 @@ optional arguments:
''' '''
import argparse
import getpass import getpass
import argparse
from version import * from version import *
from functions import * from functions import *
from colors import colors from colors import colors
from __metadata__ import path from __metadata__ import path
from messages import ext_err_args from messages import ext_err_args, s_user
from messages import err1_args, err2_args from messages import err1_args, err2_args
from pkg.build import build_package from pkg.build import build_package
@ -89,8 +89,8 @@ def main():
parser.add_argument("-a", help="auto build packages", parser.add_argument("-a", help="auto build packages",
type=str, nargs="+", metavar=("script", "source")) type=str, nargs="+", metavar=("script", "source"))
parser.add_argument("-l", help="list of installed packages", parser.add_argument("-l", help="list of installed packages",
choices="all sbo slack noarch other".split(), choices="all sbo slack noarch".split(),
metavar=("all, sbo, slack, noarch, other")) metavar=("all, sbo, slack, noarch"))
parser.add_argument("-c", help="check if your packages is up to date", parser.add_argument("-c", help="check if your packages is up to date",
type=str, nargs="+", metavar=("sbo, slack")) type=str, nargs="+", metavar=("sbo, slack"))
parser.add_argument("-s", help="download, build & install packages", parser.add_argument("-s", help="download, build & install packages",
@ -112,98 +112,109 @@ def main():
parser.add_argument("-d", help="display the contents of the packages", parser.add_argument("-d", help="display the contents of the packages",
type=str, nargs="+", metavar=("")) type=str, nargs="+", metavar=(""))
args = parser.parse_args() args = parser.parse_args()
if args.verbose: try:
prog_version() if args.verbose:
if args.a: prog_version()
s_user(getpass.getuser()) if args.a:
build_package(args.a[0], args.a[1], args.a[2:], path) s_user(getpass.getuser())
if args.l: build_package(args.a[0], args.a[1:], path)
pkg_list(args.l) if args.l:
if args.t: pkg_list(args.l)
s_user(getpass.getuser()) if args.t:
pkg_tracking(args.t) s_user(getpass.getuser())
if args.n: pkg_tracking(args.t)
s_user(getpass.getuser()) if args.n:
sbo_network(args.n) s_user(getpass.getuser())
if args.c: sbo_network(args.n)
s_user(getpass.getuser()) if args.c:
if len(args.c) == 2: s_user(getpass.getuser())
if "sbo" in args.c: if len(args.c) == 2:
sbo_check("".join(args.c[1])) if "sbo" in args.c:
elif "slack" in args.c: if args.c[1] == "upgrade":
if args.c[1] == "upgrade": sbo_check()
patches() else:
choices = ["upgrade"]
ext_err_args()
err1_args("".join(args.c[1]), choices)
elif "slack" in args.c:
if args.c[1] == "upgrade":
patches()
else:
choices = ["upgrade"]
ext_err_args()
err1_args("".join(args.c[1]), choices)
else: else:
choices = ["sbo", "slack"]
ext_err_args()
err1_args("".join(args.c[0]), choices)
elif len(args.c) < 2:
if "sbo" in args.c or "slack" in args.c:
choices = ['upgrade']
ext_err_args()
err2_args(choices)
else:
choices = ["sbo", "slack"]
ext_err_args()
err1_args("".join(args.c), choices)
else:
ext_err_args()
err2_args()
if args.s:
s_user(getpass.getuser())
if len(args.s) == 2:
if "sbo" in args.s:
sbo_build("".join(args.s[1]))
elif "slack" in args.s:
install("".join(args.s[1]))
else:
choices = ["sbo", "slack"]
ext_err_args()
err1_args("".join(args.s[0]), choices)
elif len(args.s) < 2:
if "sbo" in args.s or "slack" in args.s:
choices = ["upgrade"] choices = ["upgrade"]
ext_err_args() ext_err_args()
err1_args("".join(args.c[1]), choices) err2_args(choices)
else:
choices = ["sbo", "slack"]
ext_err_args()
err1_args("".join(args.s), choices)
else: else:
choices = ["sbo", "slack"]
ext_err_args()
err1_args("".join(args.c[0]), choices)
elif len(args.c) < 2:
if "sbo" in args.c or "slack" in args.c:
ext_err_args() ext_err_args()
err2_args() err2_args()
else: if args.i:
choices = ["sbo", "slack"] s_user(getpass.getuser())
ext_err_args() pkg_install(args.i)
err1_args("".join(args.c), choices) if args.u:
else: s_user(getpass.getuser())
ext_err_args() pkg_upgrade(args.u)
err2_args() if args.o:
if args.s: s_user(getpass.getuser())
s_user(getpass.getuser()) pkg_reinstall(args.o)
if len(args.s) == 2: if args.r:
if "sbo" in args.s: s_user(getpass.getuser())
sbo_build("".join(args.s[1])) pkg_remove(args.r)
elif "slack" in args.s: if args.f:
install("".join(args.s[1])) pkg_find(args.f)
else: if args.d:
choices = ["sbo", "slack"] pkg_display(args.d)
ext_err_args() if not any([args.verbose,
err1_args("".join(args.s[0]), choices) args.s,
elif len(args.s) < 2: args.t,
if "sbo" in args.s or "slack" in args.s: args.c,
ext_err_args() args.n,
err2_args() args.o,
else: args.i,
choices = ["sbo", "slack"] args.u,
ext_err_args() args.a,
err1_args("".join(args.s), choices) args.r,
else: args.l,
ext_err_args() args.f,
err2_args() args.d]):
if args.i: os.system("slpkg -h")
s_user(getpass.getuser()) except IndexError:
pkg_install(args.i) ext_err_args()
if args.u: err2_args("")
s_user(getpass.getuser())
pkg_upgrade(args.u)
if args.o:
s_user(getpass.getuser())
pkg_reinstall(args.o)
if args.r:
s_user(getpass.getuser())
pkg_remove(args.r)
if args.f:
pkg_find(args.f)
if args.d:
pkg_display(args.d)
if not any([args.verbose,
args.s,
args.t,
args.c,
args.n,
args.o,
args.i,
args.u,
args.a,
args.r,
args.l,
args.f,
args.d]):
os.system("slpkg -h")
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View file

@ -47,11 +47,10 @@ def ext_err_args():
''' '''
Extended error arguments view Extended error arguments view
''' '''
print ("usage: {0} [-h] [-v] [-a script [source ...]]".format(__all__)) print ("usage: {0} [-h] [-v] [-a script [source ...]] [-l all, sbo, slack, noarch]".format(__all__))
print (" [-l all, sbo, slack, noarch, other]") print (" [-c sbo, slack [sbo, slack ...]]")
print (" [-c sbo, slack [sbo, slack ...]] [-t] [-n]") print (" [-s sbo, slack [sbo, slack ...]] [-t] [-n] [-i [...]]")
print (" [-s sbo, slack [sbo, slack ...]] [-i [...]] [-u [...]]") print (" [-u [...]] [-o [...]] [-r [...]] [-f [...]] [-d [...]]")
print (" [-o [...]] [-r [...]] [-f [...]] [-d [...]]")
def err1_args(invalid, choices): def err1_args(invalid, choices):
''' '''
@ -60,12 +59,12 @@ def err1_args(invalid, choices):
print ("{0}: error: invalid choice: '{1}' choose from {2}".format( print ("{0}: error: invalid choice: '{1}' choose from {2}".format(
__all__, invalid, choices)) __all__, invalid, choices))
def err2_args(): def err2_args(choices):
''' '''
Print error message arguments Print error message arguments
''' '''
print ("{0}: error: must enter at least two arguments".format( print ("{0}: error: must enter at least two arguments: choose {1}".format(
__all__)) __all__, choices))
def s_user(user): def s_user(user):
''' '''
@ -81,7 +80,7 @@ def template(max):
''' '''
print ("+" + "=" * max) print ("+" + "=" * max)
def view_sbo(pkg, sbo_url, sbo_dwn, source_dwn, extra_dwn, sbo_req): def view_sbo(pkg, sbo_url, sbo_dwn, source_dwn, sbo_req):
print # new line at start print # new line at start
template(78) template(78)
print("| {0}Package {1}{2}{3} --> {4}".format(colors.GREEN, print("| {0}Package {1}{2}{3} --> {4}".format(colors.GREEN,
@ -89,9 +88,8 @@ def view_sbo(pkg, sbo_url, sbo_dwn, source_dwn, extra_dwn, sbo_req):
template(78) template(78)
print("| {0}SlackBuild : {1}{2}".format(colors.GREEN, colors.ENDC, sbo_dwn)) print("| {0}SlackBuild : {1}{2}".format(colors.GREEN, colors.ENDC, sbo_dwn))
print("| {0}Source : {1}{2}".format(colors.GREEN, colors.ENDC, source_dwn)) print("| {0}Source : {1}{2}".format(colors.GREEN, colors.ENDC, source_dwn))
print("| {0}Extra : {1}{2}".format(colors.GREEN, colors.ENDC, extra_dwn))
print("| {0}Requirements : {1}{2}".format(colors.YELLOW, colors.ENDC, print("| {0}Requirements : {1}{2}".format(colors.YELLOW, colors.ENDC,
", ".join(sbo_req.split()))) ", ".join(sbo_req)))
template(78) template(78)
print(" {0}R{1}EADME View the README file".format(colors.RED, colors.ENDC)) print(" {0}R{1}EADME View the README file".format(colors.RED, colors.ENDC))
print(" {0}S{1}lackBuild View the SlackBuild file".format(colors.RED, colors.ENDC)) print(" {0}S{1}lackBuild View the SlackBuild file".format(colors.RED, colors.ENDC))

View file

@ -27,9 +27,9 @@ import shutil
import tarfile import tarfile
import subprocess import subprocess
from slpkg.messages import pkg_not_found, s_user from slpkg.messages import pkg_not_found
def build_package(script, source, extra, path): def build_package(script, sources, path):
''' '''
Build package from source Build package from source
''' '''
@ -38,10 +38,10 @@ def build_package(script, source, extra, path):
tar = tarfile.open(script) tar = tarfile.open(script)
tar.extractall() tar.extractall()
tar.close() tar.close()
shutil.copy2(source, pkg_name) for src in sources:
for src in extra:
shutil.copy2(src, pkg_name) shutil.copy2(src, pkg_name)
os.chdir(path + pkg_name) os.chdir(path + pkg_name)
subprocess.call("chmod +x {0}.SlackBuild".format(pkg_name), shell=True)
subprocess.call("./{0}.SlackBuild".format(pkg_name), shell=True) subprocess.call("./{0}.SlackBuild".format(pkg_name), shell=True)
os.chdir(path) os.chdir(path)
except (OSError, IOError): except (OSError, IOError):

View file

@ -28,8 +28,8 @@ import subprocess
from collections import OrderedDict from collections import OrderedDict
from slpkg.colors import colors from slpkg.colors import colors
from slpkg.messages import pkg_not_found, s_user, template from slpkg.messages import pkg_not_found, template
from slpkg.__metadata__ import pkg_path, uname, arch, sp, log_path from slpkg.__metadata__ import pkg_path, sp, log_path
from find import find_package from find import find_package
@ -39,7 +39,7 @@ def pkg_install(binary):
''' '''
for pkg in binary: for pkg in binary:
try: try:
print subprocess.check_output('installpkg {0}'.format(pkg), shell=True) print subprocess.check_output("installpkg {0}".format(pkg), shell=True)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
message = "Can't install" message = "Can't install"
if len(binary) > 1: if len(binary) > 1:
@ -54,7 +54,7 @@ def pkg_upgrade(binary):
''' '''
for pkg in binary: for pkg in binary:
try: try:
print subprocess.check_output('upgradepkg --install-new {0}'.format(pkg), print subprocess.check_output("upgradepkg --install-new {0}".format(pkg),
shell=True) shell=True)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
message = "Can't upgrade" message = "Can't upgrade"
@ -70,7 +70,7 @@ def pkg_reinstall(binary):
''' '''
for pkg in binary: for pkg in binary:
try: try:
print subprocess.check_output('upgradepkg --reinstall {0}'.format(pkg), print subprocess.check_output("upgradepkg --reinstall {0}".format(pkg),
shell=True) shell=True)
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
message = "Can't reinstall" message = "Can't reinstall"
@ -140,17 +140,17 @@ def pkg_remove(binary):
if remove_dep == "y" or remove_dep == "Y": if remove_dep == "y" or remove_dep == "Y":
for dep in dependencies: for dep in dependencies:
if find_package(dep + sp, pkg_path): 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)
os.remove(dep_path + rmv) os.remove(dep_path + rmv)
rmv_dependencies += dependencies[:-1] rmv_dependencies += dependencies[:-1]
else: else:
if find_package(rmv + sp, pkg_path): if find_package(rmv + sp, pkg_path):
print subprocess.check_output('removepkg {0}'.format(rmv), shell=True) print subprocess.check_output("removepkg {0}".format(rmv), shell=True)
f.close() f.close()
os.remove(dep_path + rmv) os.remove(dep_path + rmv)
else: else:
if find_package(rmv + sp, pkg_path): if find_package(rmv + sp, pkg_path):
print subprocess.check_output('removepkg {0}'.format(rmv), shell=True) print subprocess.check_output("removepkg {0}".format(rmv), shell=True)
''' '''
Prints all removed packages Prints all removed packages
''' '''
@ -171,13 +171,13 @@ def pkg_find(binary):
print("\nPackages with name matching [ {0}{1}{2} ]\n".format( print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
colors.CYAN, ', '.join(binary), colors.ENDC)) colors.CYAN, ', '.join(binary), colors.ENDC))
for pkg in binary: for pkg in binary:
if find_package(pkg + sp, pkg_path) == []: if find_package(pkg + sp, pkg_path):
print(colors.GREEN + "[ installed ] - " + colors.ENDC + "\n ".join(
find_package(pkg + sp, pkg_path)))
else:
message = "Can't find" message = "Can't find"
bol, eol = "", "" bol, eol = "", ""
pkg_not_found(bol, pkg, message, eol) pkg_not_found(bol, pkg, message, eol)
else:
print(colors.GREEN + "[ installed ] - " + colors.ENDC + "\n ".join(
find_package(pkg + sp, pkg_path)))
print # new line at end print # new line at end
def pkg_display(binary): def pkg_display(binary):
@ -185,70 +185,39 @@ def pkg_display(binary):
Print the Slackware packages contents Print the Slackware packages contents
''' '''
for pkg in binary: for pkg in binary:
if find_package(pkg + sp, pkg_path) == []: if find_package(pkg + sp, pkg_path):
print subprocess.check_output("cat {0}{1}".format(pkg_path,
" /var/log/packages/".join(find_package(pkg +sp, pkg_path))), shell=True)
else:
message = "Can't dislpay" message = "Can't dislpay"
if len(binary) > 1: if len(binary) > 1:
bol, eol = "", "" bol, eol = "", ""
else: else:
bol, eol = "\n", "\n" bol, eol = "\n", "\n"
pkg_not_found(bol, pkg, message, eol) pkg_not_found(bol, pkg, message, eol)
else:
print subprocess.check_output("cat {0}{1}".format(pkg_path,
" /var/log/packages/".join(find_package(pkg +sp, pkg_path))), shell=True)
def pkg_list(binary): def pkg_list(pattern):
''' '''
List with the installed packages List with the installed packages
''' '''
try: try:
print # new line at start 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 index, page = 0, 50
if "all" in binary: for pkg in sorted(os.listdir(pkg_path)):
for pkg in sorted(os.listdir(pkg_path)): if search in pkg:
index += 1 index += 1
print("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg)) print("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg))
if index == page: if index == page:
key = raw_input('\nPress [ {0}Enter{1} ] >> Next page '.format( key = raw_input("\nPress [ {0}Enter{1} ] >> Next page ".format(
colors.CYAN, colors.ENDC)) colors.CYAN, colors.ENDC))
page += 50 page += 50
if "sbo" in binary:
for pkg in sorted(os.listdir(pkg_path)):
if 'SBo' in pkg:
index += 1
print("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg))
if index == page:
key = raw_input('\nPress [ {0}Enter{1} ] >> Next page '.format(
colors.CYAN, colors.ENDC))
page += 50
if "slack" in binary:
for pkg in sorted(os.listdir(pkg_path)):
if 'slack' in pkg:
index += 1
print("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg))
if index == page:
key = raw_input('\nPress [ {0}Enter{1} ] >> Next page '.format(
colors.CYAN, colors.ENDC))
page += 50
if "noarch" in binary:
for pkg in sorted(os.listdir(pkg_path)):
if 'noarch' in pkg:
index += 1
print("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg))
if index == page:
key = raw_input('\nPress [ {0}Enter{1} ] >> Next page '.format(
colors.CYAN, colors.ENDC))
page += 50
if "other" in binary:
for pkg in sorted(os.listdir(pkg_path)):
if 'SBo' in pkg or 'slack' in pkg or 'noarch' in pkg:
pass
else:
index += 1
print("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg))
if index == page:
key = raw_input('\nPress [ {0}Enter{1} ] >> Next page '.format(
colors.CYAN, colors.ENDC))
page += 50
print # new line at end print # new line at end
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print # new line at exit

View file

@ -25,76 +25,104 @@ import os
import sys import sys
import subprocess import subprocess
from slpkg.pkg.find import find_package
from slpkg.pkg.build import build_package from slpkg.pkg.build import build_package
from slpkg.pkg.manager import pkg_upgrade from slpkg.pkg.manager import pkg_upgrade
from slpkg.colors import colors from slpkg.colors import colors
from slpkg.messages import template
from slpkg.functions import get_file from slpkg.functions import get_file
from slpkg.messages import pkg_not_found, template from slpkg.__metadata__ import tmp, pkg_path, build_path
from slpkg.__metadata__ import tmp, pkg_path, arch, sp from slpkg.__metadata__ import sbo_arch, build, sbo_tag, sbo_filetype
from slpkg.__metadata__ import sbo_arch, sbo_tag, sbo_filetype, build_path
from init import initialization
from search import sbo_search_pkg from search import sbo_search_pkg
from download import sbo_slackbuild_dwn from download import sbo_slackbuild_dwn
from greps import sbo_source_dwn, sbo_extra_dwn, sbo_version_pkg from greps import sbo_source_dwn, sbo_version_pkg
def sbo_check(name): def sbo_check():
''' '''
Check for new package updates Upgrade all slackbuilds packages from slackbuilds.org
repository
''' '''
sys.stdout.write("Reading package lists ...") try:
sbo_file = "".join(find_package(name + sp, pkg_path)) sys.stdout.write("Reading package lists ...")
if sbo_file == "":
sys.stdout.write("Done\n")
message = "Not installed"
bol, eol = "\n", "\n"
pkg_not_found(bol, name, message, eol)
else:
sys.stdout.flush() sys.stdout.flush()
sbo_url = sbo_search_pkg(name) initialization()
if sbo_url is None: index, toolbar_width = 0, 3
pkg_name, sbo_ver, pkg_for_upg, sbo_list = [], [], [], []
for pkg in os.listdir(pkg_path):
if "_SBo" in pkg:
sbo_list.append(pkg)
if sbo_list:
for pkg in sbo_list:
index += 1
if index == toolbar_width:
sys.stdout.write(".")
sys.stdout.flush()
toolbar_width += 3
if "-x86_64-" in pkg:
arch = "x86_64"
elif "-i486-" in pkg:
arch = "i486"
elif "-arm-" in pkg:
arch = "arm"
elif "-noarch-" in pkg:
arch = "noarch"
else:
arch = os.uname()[4]
name = pkg[:-(len(arch) + len("_SBo") + 3)]
pkg_version = get_file(name, "-")[1:]
name = name[:-(len(pkg_version) + 1)]
sbo_version = sbo_version_pkg(name)
if sbo_version > pkg_version:
pkg_name.append(name)
pkg_for_upg.append(name + "-" + pkg_version)
sbo_ver.append(sbo_version)
sys.stdout.write("Done\n") sys.stdout.write("Done\n")
message = "From slackbuilds.org" if pkg_for_upg:
bol, eol = "\n", "\n" print("\nThese packages need upgrading:\n")
pkg_not_found(bol, name, message, eol)
else:
sys.stdout.write("Done\n")
sbo_version = sbo_version_pkg(name)
sbo_dwn = sbo_slackbuild_dwn(sbo_url, name)
source_dwn = sbo_source_dwn(sbo_url, name)
extra_dwn = sbo_extra_dwn(sbo_url, name)
sbo_file_version = sbo_file[len(name) + 1:-len(arch) - 7]
if sbo_version > sbo_file_version:
print("\n{0}New version is available:{1}".format(
colors.YELLOW, colors.ENDC))
template(78) template(78)
print("| Package {0} {1} --> {2} {3}".format( print "| Package", " "*27, "New version", " "*5, "Arch", " "*7, "Repository"
name, sbo_file_version, name, sbo_version))
template(78) template(78)
print # new line at start print("Upgrading:")
try: for upg, ver in zip(pkg_for_upg, sbo_ver):
read = raw_input("Would you like to install [Y/n]? ") print " ", upg, " "*(34-len(upg)), ver, " "*(
except KeyboardInterrupt: 16-len(ver)), arch, " "*(11-len(arch)), "SBo"
print # new line at exit msg_pkg = "package"
sys.exit() if len(pkg_for_upg) > 1:
msg_pkg = msg_pkg + "s"
print("\nInstalling summary")
print("=" * 79)
print("Total {0} {1} will be upgraded.\n".format(len(pkg_for_upg), msg_pkg))
read = raw_input("Would you like to upgrade [Y/n]? ")
if read == "Y" or read == "y": if read == "Y" or read == "y":
if not os.path.exists(build_path): if not os.path.exists(build_path):
os.mkdir(build_path) os.mkdir(build_path)
os.chdir(build_path) os.chdir(build_path)
pkg_for_install = ("{0}-{1}".format(name, sbo_version)) for name, version in zip(pkg_name, sbo_ver):
script = get_file(sbo_dwn, "/") pkg_for_install = ("{0}-{1}".format(name, version))
source = get_file(source_dwn, "/") sbo_url = sbo_search_pkg(name)
print("\n{0}Start -->{1}\n".format(colors.GREEN, colors.ENDC)) sbo_dwn = sbo_slackbuild_dwn(sbo_url, name)
subprocess.call("wget -N {0} {1}".format(sbo_dwn, source_dwn), shell=True) src_dwn = sbo_source_dwn(name).split()
extra = [] script = get_file(sbo_dwn, "/")
if extra_dwn: print("\n{0}Start -->{1} {2}\n".format(colors.GREEN, colors.ENDC, name))
for src in extra_dwn.split(): subprocess.call("wget -N {0}".format(sbo_dwn), shell=True)
sources = []
for src in src_dwn:
subprocess.call("wget -N {0}".format(src), shell=True) subprocess.call("wget -N {0}".format(src), shell=True)
extra.append(get_file(src, "/")) sources.append(get_file(src, "/"))
build_package(script, source, extra, build_path) build_package(script, sources, build_path)
binary = ("{0}{1}{2}{3}{4}".format( binary = ("{0}{1}{2}{3}{4}{5}".format(
tmp, pkg_for_install, sbo_arch, sbo_tag, sbo_filetype).split()) tmp, pkg_for_install, sbo_arch, build, sbo_tag, sbo_filetype).split())
pkg_upgrade(binary) print("{0}[ Upgrading ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, name))
pkg_upgrade(binary)
print("Completed!\n")
else: else:
print("\nPackage {0}-{1} is up to date\n".format(name, sbo_file_version)) print("\nAll SBo packages are up to date\n")
else:
sys.stdout.write("Done\n")
print("\nNo SBo packages found\n")
except KeyboardInterrupt:
print # new line at exit
sys.exit()

View file

@ -29,8 +29,9 @@ from slpkg.messages import pkg_not_found, template
from slpkg.pkg.find import find_package from slpkg.pkg.find import find_package
from greps import sbo_requires_pkg from init import initialization
from search import sbo_search_pkg from search import sbo_search_pkg
from greps import sbo_requires_pkg
from download import sbo_slackbuild_dwn from download import sbo_slackbuild_dwn
dep_results = [] dep_results = []
@ -48,14 +49,13 @@ def sbo_dependencies_pkg(name):
bol, eol = "\n", "\n" bol, eol = "\n", "\n"
pkg_not_found(bol, name, message, eol) pkg_not_found(bol, name, message, eol)
else: else:
sbo_req = sbo_requires_pkg(sbo_url, name) dependencies = sbo_requires_pkg(sbo_url, name)
dependencies = sbo_req.split()
if dependencies: if dependencies:
dep_results.append(dependencies) dep_results.append(dependencies)
for line in dependencies: for dep in dependencies:
sys.stdout.write(".") sys.stdout.write(".")
sys.stdout.flush() sys.stdout.flush()
sbo_dependencies_pkg(line) sbo_dependencies_pkg(dep)
return dep_results return dep_results
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print # new line at exit
@ -66,6 +66,7 @@ def pkg_tracking(name):
Print tree of dependencies Print tree of dependencies
''' '''
sys.stdout.write("Reading package lists ...") sys.stdout.write("Reading package lists ...")
initialization()
dependencies_list = sbo_dependencies_pkg(name) dependencies_list = sbo_dependencies_pkg(name)
if dependencies_list is None: if dependencies_list is None:
pass pass

View file

@ -26,35 +26,26 @@ import os
from slpkg.url_read import url_read from slpkg.url_read import url_read
from slpkg.__metadata__ import arch, lib_path from slpkg.__metadata__ import arch, lib_path
def sbo_source_dwn(sbo_url, name): def sbo_source_dwn(name):
''' '''
Grep source downloads links Grep sources downloads links
''' '''
read_info = url_read(sbo_url + name + ".info")
if arch == "x86_64": if arch == "x86_64":
for line in read_info.splitlines(): for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"):
if line.startswith("DOWNLOAD_x86_64="): if arch == "x86_64":
if len(line) > 18: if line.startswith("SLACKBUILD NAME: "):
return line[17:-1].strip() sbo_name = line[17:].strip()
for line in read_info.splitlines(): if line.startswith("SLACKBUILD DOWNLOAD_x86_64: "):
if line.startswith("DOWNLOAD="): if sbo_name == name:
return line[10:-1].strip() if line[28:].strip():
return line[28:].strip()
def sbo_extra_dwn(sbo_url, name): for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"):
''' if line.startswith("SLACKBUILD NAME: "):
Grep extra source downloads links sbo_name = line[17:].strip()
''' if line.startswith("SLACKBUILD DOWNLOAD: "):
read_info = url_read(sbo_url + name + ".info") if sbo_name == name:
extra = [] return line[21:].strip()
for line in read_info.split():
if line.endswith("\""):
line = line[:-1].strip()
if line.startswith("http"):
extra.append(line.strip())
if line.startswith("ftp"):
extra.append(line.strip())
return extra
def sbo_requires_pkg(sbo_url, name): def sbo_requires_pkg(sbo_url, name):
''' '''
Grep package requirements Grep package requirements
@ -62,15 +53,15 @@ def sbo_requires_pkg(sbo_url, name):
read_info = url_read(sbo_url + name + ".info") read_info = url_read(sbo_url + name + ".info")
for line in read_info.splitlines(): for line in read_info.splitlines():
if line.startswith("REQUIRES=\""): if line.startswith("REQUIRES=\""):
return line[10:-1].strip() return line[10:-1].strip().split()
def sbo_version_pkg(name): def sbo_version_pkg(name):
sbo_name, sbo_ver = [], [] '''
Grep package verion
'''
for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"): for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"):
if line.startswith("SLACKBUILD NAME: "): if line.startswith("SLACKBUILD NAME: "):
sbo_name.append(line[17:].strip()) sbo_name = line[17:].strip()
if line.startswith("SLACKBUILD VERSION: "): if line.startswith("SLACKBUILD VERSION: "):
sbo_ver.append(line[20:].strip()) if sbo_name == name:
for sbo, ver in zip(sbo_name, sbo_ver): return line[20:].strip()
if sbo == name:
return ver

View file

@ -30,23 +30,16 @@ from slpkg.__metadata__ import lib_path
from slpkg.slack.slack_version import slack_ver from slpkg.slack.slack_version import slack_ver
from init import initialization
def sbo_search_pkg(name): def sbo_search_pkg(name):
''' '''
Search for package path from SLACKBUILDS.TXT file Search for package path from SLACKBUILDS.TXT file
''' '''
initialization()
try: try:
sbo_location = []
sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(slack_ver())) sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(slack_ver()))
for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"): for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"):
if line.startswith("SLACKBUILD LOCATION"): if line.startswith("SLACKBUILD LOCATION"):
sbo_location.append(line.replace("SLACKBUILD LOCATION: ./", "")) if name == get_file(line[23:].strip(), "/").replace("\n", ""):
for location in sbo_location: return sbo_url + line[23:].strip() + "/"
location = location.replace("\n", "")
if get_file(location, "/") == name:
return sbo_url + location.replace(name, "") + name + "/"
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print # new line at exit
sys.exit() sys.exit()

View file

@ -28,18 +28,19 @@ import subprocess
from slpkg.colors import colors from slpkg.colors import colors
from slpkg.functions import get_file from slpkg.functions import get_file
from slpkg.messages import pkg_not_found, pkg_found, template from slpkg.messages import pkg_not_found, pkg_found, template
from slpkg.__metadata__ import sbo_arch, sbo_tag, sbo_filetype, arch from slpkg.__metadata__ import sbo_arch, build, sbo_tag, sbo_filetype
from slpkg.__metadata__ import tmp, pkg_path, build_path, log_path, sp from slpkg.__metadata__ import tmp, pkg_path, build_path, log_path, sp
from slpkg.pkg.find import find_package from slpkg.pkg.find import find_package
from slpkg.pkg.build import build_package from slpkg.pkg.build import build_package
from slpkg.pkg.manager import pkg_upgrade from slpkg.pkg.manager import pkg_upgrade
from init import initialization
from search import sbo_search_pkg from search import sbo_search_pkg
from file_size import server_file_size from file_size import server_file_size
from download import sbo_slackbuild_dwn from download import sbo_slackbuild_dwn
from dependency import sbo_dependencies_pkg from dependency import sbo_dependencies_pkg
from greps import sbo_source_dwn, sbo_extra_dwn, sbo_version_pkg from greps import sbo_source_dwn, sbo_version_pkg
def sbo_build(name): def sbo_build(name):
''' '''
@ -47,6 +48,7 @@ def sbo_build(name):
dependencies dependencies
''' '''
sys.stdout.write("Building dependency tree ...") sys.stdout.write("Building dependency tree ...")
initialization()
dependencies_list = sbo_dependencies_pkg(name) dependencies_list = sbo_dependencies_pkg(name)
if dependencies_list == None: if dependencies_list == None:
pass pass
@ -55,7 +57,7 @@ def sbo_build(name):
if not os.path.exists(build_path): if not os.path.exists(build_path):
os.mkdir(build_path) os.mkdir(build_path)
os.chdir(build_path) os.chdir(build_path)
requires, dependencies, extra = [], [], [] requires, dependencies = [], []
requires.append(name) requires.append(name)
for pkg in dependencies_list: for pkg in dependencies_list:
requires += pkg requires += pkg
@ -70,54 +72,73 @@ def sbo_build(name):
pkg_sum = 1 pkg_sum = 1
else: else:
pkg_for_install.append(colors.RED + name + colors.ENDC) pkg_for_install.append(colors.RED + name + colors.ENDC)
sbo_url = sbo_search_pkg(name)
sbo_ver = sbo_version_pkg(name) sbo_ver = sbo_version_pkg(name)
sys.stdout.write("Done\n") sys.stdout.write("Done\n")
src = sbo_source_dwn(name)
arch = os.uname()[4]
if arch == "x86_64":
arch = "x86_64"
elif arch.startswith("i") and arch.endswith("86"):
arch = "i486"
elif "arm" in arch:
arch = "arm"
else:
arch = os.uname()[4]
if "UNSUPPORTED" in src:
arch = "UNSUPPORTED"
elif "UNTESTED" in src:
arch = "UNTESTED"
print("The following packages will be automatically installed or upgraded with new version:\n") print("The following packages will be automatically installed or upgraded with new version:\n")
template(78) template(78)
print "| Package", " "*15, "Version", " "*5, "Arch", " "*7, "Repository" print "| Package", " "*31, "Version", " "*7, "Arch", " "*5, "Repository"
template(78) template(78)
print("Installing:") print("Installing:")
print " ", "".join(pkg_for_install), " "*(22-len(name)), sbo_ver, " "*( print " ", "".join(pkg_for_install), " "*(38-len(name)), sbo_ver, " "*(
12-len(sbo_ver)), arch, " "*(11-len(arch)), "SBo" 14-len(sbo_ver)), arch, " "*(9-len(arch)), "SBo"
print("Installing for dependencies:") print("Installing for dependencies:")
for dep in dependencies[:-1]: for dep in dependencies[:-1]:
sbo_url = sbo_search_pkg(dep)
sbo_ver = sbo_version_pkg(dep) sbo_ver = sbo_version_pkg(dep)
if find_package(dep + sp, pkg_path): if find_package(dep + sp, pkg_path):
print " ", colors.GREEN + dep + colors.ENDC, " "*(22-len(dep)), sbo_ver, " "*( print " ", colors.GREEN + dep + colors.ENDC, " "*(38-len(dep)), sbo_ver, " "*(
12-len(sbo_ver)), arch, " "*(11-len(arch)), "SBo" 14-len(sbo_ver)), arch, " "*(9-len(arch)), "SBo"
pkg_sum += 1 pkg_sum += 1
else: else:
print " ", colors.RED + dep + colors.ENDC, " "*(22-len(dep)), sbo_ver, " "*( print " ", colors.RED + dep + colors.ENDC, " "*(38-len(dep)), sbo_ver, " "*(
12-len(sbo_ver)), arch, " "*(11-len(arch)), "SBo" 14-len(sbo_ver)), arch, " "*(9-len(arch)), "SBo"
msg_pkg = "package"
msg_2_pkg = msg_pkg
if len(dependencies) > 1:
msg_pkg = msg_pkg + "s"
if len(dependencies) - pkg_sum > 1:
msg_2_pkg = msg_2_pkg + "s"
print("\nInstalling summary") print("\nInstalling summary")
print("="*79) print("="*79)
print("Total {0} packages.".format(len(dependencies))) print("Total {0} {1}.".format(len(dependencies), msg_pkg))
print("{0} packages will be installed, {1} allready installed.".format( print("{0} {1} will be installed, {2} allready installed.".format(
(len(dependencies) - pkg_sum), pkg_sum)) (len(dependencies) - pkg_sum), msg_2_pkg, pkg_sum))
read = raw_input("\nDo you want to continue [Y/n]? ") read = raw_input("\nDo you want to continue [Y/n]? ")
if read == "Y" or read == "y": if read == "Y" or read == "y":
for pkg in dependencies: for pkg in dependencies:
sbo_url = sbo_search_pkg(pkg)
sbo_version = sbo_version_pkg(pkg) sbo_version = sbo_version_pkg(pkg)
sbo_file = "".join(find_package(pkg + sp, pkg_path)) sbo_file = "".join(find_package(pkg + sp, pkg_path))
sbo_file_version = sbo_file[len(pkg) + 1:-len(arch) - 7] sbo_file_version = sbo_file[len(pkg) + 1:-len(arch) - 7]
if sbo_version > sbo_file_version: if sbo_version > sbo_file_version:
prgnam = ("{0}-{1}".format(pkg, sbo_version_pkg(pkg))) prgnam = ("{0}-{1}".format(pkg, sbo_version_pkg(pkg)))
sbo_url = sbo_search_pkg(pkg)
sbo_link = sbo_slackbuild_dwn(sbo_url, pkg) sbo_link = sbo_slackbuild_dwn(sbo_url, pkg)
src_link = sbo_source_dwn(sbo_url, pkg) src_link = sbo_source_dwn(pkg).split()
ext_link = sbo_extra_dwn(sbo_url, pkg)
script = get_file(sbo_link, "/") script = get_file(sbo_link, "/")
source = get_file(src_link, "/") print("\n{0}Start -->{1} {2}\n".format(colors.GREEN, colors.ENDC, pkg))
subprocess.call("wget -N {0} {1}".format(sbo_link, src_link), shell=True) subprocess.call("wget -N {0}".format(sbo_link), shell=True)
if ext_link: sources = []
for src in ext_link: for src in src_link:
subprocess.call("wget -N {0}".format(src), shell=True) subprocess.call("wget -N {0}".format(src), shell=True)
extra.append(get_file(src, "/")) sources.append(get_file(src, "/"))
build_package(script, source, extra, build_path) build_package(script, sources, build_path)
binary = ("{0}{1}{2}{3}{4}".format( binary = ("{0}{1}{2}{3}{4}{5}".format(
tmp, prgnam, sbo_arch, sbo_tag, sbo_filetype).split()) tmp, prgnam, sbo_arch, build, sbo_tag, sbo_filetype).split())
print("{0}[ Installing ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, pkg))
pkg_upgrade(binary) pkg_upgrade(binary)
else: else:
template(78) template(78)
@ -127,16 +148,17 @@ def sbo_build(name):
Write dependencies in a log file Write dependencies in a log file
into directory `/var/log/slpkg/dep/` into directory `/var/log/slpkg/dep/`
''' '''
dep_path = log_path + "dep/" if find_package(name + sp, pkg_path):
if not os.path.exists(dep_path): dep_path = log_path + "dep/"
os.mkdir(dep_path) if not os.path.exists(dep_path):
if os.path.isfile(dep_path + name): os.mkdir(dep_path)
os.remove(dep_path + name) if os.path.isfile(dep_path + name):
if len(dependencies) > 1: os.remove(dep_path + name)
f = open(dep_path + name, "w") if len(dependencies) > 1:
for dep in dependencies: f = open(dep_path + name, "w")
f.write(dep + "\n") for dep in dependencies:
f.close() f.write(dep + "\n")
f.close()
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print # new line at exit
sys.exit() sys.exit()

View file

@ -28,8 +28,8 @@ import subprocess
from slpkg.colors import colors from slpkg.colors import colors
from slpkg.functions import get_file from slpkg.functions import get_file
from slpkg.__metadata__ import tmp, pkg_path, slpkg_tmp, sp from slpkg.__metadata__ import tmp, pkg_path, slpkg_tmp, sp
from slpkg.__metadata__ import sbo_arch, sbo_tag, sbo_filetype, build_path from slpkg.messages import pkg_not_found, pkg_found, view_sbo, template
from slpkg.messages import s_user, pkg_not_found, pkg_found, view_sbo, template from slpkg.__metadata__ import sbo_arch, build, sbo_tag, sbo_filetype, build_path
from slpkg.pkg.build import build_package from slpkg.pkg.build import build_package
from slpkg.pkg.find import find_package from slpkg.pkg.find import find_package
@ -37,6 +37,7 @@ from slpkg.pkg.manager import pkg_upgrade
from read import * from read import *
from greps import * from greps import *
from init import initialization
from search import sbo_search_pkg from search import sbo_search_pkg
from download import sbo_slackbuild_dwn from download import sbo_slackbuild_dwn
@ -47,6 +48,7 @@ def sbo_network(name):
''' '''
rdm_path = slpkg_tmp + "readme/" rdm_path = slpkg_tmp + "readme/"
sys.stdout.write("Reading package lists ...") sys.stdout.write("Reading package lists ...")
initialization()
sbo_url = sbo_search_pkg(name) sbo_url = sbo_search_pkg(name)
if sbo_url is None: if sbo_url is None:
sys.stdout.write ("Done\n") sys.stdout.write ("Done\n")
@ -59,12 +61,9 @@ def sbo_network(name):
sys.stdout.write ("Done\n") sys.stdout.write ("Done\n")
sbo_req = sbo_requires_pkg(sbo_url, name) sbo_req = sbo_requires_pkg(sbo_url, name)
sbo_dwn = sbo_slackbuild_dwn(sbo_url, name) sbo_dwn = sbo_slackbuild_dwn(sbo_url, name)
sbo_version = sbo_version_pkg(name) source_dwn = sbo_source_dwn(name).split()
source_dwn = sbo_source_dwn(sbo_url, name) view_sbo(name, sbo_url, get_file(sbo_dwn, "/"),
extra_dwn = " ".join(sbo_extra_dwn(sbo_url, name)) ", ".join([get_file(src, "/") for src in source_dwn]), sbo_req)
view_sbo(name, sbo_url, get_file(sbo_dwn, "/"), get_file(source_dwn, "/"),
", ".join([get_file(extra_dwn, "/") for extra_dwn in extra_dwn.split()]),
sbo_req)
while True: while True:
try: try:
read = raw_input("_ ") read = raw_input("_ ")
@ -72,11 +71,11 @@ def sbo_network(name):
print # new line at exit print # new line at exit
break break
if read == "D" or read == "d": if read == "D" or read == "d":
print("\n{0}Start -->{1}\n".format(colors.GREEN, colors.ENDC)) print("\n{0}Start --> {1}{2}\n".format(colors.GREEN, colors.ENDC, name))
subprocess.call("wget -N {0} {1}".format(sbo_dwn, source_dwn), shell=True) subprocess.call("wget -N {0}".format(sbo_dwn), shell=True)
if extra_dwn: for src in source_dwn:
for src in extra_dwn.split(): subprocess.call("wget -N {0}".format(src), shell=True)
subprocess.call("wget -N {0}".format(src), shell=True) print("Complete!\n")
break break
elif read == "R" or read == "r": elif read == "R" or read == "r":
site = "README" site = "README"
@ -94,41 +93,44 @@ def sbo_network(name):
subprocess.call("less {0}{1}{2}".format(rdm_path, name, site), shell=True) subprocess.call("less {0}{1}{2}".format(rdm_path, name, site), shell=True)
os.remove("{0}{1}{2}".format(rdm_path, name, site)) os.remove("{0}{1}{2}".format(rdm_path, name, site))
elif read == "B" or read == "b": elif read == "B" or read == "b":
sources = []
os.chdir(build_path) os.chdir(build_path)
script = get_file(sbo_dwn, "/") script = get_file(sbo_dwn, "/")
source = get_file(source_dwn, "/") print("\n{0}Start -->{1} {2}\n".format(colors.GREEN, colors.ENDC, name))
print("\n{0}Start -->{1}\n".format(colors.GREEN, colors.ENDC)) subprocess.call("wget -N {0}".format(sbo_dwn), shell=True)
subprocess.call("wget -N {0} {1}".format(sbo_dwn, source_dwn), shell=True) for src in source_dwn:
extra = [] subprocess.call("wget -N {0}".format(src), shell=True)
if extra_dwn: sources.append(get_file(src, "/"))
for src in extra_dwn.split(): build_package(script, sources, build_path)
subprocess.call("wget -N {0}".format(src), shell=True) print("Complete!\n")
extra.append(get_file(src, "/"))
build_package(script, source, extra, build_path)
break break
elif read == "I" or read == "i": elif read == "I" or read == "i":
os.chdir(build_path) sbo_version = sbo_version_pkg(name)
pkg_for_install = ("{0}-{1}".format(name, sbo_version))
if find_package(name + sp, pkg_path) == []: if find_package(name + sp, pkg_path) == []:
sources = []
os.chdir(build_path)
pkg_for_install = ("{0}-{1}".format(name, sbo_version))
print("\n{0}Start -->{1} {2}\n".format(colors.GREEN, colors.ENDC, name))
subprocess.call("wget -N {0}".format(sbo_dwn), shell=True)
script = get_file(sbo_dwn, "/") script = get_file(sbo_dwn, "/")
source = get_file(source_dwn, "/") for src in source_dwn:
print("\n{0}Start -->{1}\n".format(colors.GREEN, colors.ENDC))
subprocess.call("wget -N {0} {1}".format(sbo_dwn, source_dwn), shell=True)
extra = []
if extra_dwn:
for src in extra_dwn.split():
subprocess.call("wget -N {0}".format(src), shell=True) subprocess.call("wget -N {0}".format(src), shell=True)
extra.append(get_file(src, "/")) sources.append(get_file(src, "/"))
build_package(script, source, extra, build_path) build_package(script, sources, build_path)
binary = ("{0}{1}{2}{3}{4}".format( binary = ("{0}{1}{2}{3}{4}{5}".format(
tmp, pkg_for_install, sbo_arch, sbo_tag, sbo_filetype).split()) tmp, pkg_for_install, sbo_arch, build, sbo_tag, sbo_filetype).split())
print("{0}[ Installing ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, name))
pkg_upgrade(binary) pkg_upgrade(binary)
if find_package(name + sp, pkg_path):
print("Complete!\n")
else:
print("The package {0} may not install successfully".format(name))
break break
else: else:
template(78) template(78)
pkg_found(name, sbo_version) pkg_found(name, sbo_version)
template(78) template(78)
print # new line at end
break break
else: else:
break break

View file

@ -29,7 +29,7 @@ import subprocess
from slpkg.colors import colors from slpkg.colors import colors
from slpkg.url_read import url_read from slpkg.url_read import url_read
from slpkg.messages import pkg_not_found, template from slpkg.messages import pkg_not_found, template
from slpkg.__metadata__ import slpkg_tmp, pkg_path, arch, sp from slpkg.__metadata__ import slpkg_tmp, pkg_path, sp
from slpkg.pkg.manager import pkg_upgrade, pkg_reinstall from slpkg.pkg.manager import pkg_upgrade, pkg_reinstall
@ -40,9 +40,9 @@ def install(slack_pkg):
Install packages from official Slackware distribution Install packages from official Slackware distribution
''' '''
try: try:
comp_sum, uncomp_sum = [], []
dwn_list, comp_size, uncomp_size = [], [], []
install_all, package_name, package_location = [], [], [] install_all, package_name, package_location = [], [], []
comp_list, uncomp_list, comp_sum, uncomp_sum = [], [], [], []
dwn_list, dwn_packages, comp_size, uncomp_size = [], [], [], []
tmp_path = slpkg_tmp + "packages/" tmp_path = slpkg_tmp + "packages/"
pkg_sum = 0 pkg_sum = 0
if not os.path.exists(tmp_path): if not os.path.exists(tmp_path):
@ -54,14 +54,14 @@ def install(slack_pkg):
sys.stdout.write ("Reading package lists ...") sys.stdout.write ("Reading package lists ...")
sys.stdout.flush() sys.stdout.flush()
PACKAGE_TXT = url_read(mirrors(name="PACKAGES.TXT", location="")) PACKAGE_TXT = url_read(mirrors(name="PACKAGES.TXT", location=""))
index, toolbar_width = 0, 600 index, toolbar_width = 0, 800
for line in PACKAGE_TXT.splitlines(): for line in PACKAGE_TXT.splitlines():
index += 1 index += 1
if index == toolbar_width: if index == toolbar_width:
sys.stdout.write(".") sys.stdout.write(".")
sys.stdout.flush() sys.stdout.flush()
toolbar_width += 600 toolbar_width += 800
time.sleep(0.05) time.sleep(0.00888)
if line.startswith("PACKAGE NAME"): if line.startswith("PACKAGE NAME"):
package_name.append(line[15:].strip()) package_name.append(line[15:].strip())
if line.startswith("PACKAGE LOCATION"): if line.startswith("PACKAGE LOCATION"):
@ -70,61 +70,45 @@ def install(slack_pkg):
comp_size.append(line[28:-2].strip()) comp_size.append(line[28:-2].strip())
if line.startswith("PACKAGE SIZE (uncompressed): "): if line.startswith("PACKAGE SIZE (uncompressed): "):
uncomp_size.append(line[30:-2].strip()) uncomp_size.append(line[30:-2].strip())
for loc, name in zip(package_location, package_name): for loc, name, comp, uncomp in zip(package_location, package_name, comp_size, uncomp_size):
dwn_list.append("{0}{1}/{2}".format(mirrors("",""), loc, name)) if slack_pkg in name:
for name, size in zip(package_name, comp_size): dwn_list.append("{0}{1}/{2}".format(mirrors("",""), loc, name))
comp_list.append("{0}{1}".format(name, size)) install_all.append(name)
for name, size in zip(package_name, uncomp_size): comp_sum.append(comp)
uncomp_list.append("{0}{1}".format(name, size)) uncomp_sum.append(uncomp)
sys.stdout.write("Done\n\n") sys.stdout.write("Done\n\n")
for search in package_name: if install_all:
if slack_pkg in search:
install_all.append(search)
if install_all == []:
bol, eol = "", "\n"
message = "No matching"
pkg_not_found(bol, slack_pkg, message, eol)
else:
template(78) template(78)
print "| Package", " "*33, "Arch", " "*3, "Build", " ", "Repos", " ", "Size" print "| Package", " "*33, "Arch", " "*3, "Build", " ", "Repos", " ", "Size"
template(78) template(78)
print("Installing:") print("Installing:")
for pkg in package_name: for pkg, comp in zip(install_all, comp_sum):
if slack_pkg in pkg: if "-noarch-" in pkg:
for size in comp_list: arch = "noarch"
if pkg in size: elif "-x86_64-" in pkg:
Kb = size.replace(pkg, "") arch = "x86_64"
if "-noarch-" in pkg: elif "-i386-" in pkg:
arch = "noarch" arch = "i386"
elif sp+os.uname()[4]+sp in pkg: elif "-i486-" in pkg:
arch = os.uname()[4] arch = "i486"
elif "-i486-" in pkg: elif "-i686-" in pkg:
arch = "i486" arch = "i686"
elif "-i686-" in pkg: elif "-x86-" in pkg:
arch = "i686" arch = "x86"
elif "-x86-" in pkg: elif "-fw-" in pkg:
arch = "x86" arch = "fw"
elif "-fw-" in pkg: else:
arch = "fw" arch = ""
else: if os.path.isfile(pkg_path + pkg[:-4]):
arch = "" pkg_sum += 1
if os.path.isfile(pkg_path + pkg[:-4]): SC, EC = colors.GREEN, colors.ENDC
pkg_sum += 1 else:
SC, EC = colors.GREEN, colors.ENDC SC, EC = colors.RED, colors.ENDC
else: print " ", SC + pkg[:-5].replace(sp+arch+sp, "") + EC, " "*(
SC, EC = colors.RED, colors.ENDC 40-len(pkg[:-5].replace(sp+arch+sp, ""))), arch, " "*(
print " ", SC + pkg[:-5].replace(sp+arch+sp, "") + EC, " "*( 7-len(arch)), pkg[-5:-4].replace(sp+arch+sp, ""), " "*(
40-len(pkg[:-5].replace(sp+arch+sp, ""))), arch, " "*( 6-len(pkg[-5:-4].replace(sp+arch+sp, ""))), "Slack", " ", comp, " "*(
7-len(arch)), pkg[-5:-4].replace(sp+arch+sp, ""), " "*( 3-len(comp)), "K"
6-len(pkg[-5:-4].replace(sp+arch+sp, ""))), "Slack", " ", Kb, " "*(
3-len(Kb)), "K"
for install in install_all:
for comp in comp_list:
if install == comp[:-(len(comp)-len(install))]:
comp_sum.append(comp.replace(install, ""))
for uncomp in uncomp_list:
if install == uncomp[:-(len(uncomp)-len(install))]:
uncomp_sum.append(uncomp.replace(install, ""))
comp_unit, uncomp_unit = "Mb", "Mb" comp_unit, uncomp_unit = "Mb", "Mb"
compressed = round((sum(map(float, comp_sum)) * 0.0001220703125), 2) compressed = round((sum(map(float, comp_sum)) * 0.0001220703125), 2)
uncompressed = round((sum(map(float, uncomp_sum)) * 0.0001220703125), 2) uncompressed = round((sum(map(float, uncomp_sum)) * 0.0001220703125), 2)
@ -150,22 +134,19 @@ def install(slack_pkg):
uncompressed, uncomp_unit)) uncompressed, uncomp_unit))
read = raw_input("\nWould you like to install [Y/n]? ") read = raw_input("\nWould you like to install [Y/n]? ")
if read == "Y" or read == "y": if read == "Y" or read == "y":
for dwn in dwn_list:
subprocess.call("wget -N --directory-prefix={0} {1} {2}.asc".format(
tmp_path, dwn, dwn), shell=True)
for install in install_all: for install in install_all:
for dwn in dwn_list:
if "/" + install in dwn:
subprocess.call(
"wget -N --directory-prefix={0} {1} {2}.asc".format(
tmp_path, dwn, dwn), shell=True)
for install in install_all:
print install
if not os.path.isfile(pkg_path + install[:-4]): if not os.path.isfile(pkg_path + install[:-4]):
print("{0}[ installing ] --> {1}{2}".format( print("{0}[ installing ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, install)) colors.GREEN, colors.ENDC, install))
pkg_upgrade((tmp_path + install).split()) pkg_upgrade((tmp_path + install).split())
else: else:
print("{0}[ reinstalling ] --> {1}{2}".format( print("{0}[ reinstalling ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, install)) colors.GREEN, colors.ENDC, install))
pkg_reinstall((tmp_path + install).split()) pkg_reinstall((tmp_path + install).split())
print("Completed!\n")
read = raw_input("Removal downloaded packages [Y/n]? ") read = raw_input("Removal downloaded packages [Y/n]? ")
if read == "Y" or read == "y": if read == "Y" or read == "y":
for remove in install_all: for remove in install_all:
@ -179,6 +160,10 @@ def install(slack_pkg):
else: else:
print("\nThere are packages in directory {0}\n".format( print("\nThere are packages in directory {0}\n".format(
tmp_path)) tmp_path))
else:
bol, eol = "", "\n"
message = "No matching"
pkg_not_found(bol, slack_pkg, message, eol)
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print # new line at exit
sys.exit() sys.exit()

View file

@ -41,9 +41,9 @@ def patches():
Install new patches from official Slackware mirrors Install new patches from official Slackware mirrors
''' '''
try: try:
comp_sum, uncomp_sum = [], []
dwn_patches, comp_size, uncomp_size = [], [], []
upgrade_all, package_name, package_location = [], [], [] upgrade_all, package_name, package_location = [], [], []
comp_list, uncomp_list, comp_sum, uncomp_sum = [], [], [], []
dwn_list, dwn_patches, comp_size, uncomp_size = [], [], [], []
pch_path = slpkg_tmp + "patches/" pch_path = slpkg_tmp + "patches/"
slack_arch = "" slack_arch = ""
if not os.path.exists(pch_path): if not os.path.exists(pch_path):
@ -69,15 +69,12 @@ def patches():
comp_size.append(line[28:-2].strip()) comp_size.append(line[28:-2].strip())
if line.startswith("PACKAGE SIZE (uncompressed): "): if line.startswith("PACKAGE SIZE (uncompressed): "):
uncomp_size.append(line[30:-2].strip()) uncomp_size.append(line[30:-2].strip())
for loc, name in zip(package_location, package_name): for loc, name, comp, uncomp in zip(package_location, package_name, comp_size, uncomp_size):
dwn_list.append("{0}{1}/{2}".format(mirrors("",""), loc, name)) if not os.path.isfile(pkg_path + name[:-4]):
for name, size in zip(package_name, comp_size): dwn_patches.append("{0}{1}/{2}".format(mirrors("",""), loc, name))
comp_list.append("{0}{1}".format(name, size)) comp_sum.append(comp)
for name, size in zip(package_name, uncomp_size): uncomp_sum.append(uncomp)
uncomp_list.append("{0}{1}".format(name, size)) upgrade_all.append(name)
for pkg in package_name:
if not os.path.isfile(pkg_path + pkg[:-4]):
upgrade_all.append(pkg)
sys.stdout.write("Done\n") sys.stdout.write("Done\n")
if upgrade_all: if upgrade_all:
print("\nThese packages need upgrading:\n") print("\nThese packages need upgrading:\n")
@ -85,44 +82,33 @@ def patches():
print "| Package", " "*33, "Arch", " "*3, "Build", " ", "Repos", " ", "Size" print "| Package", " "*33, "Arch", " "*3, "Build", " ", "Repos", " ", "Size"
template(78) template(78)
print("Upgrading:") print("Upgrading:")
for upgrade in upgrade_all: for upgrade, size in zip(upgrade_all, comp_sum):
for size in comp_list: if "-noarch-" in upgrade:
if upgrade in size: arch = "noarch"
Kb = size.replace(upgrade, "") elif "-x86_64-" in upgrade:
if "-noarch-" in upgrade: arch = "x86_64"
arch = "noarch" elif "-i386-" in upgrade:
elif sp+os.uname()[4]+sp in upgrade: arch = "i386"
arch = os.uname()[4] elif "-i486-" in upgrade:
elif "-i486-" in upgrade: arch = "i486"
arch = "i486" elif "-i686-" in upgrade:
elif "-i686-" in upgrade: arch = "i686"
arch = "i686" elif "-x86-" in upgrade:
elif "-x86-" in upgrade: arch = "x86"
arch = "x86" elif "-fw-" in upgrade:
elif "-fw-" in upgrade: arch = "fw"
arch = "fw" else:
else: arch = ""
arch = "" if "_slack" in upgrade:
if "_slack" in upgrade: slack = "_slack" + slack_ver()
slack = "_slack" + slack_ver() else:
else: slack = ""
slack = "" print " ", upgrade[:-(5+len(slack))].replace(
print " ", upgrade[:-(5+len(slack))].replace( sp+arch+sp, ""), " "*(40-len(upgrade[:-(
sp+arch+sp, ""), " "*(40-len(upgrade[:-( 5+len(slack))].replace(sp+arch+sp, ""))), arch, " "*(
5+len(slack))].replace(sp+arch+sp, ""))), arch, " "*( 7-len(arch)), upgrade[-15:-14].replace(sp+arch+sp, ""), " "*(
7-len(arch)), upgrade[-15:-14].replace(sp+arch+sp, ""), " "*( 6-len(upgrade[-15:-14].replace(sp+arch+sp, ""))), "Slack", " ", size, " "*(
6-len(upgrade[-15:-14].replace(sp+arch+sp, ""))), "Slack", " ", Kb, " "*( 3-len(size)), "K"
3-len(Kb)), "K"
for dwn in dwn_list:
if "/" + upgrade in dwn:
dwn_patches.append(dwn)
for install in upgrade_all:
for comp in comp_list:
if install == comp[:-(len(comp)-len(install))]:
comp_sum.append(comp.replace(install, ""))
for uncomp in uncomp_list:
if install == uncomp[:-(len(uncomp)-len(install))]:
uncomp_sum.append(uncomp.replace(install, ""))
comp_unit, uncomp_unit = "Mb", "Mb" comp_unit, uncomp_unit = "Mb", "Mb"
compressed = round((sum(map(float, comp_sum)) * 0.0001220703125), 2) compressed = round((sum(map(float, comp_sum)) * 0.0001220703125), 2)
uncompressed = round((sum(map(float, uncomp_sum)) * 0.0001220703125), 2) uncompressed = round((sum(map(float, uncomp_sum)) * 0.0001220703125), 2)
@ -137,7 +123,7 @@ def patches():
msg_pkg = msg_pkg + "s" msg_pkg = msg_pkg + "s"
print("\nInstalling summary") print("\nInstalling summary")
print("="*79) print("="*79)
print("Total {0} {1} will be upgrading.".format(len(upgrade_all), msg_pkg)) print("Total {0} {1} will be upgraded.".format(len(upgrade_all), msg_pkg))
print("Need to get {0} {1} of archives.".format(compressed, comp_unit)) 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.".format( print("After this process, {0} {1} of additional disk space will be used.".format(
uncompressed, uncomp_unit)) uncompressed, uncomp_unit))
@ -155,6 +141,7 @@ def patches():
print("The kernel has been upgraded, reinstall `lilo` ...") print("The kernel has been upgraded, reinstall `lilo` ...")
subprocess.call("lilo", shell=True) subprocess.call("lilo", shell=True)
break break
print("Completed!\n")
read = raw_input("Removal downloaded packages [Y/n]? ") read = raw_input("Removal downloaded packages [Y/n]? ")
if read == "Y" or read == "y": if read == "Y" or read == "y":
for pkg in upgrade_all: for pkg in upgrade_all:

View file

@ -27,7 +27,7 @@ def slack_ver():
''' '''
Open file and read Slackware version Open file and read Slackware version
''' '''
f = open('/etc/slackware-version', 'r') f = open("/etc/slackware-version", "r")
sv = f.read() sv = f.read()
f.close() f.close()
return '.'.join(re.findall(r'\d+', sv)) return ".".join(re.findall(r"\d+", sv))