updated for version 2.0.4

This commit is contained in:
Dimitris Zlatanidis 2014-11-07 07:05:23 +02:00
parent 400f20bbca
commit 57b344a208
35 changed files with 1385 additions and 421 deletions

View file

@ -1,3 +1,11 @@
Version 2.0.4
7-11-2014
[Feature] - Add Robby Workman, Alien Bob (Eric Hameleers) and
slacky.eu repositories.
[Updated] - Fix remove list reference.
Version 2.0.3 Version 2.0.3
29-10-2014 29-10-2014

View file

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

View file

@ -11,9 +11,9 @@
Latest Release: Latest Release:
- Version: 2.0.3 - Version: 2.0.4
- `Package <https://sourceforge.net/projects/slpkg/files/slpkg/binary/>`_ - `Package <https://sourceforge.net/projects/slpkg/files/slpkg/binary/>`_
- `Source <https://github.com/dslackw/slpkg/archive/v2.0.3.tar.gz>`_ - `Source <https://github.com/dslackw/slpkg/archive/v2.0.4.tar.gz>`_
- `CHANGELOG <https://github.com/dslackw/slpkg/blob/master/CHANGELOG>`_ - `CHANGELOG <https://github.com/dslackw/slpkg/blob/master/CHANGELOG>`_
.. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/logo.png .. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/logo.png
@ -29,10 +29,13 @@ packages.
Slpkg is `Open Source <http://en.wikipedia.org/wiki/Open_source>`_ software written in Slpkg is `Open Source <http://en.wikipedia.org/wiki/Open_source>`_ software written in
Python language. It's use is for managing packages in Slackware linux distribution. Python language. It's use is for managing packages in Slackware linux distribution.
Species are adapted to two repositories: Supported Repositories:
- SBo - `slackbuilds.org <http://slackbuilds.org/>`_ - SBo - `slackbuilds.org <http://slackbuilds.org/>`_
- Slack - `slackware.com <http://www.slackware.com/>`_ - Slack - `slackware.com <http://www.slackware.com/>`_
- Alien - `alien bob <http://www.slackware.com/~alien/slackbuilds/>`_
- Slacky - `slacky.eu <http://repository.slacky.eu/>`_
- Robby's - `rworkman's <http://rlworkman.net/pkgs/>`_
Slpkg works in accordance with the standards of the organization slackbuilds.org Slpkg works in accordance with the standards of the organization slackbuilds.org
to builds packages. Also uses the Slackware linux instructions for installation, to builds packages. Also uses the Slackware linux instructions for installation,
@ -65,9 +68,8 @@ Features
-------- --------
- Build third party packages from source with all dependencies - Build third party packages from source with all dependencies
- Install packages through from official `Slackware <http://www.slackware.com/>`_ mirrors - Grabs packages from repositories in real time
- Find and Download packages from `slackbuilds.org <http://slackbuilds.org/>`_ - Find and Download packages from repositories
- 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 - Remove packages with all dependencies
@ -100,8 +102,8 @@ Untar the archive and run install.sh script:
.. code-block:: bash .. code-block:: bash
$ tar xvf slpkg-2.0.3.tar.gz $ tar xvf slpkg-2.0.4.tar.gz
$ cd slpkg-2.0.3 $ cd slpkg-2.0.4
$ ./install.sh $ ./install.sh
Using `pip <https://pip.pypa.io/en/latest/>`_ : Using `pip <https://pip.pypa.io/en/latest/>`_ :
@ -132,7 +134,7 @@ Command Line Tool Usage
-b, --list, [package...] --add, --remove add, remove packages in blacklist -b, --list, [package...] --add, --remove add, remove packages in blacklist
-q, --list, [package...] --add, --remove add, remove packages in queue -q, --list, [package...] --add, --remove add, remove packages in queue
--build, --install, --build-install build or install from queue --build, --install, --build-install build or install from queue
-l, all, sbo, slack, noarch list of installed packages -l, <repository>, all, noarch list of installed packages
-c, <repository> --upgrade --current check for updated packages -c, <repository> --upgrade --current check for updated packages
-s, <repository> <package> --current download, build & install -s, <repository> <package> --current download, build & install
-f, <package> find installed packages -f, <package> find installed packages
@ -143,10 +145,15 @@ Command Line Tool Usage
-o, [package...] reinstall binary packages -o, [package...] reinstall binary packages
-r, [package...] remove binary packages -r, [package...] remove binary packages
-d, [package...] display the contents -d, [package...] display the contents
Repositories:
SlackBuilds = sbo
Slackware = slack '--current'
Note: '-q' options is working only for SBo repository
Repositories:
Slackware = slack '--current'
Alien = alien '--current'
SlackBuilds = sbo
Slacky = slacky
Robby's = rlw
Slpkg Examples Slpkg Examples
-------------- --------------
@ -378,7 +385,7 @@ Auto tool to build package:
Searching for symbolic links: Searching for symbolic links:
No symbolic links were found, so we won't make an installation script. No symbolic links were found, so we wont make an installation script.
You can make your own later in ./install/doinst.sh and rebuild the You can make your own later in ./install/doinst.sh and rebuild the
package if you like. package if you like.

View file

@ -21,7 +21,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PRGNAM=slpkg PRGNAM=slpkg
VERSION=${VERSION:-2.0.3} VERSION=${VERSION:-2.0.4}
TAG=${TAG:-_dsw} TAG=${TAG:-_dsw}
cd .. cd ..
@ -35,18 +35,21 @@ if [ -f $PRGNAM-$VERSION.zip ]; then
chmod +x $PRGNAM.SlackBuild chmod +x $PRGNAM.SlackBuild
./$PRGNAM.SlackBuild ./$PRGNAM.SlackBuild
rm $PRGNAM-$VERSION.zip rm $PRGNAM-$VERSION.zip
elif [ -f v$VERSION.zip ]; then elif [ -f v$VERSION.zip ]; then
cp v$VERSION.zip $PRGNAM-$VERSION/slackbuild cp v$VERSION.zip $PRGNAM-$VERSION/slackbuild
cd $PRGNAM-$VERSION/slackbuild cd $PRGNAM-$VERSION/slackbuild
chmod +x $PRGNAM.SlackBuild chmod +x $PRGNAM.SlackBuild
./$PRGNAM.SlackBuild ./$PRGNAM.SlackBuild
rm v$VERSION.zip rm v$VERSION.zip
elif [ -f $PRGNAM-$VERSION.tar.gz ]; then elif [ -f $PRGNAM-$VERSION.tar.gz ]; then
cp $PRGNAM-$VERSION.tar.gz $PRGNAM-$VERSION/slackbuild cp $PRGNAM-$VERSION.tar.gz $PRGNAM-$VERSION/slackbuild
cd $PRGNAM-$VERSION/slackbuild cd $PRGNAM-$VERSION/slackbuild
chmod +x $PRGNAM.SlackBuild chmod +x $PRGNAM.SlackBuild
./$PRGNAM.SlackBuild ./$PRGNAM.SlackBuild
rm $PRGNAM-$VERSION.tar.gz rm $PRGNAM-$VERSION.tar.gz
else else
cp v$VERSION.tar.gz $PRGNAM-$VERSION/slackbuild cp v$VERSION.tar.gz $PRGNAM-$VERSION/slackbuild
cd $PRGNAM-$VERSION/slackbuild cd $PRGNAM-$VERSION/slackbuild

View file

@ -39,7 +39,7 @@ Optional arguments:
-b, --list, [package...] --add, --remove add, remove packages in blacklist -b, --list, [package...] --add, --remove add, remove packages in blacklist
-q, --list, [package...] --add, --remove add, remove packages in queue -q, --list, [package...] --add, --remove add, remove packages in queue
--build, --install, --build-install build or install from queue --build, --install, --build-install build or install from queue
-l, all, sbo, slack, noarch list of installed packages -l, <repository>, all, noarch list of installed packages
-c, <repository> --upgrade --current check for updated packages -c, <repository> --upgrade --current check for updated packages
-s, <repository> <package> --current download, build & install -s, <repository> <package> --current download, build & install
-f, <package> find installed packages -f, <package> find installed packages
@ -51,9 +51,14 @@ Optional arguments:
-r, [package...] remove binary packages -r, [package...] remove binary packages
-d, [package...] display the contents -d, [package...] display the contents
Note: '-q' options is working only for SBo repository
Repositories: Repositories:
Slackware = slack '--current'
Alien = alien '--current'
SlackBuilds = sbo SlackBuilds = sbo
Slackware = slack '--current'\fP Slacky = slacky
Robby's = rlw\fP
.SH GLOBAL OPTIONS .SH GLOBAL OPTIONS
.TP .TP

View file

@ -35,7 +35,8 @@ except ImportError:
setup( setup(
name="slpkg", name="slpkg",
packages=["slpkg", "slpkg/sbo", "slpkg/pkg", "slpkg/slack"], packages=["slpkg", "slpkg/sbo", "slpkg/pkg", "slpkg/slack",
"slpkg/others"],
scripts=["bin/slpkg"], scripts=["bin/slpkg"],
version=__version__, version=__version__,
description="Python tool to manage Slackware packages", description="Python tool to manage Slackware packages",

View file

@ -1,9 +1,12 @@
Slpkg is Open Source software written in Python language. Slpkg is Open Source software written in Python language.
It's use is for managing packages in Slackware linux It's use is for managing packages in Slackware linux
distribution. Species are adapted to two repositories: distribution. Supported Repositories:
- SBo - slackbuilds.org - SBo - slackbuilds.org
- Slack - slackware.com - Slack - slackware.com
- Alien - alien bob
- Slacky - slacky.eu
- Robby's - rworkman's
Slpkg works in accordance with the standards of the organization Slpkg works in accordance with the standards of the organization
slackbuilds.org to builds packages. Also uses the Slackware linux slackbuilds.org to builds packages. Also uses the Slackware linux

View file

@ -23,7 +23,7 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PRGNAM=slpkg PRGNAM=slpkg
VERSION=${VERSION:-2.0.3} VERSION=${VERSION:-2.0.4}
BUILD=${BUILD:-1} BUILD=${BUILD:-1}
TAG=${TAG:-_dsw} TAG=${TAG:-_dsw}

View file

@ -1,7 +1,7 @@
PRGNAM="slpkg" PRGNAM="slpkg"
VERSION="2.0.3" VERSION="2.0.4"
HOMEPAGE="https://github.com/dslackw/slpkg" HOMEPAGE="https://github.com/dslackw/slpkg"
DOWNLOAD="https://github.com/dslackw/slpkg/archive/v2.0.3.tar.gz" DOWNLOAD="https://github.com/dslackw/slpkg/archive/v2.0.4.tar.gz"
MD5SUM="" MD5SUM=""
DOWNLOAD_x86_64="" DOWNLOAD_x86_64=""
MD5SUM_x86_64="" MD5SUM_x86_64=""

View file

@ -25,7 +25,7 @@ import os
__all__ = "slpkg" __all__ = "slpkg"
__author__ = "dslackw" __author__ = "dslackw"
__version_info__ = (2, 0, 3) __version_info__ = (2, 0, 4)
__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"

View file

@ -40,7 +40,7 @@ def options():
"queue", "queue",
" --build, --install, --build-install build or install from " + " --build, --install, --build-install build or install from " +
"queue", "queue",
" -l, all, sbo, slack, noarch list of installed " + " -l, <repository>, all, noarch list of installed " +
"packages", "packages",
" -c, <repository> --upgrade --current check for updated " + " -c, <repository> --upgrade --current check for updated " +
"packages", "packages",
@ -54,9 +54,13 @@ def options():
" -o, [package...] reinstall binary packages", " -o, [package...] reinstall binary packages",
" -r, [package...] remove binary packages", " -r, [package...] remove binary packages",
" -d, [package...] display the contents\n", " -d, [package...] display the contents\n",
"Note: '-q' options is working only for SBo repository\n",
"Repositories:", "Repositories:",
" Slackware = slack '--current'",
" Alien = alien '--current'",
" SlackBuilds = sbo", " SlackBuilds = sbo",
" Slackware = slack '--current'\n", " Slacky = slacky",
" Robby's = rlw\n"
] ]
for opt in arguments: for opt in arguments:
print(opt) print(opt)

View file

@ -25,81 +25,143 @@ import os
import sys import sys
from url_read import URL from url_read import URL
from repositories import Repo
from file_size import FileSize from file_size import FileSize
from __metadata__ import log_path, lib_path from __metadata__ import log_path, lib_path
from slack.slack_version import slack_ver from slack.slack_version import slack_ver
def initialization(): class Initialization(object):
'''
Slpkg initialization, creating directories and SLACKBUILDS.TXT in def __init__(self):
/var/lib/slpkg/sbo_repo/ and ChangeLog.txt in /var/log/slpkg/ from if not os.path.exists(log_path):
slackbuilds.org. os.mkdir(log_path)
''' if not os.path.exists(lib_path):
sbo_log = log_path + "sbo/" os.mkdir(lib_path)
sbo_lib = lib_path + "sbo_repo/"
pkg_que = lib_path + "queue" def sbo(self):
if not os.path.exists(log_path): '''
os.mkdir(log_path) Creating sbo local library
if not os.path.exists(lib_path): '''
os.mkdir(lib_path) repo = Repo().sbo()
if not os.path.exists(sbo_log): log = log_path + "sbo/"
os.mkdir(sbo_log) lib = lib_path + "sbo_repo/"
if not os.path.exists(sbo_lib): lib_file = "SLACKBUILDS.TXT"
os.mkdir(sbo_lib) log_file = "ChangeLog.txt"
if not os.path.exists(pkg_que): if not os.path.exists(log):
os.mkdir(pkg_que) os.mkdir(log)
sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(slack_ver())) if not os.path.exists(lib):
# Read SLACKBUILDS.TXT from slackbuilds.org and write in os.mkdir(lib)
# /var/lib/slpkg/sbo_repo directory if not exist packages_txt = "{0}{1}/{2}".format(repo, slack_ver(), lib_file)
if not os.path.isfile(sbo_lib + "SLACKBUILDS.TXT"): changelog_txt = "{0}/{1}/{2}".format(repo, slack_ver(), log_file)
print("\nslpkg ...initialization") self.write(lib, lib_file, packages_txt)
sys.stdout.write("SLACKBUILDS.TXT read ...") self.write(log, log_file, changelog_txt)
sys.stdout.flush() self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt)
SLACKBUILDS_TXT = URL((
"http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format( def rlw(self):
slack_ver()))).reading() '''
sys.stdout.write("Done\n") Creating rlw local library
with open("{0}SLACKBUILDS.TXT".format(sbo_lib), "w") as sbo: '''
sbo.write(SLACKBUILDS_TXT) repo = Repo().rlw()
sbo.close() log = log_path + "rlw/"
print("File SLACKBUILDS.TXT created in {0}".format(sbo_lib)) lib = lib_path + "rlw_repo/"
# Read ChangeLog.txt from slackbuilds.org and write in /var/log/slpkg/sbo/ lib_file = "PACKAGES.TXT"
# directory if not exist log_file = "ChangeLog.txt"
if not os.path.isfile(sbo_log + "ChangeLog.txt"): if not os.path.exists(log):
print("\nslpkg initialization") os.mkdir(log)
sys.stdout.write("ChangeLog.txt read ...") if not os.path.exists(lib):
sys.stdout.flush() os.mkdir(lib)
ChangeLog_txt = URL(( packages_txt = "{0}{1}/{2}".format(repo, slack_ver(), lib_file)
"http://slackbuilds.org/slackbuilds/{0}/ChangeLog.txt".format( changelog_txt = "{0}{1}/{2}".format(repo, slack_ver(), log_file)
slack_ver()))).reading() self.write(lib, lib_file, packages_txt)
sys.stdout.write("Done\n") self.write(log, log_file, changelog_txt)
with open("{0}ChangeLog.txt".format(sbo_log), "w") as log: self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt)
log.write(ChangeLog_txt)
log.close() def alien(self):
print("File ChangeLog.txt created in {0}".format(sbo_log)) '''
# We take the size of ChangeLog.txt from the server and locally Creating alien local library
server = FileSize(sbo_url + "ChangeLog.txt").server() '''
local = FileSize(sbo_log + "ChangeLog.txt").local() repo = Repo().alien()
# If the two files differ in size delete and replaced with new log = log_path + "alien/"
if server != local: lib = lib_path + "alien_repo/"
os.remove("{0}{1}".format(sbo_lib, "SLACKBUILDS.TXT")) lib_file = "PACKAGES.TXT"
os.remove("{0}{1}".format(sbo_log, "ChangeLog.txt")) log_file = "ChangeLog.txt"
print("\nNEWS in ChangeLog.txt") if not os.path.exists(log):
print("slpkg ...initialization") os.mkdir(log)
sys.stdout.write("Files re-created ...") if not os.path.exists(lib):
sys.stdout.flush() os.mkdir(lib)
SLACKBUILDS_TXT = URL(( packages_txt = "{0}{1}".format(repo, lib_file)
"http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format( changelog_txt = "{0}{1}".format(repo, log_file)
slack_ver()))).reading() self.write(lib, lib_file, packages_txt)
ChangeLog_txt = URL(( self.write(log, log_file, changelog_txt)
"http://slackbuilds.org/slackbuilds/{0}/ChangeLog.txt".format( self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt)
slack_ver()))).reading()
with open("{0}SLACKBUILDS.TXT".format(sbo_lib), "w") as sbo: def slacky(self):
sbo.write(SLACKBUILDS_TXT) '''
sbo.close() Creating alien local library
with open("{0}ChangeLog.txt".format(sbo_log), "w") as log: '''
log.write(ChangeLog_txt) ar = ""
log.close() arch = os.uname()[4]
sys.stdout.write("Done\n") repo = Repo().slacky()
log = log_path + "slacky/"
lib = lib_path + "slacky_repo/"
lib_file = "PACKAGES.TXT"
log_file = "ChangeLog.txt"
if not os.path.exists(log):
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
if arch == "x86_64":
ar = "64"
packages_txt = "{0}slackware{1}-{2}/{3}".format(repo, ar, slack_ver(),
lib_file)
changelog_txt = "{0}slackware{1}-{2}/{3}".format(repo, ar, slack_ver(),
log_file)
self.write(lib, lib_file, packages_txt)
self.write(log, log_file, changelog_txt)
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt)
@staticmethod
def write(path, files, file_url):
'''
Write files in /var/lib/slpkg/?_repo directory
'''
if not os.path.isfile(path + files):
print("\nslpkg ...initialization")
sys.stdout.write(files + " read ...")
sys.stdout.flush()
PACKAGES_TXT = URL(file_url).reading()
sys.stdout.write("Done\n")
with open("{0}{1}".format(path, files), "w") as f:
f.write(PACKAGES_TXT)
f.close()
print("File {0} created in {1}".format(files, path))
@staticmethod
def remote(*args):
'''
args[0]=log, args[1]=log_file, arg[2]=changelog_txt
args[3]=lib, args[4]=lib_file, arg[5]=packages_txt
If the two files differ in size delete and replaced with new.
We take the size of ChangeLog.txt from the server and locally
'''
server = FileSize(args[2]).server()
local = FileSize(args[0] + args[1]).local()
if server != local:
os.remove("{0}{1}".format(args[3], args[4]))
os.remove("{0}{1}".format(args[0], args[1]))
print("\nNEWS in " + args[1])
print("slpkg ...initialization")
sys.stdout.write("Files re-created ...")
sys.stdout.flush()
PACKAGES_TXT = URL(args[5]).reading()
CHANGELOG_TXT = URL(args[2]).reading()
with open("{0}{1}".format(args[3], args[4]), "w") as f:
f.write(PACKAGES_TXT)
f.close()
with open("{0}{1}".format(args[0], args[1]), "w") as f:
f.write(CHANGELOG_TXT)
f.close()
sys.stdout.write("Done\n")

View file

@ -41,15 +41,16 @@ from sbo.slackbuild import SBoInstall
from slack.install import Slack from slack.install import Slack
from slack.patches import Patches from slack.patches import Patches
from others.check import OthersUpgrade
from others.install import OthersInstall
def main(): def main():
# root privileges required # root privileges required
s_user(getpass.getuser()) s_user(getpass.getuser())
args = sys.argv args = sys.argv
args.pop(0) args.pop(0)
repository = ["sbo", "slack"] repository = ["sbo", "slack", "rlw", "alien", "slacky"]
blacklist = BlackList() blacklist = BlackList()
queue = QueuePkgs() queue = QueuePkgs()
@ -64,8 +65,8 @@ def main():
elif len(args) == 3 and args[0] == "-a": elif len(args) == 3 and args[0] == "-a":
BuildPackage(args[1], args[2:], path).build() BuildPackage(args[1], args[2:], path).build()
elif len(args) == 2 and args[0] == "-l": elif len(args) == 2 and args[0] == "-l":
sbo_list = ["all", "sbo", "slack", "noarch"] pkg_list = ["all", "noarch"] + repository
if args[1] in sbo_list: if args[1] in pkg_list:
PackageManager(None).list(args[1]) PackageManager(None).list(args[1])
else: else:
usage() usage()
@ -75,12 +76,19 @@ def main():
elif args[1] == repository[1] and args[2] == "--upgrade": elif args[1] == repository[1] and args[2] == "--upgrade":
version = "stable" version = "stable"
Patches(version).start() Patches(version).start()
elif args[1] == repository[2] and args[2] == "--upgrade":
OthersUpgrade(repository[2], "").start()
elif args[1] == repository[3] and args[2] == "--upgrade":
OthersUpgrade(repository[3], "").start()
elif args[1] == repository[4] and args[2] == "--upgrade":
OthersUpgrade(repository[4], "").start()
else: else:
usage() usage()
elif len(args) == 4 and args[0] == "-c": elif len(args) == 4 and args[0] == "-c":
if args[1] == repository[1] and args[3] == "--current": if args[1] == repository[1] and args[3] == "--current":
version = "current" Patches("current").start()
Patches(version).start() elif args[1] == repository[3] and args[3] == "--current":
OthersUpgrade(repository[3], "current").start()
else: else:
usage() usage()
elif len(args) == 3 and args[0] == "-s": elif len(args) == 3 and args[0] == "-s":
@ -88,11 +96,19 @@ def main():
SBoInstall(args[2]).start() SBoInstall(args[2]).start()
elif args[1] == repository[1]: elif args[1] == repository[1]:
Slack(args[2], "stable").start() Slack(args[2], "stable").start()
elif args[1] == repository[2]:
OthersInstall(args[2], repository[2], "").start()
elif args[1] == repository[3]:
OthersInstall(args[2], repository[3], "").start()
elif args[1] == repository[4]:
OthersInstall(args[2], repository[4], "").start()
else: else:
usage() usage()
elif len(args) == 4 and args[0] == "-s": elif len(args) == 4 and args[0] == "-s":
if args[1] == repository[1] and args[3] == "--current": if args[1] == repository[1] and args[3] == "--current":
Slack(args[2], "current").start() Slack(args[2], "current").start()
elif args[1] == repository[3] and args[3] == "--current":
OthersInstall(args[2], repository[3], "current").start()
else: else:
usage() usage()
elif len(args) == 2 and args[0] == "-t": elif len(args) == 2 and args[0] == "-t":

1
slpkg/others/__init__.py Normal file
View file

@ -0,0 +1 @@
# [ others ] directory

218
slpkg/others/check.py Executable file
View file

@ -0,0 +1,218 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# check.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 os
import sys
from slpkg.sizes import units
from slpkg.repositories import Repo
from slpkg.messages import template
from slpkg.blacklist import BlackList
from slpkg.init import Initialization
from slpkg.splitting import split_package
from slpkg.colors import YELLOW, GREY, ENDC
from slpkg.__metadata__ import slpkg_tmp, pkg_path, lib_path
from slpkg.pkg.manager import PackageManager
from slpkg.slack.remove import delete
from slpkg.slack.slack_version import slack_ver
from greps import repo_data
from download import packages_dwn
class OthersUpgrade(object):
def __init__(self, repo, version):
self.repo = repo
self.version = version
self.tmp_path = slpkg_tmp + "packages/"
self.repo_init()
repos = Repo()
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
sys.stdout.flush()
self.step = 700
repos = Repo()
if self.repo == "rlw":
lib = lib_path + "rlw_repo/PACKAGES.TXT"
self.mirror = "{0}{1}/".format(repos.rlw(), slack_ver())
elif self.repo == "alien":
lib = lib_path + "alien_repo/PACKAGES.TXT"
self.mirror = repos.alien()
self.step = self.step * 2
elif self.repo == "slacky":
lib = lib_path + "slacky_repo/PACKAGES.TXT"
arch = ""
if os.uname()[4] == "x86_64":
arch = "64"
self.mirror = "{0}slackware{1}-{2}/".format(repos.slacky(), arch,
slack_ver())
self.step = self.step * 2
f = open(lib, "r")
self.PACKAGES_TXT = f.read()
f.close()
def repo_init(self):
'''
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,
'slacky': Initialization().slacky
}
repository[self.repo]()
def start(self):
'''
Install packages from official Slackware distribution
'''
try:
dwn_links, upgrade_all, comp_sum, uncomp_sum = self.store()
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
print # new line at start
if upgrade_all:
template(78)
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
"| Package", " " * 17,
"Version", " " * 12,
"Arch", " " * 4,
"Build", " " * 2,
"Repos", " " * 10,
"Size"))
template(78)
print("Upgrading:")
views(upgrade_all, comp_sum, self.repo)
unit, size = units(comp_sum, uncomp_sum)
msg = msgs(upgrade_all)
print("\nInstalling summary")
print("=" * 79)
print("{0}Total {1} {2} will be upgraded.".format(
GREY, len(upgrade_all), msg))
print("Need to get {0} {1} of archives.".format(size[0],
unit[0]))
print("After this process, {0} {1} of additional disk "
"space will be used.{2}".format(size[1], unit[1], ENDC))
read = raw_input("\nWould you like to upgrade [Y/n]? ")
if read in ['Y', 'y']:
upgrade_all.reverse()
packages_dwn(self.tmp_path, dwn_links)
upgrade(upgrade_all)
delete(self.tmp_path, upgrade_all)
else:
print("There are no packages for upgrade\n")
except KeyboardInterrupt:
print # new line at exit
sys.exit()
def store(self):
'''
Store and return packages for install
'''
dwn, install, comp_sum, uncomp_sum = ([] for i in range(4))
black = BlackList().packages()
# name = data[0]
# location = data[1]
# size = data[2]
# unsize = data[3]
installed = self.installed()
data = repo_data(self.PACKAGES_TXT, self.step, self.repo, self.version)
for pkg in installed:
for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
data[3]):
inst_pkg = split_package(pkg)
repo_pkg = split_package(name[:-4])
if repo_pkg[0] == inst_pkg[0] and name[:-4] > pkg \
and inst_pkg[0] not in black:
# store downloads packages by repo
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
install.append(name)
comp_sum.append(comp)
uncomp_sum.append(uncomp)
return [dwn, install, comp_sum, uncomp_sum]
def installed(self):
'''
Return all installed packages by repository
'''
packages = []
repository = {
'rlw': '_rlw',
'alien': 'alien',
'slacky': 'sl'
}
repo = repository[self.repo]
for pkg in os.listdir(pkg_path):
if pkg.endswith(repo):
packages.append(pkg)
return packages
def views(upgrade_all, comp_sum, repository):
'''
Views packages
'''
upg_sum = 0
# fix repositories align
align = {
'rlw': ' ' * 3,
'alien': ' ',
'slacky': ''
}
repository += align[repository]
for pkg, comp in zip(upgrade_all, comp_sum):
pkg_split = split_package(pkg[:-4])
upg_sum += 1
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11:>11}{12}".format(
YELLOW, pkg_split[0], ENDC,
" " * (25-len(pkg_split[0])), pkg_split[1],
" " * (19-len(pkg_split[1])), pkg_split[2],
" " * (8-len(pkg_split[2])), pkg_split[3],
" " * (7-len(pkg_split[3])), repository,
comp, " K"))
return upg_sum
def msgs(upgrade_all):
'''
Print singular plural
'''
msg_pkg = "package"
if len(upgrade_all) > 1:
msg_pkg = msg_pkg + "s"
return msg_pkg
def upgrade(upgrade_all):
'''
Install or upgrade packages
'''
for pkg in upgrade_all:
print("[ {0}upgrading{1} ] --> {2}".format(YELLOW, ENDC, pkg[:-4]))
PackageManager(pkg).upgrade()

53
slpkg/others/dependency.py Executable file
View file

@ -0,0 +1,53 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# dependency.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 sys
from slpkg.colors import GREY, ENDC
from greps import repo_requires
dep_results = []
def dependencies_pkg(name, repo):
'''
Build all dependencies of a package
'''
try:
dependencies = []
requires = repo_requires(name, repo)
if requires:
for req in requires:
if req:
dependencies.append(req)
if dependencies:
dep_results.append(dependencies)
for dep in dependencies:
sys.stdout.write("{0}.{1}".format(GREY, ENDC))
sys.stdout.flush()
dependencies_pkg(dep, repo)
return dep_results
except KeyboardInterrupt:
print # new line at exit
sys.exit()

33
slpkg/others/download.py Executable file
View file

@ -0,0 +1,33 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# downloads.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/>.
from slpkg.downloader import Download
def packages_dwn(path, links):
'''
Download patches
'''
for dwn in links:
Download(path, dwn).start()
Download(path, dwn + ".asc").start()

123
slpkg/others/greps.py Executable file
View file

@ -0,0 +1,123 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# greps.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 os
from slpkg.toolbar import status
from slpkg.__metadata__ import lib_path
from slpkg.splitting import split_package
from slpkg.slack.slack_version import slack_ver
def repo_data(PACKAGES_TXT, step, repo, version):
'''
Grap data packages
'''
(name, location, size, unsize,
rname, rlocation, rsize, runsize) = ([] for i in range(8))
index, toolbar_width = 0, 700
for line in PACKAGES_TXT.splitlines():
index += 1
toolbar_width = status(index, toolbar_width, step)
if line.startswith("PACKAGE NAME"):
name.append(line[15:].strip())
if line.startswith("PACKAGE LOCATION"):
location.append(line[21:].strip())
if line.startswith("PACKAGE SIZE (compressed): "):
size.append(line[28:-2].strip())
if line.startswith("PACKAGE SIZE (uncompressed): "):
unsize.append(line[30:-2].strip())
if repo == "rlw":
(rname,
rlocation,
rsize,
runsize
) = rlw_filter(name, location, size, unsize)
elif repo == "alien":
(rname,
rlocation,
rsize,
runsize
) = alien_filter(name, location, size, unsize, version)
elif repo == "slacky":
rname, rlocation, rsize, runsize = name, location, size, unsize
return [rname, rlocation, rsize, runsize]
def rlw_filter(name, location, size, unsize):
'''
Filter rlw repository data
'''
arch = os.uname()[4]
if arch.startswith("i") and arch.endswith("86"):
arch = "i486"
(fname, flocation, fsize, funsize) = ([] for i in range(4))
for n, l, s, u in zip(name, location, size, unsize):
loc = l.split("/")
if arch == loc[-1]:
fname.append(n)
flocation.append(l)
fsize.append(s)
funsize.append(u)
return [fname, flocation, fsize, funsize]
def alien_filter(name, location, size, unsize, version):
'''
Filter alien repository data
'''
ver = slack_ver()
if version == "current":
ver = "current"
path_pkg = "pkg"
if os.uname()[4] == "x86_64":
path_pkg = "pkg64"
(fname, flocation, fsize, funsize) = ([] for i in range(4))
for n, l, s, u in zip(name, location, size, unsize):
if path_pkg == l.split("/")[-2] and ver == l.split("/")[-1]:
fname.append(n)
flocation.append(l)
fsize.append(s)
funsize.append(u)
return [fname, flocation, fsize, funsize]
def repo_requires(name, repo):
'''
Grap package requirements from alien repository
'''
lib = {
'alien': lib_path + "alien_repo/PACKAGES.TXT",
'slacky': lib_path + "slacky_repo/PACKAGES.TXT"
}
f = open(lib[repo], "r")
PACKAGES_TXT = f.read()
f.close()
for line in PACKAGES_TXT.splitlines():
if line.startswith("PACKAGE NAME: "):
pkg = line[14:].strip()
pkg_name = split_package(pkg)[0]
if line.startswith("PACKAGE REQUIRED: "):
if pkg_name == name:
return line[18:].strip().split(",")

357
slpkg/others/install.py Executable file
View file

@ -0,0 +1,357 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# install.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 os
import sys
from slpkg.sizes import units
from slpkg.repositories import Repo
from slpkg.init import Initialization
from slpkg.blacklist import BlackList
from slpkg.splitting import split_package
from slpkg.messages import pkg_not_found, template
from slpkg.colors import RED, GREEN, CYAN, YELLOW, GREY, ENDC
from slpkg.__metadata__ import slpkg_tmp, pkg_path, lib_path, log_path
from slpkg.pkg.find import find_package
from slpkg.pkg.manager import PackageManager
from slpkg.slack.remove import delete
from slpkg.slack.slack_version import slack_ver
from greps import repo_data
from download import packages_dwn
from dependency import dependencies_pkg
class OthersInstall(object):
def __init__(self, package, repo, version):
self.package = package
self.repo = repo
self.version = version
self.tmp_path = slpkg_tmp + "packages/"
self.repo_init()
repos = Repo()
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
CYAN, self.package, ENDC))
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
sys.stdout.flush()
self.step = 700
repos = Repo()
if self.repo == "rlw":
lib = lib_path + "rlw_repo/PACKAGES.TXT"
self.mirror = "{0}{1}/".format(repos.rlw(), slack_ver())
elif self.repo == "alien":
lib = lib_path + "alien_repo/PACKAGES.TXT"
self.mirror = repos.alien()
self.step = self.step * 2
elif self.repo == "slacky":
lib = lib_path + "slacky_repo/PACKAGES.TXT"
arch = ""
if os.uname()[4] == "x86_64":
arch = "64"
self.mirror = "{0}slackware{1}-{2}/".format(repos.slacky(), arch,
slack_ver())
self.step = self.step * 2
f = open(lib, "r")
self.PACKAGES_TXT = f.read()
f.close()
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
def repo_init(self):
'''
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,
"slacky": Initialization().slacky
}
repository[self.repo]()
def start(self):
'''
Install packages from official Slackware distribution
'''
try:
dependencies = resolving_deps(self.package, self.repo)
(dwn_links, install_all, comp_sum, uncomp_sum,
matching) = self.store(dependencies)
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
print # new line at start
if install_all:
template(78)
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
"| Package", " " * 17,
"Version", " " * 12,
"Arch", " " * 4,
"Build", " " * 2,
"Repos", " " * 10,
"Size"))
template(78)
if not matching:
print("Installing:")
sums = views(install_all, comp_sum, self.repo, dependencies)
unit, size = units(comp_sum, uncomp_sum)
msg = msgs(install_all, sums[2])
print("\nInstalling summary")
print("=" * 79)
print("{0}Total {1} {2}.".format(GREY, len(install_all),
msg[0]))
print("{0} {1} will be installed, {2} will be upgraded and "
"{3} will be resettled.".format(sums[2], msg[1],
sums[1], sums[0]))
print("Need to get {0} {1} of archives.".format(size[0],
unit[0]))
print("After this process, {0} {1} of additional disk "
"space will be used.{2}".format(size[1], unit[1],
ENDC))
read = raw_input("\nWould you like to install [Y/n]? ")
if read in ['Y', 'y']:
install_all.reverse()
packages_dwn(self.tmp_path, dwn_links)
install(self.tmp_path, install_all)
write_deps(dependencies)
delete(self.tmp_path, install_all)
else:
print("Matching:")
sums = views(install_all, comp_sum, self.repo, dependencies)
msg = msgs(install_all, sums[2])
print("\nInstalling summary")
print("=" * 79)
print("{0}Total found {1} matching {2}.".format(
GREY, len(install_all), msg[1]))
print("{0} installed {1} and {2} uninstalled {3}.{4}"
"\n".format(sums[0] + sums[1], msg[0], sums[2],
msg[1], ENDC))
else:
pkg_not_found("", self.package, "No matching", "\n")
except KeyboardInterrupt:
print # new line at exit
sys.exit()
def store(self, deps):
'''
Store and return packages for install
'''
dwn, install, comp_sum, uncomp_sum = ([] for i in range(4))
black = BlackList().packages()
matching = False
# name = data[0]
# location = data[1]
# size = data[2]
# unsize = data[3]
data = repo_data(self.PACKAGES_TXT, self.step, self.repo, self.version)
if len(deps) > 1:
for pkg in deps:
for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
data[3]):
if name.startswith(pkg) and pkg not in black:
# store downloads packages by repo
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
install.append(name)
comp_sum.append(comp)
uncomp_sum.append(uncomp)
else:
for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
data[3]):
package = "".join(deps)
if package in name and package not in BlackList().packages():
# store downloads packages by repo
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
install.append(name)
comp_sum.append(comp)
uncomp_sum.append(uncomp)
if len(install) > 1:
matching = True
dwn.reverse()
install.reverse()
comp_sum.reverse()
uncomp_sum.reverse()
return [dwn, install, comp_sum, uncomp_sum, matching]
def views(install_all, comp_sum, repository, dependencies):
'''
Views packages
'''
count = pkg_sum = uni_sum = upg_sum = 0
# fix repositories align
align = {
"rlw": ' ' * 3,
"alien": ' ',
"slacky": ''
}
repository += align[repository]
for pkg, comp in zip(install_all, comp_sum):
pkg_split = split_package(pkg[:-4])
if find_package(pkg_split[0] + "-" + pkg_split[1], pkg_path):
pkg_sum += 1
COLOR = GREEN
elif find_package(pkg_split[0] + "-", pkg_path):
COLOR = YELLOW
upg_sum += 1
else:
COLOR = RED
uni_sum += 1
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11:>11}{12}".format(
COLOR, pkg_split[0], ENDC,
" " * (25-len(pkg_split[0])), pkg_split[1],
" " * (19-len(pkg_split[1])), pkg_split[2],
" " * (8-len(pkg_split[2])), pkg_split[3],
" " * (7-len(pkg_split[3])), repository,
comp, " K"))
if len(dependencies) > 1 and count == 0:
print("Installing for dependencies:")
count += 1
return [pkg_sum, upg_sum, uni_sum]
def msgs(install_all, uni_sum):
'''
Print singular plural
'''
msg_pkg = "package"
msg_2_pkg = msg_pkg
if len(install_all) > 1:
msg_pkg = msg_pkg + "s"
if uni_sum > 1:
msg_2_pkg = msg_2_pkg + "s"
return [msg_pkg, msg_2_pkg]
def install(tmp_path, install_all):
'''
Install or upgrade packages
'''
for install in install_all:
package = (tmp_path + install).split()
if os.path.isfile(pkg_path + install[:-4]):
print("[ {0}reinstalling{1} ] --> {2}".format(GREEN, ENDC, install))
PackageManager(package).reinstall()
elif find_package(split_package(install)[0] + "-", pkg_path):
print("[ {0}upgrading{1} ] --> {2}".format(YELLOW, ENDC, install))
PackageManager(package).upgrade()
else:
print("[ {0}installing{1} ] --> {2}".format(GREEN, ENDC, install))
PackageManager(package).upgrade()
def repo_deps(name, repo):
'''
Return package dependencies
'''
deps = dependencies_pkg(name, repo)
requires, dependencies = [], []
requires.append(name)
# Create one list for all packages
for pkg in deps:
requires += pkg
if repo == "slacky":
requires = slacky_req_check(name, requires)
requires.reverse()
# Remove double dependencies
for duplicate in requires:
if duplicate not in dependencies:
dependencies.append(duplicate)
return dependencies
def rlw_deps(name):
'''
Robby's repository dependencies as shown in the central page
http://rlworkman.net/pkgs/
'''
dependencies = {
"abiword": "wv",
"claws-mail": "libetpan bogofilter html2ps",
"inkscape": "gtkmm atkmm pangomm cairomm mm-common libsigc++ libwpg" +
"lxml gsl numpy BeautifulSoup",
"texlive": "libsigsegv texi2html",
"xfburn": "libburn libisofs"
}
if name in dependencies.keys():
return dependencies[name]
else:
return ""
def resolving_deps(name, repo):
'''
Return dependencies for one package from
alien repository
'''
dependencies = []
sys.stdout.write("{0}Resolving dependencies ...{1}".format(GREY, ENDC))
sys.stdout.flush()
if repo == "alien" or repo == "slacky":
dependencies = repo_deps(name, repo)
elif repo == "rlw":
dependencies = rlw_deps(name).split()
dependencies.append(name)
return dependencies
def slacky_req_check(name, requires):
'''
Checks if the requirement is installed or if it is
smaller version
'''
new = []
for req in requires[1:]:
split_req = req.split() # split requirements
req_name = split_req[0] # store name
installed = find_package(req_name + "-", pkg_path)
if not installed:
new.append(req_name)
requires = []
requires.append(name)
requires += new
return requires
def write_deps(dependencies):
'''
Write dependencies in a log file
into directory `/var/log/slpkg/dep/`
'''
name = dependencies[-1]
if find_package(name + "-", pkg_path):
dep_path = log_path + "dep/"
if not os.path.exists(log_path):
os.mkdir(log_path)
if not os.path.exists(dep_path):
os.mkdir(dep_path)
if os.path.isfile(dep_path + name):
os.remove(dep_path + name)
if len(dependencies[:-1]) > 0:
with open(dep_path + name, "w") as f:
for dep in dependencies[:-1]:
f.write(dep + "\n")
f.close()

View file

@ -34,6 +34,6 @@ def find_package(find_pkg, directory):
pkgs = [] pkgs = []
blacklist = BlackList().packages() blacklist = BlackList().packages()
for pkg in sorted(os.listdir(directory)): for pkg in sorted(os.listdir(directory)):
if pkg.startswith(find_pkg) and split_package(pkg)[0] not in blacklist: if pkg.startswith(find_pkg)and split_package(pkg)[0] not in blacklist:
pkgs.append(pkg) pkgs.append(pkg)
return pkgs return pkgs

View file

@ -90,7 +90,7 @@ class PackageManager(object):
Remove Slackware binary packages Remove Slackware binary packages
''' '''
dep_path = log_path + "dep/" dep_path = log_path + "dep/"
dependencies = [] dependencies, rmv_list = [], []
removed = self.view_removed(self.binary) removed = self.view_removed(self.binary)
if not removed: if not removed:
print # new line at end print # new line at end
@ -105,7 +105,7 @@ class PackageManager(object):
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print # new line at exit
sys.exit() sys.exit()
if remove_pkg == "y" or remove_pkg == "Y": if remove_pkg in ['y', 'Y']:
for rmv in removed: for rmv in removed:
# If package build and install with 'slpkg -s sbo <package>' # If package build and install with 'slpkg -s sbo <package>'
# then look log file for dependencies in /var/log/slpkg/dep, # then look log file for dependencies in /var/log/slpkg/dep,
@ -119,14 +119,15 @@ class PackageManager(object):
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print # new line at exit
sys.exit() sys.exit()
if remove_dep == "y" or remove_dep == "Y": if remove_dep in ['y', 'Y']:
rmv_list = self.rmv_deps(self.binary, dependencies, rmv_list += self.rmv_deps(self.binary,
dep_path, rmv) dependencies,
dep_path, rmv)
else: else:
rmv_list = self.rmv_pkg(rmv) rmv_list += self.rmv_pkg(rmv)
os.remove(dep_path + rmv) os.remove(dep_path + rmv)
else: else:
rmv_list = self.rmv_pkg(rmv) rmv_list += self.rmv_pkg(rmv)
# Prints all removed packages # Prints all removed packages
self.reference_rmvs(rmv_list) self.reference_rmvs(rmv_list)
@ -188,16 +189,15 @@ class PackageManager(object):
if find_package(package + sp, pkg_path): if find_package(package + sp, pkg_path):
print(subprocess.check_output("removepkg {0}".format(package), print(subprocess.check_output("removepkg {0}".format(package),
shell=True)) shell=True))
return package.split() return package.split()
@staticmethod @staticmethod
def reference_rmvs(removes): def reference_rmvs(removes):
''' '''
Prints all removed packages Prints all removed packages
''' '''
if len(removes) > 1: template(78)
template(78) print("| Total {0} packages removed".format(len(removes)))
print("| Total {0} packages removed".format(len(removes)))
template(78) template(78)
for pkg in removes: for pkg in removes:
if not find_package(pkg + sp, pkg_path): if not find_package(pkg + sp, pkg_path):
@ -269,22 +269,29 @@ class PackageManager(object):
tty_size = os.popen('stty size', 'r').read().split() tty_size = os.popen('stty size', 'r').read().split()
row = int(tty_size[0]) - 2 row = int(tty_size[0]) - 2
try: try:
if "sbo" in pattern: pkg_list = {
search = "_SBo" 'sbo': '_SBo',
elif "slack" in pattern: 'slack': '_slack',
search = "_slack" 'noarch': '-noarch-',
elif "noarch" in pattern: 'rlw': '_rlw',
search = "-noarch-" 'alien': 'alien',
elif "all" in pattern: 'slacky': 'sl',
search = "" 'all': ''
}
search = pkg_list[pattern]
index, page = 0, row index, page = 0, row
sl = search
if search == "-noarch-":
search = ""
for pkg in find_package("", pkg_path): for pkg in find_package("", pkg_path):
if search in pkg: if pkg.endswith(search) and sl in pkg:
index += 1 index += 1
print("{0}{1}:{2} {3}".format(GREY, index, ENDC, pkg)) print("{0}{1}:{2} {3}".format(GREY, index, ENDC, pkg))
if index == page: if index == page:
raw_input("\nPress {0}Enter{1} to continue...".format( read = raw_input("\nPress {0}Enter{1} to "
CYAN, ENDC)) "continue... ".format(CYAN, ENDC))
if read in ['Q', 'q']:
break
print # new line after page print # new line after page
page += row page += row
print # new line at end print # new line at end

View file

@ -157,7 +157,7 @@ class QueuePkgs(object):
if packages: if packages:
print # new line at start print # new line at start
for pkg in packages: for pkg in packages:
# check if package exist in repository # check if package exist in /tmp
find = find_package(pkg, tmp) find = find_package(pkg, tmp)
try: try:
find = max(find) find = max(find)

58
slpkg/repositories.py Executable file
View file

@ -0,0 +1,58 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# repositories.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/>.
class Repo(object):
def __init__(self):
pass
def slack(self):
'''
Official slackware repository
'''
return "http://mirrors.slackware.com/slackware/"
def sbo(self):
'''
SlackBuilds.org repository
'''
return "http://slackbuilds.org/slackbuilds/"
def rlw(self):
'''
Robby's repoisitory
'''
return "http://rlworkman.net/pkgs/"
def alien(self):
'''
Alien repository
'''
return "http://www.slackware.com/~alien/slackbuilds/"
def slacky(self):
'''
Slacky.eu repository
'''
return "http://repository.slacky.eu/"

View file

@ -29,7 +29,7 @@ from slpkg.pkg.build import BuildPackage
from slpkg.pkg.manager import PackageManager from slpkg.pkg.manager import PackageManager
from slpkg.toolbar import status from slpkg.toolbar import status
from slpkg.init import initialization from slpkg.init import Initialization
from slpkg.downloader import Download from slpkg.downloader import Download
from slpkg.splitting import split_package from slpkg.splitting import split_package
from slpkg.messages import template, build_FAILED from slpkg.messages import template, build_FAILED
@ -48,7 +48,7 @@ class SBoCheck(object):
self.done = "{0}Done{1}\n".format(GREY, ENDC) self.done = "{0}Done{1}\n".format(GREY, ENDC)
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC)) sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
sys.stdout.flush() sys.stdout.flush()
initialization() Initialization().sbo()
self.installed = [] self.installed = []
self.index, self.toolbar_width = 0, 3 self.index, self.toolbar_width = 0, 3
@ -62,23 +62,19 @@ class SBoCheck(object):
some version in /tmp directory. some version in /tmp directory.
''' '''
try: try:
if sbo_list(): if self.sbo_list():
upg_name = exists(self.index, self.toolbar_width) upg_name = self.exists()
sys.stdout.write(self.done) sys.stdout.write(self.done)
data = [] data = []
if upg_name: if upg_name:
sys.stdout.write("{0}Resolving dependencies ...{1}".format( sys.stdout.write("{0}Resolving dependencies ...{1}".format(
GREY, ENDC)) GREY, ENDC))
sys.stdout.flush() sys.stdout.flush()
dependencies = deps(upg_name)
requires = one_for_all(dependencies)
dependencies_list = order_list(upg_name,
remove_dbs(requires))
# upgrade name = data[0] # upgrade name = data[0]
# package for upgrade = data[1] # package for upgrade = data[1]
# upgrade version = data[2] # upgrade version = data[2]
# upgrade arch = data[3] # upgrade arch = data[3]
data = store(dependencies_list) data = store(order_list(upg_name))
sys.stdout.write(self.done) sys.stdout.write(self.done)
if data: if data:
# count installed = count[0] # count installed = count[0]
@ -87,7 +83,7 @@ class SBoCheck(object):
# message upgrade = msg[1] # message upgrade = msg[1]
count, msg = view_packages(data[1], data[2], data[3]) count, msg = view_packages(data[1], data[2], data[3])
read = raw_input("Would you like to upgrade [Y/n]? ") read = raw_input("Would you like to upgrade [Y/n]? ")
if read == "Y" or read == "y": if read in ['y', 'Y']:
create_build_path() create_build_path()
os.chdir(build_path) os.chdir(build_path)
for name, version in zip(data[0], data[2]): for name, version in zip(data[0], data[2]):
@ -122,7 +118,7 @@ class SBoCheck(object):
msg[0], msg[1], self.installed) msg[0], msg[1], self.installed)
else: else:
print("\nTotal {0} SBo packages are up to date\n".format( print("\nTotal {0} SBo packages are up to date\n".format(
len(sbo_list()))) len(self.sbo_list())))
else: else:
sys.stdout.write(self.done) sys.stdout.write(self.done)
print("\nNo SBo packages found\n") print("\nNo SBo packages found\n")
@ -130,35 +126,33 @@ class SBoCheck(object):
print # new line at exit print # new line at exit
sys.exit() sys.exit()
def sbo_list(self):
'''
Return all SBo packages
'''
sbo_packages = []
for pkg in os.listdir(pkg_path):
if pkg.endswith("_SBo"):
sbo_packages.append(pkg)
return sbo_packages
def sbo_list(): def exists(self):
''' '''
Return all SBo packages search packages if exists in the repository
''' and it gets to avoidable modified packages
sbo_packages = [] from the user with the tag _SBo
for pkg in os.listdir(pkg_path): '''
if pkg.endswith("_SBo"): upgrade_names = []
sbo_packages.append(pkg) for pkg in self.sbo_list():
return sbo_packages self.index += 1
self.toolbar_width = status(self.index, self.toolbar_width, 4)
name = split_package(pkg)[0]
def exists(index, toolbar_width): if sbo_search_pkg(name):
''' sbo_package = ("{0}-{1}".format(name, SBoGrep(name).version()))
search packages if exists in the repository package = ("{0}-{1}".format(name, split_package(pkg)[1]))
and it gets to avoidable modified packages if sbo_package > package:
from the user with the tag _SBo upgrade_names.append(name)
''' return upgrade_names
upgrade_names = []
for pkg in sbo_list():
index += 1
toolbar_width = status(index, toolbar_width, 4)
name = split_package(pkg)[0]
if sbo_search_pkg(name):
sbo_package = ("{0}-{1}".format(name, SBoGrep(name).version()))
package = ("{0}-{1}".format(name, split_package(pkg)[1]))
if sbo_package > package:
upgrade_names.append(name)
return upgrade_names
def deps(upgrade_names): def deps(upgrade_names):
@ -172,13 +166,14 @@ def deps(upgrade_names):
return dependencies return dependencies
def one_for_all(dependencies): def one_for_all(upgrade_names):
''' '''
Because there are dependencies that depend on other Because there are dependencies that depend on other
dependencies are created lists into other lists. dependencies are created lists into other lists.
Thus creating this loop create one-dimensional list. Thus creating this loop create one-dimensional list.
''' '''
requires = [] requires = []
dependencies = deps(upgrade_names)
for dep in dependencies: for dep in dependencies:
requires += dep requires += dep
# Inverting the list brings the # Inverting the list brings the
@ -187,33 +182,35 @@ def one_for_all(dependencies):
return requires return requires
def remove_dbs(requires): def remove_dbs(upgrade_names):
''' '''
Many packages use the same dependencies, in this loop Many packages use the same dependencies, in this loop
creates a new list by removing duplicate dependencies but creates a new list by removing duplicate dependencies but
without spoiling the line must be installed. without spoiling the line must be installed.
''' '''
dependencies = [] dependencies = []
requires = one_for_all(upgrade_names)
for duplicate in requires: for duplicate in requires:
if duplicate not in dependencies: if duplicate not in dependencies:
dependencies.append(duplicate) dependencies.append(duplicate)
return dependencies return dependencies
def order_list(upgrade_names, dependencies): def order_list(upgrade_names):
''' '''
Last and after the list is created with the correct number Last and after the list is created with the correct number
of dependencies that must be installed, and add the particular of dependencies that must be installed, and add the particular
packages that need to be upgraded if they are not already on packages that need to be upgraded if they are not already on
the list in end to list. the list in end to list.
''' '''
dependencies = remove_dbs(upgrade_names)
for upg in upgrade_names: for upg in upgrade_names:
if upg not in dependencies: if upg not in dependencies:
dependencies.append(upg) dependencies.append(upg)
return dependencies return dependencies
def store(dependencies_list): def store(dependencies):
''' '''
In the end lest a check of the packages that are on the list In the end lest a check of the packages that are on the list
are already installed. are already installed.
@ -223,7 +220,7 @@ def store(dependencies_list):
upgrade_version, upgrade_version,
upgrade_arch upgrade_arch
) = ([] for i in range(4)) ) = ([] for i in range(4))
for pkg in dependencies_list: for pkg in dependencies:
ver = SBoGrep(pkg).version() ver = SBoGrep(pkg).version()
prgnam = ("{0}-{1}".format(pkg, ver)) prgnam = ("{0}-{1}".format(pkg, ver))
# if package not installed # if package not installed

View file

@ -48,8 +48,7 @@ def sbo_dependencies_pkg(name):
if dependencies: if dependencies:
dep_results.append(dependencies) dep_results.append(dependencies)
for dep in dependencies: for dep in dependencies:
sys.stdout.write("{0}.{1}".format( sys.stdout.write("{0}.{1}".format(GREY, ENDC))
GREY, ENDC))
sys.stdout.flush() sys.stdout.flush()
sbo_dependencies_pkg(dep) sbo_dependencies_pkg(dep)
return dep_results return dep_results

View file

@ -23,6 +23,7 @@
import sys import sys
from slpkg.repositories import Repo
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from slpkg.__metadata__ import lib_path from slpkg.__metadata__ import lib_path
@ -34,9 +35,9 @@ def sbo_search_pkg(name):
Search for package path from SLACKBUILDS.TXT file Search for package path from SLACKBUILDS.TXT file
''' '''
try: try:
repo = Repo().sbo()
blacklist = BlackList().packages() blacklist = BlackList().packages()
sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format( sbo_url = "{0}{1}/".format(repo, slack_ver())
slack_ver()))
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT", with open(lib_path + "sbo_repo/SLACKBUILDS.TXT",
"r") as SLACKBUILDS_TXT: "r") as SLACKBUILDS_TXT:
for line in SLACKBUILDS_TXT: for line in SLACKBUILDS_TXT:

View file

@ -25,8 +25,9 @@ import os
import sys import sys
from slpkg.toolbar import status from slpkg.toolbar import status
from slpkg.init import initialization from slpkg.init import Initialization
from slpkg.downloader import Download from slpkg.downloader import Download
from slpkg.splitting import split_package
from slpkg.__metadata__ import (tmp, pkg_path, build_path, from slpkg.__metadata__ import (tmp, pkg_path, build_path,
log_path, lib_path, sp) log_path, lib_path, sp)
@ -50,7 +51,7 @@ class SBoInstall(object):
self.name = name self.name = name
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC)) sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
sys.stdout.flush() sys.stdout.flush()
initialization() Initialization().sbo()
self.UNST = ["UNSUPPORTED", "UNTESTED"] self.UNST = ["UNSUPPORTED", "UNTESTED"]
self.dependencies_list = sbo_dependencies_pkg(name) self.dependencies_list = sbo_dependencies_pkg(name)
@ -62,8 +63,7 @@ class SBoInstall(object):
''' '''
try: try:
if self.dependencies_list or sbo_search_pkg(self.name) is not None: if self.dependencies_list or sbo_search_pkg(self.name) is not None:
requires = one_for_all(self.name, self.dependencies_list) dependencies = self.remove_dbs()
dependencies = remove_dbs(requires)
# sbo versions = idata[0] # sbo versions = idata[0]
# package arch = idata[1] # package arch = idata[1]
# package sum = idata[2] # package sum = idata[2]
@ -81,13 +81,14 @@ class SBoInstall(object):
ARCH_COLOR = arch_colors_tag(self.UNST, idata[1]) ARCH_COLOR = arch_colors_tag(self.UNST, idata[1])
view_packages(PKG_COLOR, self.name, idata[0][-1], ARCH_COLOR, view_packages(PKG_COLOR, self.name, idata[0][-1], ARCH_COLOR,
idata[1][-1]) idata[1][-1])
print("Installing for dependencies:") if len(dependencies) > 1:
for dep, ver, dep_arch in zip(dependencies[:-1], idata[0][:-1], print("Installing for dependencies:")
idata[1][:-1]): for dep, ver, dep_arch in zip(dependencies[:-1],
(DEP_COLOR, count) = pkg_colors_tag(dep, ver, count[0], idata[0][:-1], idata[1][:-1]):
count[1]) (DEP_COLOR, count) = pkg_colors_tag(dep, ver, count[0],
ARCH_COLOR = arch_colors_tag(self.UNST, dep) count[1])
view_packages(DEP_COLOR, dep, ver, ARCH_COLOR, dep_arch) ARCH_COLOR = arch_colors_tag(self.UNST, dep)
view_packages(DEP_COLOR, dep, ver, ARCH_COLOR, dep_arch)
# insstall message = msg[0] # insstall message = msg[0]
# upgraded message = msg[1] # upgraded message = msg[1]
# total message = msg[2] # total message = msg[2]
@ -101,14 +102,14 @@ class SBoInstall(object):
msg[1])) msg[1]))
print("will be upgraded.{0}\n".format(ENDC)) print("will be upgraded.{0}\n".format(ENDC))
read = arch_support(idata[3], self.UNST, idata[2], dependencies) read = arch_support(idata[3], self.UNST, idata[2], dependencies)
if read == "Y" or read == "y": if read in['y', 'Y']:
# installs = b_ins[0] # installs = b_ins[0]
# upgraded = b_ins[1] # upgraded = b_ins[1]
# versions = b_ins[2] # versions = b_ins[2]
b_ins = build_install(dependencies, idata[0], idata[1]) b_ins = build_install(dependencies, idata[0])
reference(count[1], msg[0], count[0], msg[1], reference(count[1], msg[0], count[0], msg[1],
b_ins[0], b_ins[2], b_ins[1]) b_ins[0], b_ins[2], b_ins[1])
write_deps(self.name, dependencies) write_deps(dependencies)
else: else:
count_installed = count_uninstalled = 0 count_installed = count_uninstalled = 0
# sbo matching = mdata[0] # sbo matching = mdata[0]
@ -145,28 +146,27 @@ class SBoInstall(object):
print # new line at exit print # new line at exit
sys.exit() sys.exit()
def one_for_all(self):
'''
Create one list for all packages
'''
requires = []
requires.append(self.name)
for pkg in self.dependencies_list:
requires += pkg
requires.reverse()
return requires
def one_for_all(name, dependencies): def remove_dbs(self):
''' '''
Create one list for all packages Remove double dependencies
''' '''
requires = [] requires = self.one_for_all()
requires.append(name) dependencies = []
for pkg in dependencies: for duplicate in requires:
requires += pkg if duplicate not in dependencies:
requires.reverse() dependencies.append(duplicate)
return requires return dependencies
def remove_dbs(requires):
'''
Remove double dependencies
'''
dependencies = []
for duplicate in requires:
if duplicate not in dependencies:
dependencies.append(duplicate)
return dependencies
def installing_data(dependencies, support): def installing_data(dependencies, support):
@ -308,7 +308,7 @@ def search_in_tmp(prgnam):
return binary return binary
def build_install(dependencies, sbo_versions, packages_arch): def build_install(dependencies, sbo_versions):
''' '''
Searches the package name and version in /tmp to Searches the package name and version in /tmp to
install. If find two or more packages e.g. to build install. If find two or more packages e.g. to build
@ -317,13 +317,12 @@ def build_install(dependencies, sbo_versions, packages_arch):
installs, upgraded, versions = [], [], [] installs, upgraded, versions = [], [], []
create_build_path() create_build_path()
os.chdir(build_path) os.chdir(build_path)
for pkg, ver, ar in zip(dependencies, sbo_versions, packages_arch): for pkg, ver in zip(dependencies, sbo_versions):
prgnam = ("{0}-{1}".format(pkg, ver)) prgnam = ("{0}-{1}".format(pkg, ver))
sbo_file = "".join(find_package(prgnam, pkg_path)) sbo_file = "".join(find_package(prgnam, pkg_path))
if sbo_file: if sbo_file:
sbo_file_version = sbo_file[len(pkg) + 1:-len(ar) - 7]
template(78) template(78)
pkg_found(pkg, sbo_file_version) pkg_found(pkg, split_package(sbo_file)[1])
template(78) template(78)
else: else:
sbo_url = sbo_search_pkg(pkg) sbo_url = sbo_search_pkg(pkg)
@ -362,7 +361,7 @@ def reference(*args):
for pkg, ver in zip(args[4], args[5]): for pkg, ver in zip(args[4], args[5]):
installed = ("{0}-{1}".format(pkg, ver)) installed = ("{0}-{1}".format(pkg, ver))
if find_package(installed, pkg_path): if find_package(installed, pkg_path):
if pkg in args[5]: if pkg in args[6]:
print("| Package {0} upgraded successfully".format(installed)) print("| Package {0} upgraded successfully".format(installed))
else: else:
print("| Package {0} installed successfully".format(installed)) print("| Package {0} installed successfully".format(installed))
@ -371,11 +370,12 @@ def reference(*args):
template(78) template(78)
def write_deps(name, dependencies): def write_deps(dependencies):
''' '''
Write dependencies in a log file Write dependencies in a log file
into directory `/var/log/slpkg/dep/` into directory `/var/log/slpkg/dep/`
''' '''
name = dependencies[-1]
if find_package(name + sp, pkg_path): if find_package(name + sp, pkg_path):
dep_path = log_path + "dep/" dep_path = log_path + "dep/"
if not os.path.exists(log_path): if not os.path.exists(log_path):

View file

@ -24,12 +24,13 @@
import sys import sys
from slpkg.messages import template from slpkg.messages import template
from slpkg.init import initialization from slpkg.init import Initialization
from slpkg.__metadata__ import pkg_path, sp from slpkg.__metadata__ import pkg_path, sp
from slpkg.colors import RED, GREEN, GREY, YELLOW, CYAN, ENDC from slpkg.colors import RED, GREEN, GREY, YELLOW, CYAN, ENDC
from slpkg.pkg.find import find_package from slpkg.pkg.find import find_package
from search import sbo_search_pkg
from dependency import sbo_dependencies_pkg from dependency import sbo_dependencies_pkg
@ -42,10 +43,10 @@ def track_dep(name):
''' '''
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC)) sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
sys.stdout.flush() sys.stdout.flush()
initialization() Initialization().sbo()
dependencies_list = sbo_dependencies_pkg(name) dependencies_list = sbo_dependencies_pkg(name)
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC)) sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
if dependencies_list: if sbo_search_pkg(name):
requires, dependencies = [], [] requires, dependencies = [], []
# Create one list for all packages # Create one list for all packages
for pkg in dependencies_list: for pkg in dependencies_list:

View file

@ -25,7 +25,7 @@ import os
import sys import sys
import pydoc import pydoc
from slpkg.init import initialization from slpkg.init import Initialization
from slpkg.downloader import Download from slpkg.downloader import Download
from slpkg.__metadata__ import tmp, build_path, pkg_path, sp from slpkg.__metadata__ import tmp, build_path, pkg_path, sp
from slpkg.colors import RED, GREEN, GREY, CYAN, YELLOW, ENDC from slpkg.colors import RED, GREEN, GREY, CYAN, YELLOW, ENDC
@ -48,7 +48,7 @@ class SBoNetwork(object):
self.name = name self.name = name
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC)) sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
sys.stdout.flush() sys.stdout.flush()
initialization() Initialization().sbo()
grep = SBoGrep(self.name) grep = SBoGrep(self.name)
self.sbo_url = sbo_search_pkg(self.name) self.sbo_url = sbo_search_pkg(self.name)
self.sbo_desc = grep.description()[len(self.name) + 2:-1] self.sbo_desc = grep.description()[len(self.name) + 2:-1]
@ -66,36 +66,37 @@ class SBoNetwork(object):
''' '''
if self.sbo_url: if self.sbo_url:
prgnam = ("{0}-{1}".format(self.name, self.sbo_version)) prgnam = ("{0}-{1}".format(self.name, self.sbo_version))
view_sbo(self.name, self.sbo_url, self.sbo_desc, self.view_sbo(
self.sbo_dwn.split("/")[-1], self.name, self.sbo_url, self.sbo_desc,
", ".join([src.split("/")[-1] for src in self.source_dwn]), self.sbo_dwn.split("/")[-1],
self.sbo_req) ", ".join([src.split("/")[-1] for src in self.source_dwn]),
FAULT = error_uns(self.source_dwn) self.sbo_req)
FAULT = self.error_uns()
while True: while True:
choice = read_choice() choice = self.read_choice()
if choice in ["D", "d"]: if choice in ['D', 'd']:
download("", self.sbo_dwn, self.source_dwn) self.download(path="")
break break
elif choice in ["R", "r"]: elif choice in ['R', 'r']:
README = Read(self.sbo_url).readme("README") README = Read(self.sbo_url).readme("README")
fill = fill_pager(README) fill = self.fill_pager(README)
pydoc.pager(README + fill) pydoc.pager(README + fill)
elif choice in ["F", "f"]: elif choice in ['F', 'f']:
info = Read(self.sbo_url).info(self.name, ".info") info = Read(self.sbo_url).info(self.name, ".info")
fill = fill_pager(info) fill = self.fill_pager(info)
pydoc.pager(info + fill) pydoc.pager(info + fill)
elif choice in ["S", "s"]: elif choice in ['S', 's']:
SlackBuild = Read(self.sbo_url).slackbuild(self.name, SlackBuild = Read(self.sbo_url).slackbuild(self.name,
".SlackBuild") ".SlackBuild")
fill = fill_pager(SlackBuild) fill = self.fill_pager(SlackBuild)
pydoc.pager(SlackBuild + fill) pydoc.pager(SlackBuild + fill)
elif choice in ["B", "b"]: elif choice in ['B', 'b']:
build(self.sbo_dwn, self.source_dwn, FAULT) self.build(FAULT)
break break
elif choice in ["I", "i"]: elif choice in ['I', 'i']:
if not find_package(prgnam + sp, pkg_path): if not find_package(prgnam + sp, pkg_path):
build(self.sbo_dwn, self.source_dwn, FAULT) self.build(FAULT)
install(self.name, prgnam, self.sbo_url) self.install(prgnam)
break break
else: else:
template(78) template(78)
@ -107,110 +108,110 @@ class SBoNetwork(object):
else: else:
pkg_not_found("\n", self.name, "Can't view", "\n") pkg_not_found("\n", self.name, "Can't view", "\n")
@staticmethod
def view_sbo(*args):
'''
View slackbuild.org
'''
print # new line at start
template(78)
print("| {0}Package {1}{2}{3} --> {4}".format(GREEN, CYAN, args[0],
GREEN, ENDC + args[1]))
template(78)
print("| {0}Description : {1}{2}".format(GREEN, ENDC, args[2]))
print("| {0}SlackBuild : {1}{2}".format(GREEN, ENDC, args[3]))
print("| {0}Sources : {1}{2}".format(GREEN, ENDC, args[4]))
print("| {0}Requirements : {1}{2}".format(YELLOW, ENDC,
", ".join(args[5])))
template(78)
print(" {0}R{1}EADME View the README file".format(RED,
ENDC))
print(" {0}S{1}lackBuild View the SlackBuild file".format(
RED, ENDC))
print(" In{0}f{1}o View the Info file".format(RED,
ENDC))
print(" {0}D{1}ownload Download this package".format(RED,
ENDC))
print(" {0}B{1}uild Download and build".format(RED,
ENDC))
print(" {0}I{1}nstall Download/Build/Install".format(
RED, ENDC))
print(" {0}Q{1}uit Quit\n".format(RED, ENDC))
def view_sbo(*args): @staticmethod
''' def fill_pager(page):
View slackbuild.org '''
''' Fix pager spaces
print # new line at start '''
template(78) tty_size = os.popen('stty size', 'r').read().split()
print("| {0}Package {1}{2}{3} --> {4}".format(GREEN, CYAN, args[0], GREEN, rows = int(tty_size[0]) - 1
ENDC + args[1])) lines = sum(1 for line in page.splitlines())
template(78) diff = rows - lines
print("| {0}Description : {1}{2}".format(GREEN, ENDC, args[2])) fill = "\n" * diff
print("| {0}SlackBuild : {1}{2}".format(GREEN, ENDC, args[3])) if diff > 0:
print("| {0}Sources : {1}{2}".format(GREEN, ENDC, args[4])) return fill
print("| {0}Requirements : {1}{2}".format(YELLOW, ENDC, ", ".join(args[5]))) else:
template(78) return ""
print(" {0}R{1}EADME View the README file".format(RED, ENDC))
print(" {0}S{1}lackBuild View the SlackBuild file".format(
RED, ENDC))
print(" In{0}f{1}o View the Info file".format(RED, ENDC))
print(" {0}D{1}ownload Download this package".format(RED, ENDC))
print(" {0}B{1}uild Download and build".format(RED, ENDC))
print(" {0}I{1}nstall Download/Build/Install".format(
RED, ENDC))
print(" {0}Q{1}uit Quit\n".format(RED, ENDC))
def read_choice(self):
def fill_pager(page): '''
''' Return choice
Fix pager spaces '''
'''
tty_size = os.popen('stty size', 'r').read().split()
rows = int(tty_size[0]) - 1
lines = sum(1 for line in page.splitlines())
diff = rows - lines
fill = "\n" * diff
if diff > 0:
return fill
else:
return ""
def read_choice():
'''
Return choice
'''
try:
choice = raw_input(" {0}Choose an option: {1}".format(GREY, ENDC))
except KeyboardInterrupt:
print # new line at exit
sys.exit()
return choice
def error_uns(source_dwn):
'''
Check if package supported by arch
before proceed to install
'''
UNST = ["UNSUPPORTED", "UNTESTED"]
if "".join(source_dwn) in UNST:
return "".join(source_dwn)
def download(path, sbo_dwn, source_dwn):
'''
Download sources
'''
Download(path, sbo_dwn).start()
for src in source_dwn:
Download(path, src).start()
def build(sbo_dwn, source_dwn, FAULT):
'''
Only build and create Slackware package
'''
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, sbo_dwn).start()
script = sbo_dwn.split("/")[-1]
for src in source_dwn:
Download(build_path, src).start()
sources.append(src.split("/")[-1])
BuildPackage(script, sources, build_path).build()
def install(name, prgnam, sbo_url):
'''
Install Slackware package found in /tmp
directory.
'''
binary_list = []
for search in find_package(prgnam, tmp):
if "_SBo" in search:
binary_list.append(search)
try: try:
binary = (tmp + max(binary_list)).split() choice = raw_input(" {0}Choose an option: {1}".format(GREY, ENDC))
except ValueError: except KeyboardInterrupt:
build_FAILED(sbo_url, prgnam) print # new line at exit
sys.exit() sys.exit()
print("[ {0}Installing{1} ] --> {2}".format(GREEN, ENDC, name)) return choice
PackageManager(binary).upgrade()
def error_uns(self):
'''
Check if package supported by arch
before proceed to install
'''
UNST = ["UNSUPPORTED", "UNTESTED"]
if "".join(self.source_dwn) in UNST:
return "".join(self.source_dwn)
def download(self, path):
'''
Download sources
'''
Download(path, self.sbo_dwn).start()
for src in self.source_dwn:
Download(path, src).start()
def build(self, FAULT):
'''
Only build and create Slackware package
'''
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()
script = self.sbo_dwn.split("/")[-1]
for src in self.source_dwn:
Download(build_path, src).start()
sources.append(src.split("/")[-1])
BuildPackage(script, sources, build_path).build()
def install(self, prgnam):
'''
Install Slackware package found in /tmp
directory.
'''
binary_list = []
for search in find_package(prgnam, tmp):
if "_SBo" in search:
binary_list.append(search)
try:
binary = (tmp + max(binary_list)).split()
except ValueError:
build_FAILED(self.sbo_url, prgnam)
sys.exit()
print("[ {0}Installing{1} ] --> {2}".format(GREEN, ENDC, self.name))
PackageManager(binary).upgrade()

View file

@ -24,6 +24,7 @@
import os import os
import sys import sys
from slpkg.sizes import units
from slpkg.url_read import URL from slpkg.url_read import URL
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from slpkg.splitting import split_package from slpkg.splitting import split_package
@ -34,7 +35,6 @@ from slpkg.colors import RED, GREEN, CYAN, YELLOW, GREY, ENDC
from slpkg.pkg.find import find_package from slpkg.pkg.find import find_package
from slpkg.pkg.manager import PackageManager from slpkg.pkg.manager import PackageManager
from sizes import units
from remove import delete from remove import delete
from mirrors import mirrors from mirrors import mirrors
from greps import slack_data from greps import slack_data
@ -66,10 +66,7 @@ class Slack(object):
Install packages from official Slackware distribution Install packages from official Slackware distribution
''' '''
try: try:
data = slack_data(self.PACKAGES_TXT, 700) dwn_links, install_all, comp_sum, uncomp_sum = self.store()
(dwn_links, install_all,
comp_sum, uncomp_sum) = store(data[0], data[1], data[2], data[3],
self.slack_pkg, self.version)
sys.stdout.write("{0}Done{1}\n\n".format(GREY, ENDC)) sys.stdout.write("{0}Done{1}\n\n".format(GREY, ENDC))
if install_all: if install_all:
template(78) template(78)
@ -97,7 +94,7 @@ class Slack(object):
print("After this process, {0} {1} of additional disk space " print("After this process, {0} {1} of additional disk space "
"will be used.{2}".format(size[1], unit[1], ENDC)) "will be used.{2}".format(size[1], unit[1], ENDC))
read = raw_input("\nWould you like to install [Y/n]? ") read = raw_input("\nWould you like to install [Y/n]? ")
if read == "Y" or read == "y": if read in ['y', 'Y']:
slack_dwn(self.tmp_path, dwn_links) slack_dwn(self.tmp_path, dwn_links)
install(self.tmp_path, install_all) install(self.tmp_path, install_all)
delete(self.tmp_path, install_all) delete(self.tmp_path, install_all)
@ -107,19 +104,21 @@ class Slack(object):
print # new line at exit print # new line at exit
sys.exit() sys.exit()
def store(self):
def store(*args): '''
''' Store and return packages for install
Store and return packages for install '''
''' dwn, install, comp_sum, uncomp_sum = ([] for i in range(4))
dwn, install, comp_sum, uncomp_sum = ([] for i in range(4)) data = slack_data(self.PACKAGES_TXT, 700)
for name, loc, comp, uncomp in zip(args[0], args[1], args[2], args[3]): black = BlackList().packages()
if args[4] in name and args[4] not in BlackList().packages(): for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]):
dwn.append("{0}{1}/{2}".format(mirrors("", "", args[5]), loc, name)) if self.slack_pkg in name and self.slack_pkg not in black:
install.append(name) dwn.append("{0}{1}/{2}".format(mirrors("", "", self.version),
comp_sum.append(comp) loc, name))
uncomp_sum.append(uncomp) install.append(name)
return [dwn, install, comp_sum, uncomp_sum] comp_sum.append(comp)
uncomp_sum.append(uncomp)
return [dwn, install, comp_sum, uncomp_sum]
def views(install_all, comp_sum): def views(install_all, comp_sum):
@ -168,14 +167,11 @@ def install(tmp_path, install_all):
for install in install_all: for install in install_all:
package = (tmp_path + install).split() package = (tmp_path + install).split()
if os.path.isfile(pkg_path + install[:-4]): if os.path.isfile(pkg_path + install[:-4]):
print("[ {0}reinstalling{1} ] --> {2}".format( print("[ {0}reinstalling{1} ] --> {2}".format(GREEN, ENDC, install))
GREEN, ENDC, install))
PackageManager(package).reinstall() PackageManager(package).reinstall()
elif find_package(split_package(install)[0] + "-", pkg_path): elif find_package(split_package(install)[0] + "-", pkg_path):
print("[ {0}upgrading{1} ] --> {2}".format( print("[ {0}upgrading{1} ] --> {2}".format(YELLOW, ENDC, install))
YELLOW, ENDC, install))
PackageManager(package).upgrade() PackageManager(package).upgrade()
else: else:
print("[ {0}installing{1} ] --> {2}".format( print("[ {0}installing{1} ] --> {2}".format(GREEN, ENDC, install))
GREEN, ENDC, install))
PackageManager(package).upgrade() PackageManager(package).upgrade()

View file

@ -22,6 +22,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
from slpkg.__metadata__ import arch from slpkg.__metadata__ import arch
from slpkg.repositories import Repo
from slack_version import slack_ver from slack_version import slack_ver
@ -31,18 +32,19 @@ def mirrors(name, location, version):
Select Slackware official mirror packages Select Slackware official mirror packages
based architecture and version. based architecture and version.
''' '''
repo = Repo().slack()
if arch == "x86_64": if arch == "x86_64":
if version == "stable": if version == "stable":
http = ("http://mirrors.slackware.com/slackware/slackware64-" http = repo + "slackware64-{0}/{1}{2}".format(slack_ver(),
"{0}/{1}{2}".format(slack_ver(), location, name)) location, name)
else: else:
http = ("http://mirrors.slackware.com/slackware/slackware64-" http = repo + "slackware64-{0}/{1}{2}".format(version,
"{0}/{1}{2}".format(version, location, name)) location, name)
else: else:
if version == "stable": if version == "stable":
http = ("http://mirrors.slackware.com/slackware/slackware-" http = repo + "slackware-{0}/{1}{2}".format(slack_ver(),
"{0}/{1}{2}".format(slack_ver(), location, name)) location, name)
else: else:
http = ("http://mirrors.slackware.com/slackware/slackware-" http = repo + "slackware-{0}/{1}{2}".format(version,
"{0}/{1}{2}".format(version, location, name)) location, name)
return http return http

View file

@ -25,6 +25,7 @@ import os
import sys import sys
import subprocess import subprocess
from slpkg.sizes import units
from slpkg.url_read import URL from slpkg.url_read import URL
from slpkg.messages import template from slpkg.messages import template
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
@ -34,7 +35,6 @@ from slpkg.__metadata__ import pkg_path, slpkg_tmp
from slpkg.pkg.manager import PackageManager from slpkg.pkg.manager import PackageManager
from sizes import units
from remove import delete from remove import delete
from mirrors import mirrors from mirrors import mirrors
from greps import slack_data from greps import slack_data
@ -67,10 +67,7 @@ class Patches(object):
Install new patches from official Slackware mirrors Install new patches from official Slackware mirrors
''' '''
try: try:
data = slack_data(self.PACKAGES_TXT, self.step) dwn_links, upgrade_all, comp_sum, uncomp_sum = self.store()
(dwn_links, upgrade_all,
comp_sum, uncomp_sum) = store(data[0], data[1], data[2], data[3],
self.version)
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC)) sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
if upgrade_all: if upgrade_all:
print("\nThese packages need upgrading:\n") print("\nThese packages need upgrading:\n")
@ -95,7 +92,7 @@ class Patches(object):
print("After this process, {0} {1} of additional disk space " print("After this process, {0} {1} of additional disk space "
"will be used.{2}".format(size[1], unit[1], ENDC)) "will be used.{2}".format(size[1], unit[1], ENDC))
read = raw_input("\nWould you like to upgrade [Y/n]? ") read = raw_input("\nWould you like to upgrade [Y/n]? ")
if read == "Y" or read == "y": if read in ['y', 'Y']:
slack_dwn(self.patch_path, dwn_links) slack_dwn(self.patch_path, dwn_links)
upgrade(self.patch_path, upgrade_all) upgrade(self.patch_path, upgrade_all)
kernel(upgrade_all) kernel(upgrade_all)
@ -110,42 +107,45 @@ class Patches(object):
print # new line at exit print # new line at exit
sys.exit() sys.exit()
def store(self):
def store(*args): '''
''' Store and return packages for upgrading
Store and return packages for upgrading '''
''' (dwn, upgrade, comp_sum, uncomp_sum) = ([] for i in range(4))
(dwn, upgrade, comp_sum, uncomp_sum) = ([] for i in range(4)) data = slack_data(self.PACKAGES_TXT, self.step)
if args[4] == "stable": # stables versions upgrade black = BlackList().packages()
for name, loc, comp, uncomp in zip(args[0], args[1], args[2], args[3]): if self.version == "stable": # stables versions upgrade
if (not os.path.isfile(pkg_path + name[:-4]) and split_package( for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
name)[0] not in BlackList().packages()): data[3]):
dwn.append("{0}{1}/{2}".format( if (not os.path.isfile(pkg_path + name[:-4]) and split_package(
mirrors("", "", args[4]), loc, name)) name)[0] not in black):
comp_sum.append(comp)
uncomp_sum.append(uncomp)
upgrade.append(name)
else: # current version upgrade
installed = []
# get all installed packages and store the package name.
for pkg in os.listdir(pkg_path):
installed.append(split_package(pkg)[0])
for name, loc, comp, uncomp in zip(args[0], args[1], args[2], args[3]):
# If the package from the current repository is installed
# (check with the name) but not is in the path (check with
# all package like 'apr-1.5.0-x86_64-1') then add to list for
# upgrade.
# etc. 'apr' in list 'installed' ?? if yes 'apr-1.5.0-x86_64-1'
# exist in /var/log/packages ?? if no add to upgrade.
if split_package(name)[0] in installed:
if (not os.path.isfile(pkg_path + name[:-4]) and
split_package(name)[0] not in BlackList().packages()):
dwn.append("{0}{1}/{2}".format( dwn.append("{0}{1}/{2}".format(
mirrors("", "", args[4]), loc, name)) mirrors("", "", self.version), loc, name))
comp_sum.append(comp) comp_sum.append(comp)
uncomp_sum.append(uncomp) uncomp_sum.append(uncomp)
upgrade.append(name) upgrade.append(name)
return [dwn, upgrade, comp_sum, uncomp_sum] else: # current version upgrade
installed = []
# get all installed packages and store the package name.
for pkg in os.listdir(pkg_path):
installed.append(split_package(pkg)[0])
for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
data[3]):
# If the package from the current repository is installed
# (check with the name) but not is in the path (check with
# all package like 'apr-1.5.0-x86_64-1') then add to list for
# upgrade.
# etc. 'apr' in list 'installed' ?? if yes 'apr-1.5.0-x86_64-1'
# exist in /var/log/packages ?? if no add to upgrade.
if split_package(name)[0] in installed:
if (not os.path.isfile(pkg_path + name[:-4]) and
split_package(name)[0] not in black):
dwn.append("{0}{1}/{2}".format(
mirrors("", "", self.version), loc, name))
comp_sum.append(comp)
uncomp_sum.append(uncomp)
upgrade.append(name)
return [dwn, upgrade, comp_sum, uncomp_sum]
def views(upgrade_all, comp_sum): def views(upgrade_all, comp_sum):

View file

@ -29,7 +29,7 @@ def delete(path, packages):
Remove downloaded packages Remove downloaded packages
''' '''
read = raw_input("Removal downloaded packages [Y/n]? ") read = raw_input("Removal downloaded packages [Y/n]? ")
if read == "Y" or read == "y": if read in ['y', 'Y']:
for pkg in packages: for pkg in packages:
os.remove(path + pkg) os.remove(path + pkg)
os.remove(path + pkg + ".asc") os.remove(path + pkg + ".asc")

View file

@ -32,12 +32,20 @@ def split_package(package):
split = package.split("-") split = package.split("-")
sbo = "_SBo" sbo = "_SBo"
slack = "_slack{0}".format(slack_ver()) slack = "_slack{0}".format(slack_ver())
if sbo in package: rlw = "_rlw"
build = split[-1][:-4] # remove .t?z extension alien = "alien"
if slack in package: slacky = "sl"
build = split[-1]
if build.endswith(sbo):
build = split[-1][:-4] # and remove .t?z extension
if build.endswith(slack):
build = split[-1][:-len(slack)] build = split[-1][:-len(slack)]
else: elif build.endswith(rlw):
build = split[-1] build = split[-1][:-len(rlw)]
elif build.endswith(alien):
build = split[-1][:-len(alien)]
elif build.endswith(slacky):
build = split[-1][:-len(slacky)]
arch = split[-2] arch = split[-2]
ver = split[-3] ver = split[-3]
name = "-".join(split[:-3]) name = "-".join(split[:-3])