update code, fix repos

This commit is contained in:
Dimitris Zlatanidis 2014-11-18 07:24:49 +02:00
parent 78d00f845e
commit 9133dd9f7d
20 changed files with 303 additions and 190 deletions

15
TESTING Normal file
View file

@ -0,0 +1,15 @@
Slpkg testing log:
The majority of trials have been made in an environment Slackware x86_64 and x86 stable version
14.1.
Is logical tests are always to be latest versions of the distribution.
Slpkg are supported version 'current' but it is minimal tests have been done on this release.
TEST:
Distribution : Slackware Linux
Release : 14.1
Version : stable
Arch : x86, x86_64

View file

@ -23,9 +23,12 @@
import os
from config import slpkg_conf
__all__ = "slpkg"
__author__ = "dslackw"
__version_info__ = (2, 0, 4)
__version_info__ = (2, 0, 5)
__version__ = "{0}.{1}.{2}".format(*__version_info__)
__license__ = "GNU General Public License v3 (GPLv3)"
__email__ = "d.zlatanidis@gmail.com"
@ -34,59 +37,8 @@ __email__ = "d.zlatanidis@gmail.com"
# temponary path
tmp = "/tmp/"
if not os.path.exists("/etc/slpkg"):
os.mkdir("/etc/slpkg")
slpkg_conf = [
"# Configuration file for slpkg\n",
"\n",
"# slpkg.conf file is part of slpkg.\n",
"\n",
"# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>\n",
"# All rights reserved.\n",
"\n",
"# Utility for easy management packages in Slackware\n",
"\n",
"# https://github.com/dslackw/slpkg\n",
"\n",
"# Slpkg is free software: you can redistribute it and/or modify\n",
"# it under the terms of the GNU General Public License as published by\n",
"# the Free Software Foundation, either version 3 of the License, or\n",
"# (at your option) any later version.\n",
"# This program is distributed in the hope that it will be useful,\n",
"# but WITHOUT ANY WARRANTY; without even the implied warranty of\n",
"# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n",
"# GNU General Public License for more details.\n",
"# You should have received a copy of the GNU General Public License\n",
"# along with this program. If not, see <http://www.gnu.org/licenses/>.\n",
"\n",
"# Slackware version 'stable' or 'current'.\n",
"VERSION=stable\n",
"\n",
"# Build directory for repository slackbuilds.org. In this directory\n",
"# downloaded sources and scripts for building.\n",
"BUILD=/tmp/slpkg/build/\n",
"\n",
"# If SBO_CHECK_MD5 is 'on' the system will check all downloaded\n",
"# sources from SBo repository.\n",
"SBO_CHECK_MD5=on\n",
"\n",
"# Download directory for others repositories that use binaries files\n",
"# for installation.\n",
"PACKAGES=/tmp/slpkg/packages/\n",
"\n",
"# Download directory for Slackware patches file.\n",
"PATCHES=/tmp/slpkg/patches/\n",
"\n",
"# Delete all downloaded files if DEL_ALL is 'on'.\n",
"DEL_ALL=on\n",
"\n",
"# Delete build directory after each process if DEL_BUILD is 'on'.\n",
"DEL_BUILD=off\n",
"\n",
"# Keep build log file if SBO_BUILD_LOG is 'on'.\n",
"SBO_BUILD_LOG=on\n"
]
if not os.path.exists("/etc/slpkg/"):
os.mkdir("/etc/slpkg/")
if not os.path.isfile("/etc/slpkg/slpkg.conf"):
with open("/etc/slpkg/slpkg.conf", "w") as conf:
@ -112,6 +64,8 @@ for line in conf.splitlines():
line = line.lstrip()
if line.startswith("VERSION"):
slack_rel = line[8:].strip()
if not slack_rel:
slack_rel = "stable"
if line.startswith("BUILD"):
build_path = line[6:].strip()
if line.startswith("PACKAGES"):
@ -127,36 +81,6 @@ for line in conf.splitlines():
if line.startswith("SBO_BUILD_LOG"):
sbo_build_log = line[14:].strip()
if not slack_rel or slack_rel not in ['stable', 'current']:
slack_rel = "stable"
if not build_path:
build_path = "/tmp/slpkg/build/"
elif not build_path.endswith("/"):
build_path = build_path + "/"
if not slpkg_tmp_packages:
slpkg_tmp_packages = tmp + "slpkg/packages/"
elif not slpkg_tmp_packages.endswith("/"):
slpkg_tmp_packages = slpkg_tmp_packages + "/"
if not slpkg_tmp_patches:
slpkg_tmp_patches = tmp + "slpkg/patches/"
elif not slpkg_tmp_patches.endswith("/"):
slpkg_tmp_patches = slpkg_tmp_patches + "/"
if not del_all or del_all not in ['on', 'off']:
del_all = "on"
if not del_build or del_build not in ['on', 'off']:
del_build = "off"
if not sbo_check_md5 or sbo_check_md5 not in ['on', 'off']:
sbo_check_md5 = "on"
if not sbo_build_log or sbo_build_log not in ['on', 'off']:
sbo_build_log = "on"
# repositories
repositories = [
"sbo",

View file

@ -27,7 +27,7 @@ from __metadata__ import __version__
def options():
arguments = [
"slpkg - version {0}\n".format(__version__),
"\nslpkg - version {0}\n".format(__version__),
"Utility for easy management packages in Slackware\n",
"Optional arguments:",
" -h, --help show this help message " +
@ -36,32 +36,28 @@ def options():
" -a, script.tar.gz [source...] auto build SBo packages",
" -b, --list, [package...] --add, --remove add, remove packages in " +
"blacklist",
" -q, --list, [package...] --add, --remove add, remove packages in " +
"queue",
" --build, --install, --build-install build or install from " +
"queue",
" -q, --list, [package...] --add, --remove add, remove SBo packages "
"in queue",
" --build, --install, --build-install build or install packages "
"from queue",
" -g, --config, --config=<editor> configuration file " +
"management",
" -l, <repository>, all, noarch list of installed " +
"packages",
" -c, <repository> --upgrade check for updated " +
"packages",
" -s, <repository> <package> download, build & install",
" -t, <repository> <package> tracking dependencies",
" -p, <repository> <package> --color= print package description",
" red, green, yellow, cyan, grey colors support",
" -f, <package> find installed packages",
" -n, <package> view packages from SBo",
" -s, <repository> [package] download, build & install",
" -t, <repository> [package] tracking dependencies",
" -p, <repository> [package] --color=[] print package description",
" -f, [package] find installed packages",
" -n, [package] view packages from SBo",
" -i, [package...] install binary packages",
" -u, [package...] upgrade binary packages",
" -o, [package...] reinstall binary packages",
" -r, [package...] remove binary packages",
" -d, [package...] display the contents\n",
"Note: '-q' options is working only for SBo repository\n",
"Repositories:",
" Slackware = slack",
" Alien = alien",
" SlackBuilds = sbo",
" Slacky = slacky",
" Robby's = rlw\n"
"Repositories: <slack, sbo, alien, slacky, rlw>",
"Colors = [red, green, yellow, cyan, grey]\n",
]
for opt in arguments:
print(opt)
@ -74,6 +70,7 @@ def usage():
" [-b --list, [...] --add, --remove]",
" [-q --list, [...] --add, --remove]",
" [ --build, --install, --build-install]",
" [-g --config, --config=<editor>]",
" [-l <repository>, all, noarch]",
" [-c <repository> --upgrade]",
" [-s <repository> <package>]",
@ -81,7 +78,7 @@ def usage():
" [-p <repository> <package> --color=]",
" [ red, green, yellow, cyan, grey]",
" [-f] [-n] [-i [...]] [-u [...]]",
" [-o [...]] [-r [...]] [-d [...]]\n",
" [-o [...]] [-r [...]] [-d [...]]\n"
"For more information try 'slpkg --help'\n"
]
for usg in view:

124
slpkg/config.py Executable file
View file

@ -0,0 +1,124 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# config.py file is part of slpkg.
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# All rights reserved.
# Utility for easy management packages in Slackware
# https://github.com/dslackw/slpkg
# Slpkg is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
import os
import subprocess
from colors import CYAN, ENDC
slpkg_conf = [
"# Configuration file for slpkg\n",
"\n",
"# slpkg.conf file is part of slpkg.\n",
"\n",
"# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>\n",
"# All rights reserved.\n",
"\n",
"# Utility for easy management packages in Slackware\n",
"\n",
"# https://github.com/dslackw/slpkg\n",
"\n",
"# Slpkg is free software: you can redistribute it and/or modify\n",
"# it under the terms of the GNU General Public License as published by\n",
"# the Free Software Foundation, either version 3 of the License, or\n",
"# (at your option) any later version.\n",
"# This program is distributed in the hope that it will be useful,\n",
"# but WITHOUT ANY WARRANTY; without even the implied warranty of\n",
"# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n",
"# GNU General Public License for more details.\n",
"# You should have received a copy of the GNU General Public License\n",
"# along with this program. If not, see <http://www.gnu.org/licenses/>.\n",
"\n",
"# Slackware version 'stable' or 'current'.\n",
"VERSION=stable\n",
"\n",
"# Build directory for repository slackbuilds.org. In this directory\n",
"# downloaded sources and scripts for building.\n",
"BUILD=/tmp/slpkg/build/\n",
"\n",
"# If SBO_CHECK_MD5 is 'on' the system will check all downloaded\n",
"# sources from SBo repository.\n",
"SBO_CHECK_MD5=on\n",
"\n",
"# Download directory for others repositories that use binaries files\n",
"# for installation.\n",
"PACKAGES=/tmp/slpkg/packages/\n",
"\n",
"# Download directory for Slackware patches file.\n",
"PATCHES=/tmp/slpkg/patches/\n",
"\n",
"# Delete all downloaded files if DEL_ALL is 'on'.\n",
"DEL_ALL=on\n",
"\n",
"# Delete build directory after each process if DEL_BUILD is 'on'.\n",
"DEL_BUILD=off\n",
"\n",
"# Keep build log file if SBO_BUILD_LOG is 'on'.\n",
"SBO_BUILD_LOG=on\n"
]
if not os.path.exists("/etc/slpkg"):
os.mkdir("/etc/slpkg")
if not os.path.isfile("/etc/slpkg/slpkg.conf"):
with open("/etc/slpkg/slpkg.conf", "w") as conf:
for line in slpkg_conf:
conf.write(line)
conf.close()
class Config(object):
def __init__(self):
self.config_file = "/etc/slpkg/slpkg.conf"
def view(self):
'''
View slpkg config file
'''
print("")
conf_args = [
'VERSION',
'BUILD',
'SBO_CHECK_MD5',
'PACKAGES',
'PATCHES',
'DEL_ALL',
'DEL_BUILD',
'SBO_BUILD_LOG'
]
f = open(self.config_file, "r")
read_conf = f.read()
f.close()
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(CYAN, line, ENDC))
print("")
def edit(self, editor):
'''
Edit configuration file
'''
subprocess.call("{0} {1}".format(editor, self.config_file),
shell=True)

View file

@ -37,8 +37,8 @@ from slack.slack_version import slack_ver
class Initialization(object):
def __init__(self):
if not os.path.exists("/etc/slpkg"):
os.mkdir("/etc/slpkg")
if not os.path.exists("/etc/slpkg/"):
os.mkdir("/etc/slpkg/")
if not os.path.exists(log_path):
os.mkdir(log_path)
if not os.path.exists(lib_path):

View file

@ -25,6 +25,7 @@ import sys
import getpass
from desc import PkgDesc
from config import Config
from queue import QueuePkgs
from messages import s_user
from tracking import track_dep
@ -178,6 +179,14 @@ def main():
usage()
elif len(args) > 1 and args[0] == "-d":
PackageManager(args[1:]).display()
elif len(args) == 2 and args[0] == "-g" and args[1].startswith("--config"):
editor = args[1][len("--config="):]
if args[1] == "--config":
Config().view()
elif editor:
Config().edit(editor)
else:
usage()
else:
usage()

View file

@ -31,8 +31,11 @@ from blacklist import BlackList
from init import Initialization
from splitting import split_package
from colors import YELLOW, GREY, ENDC
from __metadata__ import (pkg_path, lib_path,
slpkg_tmp_packages)
from __metadata__ import (
pkg_path,
lib_path,
slpkg_tmp_packages
)
from pkg.manager import PackageManager
@ -92,12 +95,12 @@ class OthersUpgrade(object):
try:
dwn_links, upgrade_all, comp_sum, uncomp_sum = self.store()
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
print # new line at start
print("") # new line at start
if upgrade_all:
template(78)
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
"| Package", " " * 17,
"Version", " " * 12,
"New version", " " * 8,
"Arch", " " * 4,
"Build", " " * 2,
"Repos", " " * 10,
@ -119,12 +122,13 @@ class OthersUpgrade(object):
if read in ['Y', 'y']:
upgrade_all.reverse()
packages_dwn(self.tmp_path, dwn_links)
upgrade(upgrade_all)
upgrade(self.tmp_path, upgrade_all)
delete(self.tmp_path, upgrade_all)
else:
print("There are no packages for upgrade\n")
print("No new updates in the repository '{0}'\n".format(
self.repo))
except KeyboardInterrupt:
print # new line at exit
print("") # new line at exit
sys.exit()
def store(self):
@ -205,10 +209,11 @@ def msgs(upgrade_all):
return msg_pkg
def upgrade(upgrade_all):
def upgrade(tmp_path, upgrade_all):
'''
Install or upgrade packages
'''
for pkg in upgrade_all:
package = (tmp_path + pkg).split()
print("[ {0}upgrading{1} ] --> {2}".format(YELLOW, ENDC, pkg[:-4]))
PackageManager(pkg).upgrade()
PackageManager(package).upgrade()

View file

@ -25,7 +25,7 @@ import sys
from toolbar import status
from greps import repo_requires
from greps import Requires
dep_results = []
@ -36,7 +36,7 @@ def dependencies_pkg(name, repo):
'''
try:
dependencies = []
requires = repo_requires(name, repo)
requires = Requires(name, repo).get_deps()
toolbar_width, index = 2, 0
if requires:
for req in requires:

View file

@ -26,7 +26,7 @@ import os
from toolbar import status
from __metadata__ import lib_path
from splitting import split_package
from init import Initialization
from slack.slack_version import slack_ver
@ -103,16 +103,28 @@ def alien_filter(name, location, size, unsize, version):
return [fname, flocation, fsize, funsize]
def repo_requires(name, repo):
class Requires(object):
def __init__(self, name, repo):
self.name = name
self.repo = repo
if not os.path.isfile(lib_path + "slack_repo/PACKAGES.TXT"):
Initialization().slack()
lib = lib_path + "slack_repo/PACKAGES.TXT"
f = open(lib, "r")
self.SLACK_PACKAGES_TXT = f.read()
f.close()
def get_deps(self):
'''
Grap package requirements from repositories
'''
if repo in ["alien", "slacky"]:
if self.repo in ["alien", "slacky"]:
lib = {
'alien': lib_path + "alien_repo/PACKAGES.TXT",
'slacky': lib_path + "slacky_repo/PACKAGES.TXT"
}
f = open(lib[repo], "r")
f = open(lib[self.repo], "r")
PACKAGES_TXT = f.read()
f.close()
for line in PACKAGES_TXT.splitlines():
@ -120,12 +132,14 @@ def repo_requires(name, repo):
pkg = line[14:].strip()
pkg_name = split_package(pkg)[0]
if line.startswith("PACKAGE REQUIRED: "):
if pkg_name == name:
if repo == "slacky":
return slacky_req_fix(line)
if pkg_name == self.name:
if line[17:].strip():
if self.repo == "slacky":
return self.slacky_req_fix(line)
else:
return line[18:].strip().split(",")
elif repo == "rlw":
elif self.repo == "rlw":
# Robby's repository dependencies as shown in the central page
# http://rlworkman.net/pkgs/
dependencies = {
@ -136,15 +150,14 @@ def repo_requires(name, repo):
"texlive": "libsigsegv texi2html",
"xfburn": "libburn libisofs"
}
if name in dependencies.keys():
return dependencies[name].split()
if self.name in dependencies.keys():
return dependencies[self.name].split()
else:
return ""
def slacky_req_fix(line):
def slacky_req_fix(self, line):
'''
Fix slacky requirements because more dependencies splitting
Fix slacky requirements because many dependencies splitting
with ',' and others with '|'
'''
slacky_deps = []
@ -155,4 +168,23 @@ def slacky_req_fix(line):
slacky_deps.append(d.split()[0])
dep = "".join(dep)
slacky_deps.append(dep.split()[0])
slacky_deps = self.remove_slack_deps(slacky_deps)
return slacky_deps
def remove_slack_deps(self, dependencies):
'''
Because the repository slacky mentioned packages and dependencies
that exist in the distribution Slackware, this feature is intended
to remove them and return only those needed.
'''
name, slacky_deps = [], []
index, toolbar_width, step = 0, 700, 1800
for line in self.SLACK_PACKAGES_TXT.splitlines():
index += 1
toolbar_width = status(index, toolbar_width, step)
if line.startswith("PACKAGE NAME:"):
name.append("-".join(line[15:].split("-")[:-3]))
for deps in dependencies:
if deps not in name:
slacky_deps.append(deps)
return slacky_deps

View file

@ -48,5 +48,5 @@ def search_pkg(name, repo):
PACKAGES_TXT.close()
return pkg_name
except KeyboardInterrupt:
print # new line at exit
print("") # new line at exit
sys.exit()

View file

@ -32,7 +32,7 @@ import subprocess
from checksum import md5sum
from colors import RED, GREEN, ENDC
from messages import pkg_not_found, template
from __metadata__ import log_path, sbo_check_md5, sbo_build_log
from __metadata__ import log_path, sbo_build_log, sbo_check_md5
from sbo.greps import SBoGrep

View file

@ -93,7 +93,7 @@ class PackageManager(object):
dependencies, rmv_list = [], []
removed = self.view_removed(self.binary)
if not removed:
print # new line at end
print("") # new line at end
else:
msg = "package"
if len(removed) > 1:
@ -103,7 +103,7 @@ class PackageManager(object):
"\nAre you sure to remove {0} {1} [Y/n]? ".format(
str(len(removed)), msg))
except KeyboardInterrupt:
print # new line at exit
print("") # new line at exit
sys.exit()
if remove_pkg in ['y', 'Y']:
for rmv in removed:
@ -117,7 +117,7 @@ class PackageManager(object):
"\nRemove dependencies (maybe used by other "
"packages) [Y/n]? ")
except KeyboardInterrupt:
print # new line at exit
print("") # new line at exit
sys.exit()
if remove_dep in ['y', 'Y']:
rmv_list += self.rmv_deps(self.binary,
@ -157,7 +157,7 @@ class PackageManager(object):
with open(path + package, "r") as f:
dependencies = f.read().split()
f.close()
print # new line at start
print("") # new line at start
template(78)
print("| Found dependencies for package {0}:".format(package))
template(78)
@ -205,7 +205,7 @@ class PackageManager(object):
else:
print("| Package {0} not found".format(pkg))
template(78)
print # new line at end
print("") # new line at end
def find(self):
'''
@ -253,7 +253,7 @@ class PackageManager(object):
with open(pkg_path + "".join(find), "r") as package:
for line in package:
print(line).strip()
print # new line per file
print("") # new line per file
else:
message = "Can't dislpay"
if len(self.binary) > 1:
@ -292,9 +292,9 @@ class PackageManager(object):
"continue... ".format(CYAN, ENDC))
if read in ['Q', 'q']:
break
print # new line after page
print("") # new line after page
page += row
print # new line at end
print("") # new line at end
except KeyboardInterrupt:
print # new line at exit
print("") # new line at exit
sys.exit()

View file

@ -124,7 +124,7 @@ class SBoCheck(object):
sys.stdout.write(self.done)
print("\nNo SBo packages found\n")
except KeyboardInterrupt:
print # new line at exit
print("") # new line at exit
sys.exit()
def sbo_list(self):

View file

@ -48,5 +48,5 @@ def sbo_search_pkg(name):
SLACKBUILDS_TXT.close()
return (sbo_url + line[23:].strip() + "/")
except KeyboardInterrupt:
print # new line at exit
print("") # new line at exit
sys.exit()

View file

@ -145,7 +145,7 @@ class SBoInstall(object):
else:
pkg_not_found("\n", self.name, "No matching", "\n")
except KeyboardInterrupt:
print # new line at exit
print("") # new line at exit
sys.exit()
def one_for_all(self):

View file

@ -116,7 +116,7 @@ class SBoNetwork(object):
'''
View slackbuild.org
'''
print # new line at start
print("") # new line at start
template(78)
print("| {0}Package {1}{2}{3} --> {4}".format(GREEN, CYAN, args[0],
GREEN, ENDC + args[1]))
@ -163,7 +163,7 @@ class SBoNetwork(object):
try:
choice = raw_input(" {0}Choose an option: {1}".format(GREY, ENDC))
except KeyboardInterrupt:
print # new line at exit
print("") # new line at exit
sys.exit()
return choice

View file

@ -33,9 +33,9 @@ def slack_data(PACKAGES_TXT, step):
for line in PACKAGES_TXT.splitlines():
index += 1
toolbar_width = status(index, toolbar_width, step)
if line.startswith("PACKAGE NAME"):
if line.startswith("PACKAGE NAME:"):
name.append(line[15:].strip())
if line.startswith("PACKAGE LOCATION"):
if line.startswith("PACKAGE LOCATION:"):
location.append(line[21:].strip())
if line.startswith("PACKAGE SIZE (compressed): "):
size.append(line[28:-2].strip())

View file

@ -26,11 +26,11 @@ import sys
from sizes import units
from blacklist import BlackList
from init import Initialization
from splitting import split_package
from messages import pkg_not_found, template
from __metadata__ import pkg_path, lib_path, slpkg_tmp_packages
from init import Initialization
from colors import RED, GREEN, CYAN, YELLOW, GREY, ENDC
from __metadata__ import pkg_path, lib_path, slpkg_tmp_packages
from pkg.find import find_package
from pkg.manager import PackageManager
@ -98,7 +98,7 @@ class Slack(object):
else:
pkg_not_found("", self.slack_pkg, "No matching", "\n")
except KeyboardInterrupt:
print # new line at exit
print("") # new line at exit
sys.exit()
def store(self):

View file

@ -100,7 +100,7 @@ class Patches(object):
print("\nSlackware{0} '{1}' v{2} distribution is up to "
"date\n".format(slack_arch, self.version, slack_ver()))
except KeyboardInterrupt:
print # new line at exit
print("") # new line at exit
sys.exit()
def store(self):

View file

@ -44,7 +44,14 @@ def track_dep(name, repo):
if allready installed and color red
if not installed.
'''
Initialization().sbo()
init_repos = {
'sbo': Initialization().sbo,
'slack': Initialization().slack,
'rlw': Initialization().rlw,
'alien': Initialization().alien,
'slacky': Initialization().slacky
}
init_repos[repo]()
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
sys.stdout.flush()
if repo == "sbo":