diff --git a/slpkg/slackware_release.py b/conf/slpkg.conf old mode 100755 new mode 100644 similarity index 63% rename from slpkg/slackware_release.py rename to conf/slpkg.conf index ecce5e48..590d94ad --- a/slpkg/slackware_release.py +++ b/conf/slpkg.conf @@ -1,7 +1,8 @@ -#!/usr/bin/python -# -*- coding: utf-8 -*- +# +# slpkg.conf - Configuration for slpkg +# -# slackware_type.py file is part of slpkg. +# slpkg.conf file is part of slpkg. # Copyright 2014 Dimitris Zlatanidis # All rights reserved. @@ -21,17 +22,16 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . +# Slackware version 'stable' or 'current' +VERSION=stable -from __metadata__ import log_path -from init import Initialization +# Build directory for repository slackbuilds.org. In this directory downloaded sources +# and scripts for building. +BUILD=/tmp/slpkg/build/ +# Download directory for others repositories that use binaries files for installation. +PACKAGES=/tmp/slpkg/packages/ + +# Download directory for Slackware patches file. +PATCHES=/tmp/slpkg/patches/ -def slack_rel(): - ''' - Read and return slackware release 'stable' or 'current' - ''' - Initialization().release() - with open(log_path + "slackware-release", "r") as f: - release = f.read() - f.close() - return release.strip() diff --git a/setup.py b/setup.py index 2fe3b83a..71931b4b 100755 --- a/setup.py +++ b/setup.py @@ -79,9 +79,15 @@ if "install" in sys.argv: f_in.close() shutil.copy2(gzip_man, man_path) os.chmod(man_path, int("444", 8)) + conf_path = "/etc/slpkg/" if not os.path.exists(conf_path): os.system("mkdir -p {0}".format(conf_path)) + # slpkg.conf file + print("Installing slpkg configuration file") + conf_file = "conf/slpkg.conf" + shutil.copy2(conf_file, conf_path) + # blacklist file print("Installing blacklist configuration file") black_file = "conf/blacklist" shutil.copy2(black_file, conf_path) diff --git a/slpkg/__metadata__.py b/slpkg/__metadata__.py index e17b8410..11863b2b 100644 --- a/slpkg/__metadata__.py +++ b/slpkg/__metadata__.py @@ -30,6 +30,43 @@ __version__ = "{0}.{1}.{2}".format(*__version_info__) __license__ = "GNU General Public License v3 (GPLv3)" __email__ = "d.zlatanidis@gmail.com" + +f = open("/etc/slpkg/slpkg.conf", "r") +conf = f.read() +f.close() + +''' temponary path ''' +tmp = "/tmp/" + +for line in conf.splitlines(): + line = line.lstrip() + if line.startswith("VERSION"): + slack_rel = line[8:].strip() + if line.startswith("BUILD"): + build_path = line[6:].strip() + if line.startswith("PACKAGES"): + slpkg_tmp_packages = line[9:].strip() + if line.startswith("PATCHES"): + slpkg_tmp_patches = line[8:].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 + "/" + ''' repositories ''' repositories = [ "sbo", @@ -45,19 +82,12 @@ sp = "-" ''' current path ''' path = os.getcwd() + "/" -''' build path ''' -build_path = path + "slpkg_Build/" - ''' library path ''' lib_path = "/var/lib/slpkg/" ''' log path ''' log_path = "/var/log/slpkg/" -''' temponary path ''' -tmp = "/tmp/" -slpkg_tmp = tmp + "slpkg/" - ''' packages log files path ''' pkg_path = "/var/log/packages/" diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index 73567992..5f4a54d4 100755 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -109,7 +109,7 @@ class BlackList(object): print("{0}{1}{2}".format(GREEN, black, ENDC)) self.quit = True if self.quit: - print # new line at exit + print("") # new line at exit def add(self, pkgs): ''' @@ -126,7 +126,7 @@ class BlackList(object): self.quit = True black_conf.close() if self.quit: - print # new line at exit + print("") # new line at exit def remove(self, pkgs): ''' @@ -142,4 +142,4 @@ class BlackList(object): self.quit = True remove.close() if self.quit: - print # new line at exit + print("") # new line at exit diff --git a/slpkg/init.py b/slpkg/init.py index 83ce6c8a..963af171 100755 --- a/slpkg/init.py +++ b/slpkg/init.py @@ -27,7 +27,8 @@ import sys from url_read import URL from repositories import Repo from file_size import FileSize -from __metadata__ import log_path, lib_path +from __metadata__ import (log_path, lib_path, slack_rel, + build_path, slpkg_tmp_packages, slpkg_tmp_patches) from slack.mirrors import mirrors from slack.slack_version import slack_ver @@ -40,38 +41,12 @@ class Initialization(object): os.mkdir(log_path) if not os.path.exists(lib_path): os.mkdir(lib_path) - self.release() - self.is_release() - - def release(self): - ''' - Create file with Slackware version 'stable' or 'current' - ''' - if (not os.path.isfile(log_path + "slackware-release") or - FileSize(log_path + "slackware-release").local() == 0): - with open(log_path + "slackware-release", "w") as f: - release = raw_input("Please type Slackware version " - "(default=stable) [stable/current]: ") - if release in ["stable", "current"]: - print("Selected version '{0}'".format(release)) - f.write(release) - else: - print("Selected the default version 'stable'") - f.write("stable") - f.close() - - def is_release(self): - ''' - Check if file 'slackware-release' states correct version - ''' - if os.path.isfile(log_path + "slackware-release"): - with open(log_path + "slackware-release", "r") as f: - release = f.read() - f.close() - if release not in ["stable", "current"]: - os.remove(log_path + "slackware-release") - self.release() - return release + if not os.path.exists(build_path): + os.mkdir(build_path) + if not os.path.exists(slpkg_tmp_packages): + os.mkdir(slpkg_tmp_packages) + if not os.path.exists(slpkg_tmp_patches): + os.mkdir(slpkg_tmp_patches) def slack(self): ''' @@ -81,7 +56,7 @@ class Initialization(object): lib = lib_path + "slack_repo/" lib_file = "PACKAGES.TXT" log_file = "ChangeLog.txt" - version = self.is_release() + version = slack_rel if not os.path.exists(log): os.mkdir(log) if not os.path.exists(lib): diff --git a/slpkg/main.py b/slpkg/main.py index 55275565..d7eb6e05 100755 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -31,8 +31,7 @@ from tracking import track_dep from blacklist import BlackList from version import prog_version from arguments import options, usage -from slackware_release import slack_rel -from __metadata__ import path, repositories +from __metadata__ import path, repositories, slack_rel from pkg.build import BuildPackage from pkg.manager import PackageManager @@ -51,7 +50,7 @@ class Case(object): def __init__(self, package): self.package = package - self.release = slack_rel() + self.release = slack_rel def sbo_install(self): SBoInstall(self.package).start() diff --git a/slpkg/others/check.py b/slpkg/others/check.py index ea8b3682..1145cf73 100755 --- a/slpkg/others/check.py +++ b/slpkg/others/check.py @@ -31,8 +31,8 @@ from blacklist import BlackList from init import Initialization from splitting import split_package from colors import YELLOW, GREY, ENDC -from __metadata__ import slpkg_tmp, pkg_path, lib_path - +from __metadata__ import (pkg_path, lib_path, + slpkg_tmp_packages) from pkg.manager import PackageManager @@ -48,7 +48,7 @@ class OthersUpgrade(object): def __init__(self, repo, version): self.repo = repo self.version = version - self.tmp_path = slpkg_tmp + "packages/" + self.tmp_path = slpkg_tmp_packages self.repo_init() repos = Repo() sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC)) @@ -78,10 +78,6 @@ class OthersUpgrade(object): ''' Initialization repository if only use ''' - if not os.path.exists(slpkg_tmp): - os.mkdir(slpkg_tmp) - if not os.path.exists(self.tmp_path): - os.mkdir(self.tmp_path) repository = { 'rlw': Initialization().rlw, 'alien': Initialization().alien, diff --git a/slpkg/others/greps.py b/slpkg/others/greps.py index 27a9c355..e8dadb3d 100755 --- a/slpkg/others/greps.py +++ b/slpkg/others/greps.py @@ -105,7 +105,7 @@ def alien_filter(name, location, size, unsize, version): def repo_requires(name, repo): ''' - Grap package requirements from alien repository + Grap package requirements from repositories ''' slacky_deps = [] if repo in ["alien", "slacky"]: @@ -129,10 +129,8 @@ def repo_requires(name, repo): else: return line[18:].strip().split(",") elif repo == "rlw": - ''' - Robby's repository dependencies as shown in the central page - http://rlworkman.net/pkgs/ - ''' + # Robby's repository dependencies as shown in the central page + # http://rlworkman.net/pkgs/ dependencies = { "abiword": "wv", "claws-mail": "libetpan bogofilter html2ps", diff --git a/slpkg/others/install.py b/slpkg/others/install.py index 5320cbff..a6778e67 100755 --- a/slpkg/others/install.py +++ b/slpkg/others/install.py @@ -31,7 +31,8 @@ from blacklist import BlackList from splitting import split_package from messages import pkg_not_found, template from colors import RED, GREEN, CYAN, YELLOW, GREY, ENDC -from __metadata__ import slpkg_tmp, pkg_path, lib_path, log_path +from __metadata__ import (pkg_path, lib_path, log_path, + slpkg_tmp_packages) from pkg.find import find_package @@ -51,7 +52,7 @@ class OthersInstall(object): self.package = package self.repo = repo self.version = version - self.tmp_path = slpkg_tmp + "packages/" + self.tmp_path = slpkg_tmp_packages self.repo_init() repos = Repo() print("\nPackages with name matching [ {0}{1}{2} ]\n".format( @@ -84,10 +85,6 @@ class OthersInstall(object): ''' Initialization repository if only use ''' - if not os.path.exists(slpkg_tmp): - os.mkdir(slpkg_tmp) - if not os.path.exists(self.tmp_path): - os.mkdir(self.tmp_path) repository = { "rlw": Initialization().rlw, "alien": Initialization().alien, @@ -167,6 +164,7 @@ class OthersInstall(object): # location = data[1] # size = data[2] # unsize = data[3] + print deps data = repo_data(self.PACKAGES_TXT, self.step, self.repo, self.version) if len(deps) > 1: for pkg in deps: diff --git a/slpkg/queue.py b/slpkg/queue.py index ff2df400..3cf9e611 100755 --- a/slpkg/queue.py +++ b/slpkg/queue.py @@ -85,7 +85,7 @@ class QueuePkgs(object): print("{0}{1}{2}".format(GREEN, pkg, ENDC)) self.quit = True if self.quit: - print # new line at exit + print("") # new line at exit def add(self, pkgs): ''' @@ -106,7 +106,7 @@ class QueuePkgs(object): self.quit = True queue.close() if self.quit: - print # new line at exit + print("") # new line at exit def remove(self, pkgs): ''' @@ -124,7 +124,7 @@ class QueuePkgs(object): self.quit = True queue.close() if self.quit: - print # new line at exit + print("") # new line at exit def build(self): ''' @@ -155,7 +155,7 @@ class QueuePkgs(object): ''' packages = self.packages() if packages: - print # new line at start + print("") # new line at start for pkg in packages: # check if package exist in /tmp find = find_package(pkg, tmp) diff --git a/slpkg/sbo/check.py b/slpkg/sbo/check.py index 69e75cb3..ed02068b 100755 --- a/slpkg/sbo/check.py +++ b/slpkg/sbo/check.py @@ -84,7 +84,6 @@ class SBoCheck(object): count, msg = view_packages(data[1], data[2], data[3]) read = raw_input("Would you like to upgrade [Y/n]? ") if read in ['y', 'Y']: - create_build_path() os.chdir(build_path) for name, version in zip(data[0], data[2]): prgnam = ("{0}-{1}".format(name, version)) @@ -281,14 +280,6 @@ def view_packages(package_for_upgrade, upgrade_version, upgrade_arch): return [count_installed, count_upgraded], [msg_ins, msg_upg] -def create_build_path(): - ''' - Create build directory if not exists - ''' - if not os.path.exists(build_path): - os.mkdir(build_path) - - def dwn_sources(sources): ''' Download sources and return filenames diff --git a/slpkg/sbo/slackbuild.py b/slpkg/sbo/slackbuild.py index bccbc4f6..8bcf6569 100755 --- a/slpkg/sbo/slackbuild.py +++ b/slpkg/sbo/slackbuild.py @@ -283,14 +283,6 @@ def arch_support(source, support, package_sum, dependencies): return read -def create_build_path(): - ''' - Create build directory if not exists - ''' - if not os.path.exists(build_path): - os.mkdir(build_path) - - def dwn_sources(sources): ''' Download sources and return filenames @@ -321,7 +313,6 @@ def build_install(dependencies, sbo_versions): tag 2 or 3 will fit most ''' installs, upgraded, versions = [], [], [] - create_build_path() os.chdir(build_path) for pkg, ver in zip(dependencies, sbo_versions): prgnam = ("{0}-{1}".format(pkg, ver)) diff --git a/slpkg/sbo/views.py b/slpkg/sbo/views.py index c1fc419e..526eb953 100755 --- a/slpkg/sbo/views.py +++ b/slpkg/sbo/views.py @@ -188,8 +188,6 @@ class SBoNetwork(object): if FAULT: print("\n{0}The package {1} {2}\n".format(RED, FAULT, ENDC)) sys.exit() - if not os.path.exists(build_path): - os.mkdir(build_path) sources = [] os.chdir(build_path) Download(build_path, self.sbo_dwn).start() diff --git a/slpkg/slack/install.py b/slpkg/slack/install.py index b239faaa..fa4dd6bb 100755 --- a/slpkg/slack/install.py +++ b/slpkg/slack/install.py @@ -28,7 +28,7 @@ from sizes import units from blacklist import BlackList from splitting import split_package from messages import pkg_not_found, template -from __metadata__ import slpkg_tmp, pkg_path, lib_path +from __metadata__ import pkg_path, lib_path, slpkg_tmp_packages from init import Initialization from colors import RED, GREEN, CYAN, YELLOW, GREY, ENDC @@ -46,17 +46,13 @@ class Slack(object): def __init__(self, slack_pkg, version): self.slack_pkg = slack_pkg self.version = version - self.tmp_path = slpkg_tmp + "packages/" + self.tmp_path = slpkg_tmp_packages Initialization().slack() print("\nPackages with name matching [ {0}{1}{2} ]\n".format( CYAN, self.slack_pkg, ENDC)) sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC)) sys.stdout.flush() Initialization().slack() - if not os.path.exists(slpkg_tmp): - os.mkdir(slpkg_tmp) - if not os.path.exists(self.tmp_path): - os.mkdir(self.tmp_path) lib = lib_path + "slack_repo/PACKAGES.TXT" f = open(lib, "r") self.PACKAGES_TXT = f.read() diff --git a/slpkg/slack/patches.py b/slpkg/slack/patches.py index f3d552ad..33cb0b79 100755 --- a/slpkg/slack/patches.py +++ b/slpkg/slack/patches.py @@ -31,7 +31,7 @@ from messages import template from blacklist import BlackList from splitting import split_package from colors import GREY, YELLOW, ENDC -from __metadata__ import pkg_path, slpkg_tmp +from __metadata__ import pkg_path, slpkg_tmp_patches from pkg.manager import PackageManager @@ -46,13 +46,9 @@ class Patches(object): def __init__(self, version): self.version = version - self.patch_path = slpkg_tmp + "patches/" + self.patch_path = slpkg_tmp_patches sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC)) sys.stdout.flush() - if not os.path.exists(slpkg_tmp): - os.mkdir(slpkg_tmp) - if not os.path.exists(self.patch_path): - os.mkdir(self.patch_path) if version == "stable": self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "patches/", version)).reading() diff --git a/slpkg/tracking.py b/slpkg/tracking.py index 533f77e1..e7b19e66 100755 --- a/slpkg/tracking.py +++ b/slpkg/tracking.py @@ -33,8 +33,8 @@ from pkg.find import find_package from sbo.search import sbo_search_pkg from sbo.dependency import sbo_dependencies_pkg -from others.dependency import dependencies_pkg from others.search import search_pkg +from others.dependency import dependencies_pkg def track_dep(name, repo): @@ -51,8 +51,8 @@ def track_dep(name, repo): dependencies_list = sbo_dependencies_pkg(name) find_pkg = sbo_search_pkg(name) else: - find_pkg = search_pkg(name, repo) dependencies_list = dependencies_pkg(name, repo) + find_pkg = search_pkg(name, repo) sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC)) if find_pkg: requires, dependencies = [], [] @@ -67,7 +67,7 @@ def track_dep(name, repo): if dependencies == []: dependencies = ["No dependencies"] pkg_len = len(name) + 24 - print # new line at start + print("") # new line at start template(pkg_len) print("| Package {0}{1}{2} dependencies :".format(CYAN, name, ENDC)) template(pkg_len) @@ -83,6 +83,6 @@ def track_dep(name, repo): else: print(" |") print(" {0}{1}: {2}{3}{4}".format("+--", index, RED, pkg, ENDC)) - print # new line at end + print("") # new line at end else: print("\nNo package was found to match\n") diff --git a/slpkg/url_read.py b/slpkg/url_read.py index 3a6ee17b..147f8e3b 100755 --- a/slpkg/url_read.py +++ b/slpkg/url_read.py @@ -38,8 +38,8 @@ class URL(object): f = urllib2.urlopen(self.link) return f.read() except urllib2.URLError: - print ("\nslpkg: error: connection refused\n") + print("\nslpkg: error: connection refused\n") sys.exit() except KeyboardInterrupt: - print # new line at exit + print("") # new line at exit sys.exit()