updated for version 1.7.0

This commit is contained in:
Dimitris Zlatanidis 2014-08-09 06:31:52 +03:00
parent 11341aae49
commit c9abb9cc2e
14 changed files with 169 additions and 71 deletions

View file

@ -1,3 +1,7 @@
09-08-2014
Version 1.7.0
[Feature] - Added removes packages with all dependencies
04-08-2014 04-08-2014
Version 1.6.9 Version 1.6.9

View file

@ -1,6 +1,6 @@
Metadata-Version: 1.1 Metadata-Version: 1.1
Name: slpkg Name: slpkg
Version: 1.6.9 Version: 1.7.0
Author: dslackw Author: dslackw
Author-email: d zlatanidis at gmail com Author-email: d zlatanidis at gmail com
Maintainer: dslackw Maintainer: dslackw

View file

@ -19,6 +19,7 @@ Features
- Grabs packages from slackbuilds.org in real time - Grabs packages from slackbuilds.org in real time
- Automatic tool build and install packages - Automatic tool build and install packages
- Check if your distribution is up to date - Check if your distribution is up to date
- Remove packages with all dependencies
- Display the contents of the packages - Display the contents of the packages
- Install-upgrade Slackware packages - Install-upgrade Slackware packages
- Build and install all in a command - Build and install all in a command
@ -27,7 +28,6 @@ Features
- Find installed package - Find installed package
- Read SlackBuilds files - Read SlackBuilds files
- Τracking dependencies - Τracking dependencies
- Remove packages
- No dependencies - No dependencies
It's a quick and easy way to manage your packages in `Slackware <http://www.slackware.com/>`_ It's a quick and easy way to manage your packages in `Slackware <http://www.slackware.com/>`_
@ -233,7 +233,7 @@ Check if your distribution is up to date from `Slackware official mirrors
Would you like to upgrade ? [Y/y] Would you like to upgrade ? [Y/y]
Find slackbuild from slackbuilds.org: Find packages from slackbuilds.org:
.. code-block:: bash .. code-block:: bash
@ -337,7 +337,7 @@ Auto tool to build package:
Slackware package /tmp/termcolor-1.1.0-x86_64-1_SBo.tgz created. Slackware package /tmp/termcolor-1.1.0-x86_64-1_SBo.tgz created.
Upgrade install package: Upgrade, install package:
.. code-block:: bash .. code-block:: bash
@ -358,7 +358,7 @@ Upgrade install package:
# #
Package termcolor-1.1.0-x86_64-1_SBo.tgz installed. Package termcolor-1.1.0-x86_64-1_SBo.tgz installed.
Of course you can install mass-packages: Install mass-packages:
.. code-block:: bash .. code-block:: bash
@ -368,7 +368,7 @@ Of course you can install mass-packages:
$ slpkg -i *.t?z $ slpkg -i *.t?z
Find if your packages installed: Find installed packages:
.. code-block:: bash .. code-block:: bash
@ -383,7 +383,7 @@ Find if your packages installed:
[ installed ] - rar-5.0.1-x86_64-1_SBo [ installed ] - rar-5.0.1-x86_64-1_SBo
[ installed ] - pip-1.5.4-x86_64-1_SBo [ installed ] - pip-1.5.4-x86_64-1_SBo
Display the contents of the package: Display the contents of the packages:
.. code-block:: bash .. code-block:: bash
@ -431,7 +431,7 @@ Display the contents of the package:
No such package lua: Cant find No such package lua: Cant find
Remove package: Remove packages:
.. code-block:: bash .. code-block:: bash
@ -476,10 +476,42 @@ Remove package:
No such package lua: Cant find No such package lua: Cant find
[ installed ] - rar-5.0.1-x86_64-1_SBo [ installed ] - rar-5.0.1-x86_64-1_SBo
$ slpkg -v Remove packages with all dependencies:
Version: x.x.x (presupposes facility with the option 'slpkg -s sbo <package>)
Licence: GNU General Public License v3 (GPLv3)
Email: d.zlatanidis@gmail.com .. code-block:: bash
$ slpkg -r Flask
Packages with name matching [ Flask ]
[ delete ] --> Flask-0.10.1-x86_64-1_SBo
Are you sure to remove 1 package [Y/y]
+==============================================================================
| Found dependencies for package Flask:
+==============================================================================
| pysetuptools
| MarkupSafe
| itsdangerous
| Jinja2
| werkzeug
+==============================================================================
Remove dependencies [Y/y]
.
.
.
+==============================================================================
| Package Flask removed
| Package pysetuptools removed
| Package MarkupSafe removed
| Package itsdangerous removed
| Package Jinja2 removed
| Package werkzeug removed
+==============================================================================
Man page it is available for full support: Man page it is available for full support:

View file

@ -107,7 +107,10 @@ slackware command upgradepkg --reinstall)
Removes a previously installed Slackware package, while writing Removes a previously installed Slackware package, while writing
a progress report to the standard output. A package may be a progress report to the standard output. A package may be
specified either by the full package name (as you'd see listed in specified either by the full package name (as you'd see listed in
/var/log/packages/), or by the base package name. 'Requires root /var/log/packages/), or by the base package name. If installed
packages with command 'slpkg -s sbo <package>' then write a file
in /var/log/slpkg/dep/ with all dependencies and it allows you
can remove them all together. 'Requires root
privileges' (like slackware command removepkg) privileges' (like slackware command removepkg)
.SS -f find packages .SS -f find packages
\fBslpkg\fP \fB-f\fP <\fIname of packages\fP> \fBslpkg\fP \fB-f\fP <\fIname of packages\fP>

View file

@ -6,7 +6,7 @@ import subprocess
__all__ = "slpkg" __all__ = "slpkg"
__author__ = "dslackw" __author__ = "dslackw"
__version_info__ = (1, 6, 9) __version_info__ = (1, 7, 0)
__version__ = "{0}.{1}.{2}".format(*__version_info__) __version__ = "{0}.{1}.{2}".format(*__version_info__)
__license__ = "GNU General Public License v3 (GPLv3)" __license__ = "GNU General Public License v3 (GPLv3)"
__email__ = "d.zlatanidis@gmail.com" __email__ = "d.zlatanidis@gmail.com"
@ -18,7 +18,10 @@ sp = "-"
path = subprocess.check_output(["pwd"], shell=True).replace("\n", "/") path = subprocess.check_output(["pwd"], shell=True).replace("\n", "/")
''' build path ''' ''' build path '''
build_path = path + "Slpkg_Build/" build_path = path + "slpkg_Build/"
''' log path '''
log_path = "/var/log/slpkg/"
''' temponary path ''' ''' temponary path '''
tmp = "/tmp/" tmp = "/tmp/"

View file

@ -34,8 +34,8 @@ optional arguments:
-i [ ...] install binary packages -i [ ...] install binary packages
-u [ ...] upgrade binary packages -u [ ...] upgrade binary packages
-o [ ...] reinstall binary packages -o [ ...] reinstall binary packages
-r [ ...] remove packages -r [ ...] remove binary packages
-f [ ...] view packages installed -f [ ...] view installed packages
-d [ ...] display the contents of the packages -d [ ...] display the contents of the packages
''' '''

View file

@ -11,7 +11,7 @@ from slpkg.messages import pkg_not_found, s_user
def build_package(script, source, extra, path): def build_package(script, source, extra, path):
''' '''
Build package with source Build package from source
''' '''
s_user(getpass.getuser()) s_user(getpass.getuser())
pkg_name = script.replace(".tar.gz", "") pkg_name = script.replace(".tar.gz", "")

View file

@ -5,8 +5,7 @@ import os
def find_package(find_pkg, directory): def find_package(find_pkg, directory):
''' '''
Find installed packages from Find packages
/var/log/packages/
''' '''
pkgs = [] pkgs = []
for pkg in os.listdir(directory): for pkg in os.listdir(directory):

View file

@ -5,9 +5,12 @@ import os
import sys import sys
import getpass import getpass
import subprocess import subprocess
from collections import OrderedDict
from slpkg.colors import colors from slpkg.colors import colors
from slpkg.__metadata__ import pkg_path, uname, arch, sp
from slpkg.messages import pkg_not_found, s_user, template from slpkg.messages import pkg_not_found, s_user, template
from slpkg.__metadata__ import pkg_path, uname, arch, sp, log_path
from find import find_package from find import find_package
@ -66,8 +69,7 @@ def pkg_remove(binary):
Remove Slackware binary packages Remove Slackware binary packages
''' '''
s_user(getpass.getuser()) s_user(getpass.getuser())
removed = [] removed, not_found, dependencies, rmv_dependencies = [], [], [], []
not_found = []
print ("\nPackages with name matching [ {0}{1}{2} ]\n".format( print ("\nPackages with name matching [ {0}{1}{2} ]\n".format(
colors.CYAN, ', '.join(binary), colors.ENDC)) colors.CYAN, ', '.join(binary), colors.ENDC))
for pkg in binary: for pkg in binary:
@ -82,24 +84,69 @@ def pkg_remove(binary):
pkg_not_found(bol, pkg, message, eol) pkg_not_found(bol, pkg, message, eol)
if removed == []: if removed == []:
print # new line at end print # new line at end
sys.exit() else:
try: msg = "package"
remove_pkg = raw_input("\nAre you sure to remove " + str(len(removed)) + \ if len(removed) > 1:
" package(s) [Y/y] ") msg = msg + "s"
except KeyboardInterrupt: try:
print # new line at exit remove_pkg = raw_input("\nAre you sure to remove {0} {1} [Y/y] ".format(
sys.exit() str(len(removed)), msg))
if remove_pkg == "y" or remove_pkg == "Y": except KeyboardInterrupt:
for rmv in removed: print # new line at exit
print subprocess.check_output('removepkg {0}'.format(rmv), shell=True) sys.exit()
template(78) if remove_pkg == "y" or remove_pkg == "Y":
for pkg in removed: for rmv in removed:
if find_package(pkg + sp, pkg_path) == []: '''
print ("| Package: {0} removed".format(pkg)) If package build and install with 'slpkg -s sbo <package>'
for pkg in not_found: then look log file for dependencies in /var/log/slpkg/dep,
print ("| Package: {0} not found".format(pkg)) read and remove all else remove only the package.
template(78) '''
print # new line at end if find_package(rmv, log_path + "dep/"):
f = open("{0}dep/{1}".format(log_path, rmv), "r")
dependencies = f.read().split()
print # new line at start
template(78)
print ("| Found dependencies for package {0}:".format(rmv))
template(78)
'''
Prints dependecies before removed except master package
because referred as master package
'''
for dep in dependencies[:-1]:
print ("| " + dep)
template(78)
try:
remove_dep = raw_input("\nRemove dependencies [Y/y] ")
except KeyboardInterrupt:
print # new line at exit
sys.exit()
if remove_dep == "y" or remove_dep == "Y":
for dep in dependencies:
if find_package(dep + sp, pkg_path):
print subprocess.check_output('removepkg {0}'.format(dep), shell=True)
f.close()
os.remove("{0}dep/{1}".format(log_path, rmv))
rmv_dependencies += dependencies[:-1]
else:
if find_package(rmv + sp, pkg_path):
print subprocess.check_output('removepkg {0}'.format(rmv), shell=True)
f.close()
os.remove("{0}dep/{1}".format(log_path, rmv))
else:
if find_package(rmv + sp, pkg_path):
print subprocess.check_output('removepkg {0}'.format(rmv), shell=True)
'''
Prints all removed packages
'''
removed = removed + rmv_dependencies
template(78)
for pkg in list(OrderedDict.fromkeys(removed)):
if find_package(pkg + sp, pkg_path) == []:
print ("| Package {0} removed".format(pkg))
for pkg in not_found:
print ("| Package {0} not found".format(pkg))
template(78)
print # new line at end
def pkg_find(binary): def pkg_find(binary):
''' '''
@ -145,7 +192,8 @@ def pkg_list(binary):
index += 1 index += 1
print ("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg)) print ("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg))
if index == page: if index == page:
key = raw_input('\nPress [ Enter ] >> Next page ') key = raw_input('\nPress [ {0}Enter{1} ] >> Next page '.format(
colors.CYAN, colors.ENDC))
page += 50 page += 50
if "sbo" in binary: if "sbo" in binary:
for pkg in os.listdir(pkg_path): for pkg in os.listdir(pkg_path):
@ -153,7 +201,8 @@ def pkg_list(binary):
index += 1 index += 1
print ("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg)) print ("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg))
if index == page: if index == page:
key = raw_input('\nPress [ Enter ] >> Next page ') key = raw_input('\nPress [ {0}Enter{1} ] >> Next page '.format(
colors.CYAN, colors.ENDC))
page += 50 page += 50
if "slack" in binary: if "slack" in binary:
for pkg in os.listdir(pkg_path): for pkg in os.listdir(pkg_path):
@ -161,7 +210,8 @@ def pkg_list(binary):
index += 1 index += 1
print ("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg)) print ("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg))
if index == page: if index == page:
key = raw_input('\nPress [ Enter ] >> Next page ') key = raw_input('\nPress [ {0}Enter{1} ] >> Next page '.format(
colors.CYAN, colors.ENDC))
page += 50 page += 50
if "noarch" in binary: if "noarch" in binary:
for pkg in os.listdir(pkg_path): for pkg in os.listdir(pkg_path):
@ -169,7 +219,8 @@ def pkg_list(binary):
index += 1 index += 1
print ("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg)) print ("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg))
if index == page: if index == page:
key = raw_input('\nPress [ Enter ] >> Next page ') key = raw_input('\nPress [ {0}Enter{1} ] >> Next page '.format(
colors.CYAN, colors.ENDC))
page += 50 page += 50
if "other" in binary: if "other" in binary:
for pkg in os.listdir(pkg_path): for pkg in os.listdir(pkg_path):
@ -179,10 +230,10 @@ def pkg_list(binary):
index += 1 index += 1
print ("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg)) print ("{0}{1}:{2} {3}".format(colors.GREY, index, colors.ENDC, pkg))
if index == page: if index == page:
key = raw_input('\nPress [ Enter ] >> Next page ') key = raw_input('\nPress [ {0}Enter{1} ] >> Next page '.format(
colors.CYAN, colors.ENDC))
page += 50 page += 50
print # new line at end print # new line at end
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print # new line at exit
sys.exit() sys.exit()

View file

@ -7,4 +7,4 @@ def sbo_slackbuild_dwn(sbo_url, name):
slackbuild download link slackbuild download link
''' '''
sbo_url = sbo_url.replace(name + "/", name + ".tar.gz") sbo_url = sbo_url.replace(name + "/", name + ".tar.gz")
return sbo_url.replace("repository", "slackbuilds") return sbo_url

View file

@ -7,10 +7,9 @@ from slpkg.__metadata__ import uname, arch
def sbo_source_dwn(sbo_url, name): def sbo_source_dwn(sbo_url, name):
''' '''
Grep source code download link Grep source downloads links
''' '''
read_info = url_read((sbo_url + name + ".info").replace( read_info = url_read(sbo_url + name + ".info")
"repository", "slackbuilds"))
if arch == "x86_64": if arch == "x86_64":
for line in read_info.splitlines(): for line in read_info.splitlines():
if line.startswith('DOWNLOAD_x86_64='): if line.startswith('DOWNLOAD_x86_64='):
@ -22,10 +21,9 @@ def sbo_source_dwn(sbo_url, name):
def sbo_extra_dwn(sbo_url, name): def sbo_extra_dwn(sbo_url, name):
''' '''
Grep extra source code download link Grep extra source downloads links
''' '''
read_info = url_read((sbo_url + name + ".info").replace( read_info = url_read(sbo_url + name + ".info")
"repository", "slackbuilds"))
extra = [] extra = []
for line in read_info.split(): for line in read_info.split():
if line.endswith('"'): if line.endswith('"'):
@ -40,8 +38,7 @@ def sbo_requires_pkg(sbo_url, name):
''' '''
Grep package requirements Grep package requirements
''' '''
read_info = url_read((sbo_url + name + ".info").replace( read_info = url_read(sbo_url + name + ".info")
"repository", "slackbuilds"))
for line in read_info.splitlines(): for line in read_info.splitlines():
if line.startswith('REQUIRES="'): if line.startswith('REQUIRES="'):
return line[10:-1] return line[10:-1]
@ -50,8 +47,7 @@ def sbo_prgnam_pkg(sbo_url, name):
''' '''
Grep program name Grep program name
''' '''
read_info = url_read((sbo_url + name + ".info").replace( read_info = url_read(sbo_url + name + ".info")
"repository", "slackbuilds"))
for line in read_info.splitlines(): for line in read_info.splitlines():
if line.startswith('PRGNAM="'): if line.startswith('PRGNAM="'):
return line[8:-1] return line[8:-1]
@ -60,8 +56,7 @@ def sbo_version_pkg(sbo_url, name):
''' '''
Grep package version Grep package version
''' '''
read_info = url_read((sbo_url + name + ".info").replace( read_info = url_read(sbo_url + name + ".info")
"repository", "slackbuilds"))
for line in read_info.splitlines(): for line in read_info.splitlines():
if line.startswith('VERSION="'): if line.startswith('VERSION="'):
return line[9:-1] return line[9:-1]

View file

@ -15,17 +15,17 @@ def read_readme(sbo_url, name, site):
Read SlackBuild README file Read SlackBuild README file
''' '''
s_user(getpass.getuser()) s_user(getpass.getuser())
readme = url_read((sbo_url + site).replace("repository", "slackbuilds")) readme = url_read(sbo_url + site)
file = open("{0}readme/{1}.{2}".format(slpkg_path, name, site), "w") f = open("{0}readme/{1}.{2}".format(slpkg_path, name, site), "w")
file.write(readme) f.write(readme)
file.close() f.close()
def read_info_slackbuild(sbo_url, name, site): def read_info_slackbuild(sbo_url, name, site):
''' '''
Read info SlackBuild file Read info SlackBuild file
''' '''
s_user(getpass.getuser()) s_user(getpass.getuser())
info = url_read((sbo_url + name + site).replace("repository", "slackbuilds")) info = url_read(sbo_url + name + site)
file = open("{0}readme/{1}{2}".format(slpkg_path, name, site), "w") f = open("{0}readme/{1}{2}".format(slpkg_path, name, site), "w")
file.write(info) f.write(info)
file.close() f.close()

View file

@ -15,7 +15,7 @@ def sbo_search_pkg(name):
''' '''
try: try:
sbo_location = [] sbo_location = []
sbo_url = ("http://slackbuilds.org/repository/{0}/".format(slack_ver())) sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(slack_ver()))
SLACKBUILDS_TXT = url_read(( SLACKBUILDS_TXT = url_read((
"http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format(slack_ver()))) "http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format(slack_ver())))
for line in SLACKBUILDS_TXT.splitlines(): for line in SLACKBUILDS_TXT.splitlines():

View file

@ -7,8 +7,8 @@ import getpass
from slpkg.colors import colors from slpkg.colors import colors
from slpkg.functions import get_file from slpkg.functions import get_file
from slpkg.__metadata__ import tmp, pkg_path, build_path, sp from slpkg.__metadata__ import tmp, pkg_path, build_path, sp
from slpkg.__metadata__ import sbo_arch, sbo_tag, sbo_filetype, arch
from slpkg.messages import pkg_not_found, pkg_found, template, s_user from slpkg.messages import pkg_not_found, pkg_found, template, s_user
from slpkg.__metadata__ import sbo_arch, sbo_tag, sbo_filetype, arch, log_path
from slpkg.pkg.find import find_package from slpkg.pkg.find import find_package
from slpkg.pkg.build import build_package from slpkg.pkg.build import build_package
@ -37,7 +37,7 @@ def sbo_build(name):
try: try:
os.system("mkdir -p {0}".format(build_path)) os.system("mkdir -p {0}".format(build_path))
os.chdir(build_path) os.chdir(build_path)
requires, dependencies, extra = [], [], [] requires, dependencies, extra, = [], [], []
requires.append(name) requires.append(name)
for pkg in dependencies_list: for pkg in dependencies_list:
requires += pkg requires += pkg
@ -75,6 +75,17 @@ def sbo_build(name):
template(78) template(78)
pkg_found(pkg) pkg_found(pkg)
template(78) template(78)
'''
Write dependencies in a log file into directory '/var/log/slpkg/dep/'
'''
os.system("mkdir -p {0}dep/".format(log_path))
if find_package(name, log_path + "dep/"):
os.remove("{0}dep/{1}".format(log_path, name))
if len(dependencies) > 1:
f = open("{0}dep/{1}".format(log_path, name), "w")
for dep in dependencies:
f.write(dep + "\n")
f.close()
print # new line at end print # new line at end
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print # new line at exit