updated for version 1.1.0

This commit is contained in:
dslackw 2014-05-13 03:15:53 +03:00
parent bc25dfaa6f
commit e4827d4ec3
6 changed files with 92 additions and 16 deletions

View file

@ -1,3 +1,9 @@
12-05-2013
Version 1.1.0
[Feature] - Added search from SBo and print link for download
12-05-2014 12-05-2014
Version 1.0.9 Version 1.0.9

View file

@ -1,6 +1,6 @@
Metadata-Version: 1.1 Metadata-Version: 1.1
Name: slpkg Name: slpkg
Version: 1.0.9 Version: 1.1.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

@ -60,6 +60,7 @@ Command Line Tool Usage
auto build package auto build package
-l all, sbo [all, sbo ...], --list all, sbo [all, sbo ...] -l all, sbo [all, sbo ...], --list all, sbo [all, sbo ...]
list of installed packages list of installed packages
-n , --network find from SBo repositority
-i , --install install binary package -i , --install install binary package
-u , --upgrade install-upgrade package with new -u , --upgrade install-upgrade package with new
-a , --reinstall reinstall the same package -a , --reinstall reinstall the same package
@ -72,6 +73,16 @@ Slpkg Examples
-------------- --------------
Find from www.slackbuilds.org the slackbuild by name:
.. code-block:: bash
$ slpkg -n termcolor
Searching for `termcolor` Please wait ...
The `termcolor` found in --> http://slackbuilds.org/repository/14.1/python/termcolor/
Auto build tool to build package: Auto build tool to build package:
.. code-block:: bash .. code-block:: bash

View file

@ -3,18 +3,27 @@
import os import os
import re
import sys import sys
import urllib2
import argparse import argparse
import subprocess import subprocess
__author__ = "dslackw" __author__ = "dslackw"
__version__ = "1.0.9" __version__ = "1.1.0"
__license__ = "GNU General Public License v3 (GPLv3)" __license__ = "GNU General Public License v3 (GPLv3)"
''' path file record ''' ''' path file record '''
__packages__ = "/var/log/packages/" packages = "/var/log/packages/"
''' SlackBuilds Repository '''
sbo_url = "http://slackbuilds.org/repository/14.1/"
repository = ("academic", "business", "games", "ham",
"misc", "office", "ruby", "accessibility",
"desktop", "gis", "haskell", "multimedia",
"perl", "system", "audio", "development",
"graphics", "lbraries", "network", "python")
''' print out colors class ''' ''' print out colors class '''
class colors: class colors:
@ -22,17 +31,37 @@ class colors:
GREEN = "\e[32m" GREEN = "\e[32m"
YELLOW = "\e[93m" YELLOW = "\e[93m"
CYAN = "\e[36m" CYAN = "\e[36m"
DEF_TEXT = "\e[0m"
ENDC = "\e[39m" ENDC = "\e[39m"
''' this fuction return the path of the package ''' ''' this fuction return the path of the package '''
def find_package(find_pkg): def find_package(find_pkg):
find_pkg = subprocess.check_output(["find " + __packages__ + " -name '{}*' 2> /dev/null".format(find_pkg)],shell=True) find_pkg = subprocess.check_output(["find " + packages + " -name '{}*' 2> /dev/null".format(find_pkg)],shell=True)
return find_pkg return find_pkg
''' search and found slackbuilds links from http://slackbuilds.org/ '''
def sbo_search_pkg(link):
i = 0
os.system("echo -e 'Searching for {} Please wait ...'".format("`" + link + "`"))
link = ">" + link + "<"
for i in repository:
sbo_url_sub = sbo_url + i + "/"
f = urllib2.urlopen(sbo_url_sub)
read_page = f.read()
find_sbo = re.findall(link, read_page)
if link in find_sbo:
link = sbo_url_sub + link + "/"
rmv = "><"
for i in rmv:
link = link.replace(i, "")
return link
''' main function ''' ''' main function '''
def main(): def main():
description = "Utility to help package management in Slackware" description = "Utility to help package management in Slackware"
@ -43,6 +72,8 @@ def main():
type=str, nargs=2, metavar=('script','source')) type=str, nargs=2, metavar=('script','source'))
parser.add_argument("-l", "--list", help="list of installed packages", parser.add_argument("-l", "--list", help="list of installed packages",
nargs="+", choices="all sbo".split(), metavar=('all, sbo')) nargs="+", choices="all sbo".split(), metavar=('all, sbo'))
parser.add_argument("-n", "--network", help="find from SBo repositority",
type=str, metavar=(''))
parser.add_argument("-i", "--install", help="install binary package", parser.add_argument("-i", "--install", help="install binary package",
type=str, metavar=('')) type=str, metavar=(''))
parser.add_argument("-u", "--upgrade", help="install-upgrade package with new", parser.add_argument("-u", "--upgrade", help="install-upgrade package with new",
@ -82,10 +113,23 @@ def main():
''' view list of installed packages ''' ''' view list of installed packages '''
if args.list: if args.list:
if "all" in args.list: if "all" in args.list:
os.system("ls " + __packages__ + "* | more") os.system("ls " + packages + "* | more")
if "sbo" in args.list: if "sbo" in args.list:
os.system("ls " + __packages__ + "* | grep 'SBo' | more") os.system("ls " + packages + "* | grep 'SBo' | more")
if args.network:
find_sbo_url = sbo_search_pkg(args.network)
if find_sbo_url == None:
print
os.system("echo -e '{}The {} not found{}'".format(colors.RED,
colors.CYAN + '`' + args.network + '`' + colors.RED, colors.ENDC))
print
else:
print
os.system("echo -e '{}The {} found in --> {}'".format(colors.GREEN,
colors.CYAN + '`' + args.network + '`' + colors.GREEN, colors.ENDC + find_sbo_url))
print
''' install binary package ''' ''' install binary package '''
if args.install: if args.install:
@ -102,7 +146,8 @@ def main():
''' uninstall package ''' ''' uninstall package '''
if args.remove: if args.remove:
if find_package(args.remove) == "": if find_package(args.remove) == "":
os.system("echo -e '{}The package is not found{}'".format(colors.RED, colors.ENDC)) os.system("echo -e '{}The package {} is not found{}'".format(colors.RED,
colors.CYAN + '`' + args.remove + '`' + colors.RED, colors.ENDC))
else: else:
os.system("echo -e '{}!!! WARNING !!!{}'".format(colors.YELLOW, colors.ENDC)) os.system("echo -e '{}!!! WARNING !!!{}'".format(colors.YELLOW, colors.ENDC))
remove_pkg = raw_input("Are you sure to remove this package [y/n] ") remove_pkg = raw_input("Are you sure to remove this package [y/n] ")
@ -127,7 +172,7 @@ def main():
os.system("cat {}".format(find_package(args.display))) os.system("cat {}".format(find_package(args.display)))
''' fix null arguments ''' ''' fix null arguments '''
if not any([args.verbose, args.slackbuild, args.install, args.upgrade, args.reinstall, if not any([args.verbose, args.slackbuild, args.network, args.install, args.upgrade, args.reinstall,
args.remove, args.list, args.find, args.display]): args.remove, args.list, args.find, args.display]):
os.system("slpkg -h") os.system("slpkg -h")

View file

@ -15,7 +15,8 @@
.SH NAME .SH NAME
slpkg - Utility to help package management in Slackware slpkg - Utility to help package management in Slackware
.SH SYNOPSIS .SH SYNOPSIS
\fBslpkg\fP [\fIoptions\fP] \fB[-h]\fP \fB[-v]\fP \fB[-u UPGRADE]\fP \fB[-a REINSTALL]\fP \fB[-r REMOVE]\fP \fB[-l]\fP \fB[-f FIND]\fP \fB[-d DISPLAY]\fP <\fIcommand-arguments\fP>... \fBslpkg\fP \fB[-h]\fP \fB[-v]\fP \fB[-s script source]\fP \fB[-l all, sbo [all, sbo ...]]\fP
\fB[-n]\fP \fB[-i]\fP \fB[-u]\fP \fB[-a]\fP \fB[-r]\fP \fB[-f]\fP \fB[-d]\fP
.SH DESCRIPTION .SH DESCRIPTION
\fBslpkg\fP is a terminal tool written in Python that allows the build, install, upgrade, \fBslpkg\fP is a terminal tool written in Python that allows the build, install, upgrade,
remove, find and view Slackware packages contents. remove, find and view Slackware packages contents.
@ -28,6 +29,7 @@ It's a quick and easy way to manage your packages in slackware to a command.
\fB auto build package\fP \fB auto build package\fP
\fB-l all, sbo [all, sbo ...], --list all, sbo [all, sbo ...]\fP \fB-l all, sbo [all, sbo ...], --list all, sbo [all, sbo ...]\fP
\fB list of installed packages\fP \fB list of installed packages\fP
\fB-n , --network find from SBo repositority\fP
\fB-i , --install install binary package\fP \fB-i , --install install binary package\fP
\fB-u , --upgrade install-upgrade package with new\fP \fB-u , --upgrade install-upgrade package with new\fP
\fB-a , --reinstall reinstall the same package\fP \fB-a , --reinstall reinstall the same package\fP
@ -51,8 +53,14 @@ Support .tar.gz and .tar.bz2 slackbuilds archives.
.PP .PP
Two display options list, one for all packages and another Two display options list, one for all packages and another
only for packages SBo. only for packages SBo.
.SS -n , --network find from SBo repositority
\fBslpkg\fP \fB-n\fP <\fIname\fP>
.PP
With this method you can find the SBo script that interests you through
the network. (www.slackbuilds.org)
.SS -i , --install install binary package .SS -i , --install install binary package
\fBslpkg\fP \fB-i\fP <\fIpackage.tgz or .txz\fP> \fBslpkg\fP \fB-i\fP <\fIpackage.tgz or .txz\fP>
.PP
Installs single binary packages designed for use with the Installs single binary packages designed for use with the
Slackware Linux distribution into your system. Slackware Linux distribution into your system.
.SS -u , --upgrade install-upgrade package with new .SS -u , --upgrade install-upgrade package with new
@ -92,6 +100,13 @@ command.
For example: For example:
\fBslpkg \-\-help\fP - display help for slpkg \fBslpkg \-\-help\fP - display help for slpkg
.SH EXAMPLES .SH EXAMPLES
$ \fBslpkg -n termcolor\fP
Searching for termcolor Please wait ...
The `termcolor` found in --> http://slackbuilds.org/repository/14.1/python/termcolor/
Etc. download from www.slackbuilds.org the package termcolor Etc. download from www.slackbuilds.org the package termcolor
http://slackbuilds.org/repository/14.1/python/termcolor/ http://slackbuilds.org/repository/14.1/python/termcolor/
@ -102,7 +117,6 @@ $ \fBslpkg -s termcolor.tar.gz termcolor-1.1.0.tar.gz\fP
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.
$ \fBslpkg -u termcolor-1.1.0-x86_64-1_SBo.tgz\fP $ \fBslpkg -u termcolor-1.1.0-x86_64-1_SBo.tgz\fP
Installing new package ./termcolor-1.1.0-x86_64-1_SBo.tgz Installing new package ./termcolor-1.1.0-x86_64-1_SBo.tgz

View file

@ -7,7 +7,7 @@ from distutils.core import setup
setup( setup(
name = 'slpkg', name = 'slpkg',
version = "1.0.9", version = "1.1.0",
description = "Python tool to manage Slackware packages", description = "Python tool to manage Slackware packages",
keywords = ["slackware", "slpkg", "upgrade", "install", "remove", keywords = ["slackware", "slpkg", "upgrade", "install", "remove",
"view", "slackpkg", "tool"], "view", "slackpkg", "tool"],