added new repos rlw and alien

This commit is contained in:
Dimitris Zlatanidis 2014-11-01 06:28:40 +02:00
parent 372cb0715a
commit 0b140891eb
16 changed files with 681 additions and 83 deletions

View file

@ -31,75 +31,115 @@ from __metadata__ import log_path, lib_path
from slack.slack_version import slack_ver
def initialization():
'''
Slpkg initialization, creating directories and SLACKBUILDS.TXT in
/var/lib/slpkg/sbo_repo/ and ChangeLog.txt in /var/log/slpkg/ from
slackbuilds.org.
'''
sbo_log = log_path + "sbo/"
sbo_lib = lib_path + "sbo_repo/"
pkg_que = lib_path + "queue"
if not os.path.exists(log_path):
os.mkdir(log_path)
if not os.path.exists(lib_path):
os.mkdir(lib_path)
if not os.path.exists(sbo_log):
os.mkdir(sbo_log)
if not os.path.exists(sbo_lib):
os.mkdir(sbo_lib)
if not os.path.exists(pkg_que):
os.mkdir(pkg_que)
sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(slack_ver()))
# Read SLACKBUILDS.TXT from slackbuilds.org and write in
# /var/lib/slpkg/sbo_repo directory if not exist
if not os.path.isfile(sbo_lib + "SLACKBUILDS.TXT"):
print("\nslpkg ...initialization")
sys.stdout.write("SLACKBUILDS.TXT read ...")
sys.stdout.flush()
SLACKBUILDS_TXT = URL((
"http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format(
slack_ver()))).reading()
sys.stdout.write("Done\n")
with open("{0}SLACKBUILDS.TXT".format(sbo_lib), "w") as sbo:
sbo.write(SLACKBUILDS_TXT)
sbo.close()
print("File SLACKBUILDS.TXT created in {0}".format(sbo_lib))
# Read ChangeLog.txt from slackbuilds.org and write in /var/log/slpkg/sbo/
# directory if not exist
if not os.path.isfile(sbo_log + "ChangeLog.txt"):
print("\nslpkg initialization")
sys.stdout.write("ChangeLog.txt read ...")
sys.stdout.flush()
ChangeLog_txt = URL((
"http://slackbuilds.org/slackbuilds/{0}/ChangeLog.txt".format(
slack_ver()))).reading()
sys.stdout.write("Done\n")
with open("{0}ChangeLog.txt".format(sbo_log), "w") as log:
log.write(ChangeLog_txt)
log.close()
print("File ChangeLog.txt created in {0}".format(sbo_log))
# We take the size of ChangeLog.txt from the server and locally
server = FileSize(sbo_url + "ChangeLog.txt").server()
local = FileSize(sbo_log + "ChangeLog.txt").local()
# If the two files differ in size delete and replaced with new
if server != local:
os.remove("{0}{1}".format(sbo_lib, "SLACKBUILDS.TXT"))
os.remove("{0}{1}".format(sbo_log, "ChangeLog.txt"))
print("\nNEWS in ChangeLog.txt")
print("slpkg ...initialization")
sys.stdout.write("Files re-created ...")
sys.stdout.flush()
SLACKBUILDS_TXT = URL((
"http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format(
slack_ver()))).reading()
ChangeLog_txt = URL((
"http://slackbuilds.org/slackbuilds/{0}/ChangeLog.txt".format(
slack_ver()))).reading()
with open("{0}SLACKBUILDS.TXT".format(sbo_lib), "w") as sbo:
sbo.write(SLACKBUILDS_TXT)
sbo.close()
with open("{0}ChangeLog.txt".format(sbo_log), "w") as log:
log.write(ChangeLog_txt)
log.close()
sys.stdout.write("Done\n")
class Initialization(object):
def __init__(self):
if not os.path.exists(log_path):
os.mkdir(log_path)
if not os.path.exists(lib_path):
os.mkdir(lib_path)
def sbo(self):
'''
Creating sbo local library
'''
log = log_path + "sbo/"
lib = lib_path + "sbo_repo/"
lib_file = "SLACKBUILDS.TXT"
log_file = "ChangeLog.txt"
if not os.path.exists(log):
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
packages_txt = ("http://slackbuilds.org/slackbuilds/{0}/{1}".format(
slack_ver(), lib_file))
changelog_txt = ("http://slackbuilds.org/slackbuilds/{0}/{1}".format(
slack_ver(), log_file))
self.write(lib, lib_file, packages_txt)
self.write(log, log_file, changelog_txt)
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt)
def rlw(self):
'''
Creating rlw local library
'''
log = log_path + "rlw/"
lib = lib_path + "rlw_repo/"
lib_file = "PACKAGES.TXT"
log_file = "ChangeLog.txt"
if not os.path.exists(log):
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
packages_txt = ("http://rlworkman.net/pkgs/{0}/{1}".format(
slack_ver(), lib_file))
changelog_txt = ("http://rlworkman.net/pkgs/{0}/{1}".format(
slack_ver(), log_file))
self.write(lib, lib_file, packages_txt)
self.write(log, log_file, changelog_txt)
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt)
def alien(self):
'''
Creating alien local library
'''
log = log_path + "alien/"
lib = lib_path + "alien_repo/"
lib_file = "PACKAGES.TXT"
log_file = "ChangeLog.txt"
if not os.path.exists(log):
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
packages_txt = ("http://www.slackware.com/~alien/slackbuilds/"
"{0}".format(lib_file))
changelog_txt = ("http://www.slackware.com/~alien/slackbuilds/"
"{0}".format(log_file))
self.write(lib, lib_file, packages_txt)
self.write(log, log_file, changelog_txt)
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt)
@staticmethod
def write(path, files, file_url):
'''
Read SLACKBUILDS.TXT from slackbuilds.org and write in
/var/lib/slpkg/sbo_repo directory if not exist
'''
if not os.path.isfile(path + files):
print("\nslpkg ...initialization")
sys.stdout.write(files + " read ...")
sys.stdout.flush()
PACKAGES_TXT = URL(file_url).reading()
sys.stdout.write("Done\n")
with open("{0}{1}".format(path, files), "w") as f:
f.write(PACKAGES_TXT)
f.close()
print("File {0} created in {1}".format(files, path))
@staticmethod
def remote(*args):
'''
args[0]=log, args[1]=log_file, arg[2]=changelog_txt
args[3]=lib, args[4]=lib_file, arg[5]=packages_txt
If the two files differ in size delete and replaced with new
We take the size of ChangeLog.txt from the server and locally
'''
server = FileSize(args[2]).server()
local = FileSize(args[0] + args[1]).local()
if server != local:
os.remove("{0}{1}".format(args[3], args[4]))
os.remove("{0}{1}".format(args[0], args[1]))
print("\nNEWS in " + args[1])
print("slpkg ...initialization")
sys.stdout.write("Files re-created ...")
sys.stdout.flush()
PACKAGES_TXT = URL(args[5]).reading()
CHANGELOG_TXT = URL(args[2]).reading()
with open("{0}{1}".format(args[3], args[4]), "w") as f:
f.write(PACKAGES_TXT)
f.close()
with open("{0}{1}".format(args[0], args[1]), "w") as f:
f.write(CHANGELOG_TXT)
f.close()
sys.stdout.write("Done\n")

View file

@ -41,6 +41,7 @@ from sbo.slackbuild import SBoInstall
from slack.install import Slack
from slack.patches import Patches
from others.install import Others
def main():
@ -49,7 +50,7 @@ def main():
s_user(getpass.getuser())
args = sys.argv
args.pop(0)
repository = ["sbo", "slack"]
repository = ["sbo", "slack", "rlw", "alien"]
blacklist = BlackList()
queue = QueuePkgs()
@ -88,6 +89,10 @@ def main():
SBoInstall(args[2]).start()
elif args[1] == repository[1]:
Slack(args[2], "stable").start()
elif args[1] == repository[2]:
Others(args[2], repository[2]).start()
elif args[1] == repository[3]:
Others(args[2], repository[3]).start()
else:
usage()
elif len(args) == 4 and args[0] == "-s":

1
slpkg/others/__init__.py Normal file
View file

@ -0,0 +1 @@
# [ slackware ] directory

58
slpkg/others/dependency.py Executable file
View file

@ -0,0 +1,58 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# dependency.py file is part of slpkg.
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Utility for easy management packages in Slackware
# https://github.com/dslackw/slpkg
# Slpkg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys
from colors import GREY, ENDC
from blacklist import BlackList
from greps import SBoGrep
dep_results = []
def sbo_dependencies_pkg(name):
'''
Build all dependencies of a package
'''
try:
dependencies = []
blacklist = BlackList().packages()
requires = SBoGrep(name).requires()
if requires:
for req in requires:
# avoid to add %README% as dependency and
# if require in blacklist
if "%README%" not in req and req not in blacklist:
dependencies.append(req)
if dependencies:
dep_results.append(dependencies)
for dep in dependencies:
sys.stdout.write("{0}.{1}".format(
GREY, ENDC))
sys.stdout.flush()
sbo_dependencies_pkg(dep)
return dep_results
except KeyboardInterrupt:
print # new line at exit
sys.exit()

33
slpkg/others/download.py Executable file
View file

@ -0,0 +1,33 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# downloads.py file is part of slpkg.
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Utility for easy management packages in Slackware
# https://github.com/dslackw/slpkg
# Slpkg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from downloader import Download
def slack_dwn(path, links):
'''
Download patches
'''
for dwn in links:
Download(path, dwn).start()
Download(path, dwn + ".asc").start()

82
slpkg/others/greps.py Executable file
View file

@ -0,0 +1,82 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# greps.py file is part of slpkg.
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Utility for easy management packages in Slackware
# https://github.com/dslackw/slpkg
# Slpkg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
from toolbar import status
from slack_version import slack_ver
def repo_data(PACKAGES_TXT, step, repo):
'''
Grap data packages
'''
(name, location, size, unsize,
rname, rlocation, rsize, runsize) = ([] for i in range(8))
index, toolbar_width = 0, 700
for line in PACKAGES_TXT.splitlines():
index += 1
toolbar_width = status(index, toolbar_width, step)
if line.startswith("PACKAGE NAME"):
name.append(line[15:].strip())
if line.startswith("PACKAGE LOCATION"):
location.append(line[21:].strip())
if line.startswith("PACKAGE SIZE (compressed): "):
size.append(line[28:-2].strip())
if line.startswith("PACKAGE SIZE (uncompressed): "):
unsize.append(line[30:-2].strip())
if repo == "rlw":
(rname, rlocation, rsize, runsize) = rlw_filter(name, location, size,
unsize)
else:
(rname, rlocation, rsize, runsize) = alien_filter(name, location, size,
unsize)
return [rname, rlocation, rsize, runsize]
def rlw_filter(name, location, size, unsize):
arch = os.uname()[4]
if arch.startswith("i") and arch.endswith("86"):
arch = "i486"
(fname, flocation, fsize, funsize) = ([] for i in range(4))
for n, l, s, u in zip(name, location, size, unsize):
if arch in n:
fname.append(n)
flocation.append(l)
fsize.append(s)
funsize.append(u)
return [fname, flocation, fsize, funsize]
def alien_filter(name, location, size, unsize):
arch = os.uname()[4]
if arch.startswith("i") and arch.endswith("86"):
arch = "i486"
(fname, flocation, fsize, funsize) = ([] for i in range(4))
for n, l, s, u in zip(name, location, size, unsize):
if arch in n and l.endswith(slack_ver()):
fname.append(n)
flocation.append(l)
fsize.append(s)
funsize.append(u)
return [fname, flocation, fsize, funsize]

202
slpkg/others/install.py Executable file
View file

@ -0,0 +1,202 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# install.py file is part of slpkg.
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Utility for easy management packages in Slackware
# https://github.com/dslackw/slpkg
# Slpkg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
from init import Initialization
from blacklist import BlackList
from splitting import split_package
from messages import pkg_not_found, template
from __metadata__ import slpkg_tmp, pkg_path, lib_path
from colors import RED, GREEN, CYAN, YELLOW, GREY, ENDC
from pkg.find import find_package
from pkg.manager import PackageManager
from sizes import units
from remove import delete
from greps import repo_data
from download import slack_dwn
from slack_version import slack_ver
class Others(object):
def __init__(self, package, repo):
self.package = package
self.repo = repo
self.tmp_path = slpkg_tmp + "packages/"
Initialization().rlw()
Initialization().alien()
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
CYAN, self.package, ENDC))
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
sys.stdout.flush()
if not os.path.exists(slpkg_tmp):
os.mkdir(slpkg_tmp)
if not os.path.exists(self.tmp_path):
os.mkdir(self.tmp_path)
self.step = 700
if self.repo == "rlw":
lib = lib_path + "rlw_repo/PACKAGES.TXT"
f = open(lib, "r")
self.mirror = "http://rlworkman.net/pkgs/{0}".format(slack_ver())
else:
lib = lib_path + "alien_repo/PACKAGES.TXT"
f = open(lib, "r")
self.mirror = "http://www.slackware.com/~alien/slackbuilds/"
self.step = self.step * 2
self.PACKAGES_TXT = f.read()
f.close()
def start(self):
'''
Install packages from official Slackware distribution
'''
try:
data = repo_data(self.PACKAGES_TXT, self.step, self.repo)
(dwn_links, install_all,
comp_sum, uncomp_sum) = store(data[0], data[1], data[2], data[3],
self.package, self.mirror, self.repo)
sys.stdout.write("{0}Done{1}\n\n".format(GREY, ENDC))
if install_all:
template(78)
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
"| Package", " " * 17,
"Version", " " * 12,
"Arch", " " * 4,
"Build", " " * 2,
"Repos", " " * 10,
"Size"))
template(78)
print("Installing:")
sums = views(install_all, comp_sum, self.repo)
unit, size = units(comp_sum, uncomp_sum)
msg = msgs(install_all, sums[2])
print("\nInstalling summary")
print("=" * 79)
print("{0}Total {1} {2}.".format(GREY, len(install_all),
msg[0]))
print("{0} {1} will be installed, {2} will be upgraded and "
"{3} will be resettled.".format(sums[2], msg[1],
sums[1], sums[0]))
print("Need to get {0} {1} of archives.".format(size[0],
unit[0]))
print("After this process, {0} {1} of additional disk space "
"will be used.{2}".format(size[1], unit[1], ENDC))
read = raw_input("\nWould you like to install [Y/n]? ")
if read == "Y" or read == "y":
slack_dwn(self.tmp_path, dwn_links)
install(self.tmp_path, install_all)
delete(self.tmp_path, install_all)
else:
pkg_not_found("", self.package, "No matching", "\n")
except KeyboardInterrupt:
print # new line at exit
sys.exit()
def store(*args):
'''
Store and return packages for install
'''
dwn, install, comp_sum, uncomp_sum = ([] for i in range(4))
for name, loc, comp, uncomp in zip(args[0], args[1], args[2], args[3]):
if args[4] in name and args[4] not in BlackList().packages():
if args[6] == "rlw":
dwn.append("{0}{1}/{2}".format(args[5], loc, name))
else:
arch = os.uname()[4]
if arch.startswith("i") and arch.endswith("86"):
arch = ""
else:
arch = "64"
ver = slack_ver()
dwn.append("{0}{1}/pkg{2}/{3}/{4}".format(args[5], args[4],
arch, ver, name))
install.append(name)
comp_sum.append(comp)
uncomp_sum.append(uncomp)
return [dwn, install, comp_sum, uncomp_sum]
def views(install_all, comp_sum, repository):
'''
Views packages
'''
pkg_sum = uni_sum = upg_sum = 0
if repository == "rlw":
repository = repository + " "
for pkg, comp in zip(install_all, comp_sum):
pkg_split = split_package(pkg[:-4])
if os.path.isfile(pkg_path + pkg[:-4]):
pkg_sum += 1
COLOR = GREEN
elif find_package(pkg_split[0] + "-", pkg_path):
COLOR = YELLOW
upg_sum += 1
else:
COLOR = RED
uni_sum += 1
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11:>12}{12}".format(
COLOR, pkg_split[0], ENDC,
" " * (25-len(pkg_split[0])), pkg_split[1],
" " * (19-len(pkg_split[1])), pkg_split[2],
" " * (8-len(pkg_split[2])), pkg_split[3],
" " * (7-len(pkg_split[3])), repository,
comp, " K"))
return [pkg_sum, upg_sum, uni_sum]
def msgs(install_all, uni_sum):
'''
Print singular plural
'''
msg_pkg = "package"
msg_2_pkg = msg_pkg
if len(install_all) > 1:
msg_pkg = msg_pkg + "s"
if uni_sum > 1:
msg_2_pkg = msg_2_pkg + "s"
return [msg_pkg, msg_2_pkg]
def install(tmp_path, install_all):
'''
Install or upgrade packages
'''
for install in install_all:
package = (tmp_path + install).split()
if os.path.isfile(pkg_path + install[:-4]):
print("[ {0}reinstalling{1} ] --> {2}".format(
GREEN, ENDC, install))
PackageManager(package).reinstall()
elif find_package(split_package(install)[0] + "-", pkg_path):
print("[ {0}upgrading{1} ] --> {2}".format(
YELLOW, ENDC, install))
PackageManager(package).upgrade()
else:
print("[ {0}installing{1} ] --> {2}".format(
GREEN, ENDC, install))
PackageManager(package).upgrade()

48
slpkg/others/mirrors.py Executable file
View file

@ -0,0 +1,48 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# mirrors.py file is part of slpkg.
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Utility for easy management packages in Slackware
# https://github.com/dslackw/slpkg
# Slpkg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from __metadata__ import arch
from slack_version import slack_ver
def mirrors(name, location, version):
'''
Select Slackware official mirror packages
based architecture and version.
'''
if arch == "x86_64":
if version == "stable":
http = ("http://mirrors.slackware.com/slackware/slackware64-"
"{0}/{1}{2}".format(slack_ver(), location, name))
else:
http = ("http://mirrors.slackware.com/slackware/slackware64-"
"{0}/{1}{2}".format(version, location, name))
else:
if version == "stable":
http = ("http://mirrors.slackware.com/slackware/slackware-"
"{0}/{1}{2}".format(slack_ver(), location, name))
else:
http = ("http://mirrors.slackware.com/slackware/slackware-"
"{0}/{1}{2}".format(version, location, name))
return http

45
slpkg/others/remove.py Executable file
View file

@ -0,0 +1,45 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# remove.py file is part of slpkg.
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Utility for easy management packages in Slackware
# https://github.com/dslackw/slpkg
# Slpkg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
def delete(path, packages):
'''
Remove downloaded packages
'''
read = raw_input("Removal downloaded packages [Y/n]? ")
if read == "Y" or read == "y":
for pkg in packages:
os.remove(path + pkg)
os.remove(path + pkg + ".asc")
is_empty(path)
else:
is_empty(path)
def is_empty(path):
if not os.listdir(path):
print("Packages removed")
else:
print("\nThere are packages in direcrory {0}\n".format(path))

44
slpkg/others/sizes.py Executable file
View file

@ -0,0 +1,44 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# sizes.py file is part of slpkg.
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Utility for easy management packages in Slackware
# https://github.com/dslackw/slpkg
# Slpkg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
def units(comp_sum, uncomp_sum):
'''
Calculate package size
'''
compressed = round((sum(map(float, comp_sum)) / 1024), 2)
uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2)
comp_unit = uncomp_unit = "Mb"
if compressed > 1024:
compressed = round((compressed / 1024), 2)
comp_unit = "Gb"
if uncompressed > 1024:
uncompressed = round((uncompressed / 1024), 2)
uncomp_unit = "Gb"
if compressed < 1:
compressed = sum(map(int, comp_sum))
comp_unit = "Kb"
if uncompressed < 1:
uncompressed = sum(map(int, uncomp_sum))
uncomp_unit = "Kb"
return [comp_unit, uncomp_unit], [compressed, uncompressed]

34
slpkg/others/slack_version.py Executable file
View file

@ -0,0 +1,34 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# slack_version.py file is part of slpkg.
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Utility for easy management packages in Slackware
# https://github.com/dslackw/slpkg
# Slpkg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import re
def slack_ver():
'''
Open file and read Slackware version
'''
with open("/etc/slackware-version", "r") as f:
sv = f.read()
f.close()
return (".".join(re.findall(r"\d+", sv)))

View file

@ -29,7 +29,7 @@ from pkg.build import BuildPackage
from pkg.manager import PackageManager
from toolbar import status
from init import initialization
from init import Initialization
from downloader import Download
from splitting import split_package
from messages import template, build_FAILED
@ -48,7 +48,7 @@ class SBoCheck(object):
self.done = "{0}Done{1}\n".format(GREY, ENDC)
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
sys.stdout.flush()
initialization()
Initialization().sbo()
self.installed = []
self.index, self.toolbar_width = 0, 3

View file

@ -25,8 +25,9 @@ import os
import sys
from toolbar import status
from init import initialization
from init import Initialization
from downloader import Download
from splitting import split_package
from __metadata__ import (tmp, pkg_path, build_path,
log_path, lib_path, sp)
@ -50,7 +51,7 @@ class SBoInstall(object):
self.name = name
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
sys.stdout.flush()
initialization()
Initialization().sbo()
self.UNST = ["UNSUPPORTED", "UNTESTED"]
self.dependencies_list = sbo_dependencies_pkg(name)
@ -321,9 +322,8 @@ def build_install(dependencies, sbo_versions, packages_arch):
prgnam = ("{0}-{1}".format(pkg, ver))
sbo_file = "".join(find_package(prgnam, pkg_path))
if sbo_file:
sbo_file_version = sbo_file[len(pkg) + 1:-len(ar) - 7]
template(78)
pkg_found(pkg, sbo_file_version)
pkg_found(pkg, split_package(sbo_file)[1])
template(78)
else:
sbo_url = sbo_search_pkg(pkg)

View file

@ -24,7 +24,7 @@
import sys
from messages import template
from init import initialization
from init import Initialization
from __metadata__ import pkg_path, sp
from colors import RED, GREEN, GREY, YELLOW, CYAN, ENDC
@ -42,7 +42,7 @@ def track_dep(name):
'''
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
sys.stdout.flush()
initialization()
Initialization().sbo()
dependencies_list = sbo_dependencies_pkg(name)
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
if dependencies_list:

View file

@ -25,7 +25,7 @@ import os
import sys
import pydoc
from init import initialization
from init import Initialization
from downloader import Download
from __metadata__ import tmp, build_path, pkg_path, sp
from colors import RED, GREEN, GREY, CYAN, YELLOW, ENDC
@ -48,7 +48,7 @@ class SBoNetwork(object):
self.name = name
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
sys.stdout.flush()
initialization()
Initialization().sbo()
grep = SBoGrep(self.name)
self.sbo_url = sbo_search_pkg(self.name)
self.sbo_desc = grep.description()[len(self.name) + 2:-1]

View file

@ -32,10 +32,16 @@ def split_package(package):
split = package.split("-")
sbo = "_SBo"
slack = "_slack{0}".format(slack_ver())
rlw = "_rlw"
alien = "alien"
if sbo in package:
build = split[-1][:-4] # remove .t?z extension
if slack in package:
build = split[-1][:-len(slack)]
elif rlw in package:
build = split[-1][:-len(rlw)]
elif alien in package:
build = split[-1][:-len(alien)]
else:
build = split[-1]
arch = split[-2]