update slpkg.conf file

This commit is contained in:
Dimitris Zlatanidis 2014-11-14 10:55:35 +02:00
parent 574d75ae5e
commit 8f1b9cf359
7 changed files with 132 additions and 28 deletions

View file

@ -31,13 +31,66 @@ __license__ = "GNU General Public License v3 (GPLv3)"
__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",
"# 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"
]
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()
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"):
@ -48,6 +101,10 @@ for line in conf.splitlines():
slpkg_tmp_packages = line[9:].strip()
if line.startswith("PATCHES"):
slpkg_tmp_patches = line[8:].strip()
if line.startswith("DEL_ALL"):
del_all = line[8:].strip()
if line.startswith("DEL_BUILD"):
del_build = line[10:].strip()
if not slack_rel or slack_rel not in ['stable', 'current']:
slack_rel = "stable"
@ -67,7 +124,13 @@ if not slpkg_tmp_patches:
elif not slpkg_tmp_patches.endswith("/"):
slpkg_tmp_patches = slpkg_tmp_patches + "/"
''' repositories '''
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"
# repositories
repositories = [
"sbo",
"slack",
@ -76,23 +139,23 @@ repositories = [
"slacky"
]
''' file spacer '''
# file spacer
sp = "-"
''' current path '''
# current path
path = os.getcwd() + "/"
''' library path '''
# library path
lib_path = "/var/lib/slpkg/"
''' log path '''
# log path
log_path = "/var/log/slpkg/"
''' packages log files path '''
# packages log files path
pkg_path = "/var/log/packages/"
''' blacklist conf path '''
# blacklist conf path
bls_path = "/etc/slpkg/"
''' computer architecture '''
# computer architecture
arch = os.uname()[4]

View file

@ -22,6 +22,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from init import Initialization
from messages import pkg_not_found
from colors import RED, GREEN, YELLOW, CYAN, GREY, ENDC
from __metadata__ import pkg_path, lib_path, repositories
@ -37,6 +38,14 @@ class PkgDesc(object):
self.color = color
self.COLOR = ""
self.lib = ""
init_repos = {
'sbo': Initialization().sbo,
'slack': Initialization().slack,
'rlw': Initialization().rlw,
'alien': Initialization().alien,
'slacky': Initialization().slacky
}
init_repos[self.repo]()
color_text = {
'red': RED,
'green': GREEN,
@ -48,11 +57,11 @@ class PkgDesc(object):
self.COLOR = color_text[self.color]
if self.repo in repositories:
repos = {
"sbo": "sbo_repo/SLACKBUILDS.TXT",
"slack": "slack_repo/PACKAGES.TXT",
"rlw": "rlw_repo/PACKAGES.TXT",
"alien": "alien_repo/PACKAGES.TXT",
"slacky": "slacky_repo/PACKAGES.TXT"
'sbo': 'sbo_repo/SLACKBUILDS.TXT',
'slack': 'slack_repo/PACKAGES.TXT',
'rlw': 'rlw_repo/PACKAGES.TXT',
'alien': 'alien_repo/PACKAGES.TXT',
'slacky': 'slacky_repo/PACKAGES.TXT'
}
self.lib = lib_path + repos[self.repo]

View file

@ -37,6 +37,7 @@ from colors import RED, GREEN, GREY, YELLOW, ENDC
from __metadata__ import tmp, pkg_path, build_path, sp
from greps import SBoGrep
from remove import delete
from compressed import SBoLink
from search import sbo_search_pkg
from dependency import sbo_dependencies_pkg
@ -115,6 +116,7 @@ class SBoCheck(object):
PackageManager(binary).upgrade()
reference(data[0], data[1], data[2], count[0], count[1],
msg[0], msg[1], self.installed)
delete(build_path)
else:
print("\nTotal {0} SBo packages are up to date\n".format(
len(self.sbo_list())))

34
slpkg/sbo/remove.py Executable file
View file

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

View file

@ -40,6 +40,7 @@ from pkg.build import BuildPackage
from pkg.manager import PackageManager
from greps import SBoGrep
from remove import delete
from compressed import SBoLink
from search import sbo_search_pkg
from dependency import sbo_dependencies_pkg
@ -110,6 +111,7 @@ class SBoInstall(object):
reference(count[1], msg[0], count[0], msg[1],
b_ins[0], b_ins[2], b_ins[1])
write_deps(dependencies)
delete(build_path)
else:
count_installed = count_uninstalled = 0
# sbo matching = mdata[0]

View file

@ -37,6 +37,7 @@ from pkg.build import BuildPackage
from pkg.manager import PackageManager
from read import Read
from remove import delete
from greps import SBoGrep
from compressed import SBoLink
from search import sbo_search_pkg
@ -92,11 +93,13 @@ class SBoNetwork(object):
pydoc.pager(SlackBuild + fill)
elif choice in ['B', 'b']:
self.build(FAULT)
delete(build_path)
break
elif choice in ['I', 'i']:
if not find_package(prgnam + sp, pkg_path):
self.build(FAULT)
self.install(prgnam)
delete(build_path)
break
else:
template(78)

View file

@ -23,23 +23,14 @@
import os
from __metadata__ import del_all
def delete(path, packages):
'''
Remove downloaded packages
'''
read = raw_input("Removal downloaded packages [Y/n]? ")
if read in ['y', 'Y']:
if del_all == "on":
for pkg in packages:
os.remove(path + pkg)
os.remove(path + pkg + ".asc")
is_empty(path)
else:
is_empty(path)
def is_empty(path):
if not os.listdir(path):
print("Packages removed")
else:
print("\nThere are packages in direcrory {0}\n".format(path))