Dev: updated mess, add install for slack

This commit is contained in:
dslackw 2014-07-28 08:28:47 +03:00
parent 8e56968a1f
commit bb54655f09
18 changed files with 305 additions and 107 deletions

View file

@ -1,3 +1,12 @@
29-07-2014
Version 1.6.5
[Feature] - Added slack, noarch and other in list (slpkg -l)
Added index in list (slpkg -l)
Added install packages via official Slackware mirrors
[Updated] - Arguments views
28-07-2014
Version 1.6.4

View file

@ -5,7 +5,7 @@
.. image:: https://pypip.in/license/slpkg/badge.png
:target: https://pypi.python.org/pypi/slpkg
Slpkg is a terminal tool in order to easy use Slackware packages.
Slpkg is a terminal multitool in order to easy use Slackware packages.
.. image:: https://raw.githubusercontent.com/dslackw/slpkg/master/logo/slpkg.png
:alt: logo
@ -67,31 +67,35 @@ Command Line Tool Usage
.. code-block:: bash
usage: slpkg [-h] [-v] [-a script [source ...]] [-l all, sbo [all, sbo ...]]
[-t] [-n] [-c] [-s] [-i [...]] [-u [...]] [-o [...]]
[-r [...]] [-f [...]] [-d [...]]
usage: slpkg [-h] [-v] [-a script [source ...]]
[-l all, sbo, slack, noarch, other [all, sbo, slack, noarch, other ...]]
[-c sbo, slack [sbo, slack ...]]
[-s sbo, slack [sbo, slack ...]] [-t] [-n] [-i [...]]
[-u [...]] [-o [...]] [-r [...]] [-f [...]] [-d [...]]
Utility to help package management in Slackware
Utility for easy management packages in Slackware
optional arguments:
optional arguments:
-h, --help show this help message and exit
-v, --verbose print version and exit
-a script [source ...]
auto build package
-l all, sbo [all, sbo ...]
-l all, sbo, slack, noarch, other [all, sbo, slack, noarch, other ...]
list of installed packages
-t tracking dependencies
-n find from SBo repositority
-c sbo, slack [sbo, slack ...]
check if your packages is up to date
-s download, build & install pkg from SBo
-s sbo, slack [sbo, slack ...]
download, build & install packages
-t tracking dependencies
-n find packages from SBo repository
-i [ ...] install binary packages
-u [ ...] install-upgrade packages with new
-o [ ...] reinstall the same packages
-u [ ...] upgrade binary packages
-o [ ...] reinstall binary packages
-r [ ...] remove packages
-f [ ...] find if packages installed
-d [ ...] display the contents of the packages
Slpkg Examples
--------------
@ -153,14 +157,14 @@ Tracking all dependencies of packages:
|
+-- 1 gst1-plugins-base
|
+-- 2 libunique gst1-plugins-bad
+-- 2 libunique, gst1-plugins-bad
Check if your packages is up to date from slackbuilds.org:
.. code-block:: bash
$ slpkg -c sbo flashplayer-plugin
Searching `flashplayer-plugin` from slackbuilds.org ...
Searching [ flashplayer-plugin ] from slackbuilds.org ...
New version is available:
+==============================================================================
@ -170,11 +174,11 @@ Check if your packages is up to date from slackbuilds.org:
Would you like to install ? [Y/y]
$ slpkg -c sbo ranger
Searching `ranger` from slackbuilds.org ...
Searching [ ranger ] from slackbuilds.org ...
Package ranger is up to date
$ slpkg -c termcolor
$ slpkg -c sbo termcolor
No such package termcolor: Can't find
@ -191,15 +195,15 @@ Find slackbuild from slackbuilds.org:
.. code-block:: bash
$ slpkg -n bitfighter
Searching `bitfighter` from slackbuilds.org ...
Searching [ bitfighter ] from slackbuilds.org ...
+===============================================================================
| Package bitfighter --> http://slackbuilds.org/repository/14.1/games/bitfighter/
+===============================================================================
| SlackBuild : http://slackbuilds.org/slackbuilds/14.1/games/bitfighter.tar.gz
| Source : http://bitfighter.org/files/bitfighter-019c.tar.gz
| Extra : https://bitfighter.googlecode.com/files/classic_level_pack.zip
| Requirements : OpenAL SDL2 speex libmodplug
| SlackBuild : bitfighter.tar.gz
| Source : bitfighter-019c.tar.gz
| Extra : classic_level_pack.zip
| Requirements : OpenAL, SDL2, speex, libmodplug
+===============================================================================
README View the README file
SlackBuild View the SlackBuild file

View file

@ -33,7 +33,7 @@ It's a quick and easy way to manage your packages in slackware to a command.
\fB-n find from SBo repositority\fP
\fB-c sbo, slack [sbo, slack ...]\fp
\fb check if your package is up to date\fP
\fB-s download, build & install pkg from SBo\fP
\fB-s download, build & install packages from SBo\fP
\fB-i [ ...] install binary packages\fP
\fB-u [ ...] install-upgrade packages with new\fP
\fB-o [ ...] reinstall the same packages\fP

View file

@ -9,4 +9,5 @@ class colors:
GREEN = "\x1b[32m"
YELLOW = "\x1b[33m"
CYAN = "\x1b[36m"
WHEAT = "\x1b[38;5;101m"
ENDC = "\x1b[0m"

View file

@ -2,27 +2,30 @@
# -*- coding: utf-8 -*-
'''
usage: main.py [-h] [-v] [-a script [source ...]] [-l all, sbo [all, sbo ...]]
[-t] [-n] [-c sbo, slack [sbo, slack ...]] [-s] [-i [...]]
usage: slpkg [-h] [-v] [-a script [source ...]]
[-l all, sbo, slack, noarch, other [all, sbo, slack, noarch, other ...]]
[-c sbo, slack [sbo, slack ...]]
[-s sbo, slack [sbo, slack ...]] [-t] [-n] [-i [...]]
[-u [...]] [-o [...]] [-r [...]] [-f [...]] [-d [...]]
Utility to help package management in Slackware
Utility for easy management packages in Slackware
optional arguments:
-h, --help show this help message and exit
-v, --verbose print version and exit
-a script [source ...]
auto build package
-l all, sbo [all, sbo ...]
-l all, sbo, slack, noarch, other [all, sbo, slack, noarch, other ...]
list of installed packages
-t tracking dependencies
-n find from SBo repositority
-c sbo, slack [sbo, slack ...]
check if your packages is up to date
-s download, build & install pkg from SBo
-s sbo, slack [sbo, slack ...]
download, build & install packages
-t tracking dependencies
-n find packages from SBo repository
-i [ ...] install binary packages
-u [ ...] install-upgrade packages with new
-o [ ...] reinstall the same packages
-u [ ...] upgrade binary packages
-o [ ...] reinstall binary packages
-r [ ...] remove packages
-f [ ...] find if packages installed
-d [ ...] display the contents of the packages
@ -32,37 +35,43 @@ import argparse
from version import *
from functions import *
from colors import colors
from messages import err_args
from messages import ext_err_args
from messages import err1_args, err2_args
from pkg.build import *
from pkg.manager import *
from sbo.slackbuild import *
from sbo.dependency import *
from sbo.check import sbo_check
from sbo.views import sbo_network
from slack.patches import patches
from slack.install import install
def main():
description = "Utility to help package management in Slackware"
description = "Utility for easy management packages in Slackware"
parser = argparse.ArgumentParser(description=description)
parser.add_argument("-v", "--verbose", help="print version and exit",
action="store_true")
parser.add_argument("-a", help="auto build package",
type=str, nargs="+", metavar=('script', 'source'))
parser.add_argument("-l", help="list of installed packages", nargs="+",
choices="all sbo".split(), metavar=('all, sbo'))
parser.add_argument("-t", help="tracking dependencies",
type=str, metavar=(''))
parser.add_argument("-n", help="find from SBo repositority",
type=str, metavar=(''))
choices="all sbo slack noarch other".split(),
metavar=('all, sbo, slack, noarch, other'))
parser.add_argument("-c", help="check if your packages is up to date",
type=str, nargs="+", metavar=('sbo, slack'))
parser.add_argument("-s", help="download, build & install pkg from SBo",
parser.add_argument("-s", help="download, build & install packages",
type=str, nargs="+", metavar=('sbo, slack'))
parser.add_argument("-t", help="tracking dependencies",
type=str, metavar=(''))
parser.add_argument("-n", help="find packages from SBo repository",
type=str, metavar=(''))
parser.add_argument("-i", help="install binary packages",
type=str, nargs="+", metavar=(''))
parser.add_argument("-u", help="install-upgrade packages with new",
parser.add_argument("-u", help="upgrade binary packages",
type=str, nargs="+", metavar=(''))
parser.add_argument("-o", help="reinstall the same packages",
parser.add_argument("-o", help="reinstall binary packages",
type=str, nargs="+", metavar=(''))
parser.add_argument("-r", help="remove packages",
type=str, nargs="+", metavar=(''))
@ -95,13 +104,45 @@ def main():
if args.c[1] == "upgrade":
patches()
else:
print ("\nError: invalid option choose { upgrade }\n")
choices = ['upgrade']
ext_err_args()
err1_args(''.join(args.c), choices)
else:
print ("\nError: invalid option choose { sbo, slack }\n")
choices = ['sbo', 'slack']
ext_err_args()
err1_args(''.join(args.c[0]), choices)
elif len(args.c) < 2:
if "sbo" in args.c or "slack" in args.c:
ext_err_args()
err2_args()
else:
choices = ['sbo', 'slack']
ext_err_args()
err1_args(''.join(args.c), choices)
else:
err_args(bol='\n', eol='\n')
ext_err_args()
err2_args()
if args.s:
sbo_build(args.s)
if len(args.s) == 2:
if "sbo" in args.s:
sbo_build(''.join(args.s[1]))
elif "slack" in args.s:
install(''.join(args.s[1]))
else:
choices = ['sbo', 'slack']
ext_err_args()
err1_args(''.join(args.s), choices)
elif len(args.s) < 2:
if "sbo" in args.s or "slack" in args.s:
ext_err_args()
err2_args()
else:
choices = ['sbo', 'slack']
ext_err_args()
err1_args(''.join(args.s), choices)
else:
ext_err_args()
err2_args()
if args.i:
pkg_install(args.i)
if args.u:

View file

@ -3,6 +3,7 @@
import sys
from colors import colors
from __metadata__ import __all__
def pkg_not_found(bol, pkg, message, eol):
'''
@ -22,11 +23,30 @@ def pkg_installed(pkg):
'''
print ("| Package {0} installed".format(pkg))
def err_args(bol, eol):
def ext_err_args():
'''
Extended error arguments view
'''
print ("usage: {0} [-h] [-v] [-a script [source ...]]".format(__all__))
print (" [-l all, sbo, slack, noarch, other [all, sbo, slack, \
noarch, other ...]]")
print (" [-c sbo, slack [sbo, slack ...]] [-t] [-n]")
print (" [-s sbo, slack [sbo, slack ...]] [-i [...]] [-u [...]]")
print (" [-o [...]] [-r [...]] [-f [...]] [-d [...]]")
def err1_args(invalid, choices):
'''
Print error message arguments
'''
print ("{0}Error: must enter at least two arguments{1}".format(bol, eol))
print ("{0}: error: invalid choice: '{1}' choose from {2}".format(
__all__, invalid, choices))
def err2_args():
'''
Print error message arguments
'''
print ("{0}: error: must enter at least two arguments".format(
__all__))
def s_user(user):
'''

View file

@ -6,7 +6,7 @@ import shutil
import tarfile
import subprocess
from slpkg.messages import pkg_not_found
from messages import pkg_not_found
def build_extra_pkg(script, source, extra):
'''

View file

@ -5,9 +5,10 @@ import os
import sys
import getpass
import subprocess
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 colors import colors
from __metadata__ import pkg_path, uname, arch, sp
from messages import pkg_not_found, s_user, template
from find import find_package
def pkg_install(binary):
@ -115,6 +116,7 @@ def pkg_find(binary):
'''
Find installed Slackware packages
'''
print # new line at start
for pkg in range(len(binary)):
if find_package(binary[pkg] + sp, pkg_path) == []:
message = "Can't find"
@ -124,8 +126,9 @@ def pkg_find(binary):
bol, eol = "\n", "\n"
pkg_not_found(bol, binary[pkg], message, eol)
else:
print (colors.GREEN + "[ installed ] - " + colors.ENDC + "\n ".join(
print (colors.GREEN + "[ installed ] - " + colors.ENDC + "\n ".join(
find_package(binary[pkg] + sp, pkg_path)))
print # new line at end
def pkg_display(binary):
'''
@ -147,13 +150,48 @@ def pkg_list(binary):
'''
List with the installed packages
'''
print # new line at start
index, stop = 0, 50
if "all" in binary:
print
os.chdir(pkg_path)
os.system("ls * | more")
print
for pkg in os.listdir(pkg_path):
index += 1
print ("[{0}{1}{2}] {3}".format(colors.WHEAT, index, colors.ENDC, pkg))
if index == stop:
key = raw_input('\nPress [ Enter ] >> Next page ')
stop += 50
if "sbo" in binary:
print
os.chdir(pkg_path)
os.system("ls * | grep 'SBo' | more")
print
for pkg in os.listdir(pkg_path):
if 'SBo' in pkg:
index += 1
print ("[{0}{1}{2}] {3}".format(colors.WHEAT, index, colors.ENDC, pkg))
if index == stop:
key = raw_input('\nPress [ Enter ] >> Next page ')
stop += 50
if "slack" in binary:
for pkg in os.listdir(pkg_path):
if 'slack' in pkg:
index += 1
print ("[{0}{1}{2}] {3}".format(colors.WHEAT, index, colors.ENDC, pkg))
if index == stop:
key = raw_input('\nPress [ Enter ] >> Next page ')
stop += 50
if "noarch" in binary:
for pkg in os.listdir(pkg_path):
if 'noarch' in pkg:
index += 1
print ("[{0}{1}{2}] {3}".format(colors.WHEAT, index, colors.ENDC, pkg))
if index == stop:
key = raw_input('\nPress [ Enter ] >> Next page ')
stop += 50
if "other" in binary:
for pkg in os.listdir(pkg_path):
if 'SBo' in pkg or 'slack' in pkg or 'noarch' in pkg:
pass
else:
index += 1
print ("[{0}{1}{2}] {3}".format(colors.WHEAT, index, colors.ENDC, pkg))
if index == stop:
key = raw_input('\nPress [ Enter ] >> Next page ')
stop += 50
print # new line at end

View file

@ -3,14 +3,16 @@
import os
import getpass
from slpkg.pkg.build import *
from slpkg.pkg.find import find_package
from slpkg.pkg.manager import pkg_upgrade
from slpkg.colors import colors
from slpkg.functions import get_file
from slpkg.messages import pkg_not_found, s_user, template
from slpkg.__metadata__ import tmp, pkg_path, uname, arch, sp
from slpkg.__metadata__ import sbo_arch, sbo_tag, sbo_filetype
from pkg.build import *
from pkg.find import find_package
from pkg.manager import pkg_upgrade
from colors import colors
from functions import get_file
from messages import pkg_not_found, s_user, template
from __metadata__ import tmp, pkg_path, uname, arch, sp
from __metadata__ import sbo_arch, sbo_tag, sbo_filetype
from search import sbo_search_pkg
from download import sbo_slackbuild_dwn
from greps import sbo_source_dwn, sbo_extra_dwn, sbo_version_pkg

View file

@ -1,8 +1,9 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from slpkg.colors import colors
from slpkg.messages import pkg_not_found, template
from colors import colors
from messages import pkg_not_found, template
from greps import *
from search import sbo_search_pkg
from download import sbo_slackbuild_dwn

View file

@ -2,8 +2,8 @@
# -*- coding: utf-8 -*-
import os
from slpkg.url_read import url_read
from slpkg.__metadata__ import uname, arch
from url_read import url_read
from __metadata__ import uname, arch
def sbo_source_dwn(sbo_url, name):
'''

View file

@ -3,8 +3,8 @@
import os
import getpass
from slpkg.messages import s_user
from slpkg.url_read import url_read
from messages import s_user
from url_read import url_read
# create tmp directory if not exist
os.system("mkdir -p /tmp/slpkg/readme/")

View file

@ -3,10 +3,11 @@
import re
import sys
from slpkg.colors import colors
from slpkg.url_read import url_read
from slpkg.functions import get_file
from slpkg.slack.slack_version import slack_ver
from colors import colors
from url_read import url_read
from functions import get_file
from slack.slack_version import slack_ver
def sbo_search_pkg(name):
'''

View file

@ -4,14 +4,15 @@
import os
import sys
import getpass
from slpkg.colors import colors
from slpkg.functions import get_file
from slpkg.__metadata__ import tmp, pkg_path, sp
from slpkg.__metadata__ import sbo_arch, sbo_tag, sbo_filetype
from slpkg.messages import s_user, pkg_found, pkg_installed, template
from slpkg.pkg.build import *
from slpkg.pkg.find import find_package
from slpkg.pkg.manager import pkg_upgrade
from colors import colors
from functions import get_file
from __metadata__ import tmp, pkg_path, sp
from __metadata__ import sbo_arch, sbo_tag, sbo_filetype
from messages import s_user, pkg_found, pkg_installed, template
from pkg.build import *
from pkg.find import find_package
from pkg.manager import pkg_upgrade
from dependency import sbo_dependencies_links_pkg

View file

@ -1,14 +1,16 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from slpkg.colors import colors
from slpkg.functions import get_file
from slpkg.__metadata__ import tmp, pkg_path, slpkg_path, sp
from slpkg.__metadata__ import sbo_arch, sbo_tag, sbo_filetype
from slpkg.messages import s_user, pkg_not_found, pkg_found, view_sbo, template
from slpkg.pkg.build import *
from slpkg.pkg.find import find_package
from slpkg.pkg.manager import pkg_upgrade
from colors import colors
from functions import get_file
from __metadata__ import tmp, pkg_path, slpkg_path, sp
from __metadata__ import sbo_arch, sbo_tag, sbo_filetype
from messages import s_user, pkg_not_found, pkg_found, view_sbo, template
from pkg.build import *
from pkg.find import find_package
from pkg.manager import pkg_upgrade
from read import *
from greps import *
from search import sbo_search_pkg
@ -30,7 +32,9 @@ def sbo_network(name):
sbo_version = sbo_version_pkg(sbo_url, name)
source_dwn = sbo_source_dwn(sbo_url, name)
extra_dwn = " ".join(sbo_extra_dwn(sbo_url, name))
view_sbo(name, sbo_url, sbo_dwn, source_dwn, extra_dwn, sbo_req)
view_sbo(name, sbo_url, get_file(sbo_dwn, '/'), get_file(source_dwn, '/'),
', '.join([get_file(extra_dwn, '/') for extra_dwn in extra_dwn.split()]),
sbo_req)
while True:
read = raw_input("_ ")
if read == "D" or read == "d":

70
slpkg/slack/install.py Executable file
View file

@ -0,0 +1,70 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
from colors import colors
from url_read import url_read
from messages import pkg_not_found
from __metadata__ import slpkg_path, pkg_path
from pkg.find import find_package
from pkg.manager import pkg_upgrade
from mirrors import mirrors
def install(slack_pkg):
'''
Install packages from official Slackware distribution
'''
dwn_list, dwn_packages = [], []
install_all, package_name, package_location = [], [], []
os.system("mkdir -p {0}{1}".format(slpkg_path, 'packages/'))
PACKAGE_TXT = url_read(mirrors(name='PACKAGES.TXT', location=''))
for line in PACKAGE_TXT.splitlines():
if line.startswith('PACKAGE NAME'):
package_name.append(line.replace('PACKAGE NAME: ', ''))
if line.startswith('PACKAGE LOCATION'):
package_location.append(line.replace('PACKAGE LOCATION: ./', ''))
for loc, name in zip(package_location, package_name):
dwn_list.append('{0}{1}/{2}'.format(mirrors('',''), loc, name))
print ("\nPackages with name matching [ {0}{1}{2} ]\n".format(
colors.CYAN, slack_pkg, colors.ENDC))
for pkg in package_name:
if slack_pkg in pkg:
if pkg.endswith('.txz'):
print ("{0}[ install ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, pkg.replace('.txz', '')))
install_all.append(pkg)
elif pkg.endswith('.tgz'):
print ("{0}[ install ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, pkg.replace('.tgz', '')))
install_all.append(pkg)
if install_all == []:
bol, eol = '', '\n'
message = "No matching"
pkg_not_found(bol, slack_pkg, message, eol)
else:
print
read = raw_input("Would you like to install [Y/y] ")
if read == "Y" or read == "y":
for install in install_all:
for dwn in dwn_list:
if install in dwn:
os.system("wget -N --directory-prefix={0}{1} {2}".format(
slpkg_path, 'packages/', dwn))
for install in install_all:
print ("{0}[ installing ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, install))
pkg_upgrade((slpkg_path + 'packages/' + install).split())
read = raw_input("Remove the packages downloaded ? [Y/y] ")
if read == "Y" or read == "y":
for remove in install_all:
os.remove("{0}{1}{2}".format(slpkg_path, 'packages/', remove))
if os.listdir(slpkg_path + 'packages/') == []:
print ("Packages removed")
else:
print ("\nThere are packages in directory {0}{1}\n".format(
slpkg_path, 'packages/'))
else:
print ("\nThere are packages in directory {0}{1}\n".format(
slpkg_path, 'packages/'))

View file

@ -1,7 +1,7 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
from slpkg.__metadata__ import arch
from __metadata__ import arch
from slack_version import slack_ver
def mirrors(name, location):

View file

@ -2,11 +2,13 @@
# -*- coding: utf-8 -*-
import os
from slpkg.colors import colors
from slpkg.url_read import url_read
from slpkg.__metadata__ import pkg_path, slpkg_path
from slpkg.pkg.find import find_package
from slpkg.pkg.manager import pkg_upgrade
from colors import colors
from url_read import url_read
from __metadata__ import pkg_path, slpkg_path
from pkg.find import find_package
from pkg.manager import pkg_upgrade
from mirrors import mirrors
def patches():
@ -31,7 +33,8 @@ def patches():
if upgrade_all != []:
print ("\nThese packages need upgrading:\n")
for upgrade in upgrade_all:
print ("{0}[ upgrade ] --> {1}{2}".format(colors.GREEN, colors.ENDC, upgrade))
print ("{0}[ upgrade ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, upgrade))
for dwn in dwn_list:
if upgrade in dwn:
dwn_patches.append(dwn)
@ -41,17 +44,20 @@ def patches():
os.system("wget -N --directory-prefix={0}{1} {2}".format(
slpkg_path, 'patches/', dwn))
for pkg in upgrade_all:
print ("{0}[ upgrading ] --> {1}{2}".format(colors.GREEN, colors.ENDC, pkg))
print ("{0}[ upgrading ] --> {1}{2}".format(
colors.GREEN, colors.ENDC, pkg))
pkg_upgrade((slpkg_path + 'patches/' + pkg).split())
read = raw_input("Delete downloaded packages ? [Y/y] ")
read = raw_input("Remove the packages downloaded ? [Y/y] ")
if read == "Y" or read == "y":
for pkg in upgrade_all:
os.remove("{0}{1}{2}".format(slpkg_path, 'patches/', pkg))
if os.listdir(slpkg_path + 'patches/') == []:
print ("Done")
print ("Packages removed")
else:
print ("\nThe packages were kept in {0}{1}\n".format(slpkg_path, 'patches/'))
print ("\nThere are packages in direcrory {0}{1}\n".format(
slpkg_path, 'patches/'))
else:
print ("\nThe packages were kept in {0}{1}\n".format(slpkg_path, 'patches/'))
print ("\nThere are packages in directory {0}{1}\n".format(
slpkg_path, 'patches/'))
else:
print ("\nYour system is up to date\n")