updated for version 1.7.5

This commit is contained in:
Dimitris Zlatanidis 2014-08-22 16:27:57 +03:00
parent 329b90d84b
commit b05603487f
18 changed files with 285 additions and 165 deletions

View file

@ -1,3 +1,12 @@
22-08-2014
Version 1.7.5.dev
[Feature] - Added report of packages will be installed the options
`slpkg -s sbo <package>`
`slpkg -s slack <package>`
`slpkg -c slack upgrade`
[Updated] - Fix mirrors for Slackware x86
17-08-2014
Version 1.7.4

View file

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

View file

@ -107,8 +107,22 @@ build and install with all dependencies :
$ slpkg -s sbo brasero
Building dependency tree...... Done
The following packages will be automatically installed or upgraded with new version:
+==============================================================================
| Package Version Arch Repository
+==============================================================================
Installing:
brasero 3.11.3 x86_64 SBo
Installing for dependencies:
orc 0.4.19 x86_64 SBo
gstreamer1 1.2.2 x86_64 SBo
gst1-plugins-base 1.2.2 x86_64 SBo
gst1-plugins-bad 1.2.2 x86_64 SBo
libunique 1.1.6 x86_64 SBo
orc gstreamer1 gst1-plugins-base gst1-plugins-bad libunique brasero
Installing summary
===============================================================================
Total 6 packages.
0 packages will be installed, 6 allready installed.
Do you want to continue [Y/n]? y
.
@ -143,10 +157,19 @@ download and install:
Reading package lists.............................. Done
[ install ] --> mozilla-firefox-24.1.0esr-x86_64-1
[ install ] --> mozilla-nss-3.15.2-x86_64-2
[ install ] --> mozilla-thunderbird-24.1.0-x86_64-1
+==============================================================================
| Package Arch Build Repos Size
+==============================================================================
Installing:
mozilla-firefox-24.1.0esr x86_64 1 Slack 23524 K
mozilla-nss-3.15.2 x86_64 2 Slack 1592 K
mozilla-thunderbird-24.1.0 x86_64 1 Slack 24208 K
Installing summary
===============================================================================
Total 3 packages.
3 packages will be installed, 0 allready installed.
Need to get 6.02 Mb of archives.
After this process, 15.72 Mb of additional disk space will be used.
@ -176,9 +199,6 @@ and also displays installed packages:
|
+--5 libunique
NOTE: green installed, red not installed
Check if your packages is up to date from slackbuilds.org:
.. code-block:: bash
@ -213,10 +233,17 @@ Check if your distribution is up to date from `Slackware official mirrors
These packages need upgrading:
[ upgrade ] --> dhcpcd-6.0.5-x86_64-3_slack14.1.txz
[ upgrade ] --> samba-4.1.11-x86_64-1_slack14.1.txz
[ upgrade ] --> xscreensaver-5.29-x86_64-1_slack14.1.txz
+==============================================================================
| Package Arch Build Repos Size
+==============================================================================
Upgrading:
dhcpcd-6.0.5 x86_64 3 Slack 92 K
samba-4.1.11 x86_64 1 Slack 9928 K
xscreensaver-5.29 x86_64 1 Slack 3896 K
Installing summary
===============================================================================
Total 3 package will be upgrading.
Need to get 1.70 Mb of archives.
After this process, 9.51 Mb of additional disk space will be used.
@ -243,7 +270,7 @@ Find packages from slackbuilds.org:
Download Download this package
Build Download and build this package
Install Download/Build/Install
Quit Quit
_
Auto tool to build package:

View file

@ -81,7 +81,7 @@ slackbuilds.org is up to date.
Find package from slackbuild.org with all dependencies,
download, build and install them if not installed or new version is
available. Even download and install official packages from Slackware
official mirrors and install.
official mirrors and install or reinstall if already installed.
.SS -i , install binary package
\fBslpkg\fP \fB-i\fP <\fIpackages.t?z\fP>
.PP
@ -148,13 +148,25 @@ $ \fBslpkg -t brasero\fP
|
--5: libunique
NOTE: green installed, red not installed
$ \fBslpkg -s sbo brasero\fP
Building dependency tree...... Done
The following packages will be automatically installed or upgraded with new version:
+==============================================================================
| Package Version Arch Repository
+==============================================================================
Installing:
brasero 3.11.3 x86_64 SBo
Installing for dependencies:
orc 0.4.19 x86_64 SBo
gstreamer1 1.2.2 x86_64 SBo
gst1-plugins-base 1.2.2 x86_64 SBo
gst1-plugins-bad 1.2.2 x86_64 SBo
libunique 1.1.6 x86_64 SBo
orc gstreamer1 gst1-plugins-base gst1-plugins-bad libunique brasero
Installing summary
===============================================================================
Total 6 packages.
0 packages will be installed, 6 allready installed.
Do you want to continue [Y/n]? y
.

View file

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

View file

@ -34,4 +34,4 @@ def get_file(link, char):
results.append(link[i])
if link[i] == char:
break
return "".join(results[::-1]).replace("/", "").strip(" ")
return "".join(results[::-1]).replace("/", "").strip()

View file

@ -136,7 +136,7 @@ def main():
else:
choices = ["upgrade"]
ext_err_args()
err1_args("".join(args.c), choices)
err1_args("".join(args.c[1]), choices)
else:
choices = ["sbo", "slack"]
ext_err_args()
@ -162,7 +162,7 @@ def main():
else:
choices = ["sbo", "slack"]
ext_err_args()
err1_args("".join(args.s), choices)
err1_args("".join(args.s[0]), choices)
elif len(args.s) < 2:
if "sbo" in args.s or "slack" in args.s:
ext_err_args()

View file

@ -84,18 +84,20 @@ def template(max):
def view_sbo(pkg, sbo_url, sbo_dwn, source_dwn, extra_dwn, sbo_req):
print # new line at start
template(78)
print ("| {0}Package {1}{2}{3} --> {4}".format(colors.GREEN,
print("| {0}Package {1}{2}{3} --> {4}".format(colors.GREEN,
colors.CYAN, pkg, colors.GREEN, colors.ENDC + sbo_url))
template(78)
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}Extra : {1}{2}".format(colors.GREEN, colors.ENDC, extra_dwn))
print ("| {0}Requirements : {1}{2}".format(colors.YELLOW, colors.ENDC,
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}Extra : {1}{2}".format(colors.GREEN, colors.ENDC, extra_dwn))
print("| {0}Requirements : {1}{2}".format(colors.YELLOW, colors.ENDC,
", ".join(sbo_req.split())))
template(78)
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 (" In{0}f{1}o View the Info file".format(colors.RED, colors.ENDC))
print (" {0}D{1}ownload Download this package".format(colors.RED, colors.ENDC))
print (" {0}B{1}uild Download and build".format(colors.RED, colors.ENDC))
print (" {0}I{1}nstall Download/Build/Install\n".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(" In{0}f{1}o View the Info file".format(colors.RED, colors.ENDC))
print(" {0}D{1}ownload Download this package".format(colors.RED, colors.ENDC))
print(" {0}B{1}uild Download and build".format(colors.RED, colors.ENDC))
print(" {0}I{1}nstall Download/Build/Install".format(colors.RED, colors.ENDC))
print(" {0}Q{1}uit Quit\n".format(colors.RED, colors.ENDC))

View file

@ -22,17 +22,17 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import getpass
import sys
import subprocess
from slpkg.pkg.build import *
from slpkg.pkg.find import find_package
from slpkg.pkg.build import build_package
from slpkg.pkg.manager import pkg_upgrade
from slpkg.colors import colors
from slpkg.functions import get_file
from slpkg.messages import pkg_not_found, s_user, template
from slpkg.__metadata__ import tmp, pkg_path, uname, arch, sp
from slpkg.messages import pkg_not_found, template
from slpkg.__metadata__ import tmp, pkg_path, arch, sp
from slpkg.__metadata__ import sbo_arch, sbo_tag, sbo_filetype, build_path
from search import sbo_search_pkg
@ -60,7 +60,7 @@ def sbo_check(name):
pkg_not_found(bol, name, message, eol)
else:
sys.stdout.write("Done\n")
sbo_version = sbo_version_pkg(sbo_url, name)
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)
@ -79,7 +79,6 @@ def sbo_check(name):
print # new line at exit
sys.exit()
if read == "Y" or read == "y":
s_user(getpass.getuser())
if not os.path.exists(build_path):
os.mkdir(build_path)
os.chdir(build_path)

View file

@ -25,11 +25,11 @@ import sys
from slpkg.colors import colors
from slpkg.__metadata__ import pkg_path, sp
from slpkg.messages import pkg_not_found, template, s_user
from slpkg.messages import pkg_not_found, template
from slpkg.pkg.find import find_package
from greps import *
from greps import sbo_requires_pkg
from search import sbo_search_pkg
from download import sbo_slackbuild_dwn
@ -98,4 +98,4 @@ def pkg_tracking(name):
else:
print(" |")
print(" {0}{1}: {2}{3}{4}".format("+--", index, colors.RED, pkg, colors.ENDC))
print("\n NOTE: green installed, red not installed\n")
print # new line at end

View file

@ -24,7 +24,7 @@
import os
from slpkg.url_read import url_read
from slpkg.__metadata__ import uname, arch
from slpkg.__metadata__ import arch, lib_path
def sbo_source_dwn(sbo_url, name):
'''
@ -35,10 +35,10 @@ def sbo_source_dwn(sbo_url, name):
for line in read_info.splitlines():
if line.startswith("DOWNLOAD_x86_64="):
if len(line) > 18:
return line[17:-1]
return line[17:-1].strip()
for line in read_info.splitlines():
if line.startswith("DOWNLOAD="):
return line[10:-1]
return line[10:-1].strip()
def sbo_extra_dwn(sbo_url, name):
'''
@ -48,11 +48,11 @@ def sbo_extra_dwn(sbo_url, name):
extra = []
for line in read_info.split():
if line.endswith("\""):
line = line[:-1].replace("\"", "")
line = line[:-1].strip()
if line.startswith("http"):
extra.append(line)
extra.append(line.strip())
if line.startswith("ftp"):
extra.append(line)
extra.append(line.strip())
return extra
def sbo_requires_pkg(sbo_url, name):
@ -62,13 +62,15 @@ def sbo_requires_pkg(sbo_url, name):
read_info = url_read(sbo_url + name + ".info")
for line in read_info.splitlines():
if line.startswith("REQUIRES=\""):
return line[10:-1]
return line[10:-1].strip()
def sbo_version_pkg(sbo_url, name):
'''
Grep package version
'''
read_info = url_read(sbo_url + name + ".info")
for line in read_info.splitlines():
if line.startswith("VERSION=\""):
return line[9:-1]
def sbo_version_pkg(name):
sbo_name, sbo_ver = [], []
for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"):
if line.startswith("SLACKBUILD NAME: "):
sbo_name.append(line[17:].strip())
if line.startswith("SLACKBUILD VERSION: "):
sbo_ver.append(line[20:].strip())
for sbo, ver in zip(sbo_name, sbo_ver):
if sbo == name:
return ver

View file

@ -23,7 +23,6 @@
import os
from slpkg.messages import s_user
from slpkg.url_read import url_read
from slpkg.__metadata__ import slpkg_tmp

View file

@ -41,12 +41,12 @@ def sbo_search_pkg(name):
sbo_location = []
sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(slack_ver()))
for line in open(lib_path + "sbo_repo/SLACKBUILDS.TXT", "r"):
if line.startswith('SLACKBUILD LOCATION'):
sbo_location.append(line.replace('SLACKBUILD LOCATION: ./', ''))
if line.startswith("SLACKBUILD LOCATION"):
sbo_location.append(line.replace("SLACKBUILD LOCATION: ./", ""))
for location in sbo_location:
location = location.replace('\n', '')
if get_file(location, '/') == name:
return sbo_url + location.replace(name, '') + name + "/"
location = location.replace("\n", "")
if get_file(location, "/") == name:
return sbo_url + location.replace(name, "") + name + "/"
except KeyboardInterrupt:
print # new line at exit
sys.exit()

View file

@ -27,9 +27,9 @@ import subprocess
from slpkg.colors import colors
from slpkg.functions import get_file
from slpkg.__metadata__ import tmp, pkg_path, build_path, sp
from slpkg.messages import pkg_not_found, pkg_found, template, s_user
from slpkg.__metadata__ import sbo_arch, sbo_tag, sbo_filetype, arch, log_path
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 tmp, pkg_path, build_path, log_path, sp
from slpkg.pkg.find import find_package
from slpkg.pkg.build import build_package
@ -63,19 +63,48 @@ def sbo_build(name):
for duplicate in requires:
if duplicate not in dependencies:
dependencies.append(duplicate)
sys.stdout.write("Done")
print # new lines at start
pkg_sum = 0
pkg_for_install = []
if find_package(name + sp, pkg_path):
pkg_for_install.append(colors.GREEN + name + colors.ENDC)
pkg_sum = 1
else:
pkg_for_install.append(colors.RED + name + colors.ENDC)
sbo_url = sbo_search_pkg(name)
sbo_ver = sbo_version_pkg(name)
sys.stdout.write("Done\n")
print("The following packages will be automatically installed or upgraded with new version:\n")
print(" " + " ".join(dependencies))
template(78)
print "| Package", " "*15, "Version", " "*5, "Arch", " "*7, "Repository"
template(78)
print("Installing:")
print " ", "".join(pkg_for_install), " "*(22-len(name)), sbo_ver, " "*(
12-len(sbo_ver)), arch, " "*(11-len(arch)), "SBo"
print("Installing for dependencies:")
for dep in dependencies[:-1]:
sbo_url = sbo_search_pkg(dep)
sbo_ver = sbo_version_pkg(dep)
if find_package(dep + sp, pkg_path):
print " ", colors.GREEN + dep + colors.ENDC, " "*(22-len(dep)), sbo_ver, " "*(
12-len(sbo_ver)), arch, " "*(11-len(arch)), "SBo"
pkg_sum += 1
else:
print " ", colors.RED + dep + colors.ENDC, " "*(22-len(dep)), sbo_ver, " "*(
12-len(sbo_ver)), arch, " "*(11-len(arch)), "SBo"
print("\nInstalling summary")
print("="*79)
print("Total {0} packages.".format(len(dependencies)))
print("{0} packages will be installed, {1} allready installed.".format(
(len(dependencies) - pkg_sum), pkg_sum))
read = raw_input("\nDo you want to continue [Y/n]? ")
if read == "Y" or read == "y":
for pkg in dependencies:
sbo_url = sbo_search_pkg(pkg)
sbo_version = sbo_version_pkg(sbo_url, pkg)
sbo_version = sbo_version_pkg(pkg)
sbo_file = "".join(find_package(pkg + sp, pkg_path))
sbo_file_version = sbo_file[len(pkg) + 1:-len(arch) - 7]
if sbo_version > sbo_file_version:
prgnam = ("{0}-{1}".format(pkg, sbo_version_pkg(sbo_url, pkg)))
prgnam = ("{0}-{1}".format(pkg, sbo_version_pkg(pkg)))
sbo_link = sbo_slackbuild_dwn(sbo_url, pkg)
src_link = sbo_source_dwn(sbo_url, pkg)
ext_link = sbo_extra_dwn(sbo_url, pkg)
@ -95,7 +124,8 @@ def sbo_build(name):
pkg_found(pkg, sbo_file_version)
template(78)
'''
Write dependencies in a log file into directory `/var/log/slpkg/dep/`
Write dependencies in a log file
into directory `/var/log/slpkg/dep/`
'''
dep_path = log_path + "dep/"
if not os.path.exists(dep_path):

View file

@ -59,7 +59,7 @@ def sbo_network(name):
sys.stdout.write ("Done\n")
sbo_req = sbo_requires_pkg(sbo_url, name)
sbo_dwn = sbo_slackbuild_dwn(sbo_url, name)
sbo_version = sbo_version_pkg(sbo_url, name)
sbo_version = sbo_version_pkg(name)
source_dwn = sbo_source_dwn(sbo_url, name)
extra_dwn = " ".join(sbo_extra_dwn(sbo_url, name))
view_sbo(name, sbo_url, get_file(sbo_dwn, "/"), get_file(source_dwn, "/"),

View file

@ -28,10 +28,9 @@ import subprocess
from slpkg.colors import colors
from slpkg.url_read import url_read
from slpkg.messages import pkg_not_found, s_user
from slpkg.__metadata__ import slpkg_tmp, pkg_path
from slpkg.messages import pkg_not_found, template
from slpkg.__metadata__ import slpkg_tmp, pkg_path, arch, sp
from slpkg.pkg.find import find_package
from slpkg.pkg.manager import pkg_upgrade, pkg_reinstall
from mirrors import mirrors
@ -41,14 +40,15 @@ def install(slack_pkg):
Install packages from official Slackware distribution
'''
try:
dwn_list, dwn_packages, comp_size, uncomp_size = [], [], [], []
install_all, package_name, package_location = [], [], []
comp_list, uncomp_list, comp_sum, uncomp_sum = [], [], [], []
pkg_path = slpkg_tmp + "packages/"
if not os.path.exists(pkg_path):
dwn_list, dwn_packages, comp_size, uncomp_size = [], [], [], []
tmp_path = slpkg_tmp + "packages/"
pkg_sum = 0
if not os.path.exists(tmp_path):
if not os.path.exists(slpkg_tmp):
os.mkdir(slpkg_tmp)
os.mkdir(pkg_path)
os.mkdir(tmp_path)
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
colors.CYAN, slack_pkg, colors.ENDC))
sys.stdout.write ("Reading package lists ...")
@ -63,47 +63,61 @@ def install(slack_pkg):
toolbar_width += 600
time.sleep(0.05)
if line.startswith("PACKAGE NAME"):
package_name.append(line.replace("PACKAGE NAME: ", ""))
package_name.append(line[15:].strip())
if line.startswith("PACKAGE LOCATION"):
package_location.append(line.replace("PACKAGE LOCATION: ./", ""))
package_location.append(line[21:].strip())
if line.startswith("PACKAGE SIZE (compressed): "):
comp_size.append(line[:-2].replace("PACKAGE SIZE (compressed): ", ""))
comp_size.append(line[28:-2].strip())
if line.startswith("PACKAGE SIZE (uncompressed): "):
uncomp_size.append(line[:-2].replace("PACKAGE SIZE (uncompressed): ", ""))
'''
Create list with location and package name
'''
uncomp_size.append(line[30:-2].strip())
for loc, name in zip(package_location, package_name):
dwn_list.append("{0}{1}/{2}".format(mirrors("",""), loc, name))
'''
Create list with package name and compressed size
'''
for name, size in zip(package_name, comp_size):
comp_list.append("{0}{1}".format(name, size))
'''
Create list with package name and uncompressed size
'''
for name, size in zip(package_name, uncomp_size):
uncomp_list.append("{0}{1}".format(name, size))
sys.stdout.write("Done\n\n")
for pkg in package_name:
if slack_pkg in pkg:
if pkg.endswith(".txz"):
print("{0}[ install ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, pkg.replace(".txz", "")))
install_all.append(pkg)
elif pkg.endswith(".tgz"):
print("{0}[ install ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, pkg.replace(".tgz", "")))
install_all.append(pkg)
for search in package_name:
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:
'''
Grep sizes from list and saved
'''
template(78)
print "| Package", " "*33, "Arch", " "*3, "Build", " ", "Repos", " ", "Size"
template(78)
print("Installing:")
for pkg in package_name:
if slack_pkg in pkg:
for size in comp_list:
if pkg in size:
Kb = size.replace(pkg, "")
if "-noarch-" in pkg:
arch = "noarch"
elif sp+os.uname()[4]+sp in pkg:
arch = os.uname()[4]
elif "-i486-" in pkg:
arch = "i486"
elif "-i686-" in pkg:
arch = "i686"
elif "-x86-" in pkg:
arch = "x86"
elif "-fw-" in pkg:
arch = "fw"
else:
arch = ""
if os.path.isfile(pkg_path + pkg[:-4]):
pkg_sum += 1
SC, EC = colors.GREEN, colors.ENDC
else:
SC, EC = colors.RED, colors.ENDC
print " ", SC + pkg[:-5].replace(sp+arch+sp, "") + EC, " "*(
40-len(pkg[:-5].replace(sp+arch+sp, ""))), arch, " "*(
7-len(arch)), pkg[-5:-4].replace(sp+arch+sp, ""), " "*(
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))]:
@ -111,9 +125,6 @@ def install(slack_pkg):
for uncomp in uncomp_list:
if install == uncomp[:-(len(uncomp)-len(install))]:
uncomp_sum.append(uncomp.replace(install, ""))
'''
Calculate sizes and print
'''
comp_unit, uncomp_unit = "Mb", "Mb"
compressed = round((sum(map(float, comp_sum)) * 0.0001220703125), 2)
uncompressed = round((sum(map(float, uncomp_sum)) * 0.0001220703125), 2)
@ -123,39 +134,51 @@ def install(slack_pkg):
if uncompressed < 1:
uncompressed = sum(map(int, uncomp_sum))
uncomp_unit = "Kb"
print("\nNeed to get {0} {1} of archives.".format(compressed, comp_unit))
msg_pkg = "package"
msg_2_pkg = msg_pkg
if len(install_all) > 1:
msg_pkg = msg_pkg + "s"
if len(install_all) - pkg_sum > 1:
msg_2_pkg = msg_2_pkg + "s"
print("\nInstalling summary")
print("="*79)
print("Total {0} {1}.".format(len(install_all), msg_pkg))
print("{0} {1} will be installed, {2} allready installed.".format(
(len(install_all) - pkg_sum), msg_2_pkg, 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.".format(
uncompressed, uncomp_unit))
read = raw_input("\nWould you like to install [Y/n]? ")
if read == "Y" or read == "y":
for install in install_all:
for dwn in dwn_list:
if install in dwn:
if "/" + install in dwn:
subprocess.call(
"wget -N --directory-prefix={0} {1} {2}.asc".format(
pkg_path, dwn, dwn), shell=True)
tmp_path, dwn, dwn), shell=True)
for install in install_all:
if not os.path.isfile(pkg_path + install):
print install
if not os.path.isfile(pkg_path + install[:-4]):
print("{0}[ installing ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, install))
pkg_upgrade((pkg_path + install).split())
pkg_upgrade((tmp_path + install).split())
else:
print("{0}[ reinstalling ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, install))
pkg_reinstall((pkg_path + install).split())
pkg_reinstall((tmp_path + install).split())
read = raw_input("Removal downloaded packages [Y/n]? ")
if read == "Y" or read == "y":
for remove in install_all:
os.remove(pkg_path + remove)
os.remove(pkg_path + remove + ".asc")
if os.listdir(pkg_path) == []:
os.remove(tmp_path + remove)
os.remove(tmp_path + remove + ".asc")
if os.listdir(tmp_path) == []:
print("Packages removed")
else:
print("\nThere are packages in directory {0}\n".format(
pkg_path))
tmp_path))
else:
print("\nThere are packages in directory {0}\n".format(
pkg_path))
tmp_path))
except KeyboardInterrupt:
print # new line at exit
sys.exit()

View file

@ -33,6 +33,6 @@ def mirrors(name, location):
http = "http://mirrors.slackware.com/slackware/slackware64-{0}/{1}{2}".format(
slack_ver(), location, name)
else:
http = "http://mirrors.slackware.com/slackware/slackware-{0}/{1}{3}".format(
http = "http://mirrors.slackware.com/slackware/slackware-{0}/{1}{2}".format(
slack_ver(), location, name)
return http

View file

@ -27,11 +27,10 @@ import time
import subprocess
from slpkg.colors import colors
from slpkg.messages import s_user
from slpkg.url_read import url_read
from slpkg.__metadata__ import pkg_path, slpkg_tmp, arch
from slpkg.messages import template
from slpkg.__metadata__ import pkg_path, slpkg_tmp, sp
from slpkg.pkg.find import find_package
from slpkg.pkg.manager import pkg_upgrade
from mirrors import mirrors
@ -42,10 +41,11 @@ def patches():
Install new patches from official Slackware mirrors
'''
try:
dwn_list, dwn_patches, comp_size, uncomp_size = [], [], [], []
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/"
slack_arch = ""
if not os.path.exists(pch_path):
if not os.path.exists(slpkg_tmp):
os.mkdir(slpkg_tmp)
@ -62,44 +62,60 @@ def patches():
toolbar_width += 100
time.sleep(0.05)
if line.startswith("PACKAGE NAME"):
package_name.append(line.replace("PACKAGE NAME: ", ""))
package_name.append(line[15:].strip())
if line.startswith("PACKAGE LOCATION"):
package_location.append(line.replace("PACKAGE LOCATION: ./", ""))
package_location.append(line[21:].strip())
if line.startswith("PACKAGE SIZE (compressed): "):
comp_size.append(line[:-2].replace("PACKAGE SIZE (compressed): ", ""))
comp_size.append(line[28:-2].strip())
if line.startswith("PACKAGE SIZE (uncompressed): "):
uncomp_size.append(line[:-2].replace("PACKAGE SIZE (uncompressed): ", ""))
'''
Create list with location and package name
'''
uncomp_size.append(line[30:-2].strip())
for loc, name in zip(package_location, package_name):
dwn_list.append("{0}{1}/{2}".format(mirrors("",""), loc, name))
'''
Create list with package name and compressed size
'''
for name, size in zip(package_name, comp_size):
comp_list.append("{0}{1}".format(name, size))
'''
Create list with package name and uncompressed size
'''
for name, size in zip(package_name, uncomp_size):
uncomp_list.append("{0}{1}".format(name, size))
for pkg in package_name:
installed_pkg = "".join(find_package(pkg.replace(".txz", ""), pkg_path))
if installed_pkg == "":
if not os.path.isfile(pkg_path + pkg[:-4]):
upgrade_all.append(pkg)
sys.stdout.write("Done\n")
if upgrade_all:
print("\nThese packages need upgrading:\n")
template(78)
print "| Package", " "*33, "Arch", " "*3, "Build", " ", "Repos", " ", "Size"
template(78)
print("Upgrading:")
for upgrade in upgrade_all:
print("{0}[ upgrade ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, upgrade))
for size in comp_list:
if upgrade in size:
Kb = size.replace(upgrade, "")
if "-noarch-" in upgrade:
arch = "noarch"
elif sp+os.uname()[4]+sp in upgrade:
arch = os.uname()[4]
elif "-i486-" in upgrade:
arch = "i486"
elif "-i686-" in upgrade:
arch = "i686"
elif "-x86-" in upgrade:
arch = "x86"
elif "-fw-" in upgrade:
arch = "fw"
else:
arch = ""
if "_slack" in upgrade:
slack = "_slack" + slack_ver()
else:
slack = ""
print " ", upgrade[:-(5+len(slack))].replace(
sp+arch+sp, ""), " "*(40-len(upgrade[:-(
5+len(slack))].replace(sp+arch+sp, ""))), arch, " "*(
7-len(arch)), upgrade[-15:-14].replace(sp+arch+sp, ""), " "*(
6-len(upgrade[-15:-14].replace(sp+arch+sp, ""))), "Slack", " ", Kb, " "*(
3-len(Kb)), "K"
for dwn in dwn_list:
if upgrade in dwn:
if "/" + upgrade in dwn:
dwn_patches.append(dwn)
'''
Grep sizes from list and saved
'''
for install in upgrade_all:
for comp in comp_list:
if install == comp[:-(len(comp)-len(install))]:
@ -107,9 +123,6 @@ def patches():
for uncomp in uncomp_list:
if install == uncomp[:-(len(uncomp)-len(install))]:
uncomp_sum.append(uncomp.replace(install, ""))
'''
Calculate sizes and print
'''
comp_unit, uncomp_unit = "Mb", "Mb"
compressed = round((sum(map(float, comp_sum)) * 0.0001220703125), 2)
uncompressed = round((sum(map(float, uncomp_sum)) * 0.0001220703125), 2)
@ -119,7 +132,13 @@ def patches():
if uncompressed < 1:
uncompressed = sum(map(int, uncomp_sum))
uncomp_unit = "Kb"
print("\nNeed to get {0} {1} of archives.".format(compressed, comp_unit))
msg_pkg = "package"
if len(upgrade_all) > 1:
msg_pkg = msg_pkg + "s"
print("\nInstalling summary")
print("="*79)
print("Total {0} {1} will be upgrading.".format(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.".format(
uncompressed, uncomp_unit))
read = raw_input("\nWould you like to upgrade [Y/n]? ")
@ -129,7 +148,7 @@ def patches():
pch_path, dwn, dwn), shell=True)
for pkg in upgrade_all:
print("{0}[ upgrading ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, pkg))
colors.GREEN, colors.ENDC, pkg[:-4]))
pkg_upgrade((pch_path + pkg).split())
for kernel in upgrade_all:
if "kernel" in kernel:
@ -148,10 +167,8 @@ def patches():
else:
print("\nThere are packages in directory {0}\n".format(pch_path))
else:
if arch == "x86_64":
if os.uname()[4] == "x86_64":
slack_arch = 64
else:
slack_arch = ""
print("\nSlackware{0} v{1} distribution is up to date\n".format(
slack_arch, slack_ver()))
except KeyboardInterrupt: