mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-29 20:34:22 +01:00
Fix doc string style
This commit is contained in:
parent
d81eff0597
commit
5876c2d766
52 changed files with 978 additions and 984 deletions
|
@ -21,7 +21,7 @@
|
|||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
'''
|
||||
"""
|
||||
_ _
|
||||
___| |_ __ | | ____ _
|
||||
/ __| | '_ \| |/ / _` |
|
||||
|
@ -30,7 +30,7 @@
|
|||
|_| |___/
|
||||
|
||||
Slpkg is a user-friendly package manager for Slackware installations
|
||||
'''
|
||||
"""
|
||||
|
||||
from slpkg.main import main
|
||||
|
||||
|
|
10
clean.py
10
clean.py
|
@ -28,10 +28,10 @@ import shutil
|
|||
|
||||
class Clean(object):
|
||||
"""Clean all data like man page, log files, PACKAGES.TXT and
|
||||
configuration files. This is useful if 'slpkg' installed via
|
||||
'pip' because pip uninstalls only Python packages and script
|
||||
and not data. So if uninstall '# pip uninstall slpkg' after run
|
||||
'# python clean.py' to remove all data and configuration file.
|
||||
configuration files. This is useful if "slpkg" installed via
|
||||
"pip" because pip uninstalls only Python packages and script
|
||||
and not data. So if uninstall "# pip uninstall slpkg" after run
|
||||
"# python clean.py" to remove all data and configuration file.
|
||||
keep this script if you want to remove data some time.
|
||||
"""
|
||||
def __init__(self):
|
||||
|
@ -57,5 +57,5 @@ class Clean(object):
|
|||
print("Remove directory --> {0}".format(d))
|
||||
shutil.rmtree(d)
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
Clean().start()
|
||||
|
|
26
setup.py
26
setup.py
|
@ -71,9 +71,9 @@ if "install" in sys.argv:
|
|||
os.makedirs(man_path)
|
||||
man_page = "man/slpkg.8"
|
||||
gzip_man = "man/slpkg.8.gz"
|
||||
print("Installing '{0}' man pages".format(gzip_man.split('/')[1]))
|
||||
print("Installing '{0}' man pages".format(gzip_man.split("/")[1]))
|
||||
f_in = open(man_page, "rb")
|
||||
f_out = gzip.open(gzip_man, 'wb')
|
||||
f_out = gzip.open(gzip_man, "wb")
|
||||
f_out.writelines(f_in)
|
||||
f_out.close()
|
||||
f_in.close()
|
||||
|
@ -82,24 +82,24 @@ if "install" in sys.argv:
|
|||
bash_completion = "/etc/bash_completion.d/"
|
||||
fish_completion = "/etc/fish/completions/"
|
||||
completion_file = [
|
||||
'conf/slpkg.bash-completion',
|
||||
'conf/slpkg.fish'
|
||||
"conf/slpkg.bash-completion",
|
||||
"conf/slpkg.fish"
|
||||
]
|
||||
if not os.path.exists(bash_completion):
|
||||
os.makedirs(bash_completion)
|
||||
print("Installing '{0}' file".format(completion_file[0].split('/')[1]))
|
||||
print("Installing '{0}' file".format(completion_file[0].split("/")[1]))
|
||||
shutil.copy2(completion_file[0], bash_completion)
|
||||
os.chmod(bash_completion + completion_file[0].split('/')[1], 744)
|
||||
os.chmod(bash_completion + completion_file[0].split("/")[1], 744)
|
||||
if os.path.exists(fish_completion):
|
||||
print("Installing '{0}' file".format(completion_file[1].split('/')[1]))
|
||||
print("Installing '{0}' file".format(completion_file[1].split("/")[1]))
|
||||
shutil.copy2(completion_file[1], fish_completion)
|
||||
os.chmod(fish_completion + completion_file[1].split('/')[1], 744)
|
||||
os.chmod(fish_completion + completion_file[1].split("/")[1], 744)
|
||||
conf_file = [
|
||||
'conf/slpkg.conf',
|
||||
'conf/blacklist',
|
||||
'conf/slackware-mirrors',
|
||||
'conf/custom-repositories',
|
||||
'conf/slackware-changelogs-mirror'
|
||||
"conf/slpkg.conf",
|
||||
"conf/blacklist",
|
||||
"conf/slackware-mirrors",
|
||||
"conf/custom-repositories",
|
||||
"conf/slackware-changelogs-mirror"
|
||||
]
|
||||
if not os.path.exists(_m.conf_path):
|
||||
os.makedirs(_m.conf_path)
|
||||
|
|
|
@ -28,18 +28,14 @@ import getpass
|
|||
|
||||
|
||||
def s_user(user):
|
||||
'''
|
||||
Check for root user
|
||||
'''
|
||||
"""Check for root user"""
|
||||
if user != "root":
|
||||
print("\nslpkg: error: must have root privileges\n")
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def remove_repositories(repositories, default_repositories):
|
||||
'''
|
||||
Remove no default repositories
|
||||
'''
|
||||
"""Remove no default repositories"""
|
||||
repos = []
|
||||
for repo in repositories:
|
||||
if repo in default_repositories:
|
||||
|
@ -48,9 +44,7 @@ def remove_repositories(repositories, default_repositories):
|
|||
|
||||
|
||||
def update_repositories(repositories, conf_path):
|
||||
'''
|
||||
Upadate with user custom repositories
|
||||
'''
|
||||
"""Upadate with user custom repositories"""
|
||||
repo_file = "{0}custom-repositories".format(conf_path)
|
||||
if os.path.isfile(repo_file):
|
||||
f = open(repo_file, "r")
|
||||
|
@ -64,23 +58,23 @@ def update_repositories(repositories, conf_path):
|
|||
|
||||
|
||||
def grab_sub_repo(repositories, repos):
|
||||
'''
|
||||
"""
|
||||
Grab SUB_REPOSITORY
|
||||
'''
|
||||
"""
|
||||
for i, repo in enumerate(repositories):
|
||||
if repos in repo:
|
||||
sub = repositories[i].replace(repos, '')
|
||||
sub = repositories[i].replace(repos, "")
|
||||
repositories[i] = repos
|
||||
return sub
|
||||
|
||||
|
||||
def select_slack_release(slack_rel):
|
||||
'''
|
||||
"""
|
||||
Warning message if Slackware release not defined or
|
||||
defined wrong
|
||||
'''
|
||||
if slack_rel not in ['stable', 'current']:
|
||||
return 'FAULT'
|
||||
"""
|
||||
if slack_rel not in ["stable", "current"]:
|
||||
return "FAULT"
|
||||
return slack_rel
|
||||
|
||||
|
||||
|
@ -96,7 +90,7 @@ class MetaData(object):
|
|||
s_user(getpass.getuser())
|
||||
|
||||
# Default Slackware release
|
||||
slack_rel = 'stable'
|
||||
slack_rel = "stable"
|
||||
|
||||
# Configuration path
|
||||
conf_path = "/etc/{0}/".format(__all__)
|
||||
|
@ -107,65 +101,65 @@ class MetaData(object):
|
|||
|
||||
# Default configuration values
|
||||
_conf_slpkg = {
|
||||
'RELEASE': 'stable',
|
||||
'REPOSITORIES': ['slack', 'sbo', 'rlw', 'alien',
|
||||
'slacky', 'studio', 'slackr', 'slonly',
|
||||
'ktown{latest}', 'multi', 'slacke{18}',
|
||||
'salix', 'slackl', 'rested'],
|
||||
'BUILD_PATH': '/tmp/slpkg/build/',
|
||||
'PACKAGES': '/tmp/slpkg/packages/',
|
||||
'PATCHES': '/tmp/slpkg/patches/',
|
||||
'CHECKMD5': 'on',
|
||||
'DEL_ALL': 'on',
|
||||
'DEL_BUILD': 'off',
|
||||
'SBO_BUILD_LOG': 'on',
|
||||
'DEFAULT_ANSWER': 'n',
|
||||
'REMOVE_DEPS_ANSWER': 'n',
|
||||
'SKIP_UNST': 'n',
|
||||
'RSL_DEPS': 'on',
|
||||
'DEL_DEPS': 'off',
|
||||
'USE_COLORS': 'on',
|
||||
'WGET_OPTIONS': '-c -N',
|
||||
'SLACKPKG_LOG': 'on',
|
||||
'ONLY_INSTALLED': 'off'
|
||||
"RELEASE": "stable",
|
||||
"REPOSITORIES": ["slack", "sbo", "rlw", "alien",
|
||||
"slacky", "studio", "slackr", "slonly",
|
||||
"ktown{latest}", "multi", "slacke{18}",
|
||||
"salix", "slackl", "rested"],
|
||||
"BUILD_PATH": "/tmp/slpkg/build/",
|
||||
"PACKAGES": "/tmp/slpkg/packages/",
|
||||
"PATCHES": "/tmp/slpkg/patches/",
|
||||
"CHECKMD5": "on",
|
||||
"DEL_ALL": "on",
|
||||
"DEL_BUILD": "off",
|
||||
"SBO_BUILD_LOG": "on",
|
||||
"DEFAULT_ANSWER": "n",
|
||||
"REMOVE_DEPS_ANSWER": "n",
|
||||
"SKIP_UNST": "n",
|
||||
"RSL_DEPS": "on",
|
||||
"DEL_DEPS": "off",
|
||||
"USE_COLORS": "on",
|
||||
"WGET_OPTIONS": "-c -N",
|
||||
"SLACKPKG_LOG": "on",
|
||||
"ONLY_INSTALLED": "off"
|
||||
}
|
||||
|
||||
default_repositories = ['slack', 'sbo', 'rlw', 'alien', 'slacky', 'studio',
|
||||
'slackr', 'slonly', 'ktown', 'multi', 'slacke',
|
||||
'salix', 'slackl', 'rested']
|
||||
default_repositories = ["slack", "sbo", "rlw", "alien", "slacky", "studio",
|
||||
"slackr", "slonly", "ktown", "multi", "slacke",
|
||||
"salix", "slackl", "rested"]
|
||||
|
||||
# read value from configuration file
|
||||
if os.path.isfile('%s%s' % (conf_path, 'slpkg.conf')):
|
||||
f = open('%s%s' % (conf_path, 'slpkg.conf'), 'r')
|
||||
if os.path.isfile("%s%s" % (conf_path, "slpkg.conf")):
|
||||
f = open("%s%s" % (conf_path, "slpkg.conf"), "r")
|
||||
conf = f.read()
|
||||
f.close()
|
||||
for line in conf.splitlines():
|
||||
line = line.lstrip()
|
||||
if line and not line.startswith('#'):
|
||||
_conf_slpkg[line.split('=')[0]] = line.split('=')[1]
|
||||
if line and not line.startswith("#"):
|
||||
_conf_slpkg[line.split("=")[0]] = line.split("=")[1]
|
||||
|
||||
# Set values from configuration file
|
||||
slack_rel = _conf_slpkg['RELEASE']
|
||||
if isinstance(_conf_slpkg['REPOSITORIES'], basestring):
|
||||
repositories = _conf_slpkg['REPOSITORIES'].split(',')
|
||||
slack_rel = _conf_slpkg["RELEASE"]
|
||||
if isinstance(_conf_slpkg["REPOSITORIES"], basestring):
|
||||
repositories = _conf_slpkg["REPOSITORIES"].split(",")
|
||||
else:
|
||||
repositories = _conf_slpkg['REPOSITORIES']
|
||||
build_path = _conf_slpkg['BUILD_PATH']
|
||||
slpkg_tmp_packages = _conf_slpkg['PACKAGES']
|
||||
slpkg_tmp_patches = _conf_slpkg['PATCHES']
|
||||
checkmd5 = _conf_slpkg['CHECKMD5']
|
||||
del_all = _conf_slpkg['DEL_ALL']
|
||||
del_build = _conf_slpkg['DEL_BUILD']
|
||||
sbo_build_log = _conf_slpkg['SBO_BUILD_LOG']
|
||||
default_answer = _conf_slpkg['DEFAULT_ANSWER']
|
||||
remove_deps_answer = _conf_slpkg['REMOVE_DEPS_ANSWER']
|
||||
skip_unst = _conf_slpkg['SKIP_UNST']
|
||||
rsl_deps = _conf_slpkg['RSL_DEPS']
|
||||
del_deps = _conf_slpkg['DEL_DEPS']
|
||||
use_colors = _conf_slpkg['USE_COLORS']
|
||||
wget_options = _conf_slpkg['WGET_OPTIONS']
|
||||
slackpkg_log = _conf_slpkg['SLACKPKG_LOG']
|
||||
only_installed = _conf_slpkg['ONLY_INSTALLED']
|
||||
repositories = _conf_slpkg["REPOSITORIES"]
|
||||
build_path = _conf_slpkg["BUILD_PATH"]
|
||||
slpkg_tmp_packages = _conf_slpkg["PACKAGES"]
|
||||
slpkg_tmp_patches = _conf_slpkg["PATCHES"]
|
||||
checkmd5 = _conf_slpkg["CHECKMD5"]
|
||||
del_all = _conf_slpkg["DEL_ALL"]
|
||||
del_build = _conf_slpkg["DEL_BUILD"]
|
||||
sbo_build_log = _conf_slpkg["SBO_BUILD_LOG"]
|
||||
default_answer = _conf_slpkg["DEFAULT_ANSWER"]
|
||||
remove_deps_answer = _conf_slpkg["REMOVE_DEPS_ANSWER"]
|
||||
skip_unst = _conf_slpkg["SKIP_UNST"]
|
||||
rsl_deps = _conf_slpkg["RSL_DEPS"]
|
||||
del_deps = _conf_slpkg["DEL_DEPS"]
|
||||
use_colors = _conf_slpkg["USE_COLORS"]
|
||||
wget_options = _conf_slpkg["WGET_OPTIONS"]
|
||||
slackpkg_log = _conf_slpkg["SLACKPKG_LOG"]
|
||||
only_installed = _conf_slpkg["ONLY_INSTALLED"]
|
||||
|
||||
# Remove any gaps
|
||||
repositories = [repo.strip() for repo in repositories]
|
||||
|
@ -174,8 +168,8 @@ class MetaData(object):
|
|||
slack_rel = select_slack_release(slack_rel)
|
||||
|
||||
# Grap sub repositories
|
||||
ktown_kde_repo = grab_sub_repo(repositories, 'ktown')
|
||||
slacke_sub_repo = grab_sub_repo(repositories, 'slacke')
|
||||
ktown_kde_repo = grab_sub_repo(repositories, "ktown")
|
||||
slacke_sub_repo = grab_sub_repo(repositories, "slacke")
|
||||
|
||||
# remove no default repositories
|
||||
repositories = remove_repositories(repositories, default_repositories)
|
||||
|
@ -184,22 +178,22 @@ class MetaData(object):
|
|||
update_repositories(repositories, conf_path)
|
||||
|
||||
color = {
|
||||
'RED': '\x1b[31m',
|
||||
'GREEN': '\x1b[32m',
|
||||
'YELLOW': '\x1b[33m',
|
||||
'CYAN': '\x1b[36m',
|
||||
'GREY': '\x1b[38;5;247m',
|
||||
'ENDC': '\x1b[0m'
|
||||
"RED": "\x1b[31m",
|
||||
"GREEN": "\x1b[32m",
|
||||
"YELLOW": "\x1b[33m",
|
||||
"CYAN": "\x1b[36m",
|
||||
"GREY": "\x1b[38;5;247m",
|
||||
"ENDC": "\x1b[0m"
|
||||
}
|
||||
|
||||
if use_colors in ["off", "OFF"]:
|
||||
color = {
|
||||
'RED': '',
|
||||
'GREEN': '',
|
||||
'YELLOW': '',
|
||||
'CYAN': '',
|
||||
'GREY': '',
|
||||
'ENDC': ''
|
||||
"RED": "",
|
||||
"GREEN": "",
|
||||
"YELLOW": "",
|
||||
"CYAN": "",
|
||||
"GREY": "",
|
||||
"ENDC": ""
|
||||
}
|
||||
|
||||
CHECKSUMS_link = ("https://raw.githubusercontent.com/{0}/{1}/"
|
||||
|
@ -234,8 +228,8 @@ class MetaData(object):
|
|||
|
||||
# get sbo OUTPUT enviroment variable
|
||||
try:
|
||||
output = os.environ['OUTPUT']
|
||||
output = os.environ["OUTPUT"]
|
||||
except KeyError:
|
||||
output = tmp
|
||||
if not output.endswith('/'):
|
||||
output = output + '/'
|
||||
if not output.endswith("/"):
|
||||
output = output + "/"
|
||||
|
|
|
@ -36,7 +36,7 @@ def options():
|
|||
"""Slpkg is a user-friendly package manager for Slackware installations
|
||||
_ _
|
||||
___| |_ __ | | ____ _
|
||||
/ __| | '_ \| |/ / _` |
|
||||
/ __| | "_ \| |/ / _` |
|
||||
\__ \ | |_) | < (_| |
|
||||
|___/_| .__/|_|\_\__, |
|
||||
|_| |___/
|
||||
|
|
|
@ -38,9 +38,9 @@ from greps import repo_data
|
|||
|
||||
|
||||
def pkg_upgrade(repo, skip):
|
||||
'''
|
||||
"""
|
||||
Checking packages for upgrade
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
Msg().checking()
|
||||
PACKAGES_TXT = RepoInit(repo).fetch()[0]
|
||||
|
@ -63,7 +63,7 @@ def pkg_upgrade(repo, skip):
|
|||
repo_pkg[3] >= inst_pkg[3] and
|
||||
inst_pkg[0] not in BlackList().packages() and
|
||||
inst_pkg[0] not in skip):
|
||||
pkgs_for_upgrade.append('{0}-{1}'.format(repo_pkg[0],
|
||||
pkgs_for_upgrade.append("{0}-{1}".format(repo_pkg[0],
|
||||
repo_pkg[1]))
|
||||
Msg().done()
|
||||
return pkgs_for_upgrade
|
||||
|
@ -73,7 +73,7 @@ def pkg_upgrade(repo, skip):
|
|||
|
||||
|
||||
def installed():
|
||||
'''
|
||||
"""
|
||||
Return all installed packages
|
||||
'''
|
||||
return find_package('', _m.pkg_path)
|
||||
"""
|
||||
return find_package("", _m.pkg_path)
|
||||
|
|
|
@ -40,10 +40,10 @@ class Dependencies(object):
|
|||
self.packages = Utils().package_name(PACKAGES_TXT, repo)
|
||||
|
||||
def binary(self, name, resolve):
|
||||
'''
|
||||
"""
|
||||
Build all dependencies of a package
|
||||
'''
|
||||
if _m.rsl_deps in ['on', 'ON'] and resolve:
|
||||
"""
|
||||
if _m.rsl_deps in ["on", "ON"] and resolve:
|
||||
try:
|
||||
sys.setrecursionlimit(10000)
|
||||
dependencies = []
|
||||
|
|
|
@ -33,14 +33,14 @@ from slpkg.slack.slack_version import slack_ver
|
|||
|
||||
|
||||
def repo_data(PACKAGES_TXT, step, repo, resolve):
|
||||
'''
|
||||
"""
|
||||
Grap data packages
|
||||
'''
|
||||
"""
|
||||
(name, location, size, unsize,
|
||||
rname, rlocation, rsize, runsize) = ([] for i in range(8))
|
||||
index, toolbar_width = 0, 100
|
||||
for line in PACKAGES_TXT.splitlines():
|
||||
if _m.rsl_deps in ['on', 'ON'] and resolve:
|
||||
if _m.rsl_deps in ["on", "ON"] and resolve:
|
||||
index += 1
|
||||
toolbar_width = status(index, toolbar_width, step)
|
||||
if line.startswith("PACKAGE NAME:"):
|
||||
|
@ -84,9 +84,9 @@ def repo_data(PACKAGES_TXT, step, repo, resolve):
|
|||
|
||||
|
||||
def rlw_filter(name, location, size, unsize):
|
||||
'''
|
||||
"""
|
||||
Filter rlw repository data
|
||||
'''
|
||||
"""
|
||||
arch = os.uname()[4]
|
||||
if arch.startswith("i") and arch.endswith("86"):
|
||||
arch = "i486"
|
||||
|
@ -102,9 +102,9 @@ def rlw_filter(name, location, size, unsize):
|
|||
|
||||
|
||||
def alien_filter(name, location, size, unsize):
|
||||
'''
|
||||
Filter Alien's repository data
|
||||
'''
|
||||
"""
|
||||
Filter Alien"s repository data
|
||||
"""
|
||||
ver = slack_ver()
|
||||
if _m.slack_rel == "current":
|
||||
ver = "current"
|
||||
|
@ -122,9 +122,9 @@ def alien_filter(name, location, size, unsize):
|
|||
|
||||
|
||||
def ktown_filter(name, location, size, unsize):
|
||||
'''
|
||||
Filter Alien's ktown repository data
|
||||
'''
|
||||
"""
|
||||
Filter Alien"s ktown repository data
|
||||
"""
|
||||
ver = slack_ver()
|
||||
if _m.slack_rel == "current":
|
||||
ver = "current"
|
||||
|
@ -142,9 +142,9 @@ def ktown_filter(name, location, size, unsize):
|
|||
|
||||
|
||||
def multi_filter(name, location, size, unsize):
|
||||
'''
|
||||
Filter Alien's multilib repository data
|
||||
'''
|
||||
"""
|
||||
Filter Alien"s multilib repository data
|
||||
"""
|
||||
ver = slack_ver()
|
||||
if _m.slack_rel == "current":
|
||||
ver = "current"
|
||||
|
@ -159,17 +159,17 @@ def multi_filter(name, location, size, unsize):
|
|||
|
||||
|
||||
def fix_slackers_pkg(name):
|
||||
'''
|
||||
Fix 'PACKAGE NAME:' from PACKAGES.TXT file
|
||||
"""
|
||||
Fix "PACKAGE NAME:" from PACKAGES.TXT file
|
||||
Beacause repository slackers.it not report the full
|
||||
name in PACKAGES.TXT file use FILELIST.TXT to
|
||||
get.
|
||||
'''
|
||||
FILELIST_TXT = Utils().read_file(_m.lib_path + 'slackr_repo/FILELIST.TXT')
|
||||
"""
|
||||
FILELIST_TXT = Utils().read_file(_m.lib_path + "slackr_repo/FILELIST.TXT")
|
||||
for line in FILELIST_TXT.splitlines():
|
||||
if name in line and line.endswith(".txz"):
|
||||
return line.split("/")[-1].strip()
|
||||
# This trick fix spliting 'NoneType' packages
|
||||
# This trick fix spliting "NoneType" packages
|
||||
# reference wrong name between PACKAGE.TXT and
|
||||
# FILELIST.TXT
|
||||
return ""
|
||||
|
@ -182,11 +182,11 @@ class Requires(object):
|
|||
self.repo = repo
|
||||
|
||||
def get_deps(self):
|
||||
'''
|
||||
"""
|
||||
Grap package requirements from repositories
|
||||
'''
|
||||
"""
|
||||
if self.repo == "rlw":
|
||||
# Robby's repository dependencies as shown in the central page
|
||||
# Robby"s repository dependencies as shown in the central page
|
||||
# http://rlworkman.net/pkgs/
|
||||
dependencies = {
|
||||
"abiword": "wv",
|
||||
|
@ -201,7 +201,7 @@ class Requires(object):
|
|||
else:
|
||||
return ""
|
||||
else:
|
||||
PACKAGES_TXT = Utils().read_file('{0}{1}_repo/PACKAGES.TXT'.format(
|
||||
PACKAGES_TXT = Utils().read_file("{0}{1}_repo/PACKAGES.TXT".format(
|
||||
_m.lib_path, self.repo))
|
||||
for line in PACKAGES_TXT.splitlines():
|
||||
if line.startswith("PACKAGE NAME:"):
|
||||
|
@ -215,14 +215,14 @@ class Requires(object):
|
|||
return self._req_fix(line)
|
||||
|
||||
def _req_fix(self, line):
|
||||
'''
|
||||
"""
|
||||
Fix slacky and salix requirements because many dependencies splitting
|
||||
with ',' and others with '|'
|
||||
'''
|
||||
with "," and others with "|"
|
||||
"""
|
||||
deps = []
|
||||
for dep in line[18:].strip().split(','):
|
||||
for dep in line[18:].strip().split(","):
|
||||
dep = dep.split("|")
|
||||
if self.repo == 'slacky':
|
||||
if self.repo == "slacky":
|
||||
if len(dep) > 1:
|
||||
for d in dep:
|
||||
deps.append(d.split()[0])
|
||||
|
|
|
@ -62,15 +62,15 @@ class BinaryInstall(object):
|
|||
self.uncomp_sum, self.dep_uncomp_sum = [], []
|
||||
self.dependencies = []
|
||||
self.deps_dict = {}
|
||||
self.answer = ''
|
||||
self.answer = ""
|
||||
Msg().reading()
|
||||
self.PACKAGES_TXT, self.mirror = RepoInit(self.repo).fetch()
|
||||
self.step = 0
|
||||
|
||||
def start(self, if_upgrade):
|
||||
'''
|
||||
"""
|
||||
Install packages from official Slackware distribution
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
# fix if packages is for upgrade
|
||||
self.if_upgrade = if_upgrade
|
||||
|
@ -83,7 +83,7 @@ class BinaryInstall(object):
|
|||
self.packages = self.clear_masters()
|
||||
(self.dwn, self.install, self.comp_sum,
|
||||
self.uncomp_sum) = self.store(self.packages)
|
||||
if _m.rsl_deps in ['on', 'ON'] and self.resolve:
|
||||
if _m.rsl_deps in ["on", "ON"] and self.resolve:
|
||||
Msg().done()
|
||||
if self.install:
|
||||
print("\nThe following packages will be automatically "
|
||||
|
@ -102,7 +102,7 @@ class BinaryInstall(object):
|
|||
self.uncomp_sum + self.dep_uncomp_sum)
|
||||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print("{0}Total {1} {2}.".format(_m.color['GREY'], sum(sums),
|
||||
print("{0}Total {1} {2}.".format(_m.color["GREY"], sum(sums),
|
||||
Msg().pkg(sum(sums))))
|
||||
print("{0} {1} will be installed, {2} will be upgraded and "
|
||||
"{3} will be reinstalled.".format(sums[2],
|
||||
|
@ -112,9 +112,9 @@ class BinaryInstall(object):
|
|||
unit[0]))
|
||||
print("After this process, {0} {1} of additional disk "
|
||||
"space will be used.{2}".format(size[1], unit[1],
|
||||
_m.color['ENDC']))
|
||||
_m.color["ENDC"]))
|
||||
print("")
|
||||
if Msg().answer() in ['y', 'Y']:
|
||||
if Msg().answer() in ["y", "Y"]:
|
||||
self.install.reverse()
|
||||
Download(self.tmp_path, (self.dep_dwn + self.dwn)).start()
|
||||
self.dep_install = Utils().check_downloaded(
|
||||
|
@ -132,9 +132,9 @@ class BinaryInstall(object):
|
|||
sys.exit(0)
|
||||
|
||||
def pkg_exist(self):
|
||||
'''
|
||||
"""
|
||||
Search if package exist
|
||||
'''
|
||||
"""
|
||||
pkg_found, pkg_not_found = [], []
|
||||
for pkg in self.packages:
|
||||
if search_pkg(pkg, self.repo):
|
||||
|
@ -147,10 +147,10 @@ class BinaryInstall(object):
|
|||
self.packages = pkg_not_found
|
||||
|
||||
def clear_masters(self):
|
||||
'''
|
||||
"""
|
||||
Clear master packages if already exist in dependencies
|
||||
or if added to install two or more times
|
||||
'''
|
||||
"""
|
||||
packages = []
|
||||
for mas in Utils().remove_dbs(self.packages):
|
||||
if mas not in self.dependencies:
|
||||
|
@ -158,39 +158,39 @@ class BinaryInstall(object):
|
|||
return packages
|
||||
|
||||
def install_packages(self):
|
||||
'''
|
||||
"""
|
||||
Install or upgrade packages
|
||||
'''
|
||||
"""
|
||||
installs, upgraded = [], []
|
||||
for inst in (self.dep_install + self.install):
|
||||
package = (self.tmp_path + inst).split()
|
||||
pkg_ver = '{0}-{1}'.format(split_package(inst)[0],
|
||||
pkg_ver = "{0}-{1}".format(split_package(inst)[0],
|
||||
split_package(inst)[1])
|
||||
self.checksums(inst)
|
||||
if os.path.isfile(_m.pkg_path + inst[:-4]):
|
||||
print("[ {0}reinstalling{1} ] --> {2}".format(_m.color['GREEN'],
|
||||
_m.color['ENDC'],
|
||||
print("[ {0}reinstalling{1} ] --> {2}".format(_m.color["GREEN"],
|
||||
_m.color["ENDC"],
|
||||
inst))
|
||||
installs.append(pkg_ver)
|
||||
PackageManager(package).reinstall()
|
||||
elif find_package(split_package(inst)[0] + "-", _m.pkg_path):
|
||||
print("[ {0}upgrading{1} ] --> {2}".format(_m.color['YELLOW'],
|
||||
_m.color['ENDC'],
|
||||
print("[ {0}upgrading{1} ] --> {2}".format(_m.color["YELLOW"],
|
||||
_m.color["ENDC"],
|
||||
inst))
|
||||
upgraded.append(pkg_ver)
|
||||
PackageManager(package).upgrade()
|
||||
else:
|
||||
print("[ {0}installing{1} ] --> {2}".format(_m.color['GREEN'],
|
||||
_m.color['ENDC'],
|
||||
print("[ {0}installing{1} ] --> {2}".format(_m.color["GREEN"],
|
||||
_m.color["ENDC"],
|
||||
inst))
|
||||
installs.append(pkg_ver)
|
||||
PackageManager(package).upgrade()
|
||||
return [installs, upgraded]
|
||||
|
||||
def checksums(self, install):
|
||||
'''
|
||||
"""
|
||||
Checksums before install
|
||||
'''
|
||||
"""
|
||||
if self.repo == "alien" and self.version == "stable":
|
||||
check_md5(pkg_checksum("/" + slack_ver() + "/" + install,
|
||||
self.repo), self.tmp_path + install)
|
||||
|
@ -201,11 +201,11 @@ class BinaryInstall(object):
|
|||
check_md5(pkg_checksum(install, self.repo), self.tmp_path + install)
|
||||
|
||||
def resolving_deps(self):
|
||||
'''
|
||||
"""
|
||||
Return package dependencies
|
||||
'''
|
||||
"""
|
||||
requires = []
|
||||
if _m.rsl_deps in ['on', 'ON'] and self.resolve:
|
||||
if _m.rsl_deps in ["on", "ON"] and self.resolve:
|
||||
Msg().resolving()
|
||||
for dep in self.packages:
|
||||
if self.if_upgrade:
|
||||
|
@ -218,25 +218,25 @@ class BinaryInstall(object):
|
|||
return Utils().remove_dbs(requires)
|
||||
|
||||
def views(self, install, comp_sum):
|
||||
'''
|
||||
"""
|
||||
Views packages
|
||||
'''
|
||||
"""
|
||||
pkg_sum = uni_sum = upg_sum = 0
|
||||
# fix repositories align
|
||||
repo = self.repo + (' ' * (6 - (len(self.repo))))
|
||||
repo = self.repo + (" " * (6 - (len(self.repo))))
|
||||
for pkg, comp in zip(install, comp_sum):
|
||||
pkg_split = split_package(pkg[:-4])
|
||||
if find_package(pkg[:-4], _m.pkg_path):
|
||||
pkg_sum += 1
|
||||
COLOR = _m.color['GREEN']
|
||||
COLOR = _m.color["GREEN"]
|
||||
elif find_package(pkg_split[0] + "-", _m.pkg_path):
|
||||
COLOR = _m.color['YELLOW']
|
||||
COLOR = _m.color["YELLOW"]
|
||||
upg_sum += 1
|
||||
else:
|
||||
COLOR = _m.color['RED']
|
||||
COLOR = _m.color["RED"]
|
||||
uni_sum += 1
|
||||
print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>11}{12}".format(
|
||||
COLOR, pkg_split[0], _m.color['ENDC'],
|
||||
COLOR, pkg_split[0], _m.color["ENDC"],
|
||||
" " * (24-len(pkg_split[0])), pkg_split[1],
|
||||
" " * (18-len(pkg_split[1])), pkg_split[2],
|
||||
" " * (8-len(pkg_split[2])), pkg_split[3],
|
||||
|
@ -256,9 +256,9 @@ class BinaryInstall(object):
|
|||
Msg().template(78)
|
||||
|
||||
def store(self, packages):
|
||||
'''
|
||||
"""
|
||||
Store and return packages for install
|
||||
'''
|
||||
"""
|
||||
dwn, install, comp_sum, uncomp_sum = ([] for i in range(4))
|
||||
black = BlackList().packages()
|
||||
# name = data[0]
|
||||
|
|
|
@ -33,19 +33,19 @@ from slpkg.slack.slack_version import slack_ver
|
|||
|
||||
|
||||
class RepoInit(object):
|
||||
'''
|
||||
"""
|
||||
Return PACKAGES.TXT and mirror by repository
|
||||
'''
|
||||
"""
|
||||
|
||||
def __init__(self, repo):
|
||||
self.repo = repo
|
||||
self.mirror = ''
|
||||
self.mirror = ""
|
||||
|
||||
def fetch(self):
|
||||
if self.repo in _m.default_repositories:
|
||||
exec('self._init_{0}()'.format(self.repo))
|
||||
exec("self._init_{0}()".format(self.repo))
|
||||
else:
|
||||
exec('self._init_custom()')
|
||||
exec("self._init_custom()")
|
||||
self.lib = _m.lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo)
|
||||
PACKAGES_TXT = Utils().read_file(self.lib)
|
||||
return PACKAGES_TXT, self.mirror
|
||||
|
@ -54,7 +54,7 @@ class RepoInit(object):
|
|||
self.mirror = "{0}".format(Repo().custom_repository()[self.repo])
|
||||
|
||||
def _init_slack(self):
|
||||
self.mirror = mirrors('', '')
|
||||
self.mirror = mirrors("", "")
|
||||
|
||||
def _init_rlw(self):
|
||||
self.mirror = "{0}{1}/".format(Repo().rlw(), slack_ver())
|
||||
|
|
|
@ -32,21 +32,21 @@ from slpkg.__metadata__ import MetaData as _m
|
|||
|
||||
|
||||
def search_pkg(name, repo):
|
||||
'''
|
||||
"""
|
||||
Search if package exists in PACKAGES.TXT file
|
||||
and return the name.
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
blacklist = BlackList().packages()
|
||||
PACKAGES_TXT = Utils().read_file(_m.lib_path + '{0}_repo/'
|
||||
'PACKAGES.TXT'.format(repo))
|
||||
PACKAGES_TXT = Utils().read_file(_m.lib_path + "{0}_repo/"
|
||||
"PACKAGES.TXT".format(repo))
|
||||
num_lines = sum(1 for line in PACKAGES_TXT)
|
||||
toolbar_width, index, step = 2, 0, num_lines
|
||||
for line in PACKAGES_TXT.splitlines():
|
||||
index += 1
|
||||
toolbar_width = status(index, toolbar_width, step)
|
||||
if line.startswith("PACKAGE NAME: ") and len(line) > 16:
|
||||
if repo == 'slackr':
|
||||
if repo == "slackr":
|
||||
pkg_name = line[15:].strip()
|
||||
else:
|
||||
pkg_name = split_package(line[15:])[0].strip()
|
||||
|
|
|
@ -27,20 +27,20 @@ from __metadata__ import MetaData as _m
|
|||
|
||||
|
||||
class BlackList(object):
|
||||
'''
|
||||
"""
|
||||
Blacklist class to add, remove or listed packages
|
||||
in blacklist file.
|
||||
'''
|
||||
"""
|
||||
def __init__(self):
|
||||
self.quit = False
|
||||
self.blackfile = "/etc/slpkg/blacklist"
|
||||
self.black_conf = Utils().read_file(self.blackfile)
|
||||
|
||||
def packages(self):
|
||||
'''
|
||||
"""
|
||||
Return blacklist packages from /etc/slpkg/blacklist
|
||||
configuration file.
|
||||
'''
|
||||
"""
|
||||
blacklist = []
|
||||
for read in self.black_conf.splitlines():
|
||||
read = read.lstrip()
|
||||
|
@ -49,30 +49,30 @@ class BlackList(object):
|
|||
return blacklist
|
||||
|
||||
def listed(self):
|
||||
'''
|
||||
"""
|
||||
Print blacklist packages
|
||||
'''
|
||||
"""
|
||||
print("\nPackages in blacklist:\n")
|
||||
for black in self.packages():
|
||||
if black:
|
||||
print("{0}{1}{2}".format(_m.color['GREEN'], black,
|
||||
_m.color['ENDC']))
|
||||
print("{0}{1}{2}".format(_m.color["GREEN"], black,
|
||||
_m.color["ENDC"]))
|
||||
self.quit = True
|
||||
if self.quit:
|
||||
print("") # new line at exit
|
||||
|
||||
def add(self, pkgs):
|
||||
'''
|
||||
"""
|
||||
Add blacklist packages if not exist
|
||||
'''
|
||||
"""
|
||||
blacklist = self.packages()
|
||||
pkgs = set(pkgs)
|
||||
print("\nAdd packages in blacklist:\n")
|
||||
with open(self.blackfile, "a") as black_conf:
|
||||
for pkg in pkgs:
|
||||
if pkg not in blacklist:
|
||||
print("{0}{1}{2}".format(_m.color['GREEN'], pkg,
|
||||
_m.color['ENDC']))
|
||||
print("{0}{1}{2}".format(_m.color["GREEN"], pkg,
|
||||
_m.color["ENDC"]))
|
||||
black_conf.write(pkg + "\n")
|
||||
self.quit = True
|
||||
black_conf.close()
|
||||
|
@ -80,17 +80,17 @@ class BlackList(object):
|
|||
print("") # new line at exit
|
||||
|
||||
def remove(self, pkgs):
|
||||
'''
|
||||
"""
|
||||
Remove packages from blacklist
|
||||
'''
|
||||
"""
|
||||
print("\nRemove packages from blacklist:\n")
|
||||
with open(self.blackfile, "w") as remove:
|
||||
for line in self.black_conf.splitlines():
|
||||
if line not in pkgs:
|
||||
remove.write(line + "\n")
|
||||
else:
|
||||
print("{0}{1}{2}".format(_m.color['RED'], line,
|
||||
_m.color['ENDC']))
|
||||
print("{0}{1}{2}".format(_m.color["RED"], line,
|
||||
_m.color["ENDC"]))
|
||||
self.quit = True
|
||||
remove.close()
|
||||
if self.quit:
|
||||
|
|
|
@ -30,26 +30,26 @@ from __metadata__ import MetaData as _m
|
|||
|
||||
|
||||
def check_md5(pkg_md5, src_file):
|
||||
'''
|
||||
"""
|
||||
MD5 Checksum
|
||||
'''
|
||||
"""
|
||||
if _m.checkmd5 in ["on", "ON"]:
|
||||
print('')
|
||||
print("")
|
||||
md5s = md5(src_file)
|
||||
if pkg_md5 != md5s:
|
||||
Msg().template(78)
|
||||
print("| MD5SUM check for {0} [ {1}FAILED{2} ]".format(
|
||||
src_file.split("/")[-1], _m.color['RED'], _m.color['ENDC']))
|
||||
src_file.split("/")[-1], _m.color["RED"], _m.color["ENDC"]))
|
||||
Msg().template(78)
|
||||
print("| Expected: {0}".format(md5s))
|
||||
print("| Found: {0}".format(pkg_md5))
|
||||
Msg().template(78)
|
||||
print('')
|
||||
if not Msg().answer() in ['y', 'Y']:
|
||||
print("")
|
||||
if not Msg().answer() in ["y", "Y"]:
|
||||
sys.exit(0)
|
||||
else:
|
||||
Msg().template(78)
|
||||
print("| MD5SUM check for {0} [ {1}PASSED{2} ]".format(
|
||||
src_file.split("/")[-1], _m.color['GREEN'], _m.color['ENDC']))
|
||||
src_file.split("/")[-1], _m.color["GREEN"], _m.color["ENDC"]))
|
||||
Msg().template(78)
|
||||
print('') # new line after pass checksum
|
||||
print("") # new line after pass checksum
|
||||
|
|
|
@ -34,41 +34,41 @@ class Config(object):
|
|||
self.config_file = "/etc/slpkg/slpkg.conf"
|
||||
|
||||
def view(self):
|
||||
'''
|
||||
"""
|
||||
View slpkg config file
|
||||
'''
|
||||
"""
|
||||
print("") # new line at start
|
||||
conf_args = [
|
||||
'RELEASE',
|
||||
'REPOSITORIES',
|
||||
'BUILD_PATH',
|
||||
'PACKAGES',
|
||||
'PATCHES',
|
||||
'CHECKMD5',
|
||||
'DEL_ALL',
|
||||
'DEL_BUILD',
|
||||
'SBO_BUILD_LOG',
|
||||
'DEFAULT_ANSWER',
|
||||
'REMOVE_DEPS_ANSWER',
|
||||
'SKIP_UNST',
|
||||
'RSL_DEPS',
|
||||
'DEL_DEPS',
|
||||
'USE_COLORS',
|
||||
'WGET_OPTIONS',
|
||||
'SLACKPKG_LOG',
|
||||
'ONLY_INSTALLED'
|
||||
"RELEASE",
|
||||
"REPOSITORIES",
|
||||
"BUILD_PATH",
|
||||
"PACKAGES",
|
||||
"PATCHES",
|
||||
"CHECKMD5",
|
||||
"DEL_ALL",
|
||||
"DEL_BUILD",
|
||||
"SBO_BUILD_LOG",
|
||||
"DEFAULT_ANSWER",
|
||||
"REMOVE_DEPS_ANSWER",
|
||||
"SKIP_UNST",
|
||||
"RSL_DEPS",
|
||||
"DEL_DEPS",
|
||||
"USE_COLORS",
|
||||
"WGET_OPTIONS",
|
||||
"SLACKPKG_LOG",
|
||||
"ONLY_INSTALLED"
|
||||
]
|
||||
read_conf = Utils().read_file(self.config_file)
|
||||
for line in read_conf.splitlines():
|
||||
if not line.startswith("#") and line.split("=")[0] in conf_args:
|
||||
print(line)
|
||||
else:
|
||||
print("{0}{1}{2}".format(_m.color['CYAN'], line,
|
||||
_m.color['ENDC']))
|
||||
print("{0}{1}{2}".format(_m.color["CYAN"], line,
|
||||
_m.color["ENDC"]))
|
||||
print("") # new line at end
|
||||
|
||||
def edit(self, editor):
|
||||
'''
|
||||
"""
|
||||
Edit configuration file
|
||||
'''
|
||||
"""
|
||||
subprocess.call("{0} {1}".format(editor, self.config_file), shell=True)
|
||||
|
|
|
@ -36,18 +36,18 @@ class PkgDesc(object):
|
|||
self.COLOR = ""
|
||||
self.lib = ""
|
||||
color_text = {
|
||||
'red': _m.color['RED'],
|
||||
'green': _m.color['GREEN'],
|
||||
'yellow': _m.color['YELLOW'],
|
||||
'cyan': _m.color['CYAN'],
|
||||
'grey': _m.color['GREY'],
|
||||
'': ''
|
||||
"red": _m.color["RED"],
|
||||
"green": _m.color["GREEN"],
|
||||
"yellow": _m.color["YELLOW"],
|
||||
"cyan": _m.color["CYAN"],
|
||||
"grey": _m.color["GREY"],
|
||||
"": ""
|
||||
}
|
||||
self.COLOR = color_text[self.paint]
|
||||
if self.repo in _m.repositories and self.repo != "sbo":
|
||||
self.lib = _m.lib_path + '{0}_repo/PACKAGES.TXT'.format(self.repo)
|
||||
self.lib = _m.lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo)
|
||||
else:
|
||||
self.lib = _m.lib_path + '{0}_repo/SLACKBUILDS.TXT'.format(
|
||||
self.lib = _m.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(
|
||||
self.repo)
|
||||
|
||||
def view(self):
|
||||
|
@ -58,7 +58,7 @@ class PkgDesc(object):
|
|||
for line in PACKAGES_TXT.splitlines():
|
||||
if line.startswith(self.name + ":"):
|
||||
print(self.COLOR + line[len(self.name) + 1:] +
|
||||
_m.color['ENDC'])
|
||||
_m.color["ENDC"])
|
||||
count += 1
|
||||
if count == 11:
|
||||
break
|
||||
|
@ -67,7 +67,7 @@ class PkgDesc(object):
|
|||
if (line.startswith(
|
||||
"SLACKBUILD SHORT DESCRIPTION: " + self.name + " (")):
|
||||
count += 1
|
||||
print(self.COLOR + line[31:] + _m.color['ENDC'])
|
||||
print(self.COLOR + line[31:] + _m.color["ENDC"])
|
||||
if count == 0:
|
||||
Msg().pkg_not_found("", self.name, "No matching", "\n")
|
||||
else:
|
||||
|
|
|
@ -38,14 +38,14 @@ class Download(object):
|
|||
self.wget_options = _m.wget_options
|
||||
|
||||
def start(self):
|
||||
'''
|
||||
"""
|
||||
Download files usign wget.
|
||||
'''
|
||||
"""
|
||||
dwn_count = 1
|
||||
for dwn in self.url:
|
||||
self.file_name = dwn.split("/")[-1]
|
||||
print("\n[{0}/{1}][ {2}Download{3} ] --> {4}\n".format(
|
||||
dwn_count, len(self.url), _m.color['GREEN'], _m.color['ENDC'],
|
||||
dwn_count, len(self.url), _m.color["GREEN"], _m.color["ENDC"],
|
||||
self.file_name))
|
||||
try:
|
||||
subprocess.call("wget {0} --directory-prefix={1} {2}".format(
|
||||
|
@ -58,11 +58,11 @@ class Download(object):
|
|||
|
||||
def _check_if_downloaded(self):
|
||||
if not os.path.isfile(self.path + self.file_name):
|
||||
print('')
|
||||
print("")
|
||||
Msg().template(78)
|
||||
print("| Download '{0}' file {1}[ FAILED ]{2}".format(
|
||||
self.file_name, _m.color['RED'], _m.color['ENDC']))
|
||||
self.file_name, _m.color["RED"], _m.color["ENDC"]))
|
||||
Msg().template(78)
|
||||
print('')
|
||||
if not Msg().answer() in ['y', 'Y']:
|
||||
print("")
|
||||
if not Msg().answer() in ["y", "Y"]:
|
||||
sys.exit(0)
|
||||
|
|
|
@ -33,21 +33,21 @@ class FileSize(object):
|
|||
self.registry = registry
|
||||
|
||||
def server(self):
|
||||
'''
|
||||
"""
|
||||
Returns the size of remote files
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
tar = urllib2.urlopen(self.registry)
|
||||
meta = tar.info()
|
||||
return int(meta.getheaders("Content-Length")[0])
|
||||
except (urllib2.URLError, IndexError):
|
||||
return ' '
|
||||
return " "
|
||||
except KeyboardInterrupt:
|
||||
print("") # new line at cancel
|
||||
sys.exit(0)
|
||||
|
||||
def local(self):
|
||||
'''
|
||||
"""
|
||||
Returns the size of local files
|
||||
'''
|
||||
"""
|
||||
return os.path.getsize(self.registry)
|
||||
|
|
|
@ -29,9 +29,9 @@ from __metadata__ import MetaData as _m
|
|||
|
||||
|
||||
def pkg_checksum(binary, repo):
|
||||
'''
|
||||
"""
|
||||
Return checksum from CHECKSUMS.md5 file by repository
|
||||
'''
|
||||
"""
|
||||
md5, end = "None", "/"
|
||||
if repo == "slack_patches" and _m.slack_rel == "stable":
|
||||
CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "patches/")).reading()
|
||||
|
@ -40,7 +40,7 @@ def pkg_checksum(binary, repo):
|
|||
elif repo == "slpkg":
|
||||
CHECKSUMS_md5 = URL(_m.CHECKSUMS_link).reading()
|
||||
else:
|
||||
lib = '{0}{1}_repo/CHECKSUMS.md5'.format(_m.lib_path, repo)
|
||||
lib = "{0}{1}_repo/CHECKSUMS.md5".format(_m.lib_path, repo)
|
||||
f = open(lib, "r")
|
||||
CHECKSUMS_md5 = f.read()
|
||||
f.close()
|
||||
|
|
134
slpkg/init.py
134
slpkg/init.py
|
@ -61,9 +61,9 @@ class Initialization(object):
|
|||
os.makedirs(self.slpkg_tmp_patches)
|
||||
|
||||
def custom(self, name):
|
||||
'''
|
||||
"""
|
||||
Creating user select repository local library
|
||||
'''
|
||||
"""
|
||||
repo = Repo().custom_repository()[name]
|
||||
log = self.log_path + name + "/"
|
||||
lib = self.lib_path + "{0}_repo/".format(name)
|
||||
|
@ -83,12 +83,12 @@ class Initialization(object):
|
|||
self.write(lib, md5_file, checksums_md5)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file,
|
||||
packages_txt, md5_file, checksums_md5, '', '')
|
||||
packages_txt, md5_file, checksums_md5, "", "")
|
||||
|
||||
def slack(self):
|
||||
'''
|
||||
"""
|
||||
Creating slack local libraries
|
||||
'''
|
||||
"""
|
||||
log = self.log_path + "slack/"
|
||||
lib = self.lib_path + "slack_repo/"
|
||||
lib_file = "PACKAGES.TXT"
|
||||
|
@ -114,12 +114,12 @@ class Initialization(object):
|
|||
self.write(lib, md5_file, checksums_md5)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt,
|
||||
md5_file, checksums_md5, '', '')
|
||||
md5_file, checksums_md5, "", "")
|
||||
|
||||
def sbo(self):
|
||||
'''
|
||||
"""
|
||||
Creating sbo local library
|
||||
'''
|
||||
"""
|
||||
repo = Repo().sbo()
|
||||
log = self.log_path + "sbo/"
|
||||
lib = self.lib_path + "sbo_repo/"
|
||||
|
@ -141,9 +141,9 @@ class Initialization(object):
|
|||
md5_file, checksums_md5, lst_file, filelist_txt)
|
||||
|
||||
def rlw(self):
|
||||
'''
|
||||
"""
|
||||
Creating rlw local library
|
||||
'''
|
||||
"""
|
||||
repo = Repo().rlw()
|
||||
log = self.log_path + "rlw/"
|
||||
lib = self.lib_path + "rlw_repo/"
|
||||
|
@ -163,12 +163,12 @@ class Initialization(object):
|
|||
self.write(lib, md5_file, checksums_md5)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt,
|
||||
md5_file, checksums_md5, '', '')
|
||||
md5_file, checksums_md5, "", "")
|
||||
|
||||
def alien(self):
|
||||
'''
|
||||
"""
|
||||
Creating alien local library
|
||||
'''
|
||||
"""
|
||||
repo = Repo().alien()
|
||||
log = self.log_path + "alien/"
|
||||
lib = self.lib_path + "alien_repo/"
|
||||
|
@ -188,12 +188,12 @@ class Initialization(object):
|
|||
self.write(lib, md5_file, checksums_md5)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt,
|
||||
md5_file, checksums_md5, '', '')
|
||||
md5_file, checksums_md5, "", "")
|
||||
|
||||
def slacky(self):
|
||||
'''
|
||||
"""
|
||||
Creating alien local library
|
||||
'''
|
||||
"""
|
||||
ar = ""
|
||||
arch = os.uname()[4]
|
||||
repo = Repo().slacky()
|
||||
|
@ -221,12 +221,12 @@ class Initialization(object):
|
|||
self.write(lib, md5_file, checksums_md5)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt,
|
||||
md5_file, checksums_md5, '', '')
|
||||
md5_file, checksums_md5, "", "")
|
||||
|
||||
def studio(self):
|
||||
'''
|
||||
"""
|
||||
Creating alien local library
|
||||
'''
|
||||
"""
|
||||
ar = ""
|
||||
arch = os.uname()[4]
|
||||
repo = Repo().studioware()
|
||||
|
@ -253,12 +253,12 @@ class Initialization(object):
|
|||
self.write(lib, md5_file, checksums_md5)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt,
|
||||
md5_file, checksums_md5, '', '')
|
||||
md5_file, checksums_md5, "", "")
|
||||
|
||||
def slackr(self):
|
||||
'''
|
||||
"""
|
||||
Creating slackers local library
|
||||
'''
|
||||
"""
|
||||
repo = Repo().slackers()
|
||||
log = self.log_path + "slackr/"
|
||||
lib = self.lib_path + "slackr_repo/"
|
||||
|
@ -282,9 +282,9 @@ class Initialization(object):
|
|||
md5_file, checksums_md5, lst_file, filelist_txt)
|
||||
|
||||
def slonly(self):
|
||||
'''
|
||||
"""
|
||||
Creating slackers local library
|
||||
'''
|
||||
"""
|
||||
ar = "{0}-x86".format(slack_ver())
|
||||
arch = os.uname()[4]
|
||||
repo = Repo().slackonly()
|
||||
|
@ -310,12 +310,12 @@ class Initialization(object):
|
|||
self.write(lib, md5_file, checksums_md5)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt,
|
||||
md5_file, checksums_md5, '', '')
|
||||
md5_file, checksums_md5, "", "")
|
||||
|
||||
def ktown(self):
|
||||
'''
|
||||
"""
|
||||
Creating alien ktown local library
|
||||
'''
|
||||
"""
|
||||
repo = Repo().ktown()
|
||||
log = self.log_path + "ktown/"
|
||||
lib = self.lib_path + "ktown_repo/"
|
||||
|
@ -335,12 +335,12 @@ class Initialization(object):
|
|||
self.write(lib, md5_file, checksums_md5)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt,
|
||||
md5_file, checksums_md5, '', '')
|
||||
md5_file, checksums_md5, "", "")
|
||||
|
||||
def multi(self):
|
||||
'''
|
||||
"""
|
||||
Creating alien multilib local library
|
||||
'''
|
||||
"""
|
||||
repo = Repo().multi()
|
||||
log = self.log_path + "multi/"
|
||||
lib = self.lib_path + "multi_repo/"
|
||||
|
@ -360,12 +360,12 @@ class Initialization(object):
|
|||
self.write(lib, md5_file, checksums_md5)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt,
|
||||
md5_file, checksums_md5, '', '')
|
||||
md5_file, checksums_md5, "", "")
|
||||
|
||||
def slacke(self):
|
||||
'''
|
||||
"""
|
||||
Creating Slacke local library
|
||||
'''
|
||||
"""
|
||||
ar = ""
|
||||
arch = os.uname()[4]
|
||||
repo = Repo().slacke()
|
||||
|
@ -394,12 +394,12 @@ class Initialization(object):
|
|||
self.write(lib, md5_file, checksums_md5)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt,
|
||||
md5_file, checksums_md5, '', '')
|
||||
md5_file, checksums_md5, "", "")
|
||||
|
||||
def salix(self):
|
||||
'''
|
||||
"""
|
||||
Creating SalixOS local library
|
||||
'''
|
||||
"""
|
||||
ar = "i486"
|
||||
arch = os.uname()[4]
|
||||
repo = Repo().salix()
|
||||
|
@ -423,12 +423,12 @@ class Initialization(object):
|
|||
self.write(lib, md5_file, checksums_md5)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt,
|
||||
md5_file, checksums_md5, '', '')
|
||||
md5_file, checksums_md5, "", "")
|
||||
|
||||
def slackl(self):
|
||||
'''
|
||||
"""
|
||||
Creating SalixOS local library
|
||||
'''
|
||||
"""
|
||||
ar = "i486"
|
||||
arch = os.uname()[4]
|
||||
repo = Repo().slackel()
|
||||
|
@ -452,12 +452,12 @@ class Initialization(object):
|
|||
self.write(lib, md5_file, checksums_md5)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt,
|
||||
md5_file, checksums_md5, '', '')
|
||||
md5_file, checksums_md5, "", "")
|
||||
|
||||
def rested(self):
|
||||
'''
|
||||
"""
|
||||
Creating alien restricted local library
|
||||
'''
|
||||
"""
|
||||
repo = Repo().restricted()
|
||||
log = self.log_path + "rested/"
|
||||
lib = self.lib_path + "rested_repo/"
|
||||
|
@ -477,12 +477,12 @@ class Initialization(object):
|
|||
self.write(lib, md5_file, checksums_md5)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt,
|
||||
md5_file, checksums_md5, '', '')
|
||||
md5_file, checksums_md5, "", "")
|
||||
|
||||
def write_file(self, path, archive, contents_txt):
|
||||
'''
|
||||
"""
|
||||
Create local file
|
||||
'''
|
||||
"""
|
||||
toolbar_width, index = 2, 0
|
||||
with open("{0}{1}".format(path, archive), "w") as f:
|
||||
for line in contents_txt.splitlines():
|
||||
|
@ -492,10 +492,10 @@ class Initialization(object):
|
|||
f.close()
|
||||
|
||||
def write(self, path, data_file, file_url):
|
||||
'''
|
||||
"""
|
||||
Write repositories files in /var/lib/slpkg
|
||||
and /var/log/slpkg
|
||||
'''
|
||||
"""
|
||||
FILE_TXT = ""
|
||||
if not os.path.isfile(path + data_file):
|
||||
for fu in file_url.split():
|
||||
|
@ -503,7 +503,7 @@ class Initialization(object):
|
|||
self.write_file(path, data_file, FILE_TXT)
|
||||
|
||||
def remote(self, *args):
|
||||
'''
|
||||
"""
|
||||
args[0] = log path
|
||||
args[1] = log_file
|
||||
args[2] = changelog_txt URL
|
||||
|
@ -517,7 +517,7 @@ class Initialization(object):
|
|||
|
||||
We take the size of ChangeLog.txt from the server and locally.
|
||||
If the two files differ in size delete and replace all files with new.
|
||||
'''
|
||||
"""
|
||||
PACKAGES_TXT = ""
|
||||
server = FileSize(args[2]).server()
|
||||
local = FileSize(args[0] + args[1]).local()
|
||||
|
@ -532,10 +532,10 @@ class Initialization(object):
|
|||
# remove FILELIST.TXT
|
||||
if args[8]:
|
||||
os.remove("{0}{1}".format(args[3], args[8]))
|
||||
# read PACKAGES_TXT URL's
|
||||
# read PACKAGES_TXT URL"s
|
||||
for fu in args[5].split():
|
||||
PACKAGES_TXT += URL(fu).reading()
|
||||
# read CHANGELOG_TXX URL's
|
||||
# read CHANGELOG_TXX URL"s
|
||||
CHANGELOG_TXT = URL(args[2]).reading()
|
||||
# create PACKAGES.txt file
|
||||
self.write_file(args[3], args[4], PACKAGES_TXT)
|
||||
|
@ -551,18 +551,18 @@ class Initialization(object):
|
|||
self.write_file(args[3], args[8], FILELIST_TXT)
|
||||
|
||||
def upgrade(self):
|
||||
'''
|
||||
"""
|
||||
Remove all package lists with changelog and checksums files
|
||||
and create lists again
|
||||
'''
|
||||
"""
|
||||
for repo in _m.repositories:
|
||||
changelogs = '{0}{1}{2}'.format(self.log_path, repo,
|
||||
'/ChangeLog.txt')
|
||||
changelogs = "{0}{1}{2}".format(self.log_path, repo,
|
||||
"/ChangeLog.txt")
|
||||
if os.path.isfile(changelogs):
|
||||
os.remove(changelogs)
|
||||
if os.path.isdir(self.lib_path + '{0}_repo/'.format(repo)):
|
||||
for f in os.listdir(self.lib_path + '{0}_repo/'.format(repo)):
|
||||
files = '{0}{1}_repo/{2}'.format(self.lib_path, repo, f)
|
||||
if os.path.isdir(self.lib_path + "{0}_repo/".format(repo)):
|
||||
for f in os.listdir(self.lib_path + "{0}_repo/".format(repo)):
|
||||
files = "{0}{1}_repo/{2}".format(self.lib_path, repo, f)
|
||||
if os.path.isfile(files):
|
||||
os.remove(files)
|
||||
Update().repository()
|
||||
|
@ -571,31 +571,31 @@ class Initialization(object):
|
|||
class Update(object):
|
||||
|
||||
def __init__(self):
|
||||
self._init = 'Initialization()'
|
||||
self._init = "Initialization()"
|
||||
|
||||
def repository(self):
|
||||
'''
|
||||
"""
|
||||
Update all repositories lists
|
||||
'''
|
||||
"""
|
||||
print("\nCheck and update repositories:\n")
|
||||
for repo in _m.repositories:
|
||||
sys.stdout.write("{0}Update repository {1} ...{2}".format(
|
||||
_m.color['GREY'], repo, _m.color['ENDC']))
|
||||
_m.color["GREY"], repo, _m.color["ENDC"]))
|
||||
sys.stdout.flush()
|
||||
if repo in _m.default_repositories:
|
||||
exec('{0}.{1}()'.format(self._init, repo))
|
||||
exec("{0}.{1}()".format(self._init, repo))
|
||||
else:
|
||||
Initialization().custom(repo)
|
||||
sys.stdout.write("{0}Done{1}\n".format(_m.color['GREY'],
|
||||
_m.color['ENDC']))
|
||||
sys.stdout.write("{0}Done{1}\n".format(_m.color["GREY"],
|
||||
_m.color["ENDC"]))
|
||||
print("") # new line at end
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def check_exists_repositories():
|
||||
'''
|
||||
"""
|
||||
Checking if repositories exists by PACKAGES.TXT file
|
||||
'''
|
||||
"""
|
||||
update = False
|
||||
pkg_list = "PACKAGES.TXT"
|
||||
for repo in _m.repositories:
|
||||
|
|
|
@ -30,12 +30,12 @@ from slpkg.pkg.find import find_package
|
|||
|
||||
|
||||
def write_deps(deps_dict):
|
||||
'''
|
||||
"""
|
||||
Write dependencies in a log file
|
||||
into directory `/var/log/slpkg/dep/`
|
||||
'''
|
||||
"""
|
||||
for name, dependencies in deps_dict.iteritems():
|
||||
if find_package(name + '-', _m.pkg_path):
|
||||
if find_package(name + "-", _m.pkg_path):
|
||||
dep_path = _m.log_path + "dep/"
|
||||
if not os.path.exists(dep_path):
|
||||
os.mkdir(dep_path)
|
||||
|
|
296
slpkg/main.py
296
slpkg/main.py
|
@ -63,327 +63,327 @@ class ArgParse(object):
|
|||
def __init__(self, args):
|
||||
self.args = args
|
||||
self.packages = self.args[1:]
|
||||
if len(self.args) > 1 and self.args[0] in ['-q', '-b']:
|
||||
if len(self.args) > 1 and self.args[0] in ["-q", "-b"]:
|
||||
self.packages = self.args[1:-1]
|
||||
elif len(self.packages) > 1 and self.args[0] in ['-s', '-t',
|
||||
'-p', '-F']:
|
||||
elif len(self.packages) > 1 and self.args[0] in ["-s", "-t",
|
||||
"-p", "-F"]:
|
||||
self.packages = self.args[2:]
|
||||
|
||||
if (len(self.args) > 1 and
|
||||
self.args[0] in ['-f', '-i', '-u', '-o', '-r', '-d', '-n'] and
|
||||
self.args[1].endswith('.pkg')):
|
||||
self.args[0] in ["-f", "-i", "-u", "-o", "-r", "-d", "-n"] and
|
||||
self.args[1].endswith(".pkg")):
|
||||
self.packages = Utils().read_file_pkg(self.args[1])
|
||||
elif (len(self.args) >= 3 and
|
||||
self.args[0] in ['-s', '-t', '-p', '-F'] and
|
||||
self.args[0] in ["-s", "-t", "-p", "-F"] and
|
||||
self.args[1] in _m.repositories and
|
||||
self.args[2].endswith('.pkg')):
|
||||
self.args[2].endswith(".pkg")):
|
||||
self.packages = Utils().read_file_pkg(self.args[2])
|
||||
elif (len(self.args) == 3 and self.args[0] in ['-q', '-b'] and
|
||||
self.args[1].endswith('.pkg')):
|
||||
elif (len(self.args) == 3 and self.args[0] in ["-q", "-b"] and
|
||||
self.args[1].endswith(".pkg")):
|
||||
self.packages = Utils().read_file_pkg(self.args[1])
|
||||
|
||||
# checking if repositories exists
|
||||
if len(self.args) > 1 and self.args[0] not in [
|
||||
'-h', '--help', '-v', '--version', 'upgrade', 'repo-list',
|
||||
'repo-add', 'repo-remove', 'update', 'update-slpkg', '-g'
|
||||
"-h", "--help", "-v", "--version", "upgrade", "repo-list",
|
||||
"repo-add", "repo-remove", "update", "update-slpkg", "-g"
|
||||
]:
|
||||
check_exists_repositories()
|
||||
|
||||
def help_version(self):
|
||||
""" Help and version info """
|
||||
if (len(self.args) == 1 and self.args[0] == '-h' or
|
||||
self.args[0] == '--help' and self.args[1:] == []):
|
||||
if (len(self.args) == 1 and self.args[0] == "-h" or
|
||||
self.args[0] == "--help" and self.args[1:] == []):
|
||||
options()
|
||||
elif (len(self.args) == 1 and self.args[0] == '-v' or
|
||||
self.args[0] == '--version' and self.args[1:] == []):
|
||||
elif (len(self.args) == 1 and self.args[0] == "-v" or
|
||||
self.args[0] == "--version" and self.args[1:] == []):
|
||||
prog_version()
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def command_update(self):
|
||||
""" update package lists repositories """
|
||||
if len(self.args) == 1 and self.args[0] == 'update':
|
||||
if len(self.args) == 1 and self.args[0] == "update":
|
||||
Update().repository()
|
||||
|
||||
def command_update_slpkg(self):
|
||||
""" slpkg it self update """
|
||||
if len(self.args) == 2 and self.args[0] == 'update-slpkg':
|
||||
if len(self.args) == 2 and self.args[0] == "update-slpkg":
|
||||
it_self_update()
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def command_repo_list(self):
|
||||
""" repositories list """
|
||||
if len(self.args) == 1 and self.args[0] == 'repo-list':
|
||||
if len(self.args) == 1 and self.args[0] == "repo-list":
|
||||
RepoList().repos()
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def command_repo_add(self):
|
||||
""" add custom repositories """
|
||||
if len(self.args) == 3 and self.args[0] == 'repo-add':
|
||||
if len(self.args) == 3 and self.args[0] == "repo-add":
|
||||
Repo().add(self.args[1], self.args[2])
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def command_repo_remove(self):
|
||||
""" remove custom repositories """
|
||||
if len(self.args) == 2 and self.args[0] == 'repo-remove':
|
||||
if len(self.args) == 2 and self.args[0] == "repo-remove":
|
||||
Repo().remove(self.args[1])
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def command_upgrade(self):
|
||||
""" re create repositories package lists """
|
||||
if len(self.args) == 1 and self.args[0] == 'upgrade':
|
||||
if len(self.args) == 1 and self.args[0] == "upgrade":
|
||||
Initialization().upgrade()
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def command_repo_info(self):
|
||||
""" repositories informations """
|
||||
if (len(self.args) == 2 and self.args[0] == 'repo-info' and
|
||||
if (len(self.args) == 2 and self.args[0] == "repo-info" and
|
||||
self.args[1] in RepoList().all_repos):
|
||||
del RepoList().all_repos
|
||||
RepoInfo().view(self.args[1])
|
||||
elif (len(self.args) > 1 and self.args[0] == 'repo-info' and
|
||||
elif (len(self.args) > 1 and self.args[0] == "repo-info" and
|
||||
self.args[1] not in RepoList().all_repos):
|
||||
usage(self.args[1])
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def auto_build(self):
|
||||
""" auto built tool """
|
||||
if len(self.args) == 3 and self.args[0] == '-a':
|
||||
if len(self.args) == 3 and self.args[0] == "-a":
|
||||
BuildPackage(self.args[1], self.args[2:], _m.path).build()
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def pkg_list(self):
|
||||
""" list of packages by repository """
|
||||
if (len(self.args) == 3 and self.args[0] == '-l' and
|
||||
if (len(self.args) == 3 and self.args[0] == "-l" and
|
||||
self.args[1] in _m.repositories):
|
||||
if self.args[2] == '--index':
|
||||
if self.args[2] == "--index":
|
||||
PackageManager(binary=None).package_list(self.args[1],
|
||||
INDEX=True,
|
||||
installed=False)
|
||||
elif self.args[2] == '--installed':
|
||||
elif self.args[2] == "--installed":
|
||||
PackageManager(binary=None).package_list(self.args[1],
|
||||
INDEX=False,
|
||||
installed=True)
|
||||
else:
|
||||
usage('')
|
||||
elif (len(self.args) == 2 and self.args[0] == '-l' and
|
||||
usage("")
|
||||
elif (len(self.args) == 2 and self.args[0] == "-l" and
|
||||
self.args[1] in _m.repositories):
|
||||
PackageManager(None).package_list(self.args[1], INDEX=False,
|
||||
installed=False)
|
||||
elif (len(self.args) > 1 and self.args[0] == '-l' and
|
||||
elif (len(self.args) > 1 and self.args[0] == "-l" and
|
||||
self.args[1] not in _m.repositories):
|
||||
usage(self.args[1])
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def pkg_upgrade(self):
|
||||
""" check and upgrade packages by repository """
|
||||
skip, resolve = '', True
|
||||
flag = ['--upgrade', '--skip=', '--resolve-off']
|
||||
skip, resolve = "", True
|
||||
flag = ["--upgrade", "--skip=", "--resolve-off"]
|
||||
if flag[2] in self.args:
|
||||
resolve = False
|
||||
index = self.args.index(flag[2])
|
||||
del self.args[index]
|
||||
if (len(self.args) == 4 and self.args[0] == '-c' and
|
||||
if (len(self.args) == 4 and self.args[0] == "-c" and
|
||||
self.args[2] == flag[0] and
|
||||
self.args[3].startswith(flag[1])):
|
||||
skip = ''.join(self.args[3].split("=")[1:]).split(',')
|
||||
skip = "".join(self.args[3].split("=")[1:]).split(",")
|
||||
self.args.pop(3)
|
||||
if (len(self.args) == 3 and self.args[0] == '-c' and
|
||||
if (len(self.args) == 3 and self.args[0] == "-c" and
|
||||
self.args[2] == flag[0]):
|
||||
if (self.args[1] in _m.repositories and
|
||||
self.args[1] not in ['slack', 'sbo']):
|
||||
self.args[1] not in ["slack", "sbo"]):
|
||||
BinaryInstall(pkg_upgrade(self.args[1], skip),
|
||||
self.args[1], resolve).start(if_upgrade=True)
|
||||
elif self.args[1] == 'slack':
|
||||
if _m.only_installed in ['on', 'ON']:
|
||||
BinaryInstall(pkg_upgrade('slack', skip),
|
||||
'slack', resolve).start(if_upgrade=True)
|
||||
elif self.args[1] == "slack":
|
||||
if _m.only_installed in ["on", "ON"]:
|
||||
BinaryInstall(pkg_upgrade("slack", skip),
|
||||
"slack", resolve).start(if_upgrade=True)
|
||||
else:
|
||||
Patches(skip).start()
|
||||
elif self.args[1] == 'sbo':
|
||||
elif self.args[1] == "sbo":
|
||||
SBoInstall(sbo_upgrade(skip), resolve).start(if_upgrade=True)
|
||||
else:
|
||||
usage(self.args[1])
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def pkg_install(self):
|
||||
""" install packages by repository """
|
||||
flag = ['--resolve-off']
|
||||
flag = ["--resolve-off"]
|
||||
resolve = True
|
||||
if self.args[-1] == flag[0]:
|
||||
resolve = False
|
||||
if len(self.args) >= 3 and self.args[0] == '-s':
|
||||
if self.args[1] in _m.repositories and self.args[1] not in ['sbo']:
|
||||
if len(self.args) >= 3 and self.args[0] == "-s":
|
||||
if self.args[1] in _m.repositories and self.args[1] not in ["sbo"]:
|
||||
BinaryInstall(self.packages, self.args[1], resolve).start(
|
||||
if_upgrade=False)
|
||||
elif self.args[1] == 'sbo':
|
||||
elif self.args[1] == "sbo":
|
||||
SBoInstall(self.packages, resolve).start(
|
||||
if_upgrade=False)
|
||||
else:
|
||||
usage(self.args[1])
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def pkg_tracking(self):
|
||||
""" tracking package dependencies """
|
||||
packages = ''.join(self.packages)
|
||||
packages = "".join(self.packages)
|
||||
if len(self.packages) > 1:
|
||||
packages = self.packages[1]
|
||||
if self.args[2].endswith('.pkg'):
|
||||
if self.args[2].endswith(".pkg"):
|
||||
packages = self.packages[0]
|
||||
if (len(self.args) == 3 and self.args[0] == '-t' and
|
||||
if (len(self.args) == 3 and self.args[0] == "-t" and
|
||||
self.args[1] in _m.repositories):
|
||||
track_dep(packages, self.args[1])
|
||||
elif (len(self.args) > 1 and self.args[0] == '-t' and
|
||||
elif (len(self.args) > 1 and self.args[0] == "-t" and
|
||||
self.args[1] not in _m.repositories):
|
||||
usage(self.args[1])
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def sbo_network(self):
|
||||
""" view slackbuilds packages """
|
||||
packages = ''.join(self.packages)
|
||||
packages = "".join(self.packages)
|
||||
if len(self.packages) > 1:
|
||||
packages = self.packages[0]
|
||||
if (len(self.args) == 2 and self.args[0] == '-n' and
|
||||
'sbo' in _m.repositories):
|
||||
if (len(self.args) == 2 and self.args[0] == "-n" and
|
||||
"sbo" in _m.repositories):
|
||||
SBoNetwork(packages).view()
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def pkg_blacklist(self):
|
||||
""" manage blacklist packages """
|
||||
blacklist = BlackList()
|
||||
if (len(self.args) == 2 and self.args[0] == '-b' and
|
||||
self.args[1] == 'list'):
|
||||
if (len(self.args) == 2 and self.args[0] == "-b" and
|
||||
self.args[1] == "list"):
|
||||
blacklist.listed()
|
||||
elif (len(self.args) > 2 and self.args[0] == '-b' and
|
||||
self.args[-1] == '--add'):
|
||||
elif (len(self.args) > 2 and self.args[0] == "-b" and
|
||||
self.args[-1] == "--add"):
|
||||
blacklist.add(self.packages)
|
||||
elif (len(self.args) > 2 and self.args[0] == '-b' and
|
||||
self.args[-1] == '--remove'):
|
||||
elif (len(self.args) > 2 and self.args[0] == "-b" and
|
||||
self.args[-1] == "--remove"):
|
||||
blacklist.remove(self.packages)
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def pkg_queue(self):
|
||||
""" manage packages in queue """
|
||||
queue = QueuePkgs()
|
||||
if (len(self.args) == 2 and self.args[0] == '-q' and
|
||||
self.args[1] == 'list'):
|
||||
if (len(self.args) == 2 and self.args[0] == "-q" and
|
||||
self.args[1] == "list"):
|
||||
queue.listed()
|
||||
elif (len(self.args) > 2 and self.args[0] == '-q' and
|
||||
self.args[-1] == '--add'):
|
||||
elif (len(self.args) > 2 and self.args[0] == "-q" and
|
||||
self.args[-1] == "--add"):
|
||||
queue.add(self.packages)
|
||||
elif (len(self.args) > 2 and self.args[0] == '-q' and
|
||||
self.args[-1] == '--remove'):
|
||||
elif (len(self.args) > 2 and self.args[0] == "-q" and
|
||||
self.args[-1] == "--remove"):
|
||||
queue.remove(self.packages)
|
||||
elif (len(self.args) == 2 and self.args[0] == '-q' and
|
||||
self.args[1] == 'build'):
|
||||
elif (len(self.args) == 2 and self.args[0] == "-q" and
|
||||
self.args[1] == "build"):
|
||||
queue.build()
|
||||
elif (len(self.args) == 2 and self.args[0] == '-q' and
|
||||
self.args[1] == 'install'):
|
||||
elif (len(self.args) == 2 and self.args[0] == "-q" and
|
||||
self.args[1] == "install"):
|
||||
queue.install()
|
||||
elif (len(self.args) == 2 and self.args[0] == '-q' and
|
||||
self.args[1] == 'build-install'):
|
||||
elif (len(self.args) == 2 and self.args[0] == "-q" and
|
||||
self.args[1] == "build-install"):
|
||||
queue.build()
|
||||
queue.install()
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def bin_install(self):
|
||||
""" install Slackware binary packages """
|
||||
if len(self.args) > 1 and self.args[0] == '-i':
|
||||
if len(self.args) > 1 and self.args[0] == "-i":
|
||||
PackageManager(self.packages).install()
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def bin_upgrade(self):
|
||||
""" install-upgrade Slackware binary packages """
|
||||
if len(self.args) > 1 and self.args[0] == '-u':
|
||||
if len(self.args) > 1 and self.args[0] == "-u":
|
||||
PackageManager(self.packages).upgrade()
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def bin_reinstall(self):
|
||||
""" reinstall Slackware binary packages """
|
||||
if len(self.args) > 1 and self.args[0] == '-o':
|
||||
if len(self.args) > 1 and self.args[0] == "-o":
|
||||
PackageManager(self.packages).reinstall()
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def bin_remove(self):
|
||||
""" remove Slackware packages """
|
||||
if len(self.args) > 1 and self.args[0] == '-r':
|
||||
if len(self.args) > 1 and self.args[0] == "-r":
|
||||
PackageManager(self.packages).remove()
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def bin_find(self):
|
||||
""" find installed packages """
|
||||
if len(self.args) > 1 and self.args[0] == '-f':
|
||||
if len(self.args) > 1 and self.args[0] == "-f":
|
||||
PackageManager(self.packages).find()
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def pkg_desc(self):
|
||||
""" print slack-desc by repository"""
|
||||
packages = ''.join(self.packages)
|
||||
packages = "".join(self.packages)
|
||||
if len(self.packages) > 1:
|
||||
packages = self.packages[0]
|
||||
if (len(self.args) == 3 and self.args[0] == '-p' and
|
||||
if (len(self.args) == 3 and self.args[0] == "-p" and
|
||||
self.args[1] in _m.repositories):
|
||||
PkgDesc(packages, self.args[1], '').view()
|
||||
elif (len(self.args) == 4 and self.args[0] == '-p' and
|
||||
self.args[3].startswith('--color=')):
|
||||
colors = ['red', 'green', 'yellow', 'cyan', 'grey']
|
||||
tag = self.args[3][len('--color='):]
|
||||
PkgDesc(packages, self.args[1], "").view()
|
||||
elif (len(self.args) == 4 and self.args[0] == "-p" and
|
||||
self.args[3].startswith("--color=")):
|
||||
colors = ["red", "green", "yellow", "cyan", "grey"]
|
||||
tag = self.args[3][len("--color="):]
|
||||
if self.args[1] in _m.repositories and tag in colors:
|
||||
PkgDesc(packages, self.args[1], tag).view()
|
||||
else:
|
||||
usage('')
|
||||
elif (len(self.args) > 1 and self.args[0] == '-p' and
|
||||
usage("")
|
||||
elif (len(self.args) > 1 and self.args[0] == "-p" and
|
||||
self.args[1] not in _m.repositories):
|
||||
usage(self.args[1])
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def pkg_find(self):
|
||||
"""find packages from all enabled repositories"""
|
||||
if len(self.args) > 1 and self.args[0] == '-F':
|
||||
if len(self.args) > 1 and self.args[0] == "-F":
|
||||
find_from_repos(self.args[1:])
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def pkg_contents(self):
|
||||
""" print packages contents """
|
||||
if len(self.args) > 1 and self.args[0] == '-d':
|
||||
if len(self.args) > 1 and self.args[0] == "-d":
|
||||
PackageManager(self.packages).display()
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
def congiguration(self):
|
||||
""" manage slpkg configuration file """
|
||||
if (len(self.args) == 2 and self.args[0] == '-g' and
|
||||
self.args[1].startswith('config')):
|
||||
editor = self.args[1][len('config='):]
|
||||
if self.args[1] == 'config':
|
||||
if (len(self.args) == 2 and self.args[0] == "-g" and
|
||||
self.args[1].startswith("config")):
|
||||
editor = self.args[1][len("config="):]
|
||||
if self.args[1] == "config":
|
||||
Config().view()
|
||||
elif editor:
|
||||
Config().edit(editor)
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
else:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -395,47 +395,47 @@ def main():
|
|||
argparse = ArgParse(args)
|
||||
|
||||
if len(args) == 0:
|
||||
usage('')
|
||||
usage("")
|
||||
sys.exit(0)
|
||||
|
||||
if len(args) == 2 and args[0] == 'update' and args[1] == 'slpkg':
|
||||
args[0] = 'update-slpkg'
|
||||
if len(args) == 2 and args[0] == "update" and args[1] == "slpkg":
|
||||
args[0] = "update-slpkg"
|
||||
|
||||
arguments = {
|
||||
'-h': argparse.help_version,
|
||||
'--help': argparse.help_version,
|
||||
'-v': argparse.help_version,
|
||||
'--version': argparse.help_version,
|
||||
'update': argparse.command_update,
|
||||
'upgrade': argparse.command_upgrade,
|
||||
'update-slpkg': argparse.command_update_slpkg,
|
||||
'repo-list': argparse.command_repo_list,
|
||||
'repo-add': argparse.command_repo_add,
|
||||
'repo-remove': argparse.command_repo_remove,
|
||||
'repo-info': argparse.command_repo_info,
|
||||
'-a': argparse.auto_build,
|
||||
'-l': argparse.pkg_list,
|
||||
'-c': argparse.pkg_upgrade,
|
||||
'-s': argparse.pkg_install,
|
||||
'-t': argparse.pkg_tracking,
|
||||
'-n': argparse.sbo_network,
|
||||
'-b': argparse.pkg_blacklist,
|
||||
'-q': argparse.pkg_queue,
|
||||
'-i': argparse.bin_install,
|
||||
'-u': argparse.bin_upgrade,
|
||||
'-o': argparse.bin_reinstall,
|
||||
'-r': argparse.bin_remove,
|
||||
'-f': argparse.bin_find,
|
||||
'-F': argparse.pkg_find,
|
||||
'-p': argparse.pkg_desc,
|
||||
'-d': argparse.pkg_contents,
|
||||
'-g': argparse.congiguration,
|
||||
"-h": argparse.help_version,
|
||||
"--help": argparse.help_version,
|
||||
"-v": argparse.help_version,
|
||||
"--version": argparse.help_version,
|
||||
"update": argparse.command_update,
|
||||
"upgrade": argparse.command_upgrade,
|
||||
"update-slpkg": argparse.command_update_slpkg,
|
||||
"repo-list": argparse.command_repo_list,
|
||||
"repo-add": argparse.command_repo_add,
|
||||
"repo-remove": argparse.command_repo_remove,
|
||||
"repo-info": argparse.command_repo_info,
|
||||
"-a": argparse.auto_build,
|
||||
"-l": argparse.pkg_list,
|
||||
"-c": argparse.pkg_upgrade,
|
||||
"-s": argparse.pkg_install,
|
||||
"-t": argparse.pkg_tracking,
|
||||
"-n": argparse.sbo_network,
|
||||
"-b": argparse.pkg_blacklist,
|
||||
"-q": argparse.pkg_queue,
|
||||
"-i": argparse.bin_install,
|
||||
"-u": argparse.bin_upgrade,
|
||||
"-o": argparse.bin_reinstall,
|
||||
"-r": argparse.bin_remove,
|
||||
"-f": argparse.bin_find,
|
||||
"-F": argparse.pkg_find,
|
||||
"-p": argparse.pkg_desc,
|
||||
"-d": argparse.pkg_contents,
|
||||
"-g": argparse.congiguration,
|
||||
}
|
||||
try:
|
||||
arguments[args[0]]()
|
||||
except KeyError:
|
||||
usage('')
|
||||
usage("")
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
|
@ -26,9 +26,9 @@ import hashlib
|
|||
|
||||
|
||||
def md5(source):
|
||||
'''
|
||||
"""
|
||||
Return MD5 Checksum
|
||||
'''
|
||||
"""
|
||||
with open(source) as file_to_check:
|
||||
data = file_to_check.read()
|
||||
return hashlib.md5(data).hexdigest()
|
||||
|
|
|
@ -32,115 +32,115 @@ from slpkg.pkg.find import find_package
|
|||
class Msg(object):
|
||||
|
||||
def pkg_not_found(self, bol, pkg, message, eol):
|
||||
'''
|
||||
"""
|
||||
Print message when package not found
|
||||
'''
|
||||
"""
|
||||
print("{0}No such package {1}: {2}{3}".format(bol, pkg, message, eol))
|
||||
|
||||
def pkg_found(self, pkg, version):
|
||||
'''
|
||||
"""
|
||||
Print message when package found
|
||||
'''
|
||||
"""
|
||||
print("| Package {0}-{1} is already installed".format(pkg, version))
|
||||
|
||||
def pkg_installed(self, pkg):
|
||||
'''
|
||||
"""
|
||||
Print message when package installed
|
||||
'''
|
||||
"""
|
||||
print("| Package {0} installed".format(pkg))
|
||||
|
||||
def s_user(self, user):
|
||||
'''
|
||||
"""
|
||||
Check for root user
|
||||
'''
|
||||
"""
|
||||
if user != "root":
|
||||
print("\nslpkg: error: must have root privileges\n")
|
||||
sys.exit(0)
|
||||
|
||||
def build_FAILED(self, sbo_url, prgnam):
|
||||
'''
|
||||
"""
|
||||
Print error message if build failed
|
||||
'''
|
||||
"""
|
||||
self.template(78)
|
||||
print("| Build package {0} [ {1}FAILED{2} ]".format(prgnam,
|
||||
_m.color['RED'],
|
||||
_m.color['ENDC']))
|
||||
_m.color["RED"],
|
||||
_m.color["ENDC"]))
|
||||
self.template(78)
|
||||
print("| See log file in '{0}/var/log/slpkg/sbo/build_logs{1}' "
|
||||
"directory or read README".format(_m.color['CYAN'],
|
||||
_m.color['ENDC']))
|
||||
"directory or read README".format(_m.color["CYAN"],
|
||||
_m.color["ENDC"]))
|
||||
print("| file: {0}{1}".format(sbo_url, "README"))
|
||||
self.template(78)
|
||||
print # new line at end
|
||||
|
||||
def template(self, max_len):
|
||||
'''
|
||||
"""
|
||||
Print template
|
||||
'''
|
||||
"""
|
||||
print("+" + "=" * max_len)
|
||||
|
||||
def checking(self):
|
||||
'''
|
||||
"""
|
||||
Message checking
|
||||
'''
|
||||
sys.stdout.write("{0}Checking ...{1}".format(_m.color['GREY'],
|
||||
_m.color['ENDC']))
|
||||
"""
|
||||
sys.stdout.write("{0}Checking ...{1}".format(_m.color["GREY"],
|
||||
_m.color["ENDC"]))
|
||||
sys.stdout.flush()
|
||||
|
||||
def reading(self):
|
||||
'''
|
||||
"""
|
||||
Message reading
|
||||
'''
|
||||
"""
|
||||
sys.stdout.write("{0}Reading package lists ...{1}".format(
|
||||
_m.color['GREY'], _m.color['ENDC']))
|
||||
_m.color["GREY"], _m.color["ENDC"]))
|
||||
sys.stdout.flush()
|
||||
|
||||
def resolving(self):
|
||||
'''
|
||||
"""
|
||||
Message resolving
|
||||
'''
|
||||
"""
|
||||
sys.stdout.write("{0}Resolving dependencies ...{1}".format(
|
||||
_m.color['GREY'], _m.color['ENDC']))
|
||||
_m.color["GREY"], _m.color["ENDC"]))
|
||||
sys.stdout.flush()
|
||||
|
||||
def done(self):
|
||||
'''
|
||||
"""
|
||||
Message done
|
||||
'''
|
||||
sys.stdout.write("{0}Done{1}\n".format(_m.color['GREY'],
|
||||
_m.color['ENDC']))
|
||||
"""
|
||||
sys.stdout.write("{0}Done{1}\n".format(_m.color["GREY"],
|
||||
_m.color["ENDC"]))
|
||||
|
||||
def pkg(self, count):
|
||||
'''
|
||||
"""
|
||||
Print singular plural
|
||||
'''
|
||||
"""
|
||||
message = "package"
|
||||
if count > 1:
|
||||
message = message + "s"
|
||||
return message
|
||||
|
||||
def not_found(self, if_upgrade):
|
||||
'''
|
||||
"""
|
||||
Message not found packages
|
||||
'''
|
||||
"""
|
||||
if if_upgrade:
|
||||
print('\nNot found packages for upgrade\n')
|
||||
print("\nNot found packages for upgrade\n")
|
||||
else:
|
||||
print('\nNot found packages for installation\n')
|
||||
print("\nNot found packages for installation\n")
|
||||
|
||||
def upg_inst(self, if_upgrade):
|
||||
'''
|
||||
"""
|
||||
Message installing or upgrading
|
||||
'''
|
||||
"""
|
||||
if not if_upgrade:
|
||||
print("Installing:")
|
||||
else:
|
||||
print("Upgrading:")
|
||||
|
||||
def answer(self):
|
||||
'''
|
||||
"""
|
||||
Message answer
|
||||
'''
|
||||
"""
|
||||
if _m.default_answer == "y":
|
||||
answer = _m.default_answer
|
||||
else:
|
||||
|
@ -148,17 +148,17 @@ class Msg(object):
|
|||
return answer
|
||||
|
||||
def reference(self, install, upgrade):
|
||||
'''
|
||||
"""
|
||||
Reference list with packages installed
|
||||
and upgraded
|
||||
'''
|
||||
"""
|
||||
self.template(78)
|
||||
print("| Total {0} {1} installed and {2} {3} upgraded".format(
|
||||
len(install), self.pkg(len(install)),
|
||||
len(upgrade), self.pkg(len(upgrade))))
|
||||
self.template(78)
|
||||
for installed in (install + upgrade):
|
||||
name = '-'.join(installed.split('-')[:-1])
|
||||
name = "-".join(installed.split("-")[:-1])
|
||||
if find_package(installed, _m.pkg_path):
|
||||
if installed in upgrade:
|
||||
print("| Package {0} upgraded successfully".format(name))
|
||||
|
|
|
@ -57,11 +57,11 @@ class BuildPackage(object):
|
|||
os.mkdir(self.build_logs)
|
||||
|
||||
def build(self):
|
||||
'''
|
||||
"""
|
||||
Build package from source and create log
|
||||
file in path /var/log/slpkg/sbo/build_logs/.
|
||||
Also check md5sum calculates.
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
tar = tarfile.open(self.script)
|
||||
tar.extractall()
|
||||
|
@ -84,7 +84,7 @@ class BuildPackage(object):
|
|||
# start log write
|
||||
log_head(self.build_logs, self.log_file, self.start_log_time)
|
||||
subprocess.Popen("{0} ./{1}.SlackBuild 2>&1 | tee -a "
|
||||
"{2}{3}".format(' '.join(pass_var),
|
||||
"{2}{3}".format(" ".join(pass_var),
|
||||
self.prgnam, self.build_logs,
|
||||
self.log_file), shell=True,
|
||||
stdout=sys.stdout).communicate()
|
||||
|
@ -95,7 +95,7 @@ class BuildPackage(object):
|
|||
self.prgnam, sum_time))
|
||||
else:
|
||||
subprocess.call("{0} ./{1}.SlackBuild".format(
|
||||
' '.join(pass_var), self.prgnam, shell=True))
|
||||
" ".join(pass_var), self.prgnam, shell=True))
|
||||
os.chdir(self.path)
|
||||
except (OSError, IOError):
|
||||
Msg().pkg_not_found("\n", self.prgnam, "Wrong file", "\n")
|
||||
|
@ -104,28 +104,28 @@ class BuildPackage(object):
|
|||
sys.exit(0)
|
||||
|
||||
def _pass_variable(self):
|
||||
'''
|
||||
"""
|
||||
Return enviroment variables
|
||||
'''
|
||||
"""
|
||||
pass_var = []
|
||||
for var in os.environ.keys():
|
||||
if var.split('_')[0] == self.prgnam.upper():
|
||||
pass_var.append('{0}={1}'.format(
|
||||
var.split('_')[1], os.environ[var]))
|
||||
if var.split("_")[0] == self.prgnam.upper():
|
||||
pass_var.append("{0}={1}".format(
|
||||
var.split("_")[1], os.environ[var]))
|
||||
return pass_var
|
||||
|
||||
def _delete_sbo(self):
|
||||
'''
|
||||
"""
|
||||
Delete slackbuild tar.gz file after untar
|
||||
'''
|
||||
"""
|
||||
if os.path.isfile(self.script):
|
||||
os.remove(self.script)
|
||||
|
||||
|
||||
def log_head(path, log_file, log_time):
|
||||
'''
|
||||
"""
|
||||
write headers to log file
|
||||
'''
|
||||
"""
|
||||
with open(path + log_file, "w") as log:
|
||||
log.write("#" * 79 + "\n\n")
|
||||
log.write("File : " + log_file + "\n")
|
||||
|
@ -137,9 +137,9 @@ def log_head(path, log_file, log_time):
|
|||
|
||||
|
||||
def log_end(path, log_file, sum_time):
|
||||
'''
|
||||
"""
|
||||
append END tag to a log file
|
||||
'''
|
||||
"""
|
||||
with open(path + log_file, "a") as log:
|
||||
log.seek(2)
|
||||
log.write("#" * 79 + "\n\n")
|
||||
|
@ -151,9 +151,9 @@ def log_end(path, log_file, sum_time):
|
|||
|
||||
|
||||
def build_time(start_time):
|
||||
'''
|
||||
"""
|
||||
Calculate build time per package
|
||||
'''
|
||||
"""
|
||||
diff_time = round(time.time() - start_time, 2)
|
||||
if diff_time <= 59.99:
|
||||
sum_time = str(diff_time) + " Sec"
|
||||
|
|
|
@ -29,13 +29,13 @@ from slpkg.splitting import split_package
|
|||
|
||||
|
||||
def find_package(find_pkg, directory):
|
||||
'''
|
||||
"""
|
||||
Find packages
|
||||
'''
|
||||
"""
|
||||
pkgs = []
|
||||
blacklist = BlackList().packages()
|
||||
for pkg in sorted(os.listdir(directory)):
|
||||
if (not pkg.startswith('.') and pkg.startswith(find_pkg) and
|
||||
if (not pkg.startswith(".") and pkg.startswith(find_pkg) and
|
||||
split_package(pkg)[0] not in blacklist):
|
||||
pkgs.append(pkg)
|
||||
return pkgs
|
||||
|
|
|
@ -36,17 +36,17 @@ from slpkg.binary.greps import fix_slackers_pkg
|
|||
|
||||
|
||||
class PackageManager(object):
|
||||
'''
|
||||
"""
|
||||
Package manager class for install, upgrade,
|
||||
reinstall, remove, find and display packages.
|
||||
'''
|
||||
"""
|
||||
def __init__(self, binary):
|
||||
self.binary = binary
|
||||
|
||||
def install(self):
|
||||
'''
|
||||
"""
|
||||
Install Slackware binary packages
|
||||
'''
|
||||
"""
|
||||
for pkg in self.binary:
|
||||
try:
|
||||
print(subprocess.check_output("installpkg {0}".format(
|
||||
|
@ -56,9 +56,9 @@ class PackageManager(object):
|
|||
self._not_found("Can't install", self.binary, pkg)
|
||||
|
||||
def upgrade(self):
|
||||
'''
|
||||
"""
|
||||
Upgrade Slackware binary packages
|
||||
'''
|
||||
"""
|
||||
for pkg in self.binary:
|
||||
try:
|
||||
print(subprocess.check_output("upgradepkg --install-new "
|
||||
|
@ -68,9 +68,9 @@ class PackageManager(object):
|
|||
self._not_found("Can't upgrade", self.binary, pkg)
|
||||
|
||||
def reinstall(self):
|
||||
'''
|
||||
"""
|
||||
Reinstall Slackware binary packages
|
||||
'''
|
||||
"""
|
||||
for pkg in self.binary:
|
||||
try:
|
||||
print(subprocess.check_output(
|
||||
|
@ -87,9 +87,9 @@ class PackageManager(object):
|
|||
Msg().pkg_not_found(bol, pkg, message, eol)
|
||||
|
||||
def remove(self):
|
||||
'''
|
||||
"""
|
||||
Remove Slackware binary packages
|
||||
'''
|
||||
"""
|
||||
dep_path = _m.log_path + "dep/"
|
||||
dependencies, rmv_list = [], []
|
||||
removed = self._view_removed()
|
||||
|
@ -109,15 +109,15 @@ class PackageManager(object):
|
|||
except KeyboardInterrupt:
|
||||
print("") # new line at exit
|
||||
sys.exit(0)
|
||||
if remove_pkg in ['y', 'Y']:
|
||||
if remove_pkg in ["y", "Y"]:
|
||||
for rmv in removed:
|
||||
# If package build and install with 'slpkg -s sbo <package>'
|
||||
# If package build and install with "slpkg -s sbo <package>"
|
||||
# then look log file for dependencies in /var/log/slpkg/dep,
|
||||
# read and remove all else remove only the package.
|
||||
if os.path.isfile(dep_path + rmv) and _m.del_deps in ["on",
|
||||
"ON"]:
|
||||
dependencies = self._view_deps(dep_path, rmv)
|
||||
if self._rmv_deps_answer() in ['y', 'Y']:
|
||||
if self._rmv_deps_answer() in ["y", "Y"]:
|
||||
rmv_list += (self._rmv_deps(dependencies, dep_path,
|
||||
rmv))
|
||||
else:
|
||||
|
@ -129,9 +129,9 @@ class PackageManager(object):
|
|||
self._reference_rmvs(rmv_list)
|
||||
|
||||
def _rmv_deps_answer(self):
|
||||
'''
|
||||
"""
|
||||
Remove dependencies answer
|
||||
'''
|
||||
"""
|
||||
if _m.remove_deps_answer == "y":
|
||||
remove_dep = _m.remove_deps_answer
|
||||
else:
|
||||
|
@ -145,17 +145,17 @@ class PackageManager(object):
|
|||
return remove_dep
|
||||
|
||||
def _view_removed(self):
|
||||
'''
|
||||
"""
|
||||
View packages before removed
|
||||
'''
|
||||
"""
|
||||
removed = []
|
||||
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
||||
_m.color['CYAN'], ", ".join(self.binary), _m.color['ENDC']))
|
||||
_m.color["CYAN"], ", ".join(self.binary), _m.color["ENDC"]))
|
||||
for pkg in self.binary:
|
||||
pkgs = find_package(pkg + _m.sp, _m.pkg_path)
|
||||
if pkgs:
|
||||
print("[ {0}delete{1} ] --> {2}".format(
|
||||
_m.color['RED'], _m.color['ENDC'],
|
||||
_m.color["RED"], _m.color["ENDC"],
|
||||
"\n ".join(pkgs)))
|
||||
removed.append(pkg)
|
||||
else:
|
||||
|
@ -163,23 +163,23 @@ class PackageManager(object):
|
|||
return removed
|
||||
|
||||
def _view_deps(self, path, package):
|
||||
'''
|
||||
"""
|
||||
View dependencies for before remove
|
||||
'''
|
||||
"""
|
||||
dependencies = Utils().read_file(path + package)
|
||||
print("") # new line at start
|
||||
Msg().template(78)
|
||||
print("| Found dependencies for package {0}:".format(package))
|
||||
Msg().template(78)
|
||||
for dep in dependencies.splitlines():
|
||||
print("| {0}{1}{2}".format(_m.color['RED'], dep, _m.color['ENDC']))
|
||||
print("| {0}{1}{2}".format(_m.color["RED"], dep, _m.color["ENDC"]))
|
||||
Msg().template(78)
|
||||
return dependencies
|
||||
|
||||
def _rmv_deps(self, dependencies, path, package):
|
||||
'''
|
||||
"""
|
||||
Remove dependencies
|
||||
'''
|
||||
"""
|
||||
removes = []
|
||||
deps = dependencies.split()
|
||||
deps.append(package)
|
||||
|
@ -192,18 +192,18 @@ class PackageManager(object):
|
|||
return removes
|
||||
|
||||
def _rmv_pkg(self, package):
|
||||
'''
|
||||
"""
|
||||
Remove one signle package
|
||||
'''
|
||||
"""
|
||||
if find_package(package + _m.sp, _m.pkg_path):
|
||||
print(subprocess.check_output("removepkg {0}".format(package),
|
||||
shell=True))
|
||||
return package.split()
|
||||
|
||||
def _reference_rmvs(self, removes):
|
||||
'''
|
||||
"""
|
||||
Prints all removed packages
|
||||
'''
|
||||
"""
|
||||
Msg().template(78)
|
||||
print("| Total {0} packages removed".format(len(removes)))
|
||||
Msg().template(78)
|
||||
|
@ -216,18 +216,18 @@ class PackageManager(object):
|
|||
print("") # new line at end
|
||||
|
||||
def find(self):
|
||||
'''
|
||||
"""
|
||||
Find installed Slackware packages
|
||||
'''
|
||||
"""
|
||||
matching = size = 0
|
||||
print("\nPackages with matching name [ {0}{1}{2} ]\n".format(
|
||||
_m.color['CYAN'], ', '.join(self.binary), _m.color['ENDC']))
|
||||
_m.color["CYAN"], ", ".join(self.binary), _m.color["ENDC"]))
|
||||
for pkg in self.binary:
|
||||
for match in find_package('', _m.pkg_path):
|
||||
for match in find_package("", _m.pkg_path):
|
||||
if pkg in match:
|
||||
matching += 1
|
||||
print("[ {0}installed{1} ] - {2}".format(
|
||||
_m.color['GREEN'], _m.color['ENDC'], match))
|
||||
_m.color["GREEN"], _m.color["ENDC"], match))
|
||||
data = Utils().read_file(_m.pkg_path + match)
|
||||
for line in data.splitlines():
|
||||
if line.startswith("UNCOMPRESSED PACKAGE SIZE:"):
|
||||
|
@ -241,18 +241,18 @@ class PackageManager(object):
|
|||
Msg().pkg_not_found("", ", ".join(self.binary), message, "\n")
|
||||
else:
|
||||
print("\n{0}Total found {1} matching packages.{2}".format(
|
||||
_m.color['GREY'], matching, _m.color['ENDC']))
|
||||
_m.color["GREY"], matching, _m.color["ENDC"]))
|
||||
unit = "Kb"
|
||||
if size > 1024:
|
||||
unit = "Mb"
|
||||
size = (size / 1024)
|
||||
print("{0}Size of installed packages {1} {2}.{3}\n".format(
|
||||
_m.color['GREY'], round(size, 2), unit, _m.color['ENDC']))
|
||||
_m.color["GREY"], round(size, 2), unit, _m.color["ENDC"]))
|
||||
|
||||
def display(self):
|
||||
'''
|
||||
"""
|
||||
Print the Slackware packages contents
|
||||
'''
|
||||
"""
|
||||
for pkg in self.binary:
|
||||
find = find_package(pkg + _m.sp, _m.pkg_path)
|
||||
if find:
|
||||
|
@ -269,36 +269,36 @@ class PackageManager(object):
|
|||
Msg().pkg_not_found(bol, pkg, message, eol)
|
||||
|
||||
def package_list(self, repo, INDEX, installed):
|
||||
'''
|
||||
"""
|
||||
List with the installed packages
|
||||
'''
|
||||
tty_size = os.popen('stty size', 'r').read().split()
|
||||
"""
|
||||
tty_size = os.popen("stty size", "r").read().split()
|
||||
row = int(tty_size[0]) - 2
|
||||
try:
|
||||
index, page, pkg_list = 0, row, []
|
||||
r = self.list_lib(repo)
|
||||
pkg_list = self.list_greps(repo, r)[0]
|
||||
print('')
|
||||
print("")
|
||||
for pkg in sorted(pkg_list):
|
||||
pkg = self._slackr_repo(repo, pkg)
|
||||
if INDEX:
|
||||
index += 1
|
||||
pkg = self.list_color_tag(pkg)
|
||||
print("{0}{1}:{2} {3}".format(_m.color['GREY'], index,
|
||||
_m.color['ENDC'], pkg))
|
||||
print("{0}{1}:{2} {3}".format(_m.color["GREY"], index,
|
||||
_m.color["ENDC"], pkg))
|
||||
if index == page:
|
||||
read = raw_input("\nPress {0}Enter{1} to "
|
||||
"continue... ".format(
|
||||
_m.color['CYAN'],
|
||||
_m.color['ENDC']))
|
||||
if read in ['Q', 'q']:
|
||||
_m.color["CYAN"],
|
||||
_m.color["ENDC"]))
|
||||
if read in ["Q", "q"]:
|
||||
break
|
||||
print("") # new line after page
|
||||
page += row
|
||||
elif installed:
|
||||
if self.list_of_installed(pkg):
|
||||
print('{0}{1}{2}'.format(_m.color['GREEN'], pkg,
|
||||
_m.color['ENDC']))
|
||||
print("{0}{1}{2}".format(_m.color["GREEN"], pkg,
|
||||
_m.color["ENDC"]))
|
||||
else:
|
||||
print(pkg)
|
||||
print("") # new line at end
|
||||
|
@ -307,12 +307,12 @@ class PackageManager(object):
|
|||
sys.exit(0)
|
||||
|
||||
def list_greps(self, repo, packages):
|
||||
'''
|
||||
"""
|
||||
Grep packages
|
||||
'''
|
||||
"""
|
||||
pkg_list, pkg_size = [], []
|
||||
for line in packages.splitlines():
|
||||
if repo == 'sbo':
|
||||
if repo == "sbo":
|
||||
if line.startswith("SLACKBUILD NAME: "):
|
||||
pkg_list.append(line[17:].strip())
|
||||
pkg_size.append("0 K")
|
||||
|
@ -324,47 +324,47 @@ class PackageManager(object):
|
|||
return pkg_list, pkg_size
|
||||
|
||||
def list_lib(self, repo):
|
||||
'''
|
||||
"""
|
||||
Return package lists
|
||||
'''
|
||||
if repo == 'sbo':
|
||||
"""
|
||||
if repo == "sbo":
|
||||
if (os.path.isfile(
|
||||
_m.lib_path + '{0}_repo/SLACKBUILDS.TXT'.format(repo))):
|
||||
packages = Utils().read_file(_m.lib_path + '{0}_repo/'
|
||||
'SLACKBUILDS.TXT'.format(repo))
|
||||
_m.lib_path + "{0}_repo/SLACKBUILDS.TXT".format(repo))):
|
||||
packages = Utils().read_file(_m.lib_path + "{0}_repo/"
|
||||
"SLACKBUILDS.TXT".format(repo))
|
||||
else:
|
||||
if (os.path.isfile(_m.lib_path + '{0}_repo/PACKAGES.TXT'.format(
|
||||
if (os.path.isfile(_m.lib_path + "{0}_repo/PACKAGES.TXT".format(
|
||||
repo))):
|
||||
packages = Utils().read_file(_m.lib_path + '{0}_repo/'
|
||||
'PACKAGES.TXT'.format(repo))
|
||||
packages = Utils().read_file(_m.lib_path + "{0}_repo/"
|
||||
"PACKAGES.TXT".format(repo))
|
||||
return packages
|
||||
|
||||
def _slackr_repo(self, repo, pkg):
|
||||
'''
|
||||
"""
|
||||
Fix slackers packages
|
||||
'''
|
||||
if repo == 'slackr':
|
||||
"""
|
||||
if repo == "slackr":
|
||||
return fix_slackers_pkg(pkg)
|
||||
return pkg
|
||||
|
||||
def list_color_tag(self, pkg):
|
||||
'''
|
||||
"""
|
||||
Tag with color installed packages
|
||||
'''
|
||||
find = pkg + '-'
|
||||
if pkg.endswith('.txz') or pkg.endswith('.tgz'):
|
||||
"""
|
||||
find = pkg + "-"
|
||||
if pkg.endswith(".txz") or pkg.endswith(".tgz"):
|
||||
find = pkg[:-4]
|
||||
if find_package(find, _m.pkg_path):
|
||||
pkg = '{0}{1}{2}'.format(_m.color['GREEN'], pkg,
|
||||
_m.color['ENDC'])
|
||||
pkg = "{0}{1}{2}".format(_m.color["GREEN"], pkg,
|
||||
_m.color["ENDC"])
|
||||
return pkg
|
||||
|
||||
def list_of_installed(self, pkg):
|
||||
'''
|
||||
"""
|
||||
Return installed packages
|
||||
'''
|
||||
find = pkg + '-'
|
||||
if pkg.endswith('.txz') or pkg.endswith('.tgz'):
|
||||
"""
|
||||
find = pkg + "-"
|
||||
if pkg.endswith(".txz") or pkg.endswith(".tgz"):
|
||||
find = pkg[:-4]
|
||||
if find_package(find, _m.pkg_path):
|
||||
return pkg
|
||||
|
|
|
@ -31,13 +31,13 @@ from __metadata__ import MetaData as _m
|
|||
|
||||
|
||||
def find_from_repos(pkg):
|
||||
'''
|
||||
"""
|
||||
Find packages from enabled repositories
|
||||
'''
|
||||
"""
|
||||
cache = ""
|
||||
count_pkg = count_repo = 0
|
||||
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
||||
_m.color['CYAN'], ", ".join(pkg), _m.color['ENDC']))
|
||||
_m.color["CYAN"], ", ".join(pkg), _m.color["ENDC"]))
|
||||
Msg().template(78)
|
||||
print("| {0} {1}{2}{3}".format("Repository", "Package", " " * 54, "Size"))
|
||||
Msg().template(78)
|
||||
|
@ -58,16 +58,16 @@ def find_from_repos(pkg):
|
|||
find + ver, " " * (53 - len(find + ver)),
|
||||
size))
|
||||
print("\n{0}Total found {1} packages in {2} repositories.{3}\n".format(
|
||||
_m.color['GREY'], count_pkg, count_repo, _m.color['ENDC']))
|
||||
_m.color["GREY"], count_pkg, count_repo, _m.color["ENDC"]))
|
||||
except KeyboardInterrupt:
|
||||
print("") # new line at exit
|
||||
sys.exit(0)
|
||||
|
||||
|
||||
def sbo_version(repo, find):
|
||||
'''
|
||||
"""
|
||||
Add version to SBo packages
|
||||
'''
|
||||
"""
|
||||
ver = ""
|
||||
if repo == "sbo":
|
||||
ver = "-" + SBoGrep(find).version()
|
||||
|
|
|
@ -38,10 +38,10 @@ from pkg.manager import PackageManager
|
|||
|
||||
|
||||
class QueuePkgs(object):
|
||||
'''
|
||||
"""
|
||||
Class to list, add or remove packages in queue,
|
||||
also build or install.
|
||||
'''
|
||||
"""
|
||||
def __init__(self):
|
||||
queue_file = [
|
||||
"# In this file you can create a list of\n",
|
||||
|
@ -63,10 +63,10 @@ class QueuePkgs(object):
|
|||
self.queued = Utils().read_file(self.queue_list)
|
||||
|
||||
def packages(self):
|
||||
'''
|
||||
"""
|
||||
Return queue list from /var/lib/queue/queue_list
|
||||
file.
|
||||
'''
|
||||
"""
|
||||
queue_list = []
|
||||
for read in self.queued.splitlines():
|
||||
read = read.lstrip()
|
||||
|
@ -75,22 +75,22 @@ class QueuePkgs(object):
|
|||
return queue_list
|
||||
|
||||
def listed(self):
|
||||
'''
|
||||
"""
|
||||
Print packages from queue
|
||||
'''
|
||||
"""
|
||||
print("\nPackages in queue:\n")
|
||||
for pkg in self.packages():
|
||||
if pkg:
|
||||
print("{0}{1}{2}".format(_m.color['GREEN'], pkg,
|
||||
_m.color['ENDC']))
|
||||
print("{0}{1}{2}".format(_m.color["GREEN"], pkg,
|
||||
_m.color["ENDC"]))
|
||||
self.quit = True
|
||||
if self.quit:
|
||||
print("") # new line at exit
|
||||
|
||||
def add(self, pkgs):
|
||||
'''
|
||||
"""
|
||||
Add packages in queue if not exist
|
||||
'''
|
||||
"""
|
||||
queue_list = self.packages()
|
||||
pkgs = list(OrderedDict.fromkeys(pkgs))
|
||||
print("\nAdd packages in queue:\n")
|
||||
|
@ -98,22 +98,22 @@ class QueuePkgs(object):
|
|||
for pkg in pkgs:
|
||||
find = sbo_search_pkg(pkg)
|
||||
if pkg not in queue_list and find is not None:
|
||||
print("{0}{1}{2}".format(_m.color['GREEN'], pkg,
|
||||
_m.color['ENDC']))
|
||||
print("{0}{1}{2}".format(_m.color["GREEN"], pkg,
|
||||
_m.color["ENDC"]))
|
||||
queue.write(pkg + "\n")
|
||||
self.quit = True
|
||||
else:
|
||||
print("{0}{1}{2}".format(_m.color['RED'], pkg,
|
||||
_m.color['ENDC']))
|
||||
print("{0}{1}{2}".format(_m.color["RED"], pkg,
|
||||
_m.color["ENDC"]))
|
||||
self.quit = True
|
||||
queue.close()
|
||||
if self.quit:
|
||||
print("") # new line at exit
|
||||
|
||||
def remove(self, pkgs):
|
||||
'''
|
||||
"""
|
||||
Remove packages from queue
|
||||
'''
|
||||
"""
|
||||
print("\nRemove packages from queue:\n")
|
||||
if pkgs == ["all"]:
|
||||
pkgs = self.packages()
|
||||
|
@ -122,17 +122,17 @@ class QueuePkgs(object):
|
|||
if line not in pkgs:
|
||||
queue.write(line + "\n")
|
||||
else:
|
||||
print("{0}{1}{2}".format(_m.color['RED'], line,
|
||||
_m.color['ENDC']))
|
||||
print("{0}{1}{2}".format(_m.color["RED"], line,
|
||||
_m.color["ENDC"]))
|
||||
self.quit = True
|
||||
queue.close()
|
||||
if self.quit:
|
||||
print("") # new line at exit
|
||||
|
||||
def build(self):
|
||||
'''
|
||||
"""
|
||||
Build packages from queue
|
||||
'''
|
||||
"""
|
||||
packages = self.packages()
|
||||
if packages:
|
||||
for pkg in packages:
|
||||
|
@ -153,9 +153,9 @@ class QueuePkgs(object):
|
|||
print("\nPackages not found in the queue for building\n")
|
||||
|
||||
def install(self):
|
||||
'''
|
||||
"""
|
||||
Install packages from queue
|
||||
'''
|
||||
"""
|
||||
packages = self.packages()
|
||||
if packages:
|
||||
print("") # new line at start
|
||||
|
|
|
@ -28,9 +28,9 @@ from __metadata__ import MetaData as _m
|
|||
|
||||
|
||||
def delete(path, packages):
|
||||
'''
|
||||
"""
|
||||
Remove downloaded packages
|
||||
'''
|
||||
"""
|
||||
if _m.del_all in ["on", "ON"]:
|
||||
for pkg in packages:
|
||||
os.remove(path + pkg)
|
||||
|
|
|
@ -36,84 +36,84 @@ class RepoInfo(object):
|
|||
|
||||
def __init__(self):
|
||||
self.form = {
|
||||
'Last updated:': '',
|
||||
'Number of packages:': '',
|
||||
'Repo id:': '',
|
||||
'Default:': '',
|
||||
'Repo url:': '',
|
||||
'Status:': '',
|
||||
'Total compressed packages:': '',
|
||||
'Total uncompressed packages:': ''
|
||||
"Last updated:": "",
|
||||
"Number of packages:": "",
|
||||
"Repo id:": "",
|
||||
"Default:": "",
|
||||
"Repo url:": "",
|
||||
"Status:": "",
|
||||
"Total compressed packages:": "",
|
||||
"Total uncompressed packages:": ""
|
||||
}
|
||||
self.all_repos = RepoList().all_repos
|
||||
self.all_repos.update(Repo().custom_repository())
|
||||
del RepoList().all_repos
|
||||
|
||||
def view(self, repo):
|
||||
'''
|
||||
"""
|
||||
View repository information
|
||||
'''
|
||||
status = '{0}disabled{1}'.format(_m.color['RED'], _m.color['ENDC'])
|
||||
self.form['Status:'] = status
|
||||
self.form['Default:'] = 'no'
|
||||
"""
|
||||
status = "{0}disabled{1}".format(_m.color["RED"], _m.color["ENDC"])
|
||||
self.form["Status:"] = status
|
||||
self.form["Default:"] = "no"
|
||||
if repo in _m.default_repositories:
|
||||
self.form['Default:'] = 'yes'
|
||||
self.form["Default:"] = "yes"
|
||||
if (repo in _m.repositories and
|
||||
os.path.isfile(_m.lib_path + '{0}_repo/PACKAGES.TXT'.format(
|
||||
os.path.isfile(_m.lib_path + "{0}_repo/PACKAGES.TXT".format(
|
||||
repo))):
|
||||
status = '{0}enabled{1}'.format(_m.color['GREEN'], _m.color['ENDC'])
|
||||
if repo != 'sbo':
|
||||
status = "{0}enabled{1}".format(_m.color["GREEN"], _m.color["ENDC"])
|
||||
if repo != "sbo":
|
||||
data = self.repository_data(repo)
|
||||
size = units(data[1], data[2])
|
||||
self.form['Repo id:'] = repo
|
||||
self.form['Repo url:'] = self.all_repos[repo]
|
||||
self.form['Total compressed packages:'] = '{0} {1}'.format(
|
||||
self.form["Repo id:"] = repo
|
||||
self.form["Repo url:"] = self.all_repos[repo]
|
||||
self.form["Total compressed packages:"] = "{0} {1}".format(
|
||||
str(size[1][0]), str(size[0][0]))
|
||||
self.form['Total uncompressed packages:'] = '{0} {1}'.format(
|
||||
self.form["Total uncompressed packages:"] = "{0} {1}".format(
|
||||
str(size[1][1]), str(size[0][1]))
|
||||
self.form['Number of packages:'] = data[0]
|
||||
self.form['Status:'] = status
|
||||
self.form['Last updated:'] = data[3]
|
||||
elif (repo == 'sbo' and os.path.isfile(_m.lib_path + '{0}_repo/'
|
||||
'SLACKBUILDS.TXT'.format(repo))):
|
||||
status = '{0}enabled{1}'.format(_m.color['GREEN'], _m.color['ENDC'])
|
||||
self.form["Number of packages:"] = data[0]
|
||||
self.form["Status:"] = status
|
||||
self.form["Last updated:"] = data[3]
|
||||
elif (repo == "sbo" and os.path.isfile(_m.lib_path + "{0}_repo/"
|
||||
"SLACKBUILDS.TXT".format(repo))):
|
||||
status = "{0}enabled{1}".format(_m.color["GREEN"], _m.color["ENDC"])
|
||||
sum_sbo_pkgs = 0
|
||||
for line in (Utils().read_file(
|
||||
_m.lib_path + 'sbo_repo/SLACKBUILDS.TXT').splitlines()):
|
||||
if line.startswith('SLACKBUILD NAME: '):
|
||||
_m.lib_path + "sbo_repo/SLACKBUILDS.TXT").splitlines()):
|
||||
if line.startswith("SLACKBUILD NAME: "):
|
||||
sum_sbo_pkgs += 1
|
||||
changelog_txt = Utils().read_file(_m.log_path + 'sbo/ChangeLog.txt')
|
||||
last_upd = changelog_txt.split('\n', 1)[0]
|
||||
self.form['Repo id:'] = repo
|
||||
self.form['Repo url:'] = self.all_repos[repo]
|
||||
self.form['Total compressed packages:'] = ''
|
||||
self.form['Total uncompressed packages:'] = ''
|
||||
self.form['Number of packages:'] = sum_sbo_pkgs
|
||||
self.form['Status:'] = status
|
||||
self.form['Last updated:'] = last_upd
|
||||
print('')
|
||||
changelog_txt = Utils().read_file(_m.log_path + "sbo/ChangeLog.txt")
|
||||
last_upd = changelog_txt.split("\n", 1)[0]
|
||||
self.form["Repo id:"] = repo
|
||||
self.form["Repo url:"] = self.all_repos[repo]
|
||||
self.form["Total compressed packages:"] = ""
|
||||
self.form["Total uncompressed packages:"] = ""
|
||||
self.form["Number of packages:"] = sum_sbo_pkgs
|
||||
self.form["Status:"] = status
|
||||
self.form["Last updated:"] = last_upd
|
||||
print("")
|
||||
for key, value in sorted(self.form.iteritems()):
|
||||
print _m.color['GREY'] + key + _m.color['ENDC'], value
|
||||
print('')
|
||||
print _m.color["GREY"] + key + _m.color["ENDC"], value
|
||||
print("")
|
||||
sys.exit(0)
|
||||
|
||||
def repository_data(self, repo):
|
||||
'''
|
||||
"""
|
||||
Grap data packages
|
||||
'''
|
||||
sum_pkgs, size, unsize, last_upd = 0, [], [], ''
|
||||
"""
|
||||
sum_pkgs, size, unsize, last_upd = 0, [], [], ""
|
||||
for line in (Utils().read_file(
|
||||
_m.lib_path + repo + '_repo/PACKAGES.TXT').splitlines()):
|
||||
if line.startswith('PACKAGES.TXT;'):
|
||||
_m.lib_path + repo + "_repo/PACKAGES.TXT").splitlines()):
|
||||
if line.startswith("PACKAGES.TXT;"):
|
||||
last_upd = line[14:].strip()
|
||||
if line.startswith('PACKAGE NAME:'):
|
||||
if line.startswith("PACKAGE NAME:"):
|
||||
sum_pkgs += 1
|
||||
if line.startswith('PACKAGE SIZE (compressed): '):
|
||||
if line.startswith("PACKAGE SIZE (compressed): "):
|
||||
size.append(line[28:-2].strip())
|
||||
if line.startswith('PACKAGE SIZE (uncompressed): '):
|
||||
if line.startswith("PACKAGE SIZE (uncompressed): "):
|
||||
unsize.append(line[30:-2].strip())
|
||||
if repo in ['salix', 'slackl']:
|
||||
log = Utils().read_file(_m.log_path + '{0}/ChangeLog.txt'.format(
|
||||
if repo in ["salix", "slackl"]:
|
||||
log = Utils().read_file(_m.log_path + "{0}/ChangeLog.txt".format(
|
||||
repo))
|
||||
last_upd = log.split('\n', 1)[0]
|
||||
last_upd = log.split("\n", 1)[0]
|
||||
return [sum_pkgs, size, unsize, last_upd]
|
||||
|
|
|
@ -30,55 +30,55 @@ from __metadata__ import MetaData as _m
|
|||
|
||||
|
||||
class RepoList(object):
|
||||
'''
|
||||
"""
|
||||
List of repositories
|
||||
'''
|
||||
"""
|
||||
|
||||
def __init__(self):
|
||||
self.all_repos = {
|
||||
'slack': Repo().slack(),
|
||||
'sbo': Repo().sbo(),
|
||||
'rlw': Repo().rlw(),
|
||||
'alien': Repo().alien(),
|
||||
'slacky': Repo().slacky(),
|
||||
'studio': Repo().studioware(),
|
||||
'slackr': Repo().slackers(),
|
||||
'slonly': Repo().slackonly(),
|
||||
'ktown': Repo().ktown(),
|
||||
'multi': Repo().multi(),
|
||||
'slacke': Repo().slacke(),
|
||||
'salix': Repo().salix(),
|
||||
'slackl': Repo().slackel(),
|
||||
'rested': Repo().restricted()
|
||||
"slack": Repo().slack(),
|
||||
"sbo": Repo().sbo(),
|
||||
"rlw": Repo().rlw(),
|
||||
"alien": Repo().alien(),
|
||||
"slacky": Repo().slacky(),
|
||||
"studio": Repo().studioware(),
|
||||
"slackr": Repo().slackers(),
|
||||
"slonly": Repo().slackonly(),
|
||||
"ktown": Repo().ktown(),
|
||||
"multi": Repo().multi(),
|
||||
"slacke": Repo().slacke(),
|
||||
"salix": Repo().salix(),
|
||||
"slackl": Repo().slackel(),
|
||||
"rested": Repo().restricted()
|
||||
}
|
||||
self.all_repos.update(Repo().custom_repository())
|
||||
|
||||
def repos(self):
|
||||
'''
|
||||
"""
|
||||
View or enabled or disabled repositories
|
||||
'''
|
||||
print('')
|
||||
"""
|
||||
print("")
|
||||
Msg().template(78)
|
||||
print('{0}{1}{2}{3}{4}{5}{6}'.format(
|
||||
'| Repo id', ' ' * 2,
|
||||
'Repo URL', ' ' * 44,
|
||||
'Default', ' ' * 3,
|
||||
'Status'))
|
||||
print("{0}{1}{2}{3}{4}{5}{6}".format(
|
||||
"| Repo id", " " * 2,
|
||||
"Repo URL", " " * 44,
|
||||
"Default", " " * 3,
|
||||
"Status"))
|
||||
Msg().template(78)
|
||||
for repo_id, repo_URL in sorted(self.all_repos.iteritems()):
|
||||
status, COLOR = 'disabled', _m.color['RED']
|
||||
default = 'yes'
|
||||
status, COLOR = "disabled", _m.color["RED"]
|
||||
default = "yes"
|
||||
if len(repo_URL) > 49:
|
||||
repo_URL = repo_URL[:48] + '~'
|
||||
repo_URL = repo_URL[:48] + "~"
|
||||
if repo_id in _m.repositories:
|
||||
status, COLOR = 'enabled', _m.color['GREEN']
|
||||
status, COLOR = "enabled", _m.color["GREEN"]
|
||||
if repo_id not in _m.default_repositories:
|
||||
default = 'no'
|
||||
print(' {0}{1}{2}{3}{4}{5}{6}{7:>8}{8}'.format(
|
||||
repo_id, ' ' * (9 - len(repo_id)),
|
||||
repo_URL, ' ' * (52 - len(repo_URL)),
|
||||
default, ' ' * (8 - len(default)),
|
||||
COLOR, status, _m.color['ENDC']))
|
||||
default = "no"
|
||||
print(" {0}{1}{2}{3}{4}{5}{6}{7:>8}{8}".format(
|
||||
repo_id, " " * (9 - len(repo_id)),
|
||||
repo_URL, " " * (52 - len(repo_URL)),
|
||||
default, " " * (8 - len(default)),
|
||||
COLOR, status, _m.color["ENDC"]))
|
||||
print("\nFor enable or disable default repositories edit "
|
||||
"'/etc/slpkg/slpkg.conf' file\n")
|
||||
sys.exit(0)
|
||||
|
|
|
@ -36,12 +36,12 @@ class Repo(object):
|
|||
self.repositories_list = Utils().read_file(self.repo_file)
|
||||
|
||||
def add(self, repo, url):
|
||||
'''
|
||||
"""
|
||||
Write custom repository name and url in a file
|
||||
'''
|
||||
"""
|
||||
repo_name = []
|
||||
if not url.endswith('/'):
|
||||
url = url + '/'
|
||||
if not url.endswith("/"):
|
||||
url = url + "/"
|
||||
for line in self.repositories_list.splitlines():
|
||||
line = line.lstrip()
|
||||
if line and not line.startswith("#"):
|
||||
|
@ -56,20 +56,20 @@ class Repo(object):
|
|||
print("\nMaximum repository name length must be six (6) "
|
||||
"characters\n")
|
||||
sys.exit(0)
|
||||
elif not url.startswith('http') or url.startswith('ftp'):
|
||||
elif not url.startswith("http") or url.startswith("ftp"):
|
||||
print("\nWrong type URL '{0}'\n".format(url))
|
||||
sys.exit(0)
|
||||
with open(self.repo_file, "a") as repos:
|
||||
new_line = " {0}{1}{2}\n".format(repo, ' ' * (10 - len(repo)), url)
|
||||
new_line = " {0}{1}{2}\n".format(repo, " " * (10 - len(repo)), url)
|
||||
repos.write(new_line)
|
||||
repos.close()
|
||||
print("\nRepository '{0}' successfully added\n".format(repo))
|
||||
sys.exit(0)
|
||||
|
||||
def remove(self, repo):
|
||||
'''
|
||||
"""
|
||||
Remove custom repository
|
||||
'''
|
||||
"""
|
||||
rem_repo = False
|
||||
with open(self.repo_file, "w") as repos:
|
||||
for line in self.repositories_list.splitlines():
|
||||
|
@ -86,9 +86,9 @@ class Repo(object):
|
|||
sys.exit(0)
|
||||
|
||||
def custom_repository(self):
|
||||
'''
|
||||
"""
|
||||
Return dictionary with repo name and url
|
||||
'''
|
||||
"""
|
||||
dict_repo = {}
|
||||
for line in self.repositories_list.splitlines():
|
||||
line = line.lstrip()
|
||||
|
@ -97,12 +97,12 @@ class Repo(object):
|
|||
return dict_repo
|
||||
|
||||
def slack(self):
|
||||
'''
|
||||
"""
|
||||
Official slackware repository
|
||||
'''
|
||||
"""
|
||||
default = "http://mirrors.slackware.com/slackware/"
|
||||
if os.path.isfile("/etc/slpkg/slackware-mirrors"):
|
||||
mirrors = Utils().read_file(_m.conf_path + 'slackware-mirrors')
|
||||
mirrors = Utils().read_file(_m.conf_path + "slackware-mirrors")
|
||||
for line in mirrors.splitlines():
|
||||
line = line.rstrip()
|
||||
if not line.startswith("#") and line:
|
||||
|
@ -110,80 +110,80 @@ class Repo(object):
|
|||
return default
|
||||
|
||||
def sbo(self):
|
||||
'''
|
||||
"""
|
||||
SlackBuilds.org repository
|
||||
'''
|
||||
"""
|
||||
return "http://slackbuilds.org/slackbuilds/"
|
||||
|
||||
def rlw(self):
|
||||
'''
|
||||
Robby's repoisitory
|
||||
'''
|
||||
"""
|
||||
Robby"s repoisitory
|
||||
"""
|
||||
return "http://rlworkman.net/pkgs/"
|
||||
|
||||
def alien(self):
|
||||
'''
|
||||
Alien's slackbuilds repository
|
||||
'''
|
||||
"""
|
||||
Alien"s slackbuilds repository
|
||||
"""
|
||||
return "http://www.slackware.com/~alien/slackbuilds/"
|
||||
|
||||
def slacky(self):
|
||||
'''
|
||||
"""
|
||||
Slacky.eu repository
|
||||
'''
|
||||
"""
|
||||
return "http://repository.slacky.eu/"
|
||||
|
||||
def studioware(self):
|
||||
'''
|
||||
"""
|
||||
Studioware repository
|
||||
'''
|
||||
"""
|
||||
return "http://studioware.org/files/packages/"
|
||||
|
||||
def slackers(self):
|
||||
'''
|
||||
"""
|
||||
Slackers.it repository
|
||||
'''
|
||||
"""
|
||||
return "http://www.slackers.it/repository/"
|
||||
|
||||
def slackonly(self):
|
||||
'''
|
||||
"""
|
||||
Slackonly.com repository
|
||||
'''
|
||||
"""
|
||||
return "https://slackonly.com/pub/packages/"
|
||||
|
||||
def ktown(self):
|
||||
'''
|
||||
Alien's ktown repository
|
||||
'''
|
||||
"""
|
||||
Alien"s ktown repository
|
||||
"""
|
||||
return "http://alien.slackbook.org/ktown/"
|
||||
|
||||
def multi(self):
|
||||
'''
|
||||
Alien's multilib repository
|
||||
'''
|
||||
"""
|
||||
Alien"s multilib repository
|
||||
"""
|
||||
return "http://www.slackware.com/~alien/multilib/"
|
||||
|
||||
def slacke(self):
|
||||
'''
|
||||
"""
|
||||
Slacke slacke{17|18} repository
|
||||
'''
|
||||
"""
|
||||
return "http://ngc891.blogdns.net/pub/"
|
||||
|
||||
def salix(self):
|
||||
'''
|
||||
"""
|
||||
SalixOS salix repository
|
||||
'''
|
||||
"""
|
||||
return "http://download.salixos.org/"
|
||||
|
||||
def slackel(self):
|
||||
'''
|
||||
"""
|
||||
Slackel.gr slackel repository
|
||||
'''
|
||||
"""
|
||||
return "http://www.slackel.gr/repo/"
|
||||
|
||||
def restricted(self):
|
||||
'''
|
||||
"""
|
||||
Slackel.gr slackel repository
|
||||
'''
|
||||
"""
|
||||
return ("http://taper.alienbase.nl/mirrors/people/alien/"
|
||||
"restricted_slackbuilds/")
|
||||
|
|
|
@ -36,9 +36,9 @@ from search import sbo_search_pkg
|
|||
|
||||
|
||||
def sbo_upgrade(skip):
|
||||
'''
|
||||
"""
|
||||
Return packages for upgrade
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
Msg().checking()
|
||||
upgrade_names = []
|
||||
|
@ -61,9 +61,9 @@ def sbo_upgrade(skip):
|
|||
|
||||
|
||||
def sbo_list():
|
||||
'''
|
||||
"""
|
||||
Return all SBo packages
|
||||
'''
|
||||
"""
|
||||
sbo_packages = []
|
||||
for pkg in os.listdir(_m.pkg_path):
|
||||
if pkg.endswith("_SBo"):
|
||||
|
|
|
@ -28,7 +28,7 @@ class SBoLink(object):
|
|||
self.sbo_url = sbo_url
|
||||
|
||||
def tar_gz(self):
|
||||
'''
|
||||
"""
|
||||
Return link slackbuild tar.gz archive
|
||||
'''
|
||||
"""
|
||||
return (self.sbo_url[:-1] + ".tar.gz")
|
||||
|
|
|
@ -38,10 +38,10 @@ class Requires(object):
|
|||
self.dep_results = []
|
||||
|
||||
def sbo(self, name):
|
||||
'''
|
||||
"""
|
||||
Build all dependencies of a package
|
||||
'''
|
||||
if _m.rsl_deps in ['on', 'ON'] and self.resolve:
|
||||
"""
|
||||
if _m.rsl_deps in ["on", "ON"] and self.resolve:
|
||||
try:
|
||||
sys.setrecursionlimit(10000)
|
||||
dependencies = []
|
||||
|
|
|
@ -27,9 +27,9 @@ from slpkg.__metadata__ import MetaData as _m
|
|||
|
||||
|
||||
class SBoGrep(object):
|
||||
'''
|
||||
"""
|
||||
Class data grab
|
||||
'''
|
||||
"""
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
arch64 = "x86_64"
|
||||
|
@ -42,15 +42,15 @@ class SBoGrep(object):
|
|||
self.line_md5_64 = "SLACKBUILD MD5SUM_{0}: ".format(arch64)
|
||||
self.line_des = "SLACKBUILD SHORT DESCRIPTION: "
|
||||
self.sbo_txt = _m.lib_path + "sbo_repo/SLACKBUILDS.TXT"
|
||||
self.answer = ['y', 'Y']
|
||||
self.unst = ['UNSUPPORTED', 'UNTESTED']
|
||||
self.answer = ["y", "Y"]
|
||||
self.unst = ["UNSUPPORTED", "UNTESTED"]
|
||||
self.SLACKBUILDS_TXT = Utils().read_file(self.sbo_txt)
|
||||
|
||||
def source(self):
|
||||
'''
|
||||
"""
|
||||
Grab sources downloads links
|
||||
'''
|
||||
source, source64, = '', ''
|
||||
"""
|
||||
source, source64, = "", ""
|
||||
for line in self.SLACKBUILDS_TXT.splitlines():
|
||||
if line.startswith(self.line_name):
|
||||
sbo_name = line[17:].strip()
|
||||
|
@ -63,7 +63,7 @@ class SBoGrep(object):
|
|||
return self._select_source_arch(source, source64)
|
||||
|
||||
def _select_source_arch(self, source, source64):
|
||||
src = ''
|
||||
src = ""
|
||||
if _m.arch == "x86_64":
|
||||
if source64:
|
||||
src = source64
|
||||
|
@ -79,9 +79,9 @@ class SBoGrep(object):
|
|||
return src
|
||||
|
||||
def requires(self):
|
||||
'''
|
||||
"""
|
||||
Grab package requirements
|
||||
'''
|
||||
"""
|
||||
for line in self.SLACKBUILDS_TXT.splitlines():
|
||||
if line.startswith(self.line_name):
|
||||
sbo_name = line[17:].strip()
|
||||
|
@ -90,9 +90,9 @@ class SBoGrep(object):
|
|||
return line[21:].strip().split()
|
||||
|
||||
def version(self):
|
||||
'''
|
||||
"""
|
||||
Grab package version
|
||||
'''
|
||||
"""
|
||||
for line in self.SLACKBUILDS_TXT.splitlines():
|
||||
if line.startswith(self.line_name):
|
||||
sbo_name = line[17:].strip()
|
||||
|
@ -101,9 +101,9 @@ class SBoGrep(object):
|
|||
return line[20:].strip()
|
||||
|
||||
def checksum(self):
|
||||
'''
|
||||
"""
|
||||
Grab checksum string
|
||||
'''
|
||||
"""
|
||||
md5sum, md5sum64, = [], []
|
||||
for line in self.SLACKBUILDS_TXT.splitlines():
|
||||
if line.startswith(self.line_name):
|
||||
|
@ -117,7 +117,7 @@ class SBoGrep(object):
|
|||
return self._select_md5sum_arch(md5sum, md5sum64)
|
||||
|
||||
def _select_md5sum_arch(self, md5sum, md5sum64):
|
||||
md5 = ''
|
||||
md5 = ""
|
||||
if _m.arch == "x86_64":
|
||||
if md5sum64:
|
||||
md5 = md5sum64
|
||||
|
@ -133,9 +133,9 @@ class SBoGrep(object):
|
|||
return md5
|
||||
|
||||
def description(self):
|
||||
'''
|
||||
"""
|
||||
Grab package verion
|
||||
'''
|
||||
"""
|
||||
for line in self.SLACKBUILDS_TXT.splitlines():
|
||||
if line.startswith(self.line_name):
|
||||
sbo_name = line[17:].strip()
|
||||
|
|
|
@ -31,19 +31,19 @@ class Read(object):
|
|||
self.sbo_url = sbo_url
|
||||
|
||||
def readme(self, sbo_readme):
|
||||
'''
|
||||
"""
|
||||
Read SlackBuild README file
|
||||
'''
|
||||
"""
|
||||
return URL(self.sbo_url + sbo_readme).reading()
|
||||
|
||||
def info(self, name, sbo_file):
|
||||
'''
|
||||
"""
|
||||
Read info file
|
||||
'''
|
||||
"""
|
||||
return URL(self.sbo_url + name + sbo_file).reading()
|
||||
|
||||
def slackbuild(self, name, sbo_file):
|
||||
'''
|
||||
"""
|
||||
Read SlackBuild file
|
||||
'''
|
||||
"""
|
||||
return URL(self.sbo_url + name + sbo_file).reading()
|
||||
|
|
|
@ -29,8 +29,8 @@ from slpkg.__metadata__ import MetaData as _m
|
|||
|
||||
|
||||
def delete(build_folder):
|
||||
'''
|
||||
"""
|
||||
Delete build directory and all its contents.
|
||||
'''
|
||||
"""
|
||||
if _m.del_build in ["on", "ON"] and os.path.exists(build_folder):
|
||||
shutil.rmtree(build_folder)
|
||||
|
|
|
@ -33,9 +33,9 @@ from slpkg.slack.slack_version import slack_ver
|
|||
|
||||
|
||||
def sbo_search_pkg(name):
|
||||
'''
|
||||
"""
|
||||
Search for package path from SLACKBUILDS.TXT file
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
repo = Repo().sbo()
|
||||
blacklist = BlackList().packages()
|
||||
|
|
|
@ -59,13 +59,13 @@ class SBoInstall(object):
|
|||
self.package_found = []
|
||||
self.deps_dict = {}
|
||||
self.toolbar_width, self.index = 2, 0
|
||||
self.answer = ''
|
||||
self.answer = ""
|
||||
self.match = False
|
||||
Msg().reading()
|
||||
|
||||
def start(self, if_upgrade):
|
||||
try:
|
||||
tagc = ''
|
||||
tagc = ""
|
||||
count_ins = count_upg = count_uni = 0
|
||||
self._remove_blacklist()
|
||||
for _sbo in self.slackbuilds:
|
||||
|
@ -84,11 +84,11 @@ class SBoInstall(object):
|
|||
self.master_packages, mas_src = self.sbo_version_source(
|
||||
self.package_found)
|
||||
Msg().done()
|
||||
if _m.rsl_deps in ['on', 'ON'] and self.resolve:
|
||||
if _m.rsl_deps in ["on", "ON"] and self.resolve:
|
||||
Msg().resolving()
|
||||
self.dependencies, dep_src = self.sbo_version_source(
|
||||
self.one_for_all(self.deps))
|
||||
if _m.rsl_deps in ['on', 'ON'] and self.resolve:
|
||||
if _m.rsl_deps in ["on", "ON"] and self.resolve:
|
||||
Msg().done()
|
||||
self.clear_masters()
|
||||
if self.package_found:
|
||||
|
@ -100,27 +100,27 @@ class SBoInstall(object):
|
|||
for sbo, ar in zip(self.master_packages, mas_src):
|
||||
tagc, count_ins, count_upg, count_uni = self.tag(
|
||||
sbo, count_ins, count_upg, count_uni)
|
||||
name = '-'.join(sbo.split('-')[:-1])
|
||||
self.view_packages(tagc, name, sbo.split('-')[-1],
|
||||
name = "-".join(sbo.split("-")[:-1])
|
||||
self.view_packages(tagc, name, sbo.split("-")[-1],
|
||||
self.select_arch(ar))
|
||||
self._view_installing_for_deps()
|
||||
# view dependencies
|
||||
for dep, ar in zip(self.dependencies, dep_src):
|
||||
tagc, count_ins, count_upg, count_uni = self.tag(
|
||||
dep, count_ins, count_upg, count_uni)
|
||||
name = '-'.join(dep.split('-')[:-1])
|
||||
self.view_packages(tagc, name, dep.split('-')[-1],
|
||||
name = "-".join(dep.split("-")[:-1])
|
||||
self.view_packages(tagc, name, dep.split("-")[-1],
|
||||
self.select_arch(ar))
|
||||
count_total = (count_ins + count_upg + count_uni)
|
||||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print("{0}Total {1} {2}.".format(
|
||||
_m.color['GREY'], count_total, Msg().pkg(count_total)))
|
||||
_m.color["GREY"], count_total, Msg().pkg(count_total)))
|
||||
print("{0} {1} will be installed, {2} allready installed and "
|
||||
"{3} {4}".format(count_uni, Msg().pkg(count_uni),
|
||||
count_ins, count_upg,
|
||||
Msg().pkg(count_upg)))
|
||||
print("will be upgraded.{0}\n".format(_m.color['ENDC']))
|
||||
print("will be upgraded.{0}\n".format(_m.color["ENDC"]))
|
||||
self._continue_to_install()
|
||||
else:
|
||||
Msg().not_found(if_upgrade)
|
||||
|
@ -129,9 +129,9 @@ class SBoInstall(object):
|
|||
sys.exit(0)
|
||||
|
||||
def _remove_blacklist(self):
|
||||
'''
|
||||
"""
|
||||
Remove packages in blacklist
|
||||
'''
|
||||
"""
|
||||
rmv_black = []
|
||||
for sbo in self.slackbuilds:
|
||||
if sbo not in BlackList().packages():
|
||||
|
@ -139,36 +139,36 @@ class SBoInstall(object):
|
|||
self.slackbuilds = rmv_black
|
||||
|
||||
def _continue_to_install(self):
|
||||
'''
|
||||
"""
|
||||
Continue to install
|
||||
'''
|
||||
if self.master_packages and Msg().answer() in ['y', 'Y']:
|
||||
"""
|
||||
if self.master_packages and Msg().answer() in ["y", "Y"]:
|
||||
installs, upgraded = self.build_install()
|
||||
Msg().reference(installs, upgraded)
|
||||
write_deps(self.deps_dict)
|
||||
delete(self.build_folder)
|
||||
|
||||
def _view_installing_for_deps(self):
|
||||
'''
|
||||
"""
|
||||
View installing for dependencies message
|
||||
'''
|
||||
"""
|
||||
if not self.match and self.dependencies:
|
||||
print("Installing for dependencies:")
|
||||
|
||||
def clear_masters(self):
|
||||
'''
|
||||
"""
|
||||
Clear master slackbuilds if already exist in dependencies
|
||||
or if added to install two or more times
|
||||
'''
|
||||
"""
|
||||
self.master_packages = Utils().remove_dbs(self.master_packages)
|
||||
for mas in self.master_packages:
|
||||
if mas in self.dependencies:
|
||||
self.master_packages.remove(mas)
|
||||
|
||||
def matching(self):
|
||||
'''
|
||||
"""
|
||||
Return matching SBo
|
||||
'''
|
||||
"""
|
||||
f = open(_m.lib_path + "sbo_repo/SLACKBUILDS.TXT", "r")
|
||||
SLACKBUILDS_TXT = f.read()
|
||||
f.close()
|
||||
|
@ -178,24 +178,24 @@ class SBoInstall(object):
|
|||
self.package_found.append(line[17:])
|
||||
|
||||
def sbo_version_source(self, slackbuilds):
|
||||
'''
|
||||
"""
|
||||
Create sbo name with version
|
||||
'''
|
||||
"""
|
||||
sbo_versions, sources = [], []
|
||||
for sbo in slackbuilds:
|
||||
self.index += 1
|
||||
self.toolbar_width = status(self.index, self.toolbar_width, 4)
|
||||
sbo_ver = '{0}-{1}'.format(sbo, SBoGrep(sbo).version())
|
||||
sbo_ver = "{0}-{1}".format(sbo, SBoGrep(sbo).version())
|
||||
sbo_versions.append(sbo_ver)
|
||||
sources.append(SBoGrep(sbo).source())
|
||||
return [sbo_versions, sources]
|
||||
|
||||
def one_for_all(self, deps):
|
||||
'''
|
||||
"""
|
||||
Because there are dependencies that depend on other
|
||||
dependencies are created lists into other lists.
|
||||
Thus creating this loop create one-dimensional list.
|
||||
'''
|
||||
"""
|
||||
requires, dependencies = [], []
|
||||
deps.reverse()
|
||||
requires = Utils().dimensional_list(deps)
|
||||
|
@ -205,9 +205,9 @@ class SBoInstall(object):
|
|||
return dependencies
|
||||
|
||||
def top_view(self):
|
||||
'''
|
||||
"""
|
||||
View top template
|
||||
'''
|
||||
"""
|
||||
Msg().template(78)
|
||||
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
|
||||
"| Package", " " * 17,
|
||||
|
@ -219,42 +219,42 @@ class SBoInstall(object):
|
|||
Msg().template(78)
|
||||
|
||||
def view_packages(self, *args):
|
||||
'''
|
||||
"""
|
||||
View slackbuild packages with version and arch
|
||||
args[0] package color
|
||||
args[1] package
|
||||
args[2] version
|
||||
args[3] arch
|
||||
'''
|
||||
"""
|
||||
print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>11}{12}".format(
|
||||
args[0], args[1], _m.color['ENDC'],
|
||||
args[0], args[1], _m.color["ENDC"],
|
||||
" " * (24-len(args[1])), args[2],
|
||||
" " * (18-len(args[2])), args[3],
|
||||
" " * (15-len(args[3])), "",
|
||||
"", "SBo", "", "")).rstrip()
|
||||
|
||||
def tag(self, sbo, count_ins, count_upg, count_uni):
|
||||
'''
|
||||
"""
|
||||
Tag with color green if package already installed,
|
||||
color yellow for packages to upgrade and color red
|
||||
if not installed.
|
||||
'''
|
||||
"""
|
||||
if find_package(sbo, _m.pkg_path):
|
||||
paint = _m.color['GREEN']
|
||||
paint = _m.color["GREEN"]
|
||||
count_ins += 1
|
||||
elif find_package('-'.join(sbo.split('-')[:-1]) + '-', _m.pkg_path):
|
||||
paint = _m.color['YELLOW']
|
||||
elif find_package("-".join(sbo.split("-")[:-1]) + "-", _m.pkg_path):
|
||||
paint = _m.color["YELLOW"]
|
||||
count_upg += 1
|
||||
else:
|
||||
paint = _m.color['RED']
|
||||
paint = _m.color["RED"]
|
||||
count_uni += 1
|
||||
return paint, count_ins, count_upg, count_uni
|
||||
|
||||
def select_arch(self, src):
|
||||
'''
|
||||
"""
|
||||
Looks if sources unsupported or untested
|
||||
from arch else select arch
|
||||
'''
|
||||
"""
|
||||
arch = os.uname()[4]
|
||||
if arch.startswith("i") and arch.endswith("86"):
|
||||
arch = "i486"
|
||||
|
@ -264,9 +264,9 @@ class SBoInstall(object):
|
|||
return arch
|
||||
|
||||
def filenames(self, sources):
|
||||
'''
|
||||
"""
|
||||
Return filenames from sources
|
||||
'''
|
||||
"""
|
||||
filename = []
|
||||
for src in sources:
|
||||
# get file from source
|
||||
|
@ -274,9 +274,9 @@ class SBoInstall(object):
|
|||
return filename
|
||||
|
||||
def search_in_tmp(self, prgnam):
|
||||
'''
|
||||
"""
|
||||
Search for binary packages in /tmp directory
|
||||
'''
|
||||
"""
|
||||
binary = []
|
||||
for search in find_package(prgnam, _m.output):
|
||||
if "_SBo" in search:
|
||||
|
@ -284,19 +284,19 @@ class SBoInstall(object):
|
|||
return binary
|
||||
|
||||
def build_install(self):
|
||||
'''
|
||||
"""
|
||||
Searches the package name and version in /tmp to
|
||||
install. If find two or more packages e.g. to build
|
||||
tag 2 or 3 will fit most
|
||||
'''
|
||||
"""
|
||||
slackbuilds = self.dependencies + self.master_packages
|
||||
installs, upgraded, = [], []
|
||||
if not os.path.exists(self.build_folder):
|
||||
os.makedirs(self.build_folder)
|
||||
os.chdir(self.build_folder)
|
||||
for sbo in slackbuilds:
|
||||
pkg = '-'.join(sbo.split('-')[:-1])
|
||||
ver = sbo.split('-')[-1]
|
||||
pkg = "-".join(sbo.split("-")[:-1])
|
||||
ver = sbo.split("-")[-1]
|
||||
prgnam = ("{0}-{1}".format(pkg, ver))
|
||||
sbo_file = "".join(find_package(prgnam, _m.pkg_path))
|
||||
src_link = SBoGrep(pkg).source().split()
|
||||
|
@ -306,9 +306,9 @@ class SBoInstall(object):
|
|||
Msg().template(78)
|
||||
elif self.unst[0] in src_link or self.unst[1] in src_link:
|
||||
Msg().template(78)
|
||||
print("| Package {0} {1}{2}{3}".format(sbo, _m.color['RED'],
|
||||
''.join(src_link),
|
||||
_m.color['ENDC']))
|
||||
print("| Package {0} {1}{2}{3}".format(sbo, _m.color["RED"],
|
||||
"".join(src_link),
|
||||
_m.color["ENDC"]))
|
||||
Msg().template(78)
|
||||
else:
|
||||
sbo_url = sbo_search_pkg(pkg)
|
||||
|
@ -324,13 +324,13 @@ class SBoInstall(object):
|
|||
except ValueError:
|
||||
Msg().build_FAILED(sbo_url, prgnam)
|
||||
sys.exit(0)
|
||||
if find_package(pkg + '-', _m.pkg_path):
|
||||
if find_package(pkg + "-", _m.pkg_path):
|
||||
print("{0}[ Upgrading ] --> {1}{2}".format(
|
||||
_m.color['YELLOW'], _m.color['ENDC'], pkg))
|
||||
_m.color["YELLOW"], _m.color["ENDC"], pkg))
|
||||
upgraded.append(prgnam)
|
||||
else:
|
||||
print("{0}[ Installing ] --> {1}{2}".format(
|
||||
_m.color['GREEN'], _m.color['ENDC'], pkg))
|
||||
_m.color["GREEN"], _m.color["ENDC"], pkg))
|
||||
installs.append(prgnam)
|
||||
PackageManager(binary).upgrade()
|
||||
return installs, upgraded
|
||||
|
|
|
@ -60,10 +60,10 @@ class SBoNetwork(object):
|
|||
Msg().done()
|
||||
|
||||
def view(self):
|
||||
'''
|
||||
"""
|
||||
View SlackBuild package, read or install them
|
||||
from slackbuilds.org
|
||||
'''
|
||||
"""
|
||||
if self.sbo_url:
|
||||
prgnam = ("{0}-{1}".format(self.name, self.sbo_version))
|
||||
self.view_sbo(
|
||||
|
@ -74,27 +74,27 @@ class SBoNetwork(object):
|
|||
FAULT = self.error_uns()
|
||||
while True:
|
||||
choice = self.read_choice()
|
||||
if choice in ['D', 'd']:
|
||||
if choice in ["D", "d"]:
|
||||
Download("", self.dwn_srcs).start()
|
||||
break
|
||||
elif choice in ['R', 'r']:
|
||||
elif choice in ["R", "r"]:
|
||||
README = Read(self.sbo_url).readme("README")
|
||||
fill = self.fill_pager(README)
|
||||
pydoc.pager(README + fill)
|
||||
elif choice in ['F', 'f']:
|
||||
elif choice in ["F", "f"]:
|
||||
info = Read(self.sbo_url).info(self.name, ".info")
|
||||
fill = self.fill_pager(info)
|
||||
pydoc.pager(info + fill)
|
||||
elif choice in ['S', 's']:
|
||||
elif choice in ["S", "s"]:
|
||||
SlackBuild = Read(self.sbo_url).slackbuild(self.name,
|
||||
".SlackBuild")
|
||||
fill = self.fill_pager(SlackBuild)
|
||||
pydoc.pager(SlackBuild + fill)
|
||||
elif choice in ['B', 'b']:
|
||||
elif choice in ["B", "b"]:
|
||||
self.build(FAULT)
|
||||
delete(self.build_folder)
|
||||
break
|
||||
elif choice in ['I', 'i']:
|
||||
elif choice in ["I", "i"]:
|
||||
if not find_package(prgnam + _m.sp, _m.pkg_path):
|
||||
self.build(FAULT)
|
||||
self.install(prgnam)
|
||||
|
@ -112,48 +112,48 @@ class SBoNetwork(object):
|
|||
|
||||
@staticmethod
|
||||
def view_sbo(*args):
|
||||
'''
|
||||
"""
|
||||
View slackbuild.org
|
||||
'''
|
||||
"""
|
||||
color = _m.color
|
||||
print("") # new line at start
|
||||
Msg().template(78)
|
||||
print("| {0}Package {1}{2}{3} --> {4}".format(color['GREEN'],
|
||||
color['CYAN'], args[0],
|
||||
color['GREEN'],
|
||||
color['ENDC'] + args[1]))
|
||||
print("| {0}Package {1}{2}{3} --> {4}".format(color["GREEN"],
|
||||
color["CYAN"], args[0],
|
||||
color["GREEN"],
|
||||
color["ENDC"] + args[1]))
|
||||
Msg().template(78)
|
||||
print("| {0}Description : {1}{2}".format(color['GREEN'],
|
||||
color['ENDC'], args[2]))
|
||||
print("| {0}SlackBuild : {1}{2}".format(color['GREEN'], color['ENDC'],
|
||||
print("| {0}Description : {1}{2}".format(color["GREEN"],
|
||||
color["ENDC"], args[2]))
|
||||
print("| {0}SlackBuild : {1}{2}".format(color["GREEN"], color["ENDC"],
|
||||
args[3]))
|
||||
print("| {0}Sources : {1}{2}".format(color['GREEN'], color['ENDC'],
|
||||
print("| {0}Sources : {1}{2}".format(color["GREEN"], color["ENDC"],
|
||||
args[4]))
|
||||
print("| {0}Requirements : {1}{2}".format(color['YELLOW'],
|
||||
color['ENDC'],
|
||||
print("| {0}Requirements : {1}{2}".format(color["YELLOW"],
|
||||
color["ENDC"],
|
||||
", ".join(args[5])))
|
||||
Msg().template(78)
|
||||
print(" {0}R{1}EADME View the README file".format(
|
||||
color['RED'], color['ENDC']))
|
||||
color["RED"], color["ENDC"]))
|
||||
print(" {0}S{1}lackBuild View the SlackBuild file".format(
|
||||
color['RED'], color['ENDC']))
|
||||
color["RED"], color["ENDC"]))
|
||||
print(" In{0}f{1}o View the Info file".format(
|
||||
color['RED'], color['ENDC']))
|
||||
color["RED"], color["ENDC"]))
|
||||
print(" {0}D{1}ownload Download this package".format(
|
||||
color['RED'], color['ENDC']))
|
||||
color["RED"], color["ENDC"]))
|
||||
print(" {0}B{1}uild Download and build".format(
|
||||
color['RED'], color['ENDC']))
|
||||
color["RED"], color["ENDC"]))
|
||||
print(" {0}I{1}nstall Download/Build/Install".format(
|
||||
color['RED'], color['ENDC']))
|
||||
print(" {0}Q{1}uit Quit\n".format(color['RED'],
|
||||
color['ENDC']))
|
||||
color["RED"], color["ENDC"]))
|
||||
print(" {0}Q{1}uit Quit\n".format(color["RED"],
|
||||
color["ENDC"]))
|
||||
|
||||
@staticmethod
|
||||
def fill_pager(page):
|
||||
'''
|
||||
"""
|
||||
Fix pager spaces
|
||||
'''
|
||||
tty_size = os.popen('stty size', 'r').read().split()
|
||||
"""
|
||||
tty_size = os.popen("stty size", "r").read().split()
|
||||
rows = int(tty_size[0]) - 1
|
||||
lines = sum(1 for line in page.splitlines())
|
||||
diff = rows - lines
|
||||
|
@ -164,33 +164,33 @@ class SBoNetwork(object):
|
|||
return ""
|
||||
|
||||
def read_choice(self):
|
||||
'''
|
||||
"""
|
||||
Return choice
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
choice = raw_input(" {0}Choose an option: {1}".format(
|
||||
_m.color['GREY'], _m.color['ENDC']))
|
||||
_m.color["GREY"], _m.color["ENDC"]))
|
||||
except KeyboardInterrupt:
|
||||
print("") # new line at exit
|
||||
sys.exit(0)
|
||||
return choice
|
||||
|
||||
def error_uns(self):
|
||||
'''
|
||||
"""
|
||||
Check if package supported by arch
|
||||
before proceed to install
|
||||
'''
|
||||
"""
|
||||
UNST = ["UNSUPPORTED", "UNTESTED"]
|
||||
if "".join(self.source_dwn) in UNST:
|
||||
return "".join(self.source_dwn)
|
||||
|
||||
def build(self, FAULT):
|
||||
'''
|
||||
"""
|
||||
Only build and create Slackware package
|
||||
'''
|
||||
"""
|
||||
if FAULT:
|
||||
print("\n{0}The package {1} {2}\n".format(_m.color['RED'], FAULT,
|
||||
_m.color['ENDC']))
|
||||
print("\n{0}The package {1} {2}\n".format(_m.color["RED"], FAULT,
|
||||
_m.color["ENDC"]))
|
||||
sys.exit(0)
|
||||
sources = []
|
||||
if not os.path.exists(_m.build_path):
|
||||
|
@ -203,10 +203,10 @@ class SBoNetwork(object):
|
|||
BuildPackage(script, sources, _m.build_path).build()
|
||||
|
||||
def install(self, prgnam):
|
||||
'''
|
||||
"""
|
||||
Install Slackware package found in /tmp
|
||||
directory.
|
||||
'''
|
||||
"""
|
||||
binary_list = []
|
||||
for search in find_package(prgnam, _m.output):
|
||||
if "_SBo" in search:
|
||||
|
@ -216,7 +216,7 @@ class SBoNetwork(object):
|
|||
except ValueError:
|
||||
Msg().build_FAILED(self.sbo_url, prgnam)
|
||||
sys.exit(0)
|
||||
print("[ {0}Installing{1} ] --> {2}".format(_m.color['GREEN'],
|
||||
_m.color['ENDC'],
|
||||
print("[ {0}Installing{1} ] --> {2}".format(_m.color["GREEN"],
|
||||
_m.color["ENDC"],
|
||||
self.name))
|
||||
PackageManager(binary).upgrade()
|
||||
|
|
|
@ -23,9 +23,9 @@
|
|||
|
||||
|
||||
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"
|
||||
|
|
|
@ -29,10 +29,10 @@ from slack_version import slack_ver
|
|||
|
||||
|
||||
def mirrors(name, location):
|
||||
'''
|
||||
"""
|
||||
Select Slackware official mirror packages
|
||||
based architecture and version.
|
||||
'''
|
||||
"""
|
||||
rel = _m.slack_rel
|
||||
ver = slack_ver()
|
||||
repo = Repo().slack()
|
||||
|
|
|
@ -74,9 +74,9 @@ class Patches(object):
|
|||
self.step = 700
|
||||
|
||||
def start(self):
|
||||
'''
|
||||
"""
|
||||
Install new patches from official Slackware mirrors
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
self.store()
|
||||
Msg().done()
|
||||
|
@ -97,7 +97,7 @@ class Patches(object):
|
|||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print("{0}Total {1} {2} will be upgraded and {3} will be "
|
||||
"installed.".format(_m.color['GREY'],
|
||||
"installed.".format(_m.color["GREY"],
|
||||
self.count_upg,
|
||||
Msg().pkg(self.upgrade_all),
|
||||
self.count_added))
|
||||
|
@ -105,9 +105,9 @@ class Patches(object):
|
|||
unit[0]))
|
||||
print("After this process, {0} {1} of additional disk space "
|
||||
"will be used.{2}".format(size[1], unit[1],
|
||||
_m.color['ENDC']))
|
||||
print('')
|
||||
if Msg().answer() in ['y', 'Y']:
|
||||
_m.color["ENDC"]))
|
||||
print("")
|
||||
if Msg().answer() in ["y", "Y"]:
|
||||
Download(self.patch_path, self.dwn_links).start()
|
||||
self.upgrade_all = self.utils.check_downloaded(
|
||||
self.patch_path, self.upgrade_all)
|
||||
|
@ -128,10 +128,10 @@ class Patches(object):
|
|||
sys.exit(0)
|
||||
|
||||
def store(self):
|
||||
'''
|
||||
"""
|
||||
Store and return packages for upgrading
|
||||
'''
|
||||
data = repo_data(self.PACKAGES_TXT, self.step, 'slack', resolve=True)
|
||||
"""
|
||||
data = repo_data(self.PACKAGES_TXT, self.step, "slack", resolve=True)
|
||||
black = BlackList().packages()
|
||||
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]):
|
||||
repo_pkg_name = split_package(name)[0]
|
||||
|
@ -149,16 +149,16 @@ class Patches(object):
|
|||
self.count_upg -= 1
|
||||
|
||||
def views(self):
|
||||
'''
|
||||
"""
|
||||
Views packages
|
||||
'''
|
||||
"""
|
||||
for upg, size in sorted(zip(self.upgrade_all, self.comp_sum)):
|
||||
pkg_split = split_package(upg[:-4])
|
||||
color = _m.color['YELLOW']
|
||||
color = _m.color["YELLOW"]
|
||||
if not find_package(pkg_split[0], _m.pkg_path):
|
||||
color = _m.color['RED']
|
||||
color = _m.color["RED"]
|
||||
print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>12}{12}".format(
|
||||
color, pkg_split[0], _m.color['ENDC'],
|
||||
color, pkg_split[0], _m.color["ENDC"],
|
||||
" " * (24-len(pkg_split[0])), pkg_split[1],
|
||||
" " * (18-len(pkg_split[1])), pkg_split[2],
|
||||
" " * (8-len(pkg_split[2])), pkg_split[3],
|
||||
|
@ -166,31 +166,31 @@ class Patches(object):
|
|||
size, " K")).rstrip()
|
||||
|
||||
def upgrade(self):
|
||||
'''
|
||||
"""
|
||||
Upgrade packages
|
||||
'''
|
||||
"""
|
||||
for pkg in self.upgrade_all:
|
||||
check_md5(pkg_checksum(pkg, "slack_patches"), self.patch_path + pkg)
|
||||
pkg_ver = '{0}-{1}'.format(split_package(pkg)[0],
|
||||
pkg_ver = "{0}-{1}".format(split_package(pkg)[0],
|
||||
split_package(pkg)[1])
|
||||
if find_package(split_package(pkg)[0] + "-", _m.pkg_path):
|
||||
print("[ {0}upgrading{1} ] --> {2}".format(_m.color['YELLOW'],
|
||||
_m.color['ENDC'],
|
||||
print("[ {0}upgrading{1} ] --> {2}".format(_m.color["YELLOW"],
|
||||
_m.color["ENDC"],
|
||||
pkg[:-4]))
|
||||
PackageManager((self.patch_path + pkg).split()).upgrade()
|
||||
self.upgraded.append(pkg_ver)
|
||||
else:
|
||||
print("[ {0}installing{1} ] --> {2}".format(_m.color['GREEN'],
|
||||
_m.color['ENDC'],
|
||||
print("[ {0}installing{1} ] --> {2}".format(_m.color["GREEN"],
|
||||
_m.color["ENDC"],
|
||||
pkg[:-4]))
|
||||
PackageManager((self.patch_path + pkg).split()).upgrade()
|
||||
self.installed.append(pkg_ver)
|
||||
|
||||
def kernel(self):
|
||||
'''
|
||||
"""
|
||||
Check if kernel upgraded if true
|
||||
then reinstall 'lilo'
|
||||
'''
|
||||
then reinstall "lilo"
|
||||
"""
|
||||
for core in self.upgrade_all:
|
||||
if "kernel" in core:
|
||||
if _m.default_answer == "y":
|
||||
|
@ -199,19 +199,19 @@ class Patches(object):
|
|||
print("")
|
||||
Msg().template(78)
|
||||
print("| {0}*** HIGHLY recommended reinstall 'LILO' "
|
||||
"***{1}".format(_m.color['RED'], _m.color['ENDC']))
|
||||
"***{1}".format(_m.color["RED"], _m.color["ENDC"]))
|
||||
Msg().template(78)
|
||||
answer = raw_input("\nThe kernel has been upgraded, "
|
||||
"reinstall `LILO` [Y/n]? ")
|
||||
if answer in ['y', 'Y']:
|
||||
if answer in ["y", "Y"]:
|
||||
subprocess.call("lilo", shell=True)
|
||||
break
|
||||
|
||||
def slackpkg_update(self):
|
||||
'''
|
||||
"""
|
||||
This replace slackpkg ChangeLog.txt file with new
|
||||
from Slackware official mirrors after update distribution.
|
||||
'''
|
||||
"""
|
||||
changelog_txt = "ChangeLog.txt"
|
||||
changelog_old = changelog_txt + ".old"
|
||||
arch = "64" if os.uname()[4] == "x86_64" else ""
|
||||
|
|
|
@ -26,9 +26,9 @@ import re
|
|||
|
||||
|
||||
def slack_ver():
|
||||
'''
|
||||
"""
|
||||
Open file and read Slackware version
|
||||
'''
|
||||
"""
|
||||
with open("/etc/slackware-version", "r") as f:
|
||||
sv = f.read()
|
||||
f.close()
|
||||
|
|
|
@ -36,22 +36,22 @@ from __metadata__ import MetaData as _m
|
|||
|
||||
|
||||
def it_self_update():
|
||||
'''
|
||||
"""
|
||||
Check from GitHub slpkg repository if new version is available
|
||||
download and update itself
|
||||
'''
|
||||
"""
|
||||
__new_version__ = ""
|
||||
repository = 'github'
|
||||
branch = 'master'
|
||||
ver_link = ('https://raw.{0}usercontent.com/{1}/{2}/'
|
||||
'{3}/{4}/__metadata__.py'.format(repository, _m.__author__,
|
||||
repository = "github"
|
||||
branch = "master"
|
||||
ver_link = ("https://raw.{0}usercontent.com/{1}/{2}/"
|
||||
"{3}/{4}/__metadata__.py".format(repository, _m.__author__,
|
||||
_m.__all__, branch,
|
||||
_m.__all__))
|
||||
version_data = URL(ver_link).reading()
|
||||
for line in version_data.splitlines():
|
||||
line = line.strip()
|
||||
if line.startswith('__version_info__'):
|
||||
__new_version__ = '.'.join(re.findall(r'\d+', line))
|
||||
if line.startswith("__version_info__"):
|
||||
__new_version__ = ".".join(re.findall(r"\d+", line))
|
||||
if __new_version__ > _m.__version__:
|
||||
if _m.default_answer == "y":
|
||||
answer = _m.default_answer
|
||||
|
@ -59,28 +59,28 @@ def it_self_update():
|
|||
print("\nNew version '{0}-{1}' is available !\n".format(
|
||||
_m.__all__, __new_version__))
|
||||
answer = raw_input("Would you like to upgrade [Y/n]? ")
|
||||
if answer in ['y', 'Y']:
|
||||
if answer in ["y", "Y"]:
|
||||
print("") # new line after answer
|
||||
else:
|
||||
sys.exit(0)
|
||||
dwn_link = ['https://{0}.com/{1}/{2}/archive/'
|
||||
'v{3}.tar.gz'.format(repository, _m.__author__, _m.__all__,
|
||||
dwn_link = ["https://{0}.com/{1}/{2}/archive/"
|
||||
"v{3}.tar.gz".format(repository, _m.__author__, _m.__all__,
|
||||
__new_version__)]
|
||||
if not os.path.exists(_m.build_path):
|
||||
os.makedirs(_m.build_path)
|
||||
Download(_m.build_path, dwn_link).start()
|
||||
os.chdir(_m.build_path)
|
||||
slpkg_tar_file = 'v' + __new_version__ + '.tar.gz'
|
||||
slpkg_tar_file = "v" + __new_version__ + ".tar.gz"
|
||||
tar = tarfile.open(slpkg_tar_file)
|
||||
tar.extractall()
|
||||
tar.close()
|
||||
file_name = '{0}-{1}'.format(_m.__all__, __new_version__)
|
||||
file_name = "{0}-{1}".format(_m.__all__, __new_version__)
|
||||
os.chdir(file_name)
|
||||
check_md5(pkg_checksum(_m.__all__ + "-" + slpkg_tar_file[1:],
|
||||
_m.__all__), _m.build_path + slpkg_tar_file)
|
||||
subprocess.call('chmod +x {0}'.format('install.sh'), shell=True)
|
||||
subprocess.call('sh install.sh', shell=True)
|
||||
subprocess.call("chmod +x {0}".format("install.sh"), shell=True)
|
||||
subprocess.call("sh install.sh", shell=True)
|
||||
else:
|
||||
print('\n{0}: There is no new version, already used the last !'
|
||||
'\n'.format(_m.__all__))
|
||||
print("\n{0}: There is no new version, already used the last !"
|
||||
"\n".format(_m.__all__))
|
||||
sys.exit(0)
|
||||
|
|
|
@ -23,15 +23,15 @@
|
|||
|
||||
|
||||
def split_package(package):
|
||||
'''
|
||||
"""
|
||||
Split package in name, version
|
||||
arch and build tag.
|
||||
'''
|
||||
"""
|
||||
name = ver = arch = build = []
|
||||
split = package.split("-")
|
||||
if len(split) > 2:
|
||||
build = split[-1]
|
||||
build_a, build_b = '', ''
|
||||
build_a, build_b = "", ""
|
||||
build_a = build[:1]
|
||||
if build[1:2].isdigit():
|
||||
build_b = build[1:2]
|
||||
|
|
|
@ -29,11 +29,11 @@ from __metadata__ import MetaData as _m
|
|||
|
||||
|
||||
def status(index, width, step):
|
||||
'''
|
||||
"""
|
||||
Print toolbar status
|
||||
'''
|
||||
"""
|
||||
if index == width:
|
||||
sys.stdout.write("{0}.{1}".format(_m.color['GREY'], _m.color['ENDC']))
|
||||
sys.stdout.write("{0}.{1}".format(_m.color["GREY"], _m.color["ENDC"]))
|
||||
sys.stdout.flush()
|
||||
width += step
|
||||
time.sleep(0.02)
|
||||
|
|
|
@ -36,19 +36,19 @@ from binary.dependency import Dependencies
|
|||
|
||||
|
||||
def track_dep(name, repo):
|
||||
'''
|
||||
"""
|
||||
View tree of dependencies and also
|
||||
highlight packages with color green
|
||||
if allready installed and color red
|
||||
if not installed.
|
||||
'''
|
||||
"""
|
||||
Msg().resolving()
|
||||
if repo == "sbo":
|
||||
dependencies_list = Requires(resolve=True).sbo(name)
|
||||
find_pkg = sbo_search_pkg(name)
|
||||
else:
|
||||
PACKAGES_TXT = Utils().read_file(_m.lib_path + '{0}_repo/'
|
||||
'PACKAGES.TXT'.format(repo))
|
||||
PACKAGES_TXT = Utils().read_file(_m.lib_path + "{0}_repo/"
|
||||
"PACKAGES.TXT".format(repo))
|
||||
dependencies_list = Dependencies(PACKAGES_TXT, repo).binary(
|
||||
name, resolve=True)
|
||||
find_pkg = search_pkg(name, repo)
|
||||
|
@ -63,25 +63,25 @@ def track_dep(name, repo):
|
|||
pkg_len = len(name) + 24
|
||||
print("") # new line at start
|
||||
Msg().template(pkg_len)
|
||||
print("| Package {0}{1}{2} dependencies :".format(_m.color['CYAN'],
|
||||
print("| Package {0}{1}{2} dependencies :".format(_m.color["CYAN"],
|
||||
name,
|
||||
_m.color['ENDC']))
|
||||
_m.color["ENDC"]))
|
||||
Msg().template(pkg_len)
|
||||
print("\\")
|
||||
print(" +---{0}[ Tree of dependencies ]{1}".format(_m.color['YELLOW'],
|
||||
_m.color['ENDC']))
|
||||
print(" +---{0}[ Tree of dependencies ]{1}".format(_m.color["YELLOW"],
|
||||
_m.color["ENDC"]))
|
||||
index = 0
|
||||
for pkg in dependencies:
|
||||
index += 1
|
||||
if find_package(pkg + _m.sp, _m.pkg_path):
|
||||
print(" |")
|
||||
print(" {0}{1}: {2}{3}{4}".format("+--", index,
|
||||
_m.color['GREEN'],
|
||||
pkg, _m.color['ENDC']))
|
||||
_m.color["GREEN"],
|
||||
pkg, _m.color["ENDC"]))
|
||||
else:
|
||||
print(" |")
|
||||
print(" {0}{1}: {2}{3}{4}".format("+--", index, _m.color['RED'],
|
||||
pkg, _m.color['ENDC']))
|
||||
print(" {0}{1}: {2}{3}{4}".format("+--", index, _m.color["RED"],
|
||||
pkg, _m.color["ENDC"]))
|
||||
print("") # new line at end
|
||||
else:
|
||||
print("\nNo package was found to match\n")
|
||||
|
|
|
@ -34,16 +34,16 @@ class URL(object):
|
|||
self.link = link
|
||||
|
||||
def reading(self):
|
||||
'''
|
||||
"""
|
||||
Open url and read
|
||||
'''
|
||||
"""
|
||||
try:
|
||||
f = urllib2.urlopen(self.link)
|
||||
return f.read()
|
||||
except (urllib2.URLError, ValueError):
|
||||
print("\n{0}Can't read file '{1}'{2}".format(
|
||||
_m.color['RED'], self.link.split('/')[-1], _m.color['ENDC']))
|
||||
return ' '
|
||||
_m.color["RED"], self.link.split("/")[-1], _m.color["ENDC"]))
|
||||
return " "
|
||||
except KeyboardInterrupt:
|
||||
print("") # new line at exit
|
||||
sys.exit(0)
|
||||
|
|
|
@ -82,12 +82,12 @@ class Utils(object):
|
|||
packages.append(pkg)
|
||||
else:
|
||||
print("\nThe '{0}' file not found\n".format(
|
||||
file_pkg.split('/')[-1]))
|
||||
return filter(lambda x: x != '', packages)
|
||||
file_pkg.split("/")[-1]))
|
||||
return filter(lambda x: x != "", packages)
|
||||
|
||||
def read_config(self, config):
|
||||
""" Read config file and return uncomment line """
|
||||
for line in config.splitlines():
|
||||
line = line.lstrip()
|
||||
if line and not line.startswith('#'):
|
||||
if line and not line.startswith("#"):
|
||||
return line
|
||||
|
|
|
@ -28,9 +28,9 @@ from __metadata__ import MetaData as _m
|
|||
|
||||
|
||||
def prog_version():
|
||||
'''
|
||||
"""
|
||||
Print version, license and email
|
||||
'''
|
||||
"""
|
||||
print("Version : {0}".format(_m.__version__))
|
||||
print("Licence : {0}".format(_m.__license__))
|
||||
print("Email : {0}".format(_m.__email__))
|
||||
|
|
Loading…
Add table
Reference in a new issue