updated for version 2.0.5

This commit is contained in:
Dimitris Zlatanidis 2014-11-18 15:28:09 +02:00
parent 1551573cbb
commit 311f1a0a36
44 changed files with 1240 additions and 445 deletions

View file

@ -1,3 +1,15 @@
Version 2.0.5
18-11-2014
[Feature] - Add /etc/slpkg.conf file.
- Move "--current" switch in /etc/slpkg.conf file.
- Add local PACKAGES.TXT for Slackware repository.
- Add options to view package description.
- Add all repositories in tracking dependencies options '-t'.
- Add configuration file managment
[Updated] - Bugfix upgrading binary packages.
Version 2.0.4 Version 2.0.4
07-11-2014 07-11-2014

View file

@ -1,6 +1,6 @@
Metadata-Version: 1.1 Metadata-Version: 1.1
Name: slpkg Name: slpkg
Version: 2.0.4 Version: 2.0.5
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.4 - Version: 2.0.5
- `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.4.tar.gz>`_ - `Source <https://github.com/dslackw/slpkg/archive/v2.0.5.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
@ -102,8 +102,8 @@ Untar the archive and run install.sh script:
.. code-block:: bash .. code-block:: bash
$ tar xvf slpkg-2.0.4.tar.gz $ tar xvf slpkg-2.0.5.tar.gz
$ cd slpkg-2.0.4 $ cd slpkg-2.0.5
$ ./install.sh $ ./install.sh
Using `pip <https://pip.pypa.io/en/latest/>`_ : Using `pip <https://pip.pypa.io/en/latest/>`_ :
@ -120,6 +120,11 @@ Using Slackware command:
Download binary package from `SourceForge <https://sourceforge.net/projects/slpkg/>`_ Download binary package from `SourceForge <https://sourceforge.net/projects/slpkg/>`_
Slackware Current
-----------------
For Slackware 'current' users must change the variable VERSION in /etc/slpkg.conf file.
Command Line Tool Usage Command Line Tool Usage
----------------------- -----------------------
@ -130,30 +135,26 @@ Command Line Tool Usage
Optional arguments: Optional arguments:
-h, --help show this help message and exit -h, --help show this help message and exit
-v, --version print version and exit -v, --version print version and exit
-a, script [source...] auto build packages -a, script.tar.gz [source...] auto build SBo packages
-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 SBo packages in queue
--build, --install, --build-install build or install from queue --build, --install, --build-install build or install packages from queue
-l, <repository>, all, noarch list of installed packages -g, --config, --config=[editor] configuration file management
-c, <repository> --upgrade --current check for updated packages -l, [repository], all, noarch list of installed packages
-s, <repository> <package> --current download, build & install -c, [repository] --upgrade check for updated packages
-f, <package> find installed packages -s, [repository] [package] download, build & install
-t, <package> tracking dependencies from SBo -t, [repository] [package] tracking dependencies
-n, <package> view packages from SBo -p, [repository] [package] --color=[] print package description
-f, [package] find installed packages
-n, [package] view packages from SBo
-i, [package...] install binary packages -i, [package...] install binary packages
-u, [package...] upgrade binary packages -u, [package...] upgrade binary packages
-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
Note: '-q' options is working only for SBo repository Repositories: <slack, sbo, alien, slacky, rlw>
Colors = [red, green, yellow, cyan, grey]
Repositories:
Slackware = slack '--current'
Alien = alien '--current'
SlackBuilds = sbo
Slacky = slacky
Robby's = rlw
Slpkg Examples Slpkg Examples
-------------- --------------
@ -210,12 +211,11 @@ build and install with all dependencies :
0 installed package and 4 uninstalled packages. 0 installed package and 4 uninstalled packages.
Find packages from `Slackware official mirrors <http://mirrors.slackware.com/>`_ Install packages from `Slackware official mirrors <http://mirrors.slackware.com/>`_ :
download and install (use '--current' to switch in current repository):
.. code-block:: bash .. code-block:: bash
$ slpkg -s slack mozilla (add '--current' to switch in current version) $ slpkg -s slack mozilla
Packages with name matching [ mozilla ] Packages with name matching [ mozilla ]
Reading package lists ..............................Done Reading package lists ..............................Done
@ -242,7 +242,7 @@ and also displays installed packages:
.. code-block:: bash .. code-block:: bash
$ slpkg -t brasero $ slpkg -t sbo brasero
Reading package lists ......Done Reading package lists ......Done
+========================= +=========================
@ -261,7 +261,7 @@ and also displays installed packages:
| |
+--5 libunique +--5 libunique
Check if your packages is up to date from slackbuilds.org: Check if your packages is up to date:
.. code-block:: bash .. code-block:: bash
@ -290,11 +290,11 @@ Check if your packages is up to date from slackbuilds.org:
Would you like to upgrade [Y/n]? Would you like to upgrade [Y/n]?
Check if your distribution is up to date from `Slackware official mirrors Check if your distribution is up to date from `Slackware official mirrors
<http://mirrors.slackware.com/>`_ (use '--current' to switch in current repository): <http://mirrors.slackware.com/>`_ :
.. code-block:: bash .. code-block:: bash
$ slpkg -c slack --upgrade (add '--current' to switch in current version) $ slpkg -c slack --upgrade
Reading package lists .......Done Reading package lists .......Done
These packages need upgrading: These packages need upgrading:
@ -553,7 +553,7 @@ Remove packages:
+============================================================================== +==============================================================================
Remove packages with all dependencies: Remove packages with all dependencies:
(presupposes facility with the option 'slpkg -s sbo <package>) (presupposes facility with the option 'slpkg -s <repository> <package>)
.. code-block:: bash .. code-block:: bash
@ -652,6 +652,25 @@ Add packages in blacklist file manually from
live555 live555
faac faac
Print package description:
.. code-block:: bash
$ slpkg -p alien vlc
vlc (multimedia player for various audio and video formats)
VLC media player is a highly portable multimedia player for various
audio and video formats (MPEG-1, MPEG-2, MPEG-4, DivX, mp3, ogg, ...)
as well as DVDs, VCDs, and various streaming protocols.
It can also be used as a server to stream in unicast or multicast in
IPv4 or IPv6 on a high-bandwidth network.
vlc home: http://www.videolan.org/vlc/
Man page it is available for full support: Man page it is available for full support:
.. code-block:: bash .. code-block:: bash

15
TESTING Normal file
View file

@ -0,0 +1,15 @@
Slpkg testing log:
The majority of trials have been made in an environment Slackware x86_64 and x86 stable version
14.1.
Is logical tests are always to be latest versions of the distribution.
Slpkg are supported version 'current' but it is minimal tests have been done on this release.
TEST:
Distribution : Slackware Linux
Release : 14.1
Version : stable
Arch : x86, x86_64

48
conf/slpkg.conf Normal file
View file

@ -0,0 +1,48 @@
# Configuration file for slpkg
# slpkg.conf 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/>.
# Slackware version 'stable' or 'current'.
VERSION=stable
# Build directory for repository slackbuilds.org. In this directory
# downloaded sources and scripts for building.
BUILD=/tmp/slpkg/build/
# If SBO_CHECK_MD5 is 'on' the system will check all downloaded
# sources from SBo repository.
SBO_CHECK_MD5=on
# Download directory for others repositories that use binaries files
# for installation.
PACKAGES=/tmp/slpkg/packages/
# Download directory for Slackware patches file.
PATCHES=/tmp/slpkg/patches/
# Delete all downloaded files if DEL_ALL is 'on'.
DEL_ALL=on
# Delete build directory after each process if DEL_BUILD is 'on'.
DEL_BUILD=off
# Keep build log file if SBO_BUILD_LOG is 'on'.
SBO_BUILD_LOG=on

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.4} VERSION=${VERSION:-2.0.5}
TAG=${TAG:-_dsw} TAG=${TAG:-_dsw}
cd .. cd ..

View file

@ -15,14 +15,17 @@
.SH NAME .SH NAME
slpkg - Utility for easy management packages in Slackware slpkg - Utility for easy management packages in Slackware
.SH SYNOPSIS .SH SYNOPSIS
\fBUsage: slpkg [-h] [-v] [-a script [sources...]] \fBUsage: slpkg [-h] [-v] [-a script.tar.gz [sources...]]
[-b --list, --add, --remove [...]] [-b --list, --add, --remove [...]]
[-q --list, [...] --add, --remove] [-q --list, [...] --add, --remove]
[-q --build, --install, --build-install] [ --build, --install, --build-install]
[-l all, sbo, slack, noarch] [-g --config, --config=[editor]]
[-c <repository> --upgrade --current] [-l [repository], all, noarch]
[-s <repository> <package> --current] [-c [repository] --upgrade]
[-f] [-t] [-n] [-i [...]] [-u [...]] [-s [repository] [package][
[-t [repository] [package]]
[-p [repository] [package] --color=]
[-f] [-n] [-i [...]] [-u [...]]
[-o [...]] [-r [...]] [-d [...]]\fp [-o [...]] [-r [...]] [-d [...]]\fp
.SH DESCRIPTION .SH DESCRIPTION
@ -30,35 +33,32 @@ slpkg - Utility for easy management packages in Slackware
.PP .PP
It's a quick and easy way to manage your packages in slackware to a command. It's a quick and easy way to manage your packages in slackware to a command.
.SH EXAMPLES .SH EXAMPLES
\fBUtility for easy management packages in Slackware \fB
Utility for easy management packages in Slackware
Optional arguments: Optional arguments:
-h, --help show this help message and exit -h, --help show this help message and exit
-v, --version print version and exit -v, --version print version and exit
-a, script [source...] auto build packages -a, script.tar.gz [source...] auto build SBo packages
-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 SBo packages in queue
--build, --install, --build-install build or install from queue --build, --install, --build-install build or install packages from queue
-l, <repository>, all, noarch list of installed packages -g, --config, --config=<editor> configuration file management
-c, <repository> --upgrade --current check for updated packages -l, [repository], all, noarch list of installed packages
-s, <repository> <package> --current download, build & install -c, [repository] --upgrade check for updated packages
-f, <package> find installed packages -s, [repository] [package] download, build & install
-t, <package> tracking dependencies from SBo -t, [repository] [package] tracking dependencies
-n, <package> view packages from SBo -p, [repository] [package] --color=[] print package description
-i, [package...] install binary packages -f, [package] find installed packages
-u, [package...] upgrade binary packages -n, [package] view packages from SBo
-o, [package...] reinstall binary packages -i, [package...] install binary packages
-r, [package...] remove binary packages -u, [package...] upgrade binary packages
-d, [package...] display the contents -o, [package...] reinstall binary packages
-r, [package...] remove binary packages
-d, [package...] display the contents
Note: '-q' options is working only for SBo repository Repositories: <slack, sbo, alien, slacky, rlw>
Colors = [red, green, yellow, cyan, grey]\fP
Repositories:
Slackware = slack '--current'
Alien = alien '--current'
SlackBuilds = sbo
Slacky = slacky
Robby's = rlw\fP
.SH GLOBAL OPTIONS .SH GLOBAL OPTIONS
.TP .TP
@ -67,59 +67,77 @@ Print the version of program and exit.
.SH COMMANDS .SH COMMANDS
.PP .PP
The following commands are available. The following commands are available.
.SS -a script source extra
.SS -a, auto build packages
\fBslpkg\fP \fB-a\fP <\fIscript\fP> <\fIsources\fP> \fBslpkg\fP \fB-a\fP <\fIscript\fP> <\fIsources\fP>
.PP .PP
With this argument, build slackware package from source quickly and easy. With this argument, build slackware package from source quickly and easy.
.SS -b , --list <packages> -- add --remove
.SS -b , add, remove, view packages in blacklist
\fBslpkg\fP \fB-b\fP \fB--list\fP <\fIpackages\fP> \fB--add\fP \fB--remove\fP \fBslpkg\fP \fB-b\fP \fB--list\fP <\fIpackages\fP> \fB--add\fP \fB--remove\fP
.PP .PP
List, add or remove packages from blacklist file. The settings here affect List, add or remove packages from blacklist file. The settings here affect
all repositories. all repositories.
.SS -q , --list <packages> --add, --remove, --build, --install, --build-install
.SS -q , add, remove, view packages in queue
\fBslpkg\fP \fB-q\fP \fB--list\fP <\fIpackages\fP> \fB--add\fP \fB--remove\fP \fBslpkg\fP \fB-q\fP \fB--list\fP <\fIpackages\fP> \fB--add\fP \fB--remove\fP
.TP
\fBslpkg\fP \fB-q\fP \fB--build\fP \fB--install\fP \fB--build-install\fP
.PP .PP
List, add, or remove sbo packages from queue. If you want to remove all the packages List, add, or remove sbo packages from queue. If you want to remove all the packages
from the list 'slpkg -q all --remove'. (these arguments only working for the sbo repository) from the list 'slpkg -q all --remove'. (these arguments only working for the sbo repository)
.PP
\fBslpkg\fP \fB-q\fP \fB--build\fP \fB--install\fP \fB--build-install\fP
.PP
Build or install or build and install packages are queued. Build or install or build and install packages are queued.
.SS -l all, sbo, slack, noarch
\fBslpkg\fP \fB-l\fP \fIall\fP \fIsbo\fP \fIslack\fP \fInoarch\fP .SS -g , configuration file management
\fBslpkg\fP \fB--config\fP \fB--config=[editor]\fP
.PP .PP
Four display options list, sbo, slack, noarch and all packages Print configuration file or edit with editor.
items that are installed on the system.
.SS -c , <repository> check if your packages is up to date .SS -l , list of installed packages per repository
\fBslpkg\fP \fB-c\fP <\fIrepository\fP> \fI--upgrade\fP \fB--current\fP \fBslpkg\fP \fB-l\fP <\fIrepository\fP> \fIall\fP \fInoarch\fP
.PP .PP
Check your packages from Slackware official mirrors or from List of installed packages per repository or all.
slackbuilds.org is up to date. Use '--current' to switch in current repository.
.SS -s , <repository> download, build and install package with all dependencies .SS -c , check if your packages is up to date
\fBslpkg\fP \fB-s\fP <\fIrepository\fP> <\fIname of package\fP> \fB--current\fP \fBslpkg\fP \fB-c\fP <\fIrepository\fP> \fI--upgrade\f
.PP .PP
Installs or upgrade packages from the repository slackbuilds.org automatically resolving all Check your packages is up to date.
.SS -s , download, build and install package with all dependencies
\fBslpkg\fP \fB-s\fP <\fIrepository\fP> <\fIname of package\fP>
.PP
Installs or upgrade packages from the repositories with automatically resolving all
dependencies of the package. Also installs the official distribution Slackware dependencies of the package. Also installs the official distribution Slackware
packages. Use '--current' to install packages from Slackware current repository. packages.
.SS -t , tracking dependencies
\fBslpkg\fP \fB-t\fP <\fIrepository\fP> <\fIname of package\fP>
.PP
Tracking all dependencies of that package.
The sequence shown is that you must follow to correctly install package.
.SS -p , print packages description
\fBslpkg\fP \fB-p\fP <\fIrepository\fP> <\fIname of package\fP>
.PP
Print package description
.SS -f find packages .SS -f find packages
\fBslpkg\fP \fB-f\fP <\fIname of package\fP> \fBslpkg\fP \fB-f\fP <\fIname of package\fP>
.PP .PP
Find installed packages with view total file size. Find installed packages with view total file size.
.SS -t , tracking dependencies
\fBslpkg\fP \fB-t\fP <\fIname of package\fP>
.PP
Tracking all dependencies of that package.
The sequence shown is that you must follow to correctly install package.
.SS -n , find packages from SBo repositority .SS -n , find packages from SBo repositority
\fBslpkg\fP \fB-n\fP <\fIname of package\fP> \fBslpkg\fP \fB-n\fP <\fIname of package\fP>
.PP .PP
With this method you can find the SBo script that interests you through With this method you can find the SBo script that interests you through
the network. (www.slackbuilds.org) the network. (www.slackbuilds.org)
.SS -i , install binary packages .SS -i , install binary packages
\fBslpkg\fP \fB-i\fP <\fIpackages.t?z\fP> \fBslpkg\fP \fB-i\fP <\fIpackages.t?z\fP>
.PP .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 , install-upgrade packages with new .SS -u , install-upgrade packages with new
\fBslpkg\fP \fB-u\fP <\fIpackages.t?z\fP> \fBslpkg\fP \fB-u\fP <\fIpackages.t?z\fP>
.PP .PP
@ -127,6 +145,7 @@ Normally upgrade only upgrades packages that are already
installed on the system, and will skip any packages that do not installed on the system, and will skip any packages that do not
already have a version installed. 'Requires root privileges' already have a version installed. 'Requires root privileges'
(like slackware command upgradepkg --install-new) (like slackware command upgradepkg --install-new)
.SS -o , reinstall binary packages .SS -o , reinstall binary packages
\fBslpkg\fP \fB-o\fP <\fIpackages.t?z\fP> \fBslpkg\fP \fB-o\fP <\fIpackages.t?z\fP>
.PP .PP
@ -134,6 +153,7 @@ Upgradepkg usually skips packages if the exact same package
(matching name, version, arch, and build number) is already (matching name, version, arch, and build number) is already
installed on the system.'Requires root privileges' (like installed on the system.'Requires root privileges' (like
slackware command upgradepkg --reinstall) slackware command upgradepkg --reinstall)
.SS -r , remove packages .SS -r , remove packages
\fBslpkg\fP \fB-r\fP <\fIname of packages\fP> \fBslpkg\fP \fB-r\fP <\fIname of packages\fP>
.PP .PP
@ -145,16 +165,37 @@ packages with command 'slpkg -s sbo <package>' then write a file
in /var/log/slpkg/dep/ with all dependencies and it allows you in /var/log/slpkg/dep/ with all dependencies and it allows you
can remove them all together. 'Requires root can remove them all together. 'Requires root
privileges' (like slackware command removepkg) privileges' (like slackware command removepkg)
.SS -d , display contents .SS -d , display contents
\fBslpkg\fP \fB-d\fP <\fIname of packages\fP> \fBslpkg\fP \fB-d\fP <\fIname of packages\fP>
.PP .PP
Display the contents of the package with all descriptions. Display the contents of the package with all descriptions.
.SH HELP OPTION .SH HELP OPTION
Specifying the help option displays help for slpkg itself, or a Specifying the help option displays help for slpkg itself, or a
command. command.
.br .br
For example: For example:
\fBslpkg \-\-help\fP - display help for slpkg \fBslpkg \-\-help\fP - display help for slpkg
.SH FILES
/etc/slpkg/slpkg.conf
General configuration of slpkg
/etc/slpkg/blacklist
List of packages to skip
/var/log/slpkg
ChangeLog.txt repositories files
SlackBuilds logs and dependencies files
/var/lib/slpkg
PACKAGES.TXT files and SLACKBUILDS.TXT file
/tmp/slpkg
Slpkg temponary donwloaded files and build packages
.SH AUTHOR .SH AUTHOR
Dimitris Zlatanidis <d.zlatanidis@gmail.com> Dimitris Zlatanidis <d.zlatanidis@gmail.com>
.SH HOMEPAGE .SH HOMEPAGE
@ -163,4 +204,5 @@ https://github.com/dslackw/slpkg
Copyright \(co 2014 Dimitris Zlatanidis Copyright \(co 2014 Dimitris Zlatanidis
.SH SEE ALSO .SH SEE ALSO
installpkg(8), upgradepkg(8), removepkg(8), pkgtool(8), slackpkg(8) installpkg(8), upgradepkg(8), removepkg(8), pkgtool(8), slackpkg(8), explodepkg(8),
makepkg(8).

View file

@ -79,9 +79,17 @@ if "install" in sys.argv:
f_in.close() f_in.close()
shutil.copy2(gzip_man, man_path) shutil.copy2(gzip_man, man_path)
os.chmod(man_path, int("444", 8)) os.chmod(man_path, int("444", 8))
conf_path = "/etc/slpkg/" conf_path = "/etc/slpkg/"
conf_file = "conf/slpkg.conf"
black_file = "conf/blacklist"
if not os.path.exists(conf_path): if not os.path.exists(conf_path):
os.system("mkdir -p {0}".format(conf_path)) os.system("mkdir -p {0}".format(conf_path))
# slpkg.conf file
if not os.isfile(conf_path + conf_file):
print("Installing slpkg configuration file")
shutil.copy2(conf_file, conf_path)
# blacklist file
if not os.isfile(conf_path + black_file):
print("Installing blacklist configuration file") print("Installing blacklist configuration file")
black_file = "conf/blacklist"
shutil.copy2(black_file, conf_path) shutil.copy2(black_file, conf_path)

View file

@ -1,3 +1,15 @@
config() {
NEW="$1"
OLD="$(dirname $NEW)/$(basename $NEW .new)"
if [ ! -r $OLD ]; then
mv $NEW $OLD
elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
rm $NEW
fi
}
config /etc/slpkg/slpkg.conf.new
if [ -x /usr/bin/update-desktop-database ]; then if [ -x /usr/bin/update-desktop-database ]; then
/usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1 /usr/bin/update-desktop-database -q usr/share/applications >/dev/null 2>&1
fi fi

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.4} VERSION=${VERSION:-2.0.5}
BUILD=${BUILD:-1} BUILD=${BUILD:-1}
TAG=${TAG:-_dsw} TAG=${TAG:-_dsw}
@ -69,7 +69,7 @@ find -L . \
\( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
-o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
# avoid install man page and blacklist over setup.py # avoid install man page and slpkg.conf, blacklist over setup.py
sed -i 's/if "install"/if ""/' setup.py sed -i 's/if "install"/if ""/' setup.py
python setup.py install --root=$PKG python setup.py install --root=$PKG
@ -77,19 +77,24 @@ python setup.py install --root=$PKG
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
mkdir -p $PKG/etc/slpkg
# check if blacklist file if already exist in /etc/slpkg # check if blacklist file if already exist in /etc/slpkg
if [ ! -f "/etc/$PRGNAM/blacklist" ]; then if [ ! -f "/etc/$PRGNAM/blacklist" ]; then
mkdir -p $PKG/etc/$PRGNAM mkdir -p $PKG/etc/$PRGNAM
install -D -m0644 conf/blacklist $PKG/etc/$PRGNAM/blacklist install -D -m0644 conf/blacklist $PKG/etc/$PRGNAM/blacklist
fi fi
# install configuration file
mkdir -p $PKG/etc/slpkg
install -D -m0644 conf/slpkg.conf $PKG/etc/slpkg/slpkg.conf.new
# install man page # install man page
mkdir -p $PKG/usr/man/man8 mkdir -p $PKG/usr/man/man8
gzip -9 man/$PRGNAM.8 gzip -9 man/$PRGNAM.8
install -D -m0644 man/$PRGNAM.8.gz $PKG/usr/man/man8/$PRGNAM.8.gz install -D -m0644 man/$PRGNAM.8.gz $PKG/usr/man/man8/$PRGNAM.8.gz
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a README.rst CHANGELOG LICENSE CONTRIBUTING ISSUES $PKG/usr/doc/$PRGNAM-$VERSION cp -a README.rst CHANGELOG LICENSE TESTING ISSUES $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install mkdir -p $PKG/install

View file

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

View file

@ -22,38 +22,93 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import os import os
import getpass
from config import config_file
from messages import s_user
__all__ = "slpkg" __all__ = "slpkg"
__author__ = "dslackw" __author__ = "dslackw"
__version_info__ = (2, 0, 4) __version_info__ = (2, 0, 5)
__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"
''' file spacer ''' s_user(getpass.getuser())
# temponary path
tmp = "/tmp/"
if not os.path.exists("/etc/slpkg/"):
os.mkdir("/etc/slpkg/")
if not os.path.isfile("/etc/slpkg/slpkg.conf"):
with open("/etc/slpkg/slpkg.conf", "w") as conf:
for line in config_file():
conf.write(line)
conf.close()
f = open("/etc/slpkg/slpkg.conf", "r")
conf = f.read()
f.close()
# Default configuration values
slack_rel = "stable"
build_path = "/tmp/slpkg/build/"
slpkg_tmp_packages = tmp + "slpkg/packages/"
slpkg_tmp_patches = tmp + "slpkg/patches/"
del_all = "on"
sbo_check_md5 = "on"
del_build = "off"
sbo_build_log = "on"
for line in conf.splitlines():
line = line.lstrip()
if line.startswith("VERSION"):
slack_rel = line[8:].strip()
if not slack_rel:
slack_rel = "stable"
if line.startswith("BUILD"):
build_path = line[6:].strip()
if line.startswith("PACKAGES"):
slpkg_tmp_packages = line[9:].strip()
if line.startswith("PATCHES"):
slpkg_tmp_patches = line[8:].strip()
if line.startswith("DEL_ALL"):
del_all = line[8:].strip()
if line.startswith("DEL_BUILD"):
del_build = line[10:].strip()
if line.startswith("SBO_CHECK_MD5"):
sbo_check_md5 = line[14:].strip()
if line.startswith("SBO_BUILD_LOG"):
sbo_build_log = line[14:].strip()
# repositories
repositories = [
"sbo",
"slack",
"rlw",
"alien",
"slacky"
]
# file spacer
sp = "-" sp = "-"
''' current path ''' # current path
path = os.getcwd() + "/" path = os.getcwd() + "/"
''' build path ''' # library path
build_path = path + "slpkg_Build/"
''' library path '''
lib_path = "/var/lib/slpkg/" lib_path = "/var/lib/slpkg/"
''' log path ''' # log path
log_path = "/var/log/slpkg/" log_path = "/var/log/slpkg/"
''' temponary path ''' # packages log files path
tmp = "/tmp/"
slpkg_tmp = tmp + "slpkg/"
''' packages log files path '''
pkg_path = "/var/log/packages/" pkg_path = "/var/log/packages/"
''' blacklist conf path ''' # blacklist conf path
bls_path = "/etc/slpkg/" bls_path = "/etc/slpkg/"
''' computer architecture ''' # computer architecture
arch = os.uname()[4] arch = os.uname()[4]

View file

@ -27,40 +27,37 @@ from __metadata__ import __version__
def options(): def options():
arguments = [ arguments = [
"slpkg - version {0}\n".format(__version__), "\nslpkg - version {0}\n".format(__version__),
"Utility for easy management packages in Slackware\n", "Utility for easy management packages in Slackware\n",
"Optional arguments:", "Optional arguments:",
" -h, --help show this help message " + " -h, --help show this help message " +
"and exit", "and exit",
" -v, --version print version and exit", " -v, --version print version and exit",
" -a, script [source...] auto build packages", " -a, script.tar.gz [source...] auto build SBo packages",
" -b, --list, [package...] --add, --remove add, remove packages in " + " -b, --list, [package...] --add, --remove add, remove packages in " +
"blacklist", "blacklist",
" -q, --list, [package...] --add, --remove add, remove packages in " + " -q, --list, [package...] --add, --remove add, remove SBo packages "
"queue", "in queue",
" --build, --install, --build-install build or install from " + " --build, --install, --build-install build or install packages "
"queue", "from queue",
" -l, <repository>, all, noarch list of installed " + " -g, --config, --config=[editor] configuration file " +
"management",
" -l, [repository], all, noarch list of installed " +
"packages", "packages",
" -c, <repository> --upgrade --current check for updated " + " -c, [repository] --upgrade check for updated " +
"packages", "packages",
" -s, <repository> <package> --current download, build & install", " -s, [repository] [package] download, build & install",
" -f, <package> find installed packages", " -t, [repository] [package] tracking dependencies",
" -t, <package> tracking dependencies " + " -p, [repository] [package] --color=[] print package description",
"from SBo", " -f, [package] find installed packages",
" -n, <package> view packages from SBo", " -n, [package] view packages from SBo",
" -i, [package...] install binary packages", " -i, [package...] install binary packages",
" -u, [package...] upgrade binary packages", " -u, [package...] upgrade binary packages",
" -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: <slack, sbo, alien, slacky, rlw>",
"Repositories:", "Colors = [red, green, yellow, cyan, grey]\n",
" Slackware = slack '--current'",
" Alien = alien '--current'",
" SlackBuilds = sbo",
" Slacky = slacky",
" Robby's = rlw\n"
] ]
for opt in arguments: for opt in arguments:
print(opt) print(opt)
@ -69,14 +66,17 @@ def options():
def usage(): def usage():
view = [ view = [
"slpkg - version {0}\n".format(__version__), "slpkg - version {0}\n".format(__version__),
"Usage: slpkg [-h] [-v] [-a script [sources...]]", "Usage: slpkg [-h] [-v] [-a script.tar.gz [sources...]]",
" [-b --list, [...] --add, --remove]", " [-b --list, [...] --add, --remove]",
" [-q --list, [...] --add, --remove]", " [-q --list, [...] --add, --remove]",
" [-q --build, --install, --build-install]", " [ --build, --install, --build-install]",
" [-l all, sbo, slack, noarch]", " [-g --config, --config=[editor]]",
" [-c <repository> --upgrade --current]", " [-l [repository], all, noarch]",
" [-s <repository> <package> --current]", " [-c [repository] --upgrade]",
" [-f] [-t] [-n] [-i [...]] [-u [...]]", " [-s [repository] [package]",
" [-t [repository] [package]",
" [-p [repository] [package] --color=[]]",
" [-f] [-n] [-i [...]] [-u [...]]",
" [-o [...]] [-r [...]] [-d [...]]\n", " [-o [...]] [-r [...]] [-d [...]]\n",
"For more information try 'slpkg --help'\n" "For more information try 'slpkg --help'\n"
] ]

View file

@ -24,7 +24,11 @@
import os import os
from __metadata__ import bls_path from __metadata__ import bls_path
from colors import RED, GREEN, ENDC from colors import (
RED,
GREEN,
ENDC
)
class BlackList(object): class BlackList(object):
@ -109,7 +113,7 @@ class BlackList(object):
print("{0}{1}{2}".format(GREEN, black, ENDC)) print("{0}{1}{2}".format(GREEN, black, ENDC))
self.quit = True self.quit = True
if self.quit: if self.quit:
print # new line at exit print("") # new line at exit
def add(self, pkgs): def add(self, pkgs):
''' '''
@ -126,7 +130,7 @@ class BlackList(object):
self.quit = True self.quit = True
black_conf.close() black_conf.close()
if self.quit: if self.quit:
print # new line at exit print("") # new line at exit
def remove(self, pkgs): def remove(self, pkgs):
''' '''
@ -142,4 +146,4 @@ class BlackList(object):
self.quit = True self.quit = True
remove.close() remove.close()
if self.quit: if self.quit:
print # new line at exit print("") # new line at exit

133
slpkg/config.py Executable file
View file

@ -0,0 +1,133 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# config.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 subprocess
from colors import (
CYAN,
ENDC
)
def config_file():
slpkg_conf = [
"# Configuration file for slpkg\n",
"\n",
"# slpkg.conf file is part of slpkg.\n",
"\n",
"# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>\n",
"# All rights reserved.\n",
"\n",
"# Utility for easy management packages in Slackware\n",
"\n",
"# https://github.com/dslackw/slpkg\n",
"\n",
"# Slpkg is free software: you can redistribute it and/or modify\n",
"# it under the terms of the GNU General Public License as published " +
"by\n",
"# the Free Software Foundation, either version 3 of the License, or\n",
"# (at your option) any later version.\n",
"# This program is distributed in the hope that it will be useful,\n",
"# but WITHOUT ANY WARRANTY; without even the implied warranty of\n",
"# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n",
"# GNU General Public License for more details.\n",
"# You should have received a copy of the GNU General Public License\n",
"# along with this program. If not, see <http://www.gnu.org/licenses/" +
">.\n",
"\n",
"# Slackware version 'stable' or 'current'.\n",
"VERSION=stable\n",
"\n",
"# Build directory for repository slackbuilds.org. In this directory\n",
"# downloaded sources and scripts for building.\n",
"BUILD=/tmp/slpkg/build/\n",
"\n",
"# If SBO_CHECK_MD5 is 'on' the system will check all downloaded\n",
"# sources from SBo repository.\n",
"SBO_CHECK_MD5=on\n",
"\n",
"# Download directory for others repositories that use binaries files" +
"\n",
"# for installation.\n",
"PACKAGES=/tmp/slpkg/packages/\n",
"\n",
"# Download directory for Slackware patches file.\n",
"PATCHES=/tmp/slpkg/patches/\n",
"\n",
"# Delete all downloaded files if DEL_ALL is 'on'.\n",
"DEL_ALL=on\n",
"\n",
"# Delete build directory after each process if DEL_BUILD is 'on'.\n",
"DEL_BUILD=off\n",
"\n",
"# Keep build log file if SBO_BUILD_LOG is 'on'.\n",
"SBO_BUILD_LOG=on\n"
]
if not os.path.exists("/etc/slpkg"):
os.mkdir("/etc/slpkg")
if not os.path.isfile("/etc/slpkg/slpkg.conf"):
with open("/etc/slpkg/slpkg.conf", "w") as conf:
for line in slpkg_conf:
conf.write(line)
conf.close()
return slpkg_conf
class Config(object):
def __init__(self):
self.config_file = "/etc/slpkg/slpkg.conf"
def view(self):
'''
View slpkg config file
'''
print("") # new line at start
conf_args = [
'VERSION',
'BUILD',
'SBO_CHECK_MD5',
'PACKAGES',
'PATCHES',
'DEL_ALL',
'DEL_BUILD',
'SBO_BUILD_LOG'
]
f = open(self.config_file, "r")
read_conf = f.read()
f.close()
for line in read_conf.splitlines():
if not line.startswith("#") and line.split("=")[0] in conf_args:
print(line)
else:
print("{0}{1}{2}".format(CYAN, line, ENDC))
print("") # new line at end
def edit(self, editor):
'''
Edit configuration file
'''
subprocess.call("{0} {1}".format(editor, self.config_file),
shell=True)

107
slpkg/desc.py Executable file
View file

@ -0,0 +1,107 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# desc.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 init import Initialization
from messages import pkg_not_found
from colors import (
RED,
GREEN,
YELLOW,
CYAN,
GREY,
ENDC
)
from __metadata__ import (
pkg_path,
lib_path,
repositories
)
from pkg.find import find_package
class PkgDesc(object):
def __init__(self, name, repo, color):
self.name = name
self.repo = repo
self.color = color
self.COLOR = ""
self.lib = ""
init_repos = {
'sbo': Initialization().sbo,
'slack': Initialization().slack,
'rlw': Initialization().rlw,
'alien': Initialization().alien,
'slacky': Initialization().slacky
}
init_repos[self.repo]()
color_text = {
'red': RED,
'green': GREEN,
'yellow': YELLOW,
'cyan': CYAN,
'grey': GREY,
'': ''
}
self.COLOR = color_text[self.color]
if self.repo in repositories:
repos = {
'sbo': 'sbo_repo/SLACKBUILDS.TXT',
'slack': 'slack_repo/PACKAGES.TXT',
'rlw': 'rlw_repo/PACKAGES.TXT',
'alien': 'alien_repo/PACKAGES.TXT',
'slacky': 'slacky_repo/PACKAGES.TXT'
}
self.lib = lib_path + repos[self.repo]
def view(self):
end, n, count = ":", 1, 0
find = "".join(find_package(self.name + '-', pkg_path))
if self.repo == "sbo" and find.endswith("_SBo"):
self.lib = pkg_path + find
elif self.repo == "sbo" and not find:
sbo_name = self.name
self.name = "SLACKBUILD SHORT DESCRIPTION: "
end = sbo_name + " ("
n = 0
f = open(self.lib, "r")
PACKAGES_TXT = f.read()
f.close()
print("") # new line at start
for line in PACKAGES_TXT.splitlines():
if line.startswith(self.name + end):
print("{0}{1}{2}".format(self.COLOR,
line[len(self.name) + n:].strip(),
ENDC))
count += 1
if count == 11:
break
if count == 0:
if self.repo == "sbo":
pkg_not_found("", sbo_name, "No matching", "\n")
else:
pkg_not_found("", self.name, "No matching", "\n")
if self.repo == "sbo" and count > 0:
print("") # new line at end

View file

@ -24,7 +24,10 @@
import sys import sys
import subprocess import subprocess
from colors import GREEN, ENDC from colors import (
GREEN,
ENDC
)
class Download(object): class Download(object):

View file

@ -43,7 +43,7 @@ class FileSize(object):
print("\nError: connection refused\n") print("\nError: connection refused\n")
sys.exit() sys.exit()
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at cancel print("") # new line at cancel
sys.exit() sys.exit()
def local(self): def local(self):

View file

@ -27,18 +27,58 @@ import sys
from url_read import URL from url_read import URL
from repositories import Repo 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,
slack_rel,
build_path,
slpkg_tmp_packages,
slpkg_tmp_patches
)
from slack.mirrors import mirrors
from slack.slack_version import slack_ver from slack.slack_version import slack_ver
class Initialization(object): class Initialization(object):
def __init__(self): def __init__(self):
if not os.path.exists("/etc/slpkg/"):
os.mkdir("/etc/slpkg/")
if not os.path.exists(log_path): if not os.path.exists(log_path):
os.mkdir(log_path) os.mkdir(log_path)
if not os.path.exists(lib_path): if not os.path.exists(lib_path):
os.mkdir(lib_path) os.mkdir(lib_path)
if not os.path.exists("/tmp/slpkg/"):
os.mkdir("/tmp/slpkg/")
if not os.path.exists(build_path):
os.mkdir(build_path)
if not os.path.exists(slpkg_tmp_packages):
os.mkdir(slpkg_tmp_packages)
if not os.path.exists(slpkg_tmp_patches):
os.mkdir(slpkg_tmp_patches)
def slack(self):
'''
Creating slack local libraries
'''
log = log_path + "slack/"
lib = lib_path + "slack_repo/"
lib_file = "PACKAGES.TXT"
log_file = "ChangeLog.txt"
version = slack_rel
if not os.path.exists(log):
os.mkdir(log)
if not os.path.exists(lib):
os.mkdir(lib)
packages = mirrors(lib_file, "", version)
extra = mirrors(lib_file, "extra/", version)
pasture = mirrors(lib_file, "pasture/", version)
packages_txt = ("{0} {1} {2}".format(packages, extra, pasture))
changelog_txt = mirrors(log_file, "", version)
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)
def sbo(self): def sbo(self):
''' '''
@ -127,11 +167,13 @@ class Initialization(object):
''' '''
Write files in /var/lib/slpkg/?_repo directory Write files in /var/lib/slpkg/?_repo directory
''' '''
PACKAGES_TXT = ""
if not os.path.isfile(path + files): if not os.path.isfile(path + files):
print("\nslpkg ...initialization") print("\nslpkg ...initialization")
sys.stdout.write(files + " read ...") sys.stdout.write(files + " read ...")
sys.stdout.flush() sys.stdout.flush()
PACKAGES_TXT = URL(file_url).reading() for fu in file_url.split():
PACKAGES_TXT += URL(fu).reading()
sys.stdout.write("Done\n") sys.stdout.write("Done\n")
with open("{0}{1}".format(path, files), "w") as f: with open("{0}{1}".format(path, files), "w") as f:
f.write(PACKAGES_TXT) f.write(PACKAGES_TXT)
@ -147,6 +189,7 @@ class Initialization(object):
If the two files differ in size delete and replaced with new. If the two files differ in size delete and replaced with new.
We take the size of ChangeLog.txt from the server and locally We take the size of ChangeLog.txt from the server and locally
''' '''
PACKAGES_TXT = ""
server = FileSize(args[2]).server() server = FileSize(args[2]).server()
local = FileSize(args[0] + args[1]).local() local = FileSize(args[0] + args[1]).local()
if server != local: if server != local:
@ -156,7 +199,8 @@ class Initialization(object):
print("slpkg ...initialization") print("slpkg ...initialization")
sys.stdout.write("Files re-created ...") sys.stdout.write("Files re-created ...")
sys.stdout.flush() sys.stdout.flush()
PACKAGES_TXT = URL(args[5]).reading() for fu in args[5].split():
PACKAGES_TXT += URL(fu).reading()
CHANGELOG_TXT = URL(args[2]).reading() CHANGELOG_TXT = URL(args[2]).reading()
with open("{0}{1}".format(args[3], args[4]), "w") as f: with open("{0}{1}".format(args[3], args[4]), "w") as f:
f.write(PACKAGES_TXT) f.write(PACKAGES_TXT)

View file

@ -24,19 +24,25 @@
import sys import sys
import getpass import getpass
from desc import PkgDesc
from config import Config
from queue import QueuePkgs from queue import QueuePkgs
from messages import s_user from messages import s_user
from __metadata__ import path from tracking import track_dep
from blacklist import BlackList from blacklist import BlackList
from version import prog_version from version import prog_version
from arguments import options, usage from arguments import options, usage
from __metadata__ import (
path,
repositories,
slack_rel
)
from pkg.build import BuildPackage from pkg.build import BuildPackage
from pkg.manager import PackageManager from pkg.manager import PackageManager
from sbo.check import SBoCheck from sbo.check import SBoCheck
from sbo.views import SBoNetwork from sbo.views import SBoNetwork
from sbo.tracking import track_dep
from sbo.slackbuild import SBoInstall from sbo.slackbuild import SBoInstall
from slack.install import Slack from slack.install import Slack
@ -45,15 +51,51 @@ from others.check import OthersUpgrade
from others.install import OthersInstall from others.install import OthersInstall
class Case(object):
def __init__(self, package):
self.package = package
self.release = slack_rel
def sbo_install(self):
SBoInstall(self.package).start()
def slack_install(self):
Slack(self.package, self.release).start()
def rlw_install(self):
OthersInstall(self.package, "rlw", self.release).start()
def alien_install(self):
OthersInstall(self.package, "alien", self.release).start()
def slacky_install(self):
OthersInstall(self.package, "slacky", self.release).start()
def sbo_upgrade(self):
SBoCheck().start()
def slack_upgrade(self):
Patches(self.release).start()
def rlw_upgrade(self):
OthersUpgrade("rlw", self.release).start()
def alien_upgrade(self):
OthersUpgrade("alien", self.release).start()
def slacky_upgrade(self):
OthersUpgrade("slacky", self.release).start()
def main(): def main():
# root privileges required
# repositories = ["sbo", "slack", "rlw", "alien", "slacky"]
s_user(getpass.getuser()) s_user(getpass.getuser())
args = sys.argv args = sys.argv
args.pop(0) args.pop(0)
repository = ["sbo", "slack", "rlw", "alien", "slacky"]
blacklist = BlackList() blacklist = BlackList()
queue = QueuePkgs() queue = QueuePkgs()
if len(args) == 0: if len(args) == 0:
usage() usage()
elif (len(args) == 1 and args[0] == "-h" or elif (len(args) == 1 and args[0] == "-h" or
@ -65,54 +107,40 @@ 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":
pkg_list = ["all", "noarch"] + repository pkg_list = ["all", "noarch"] + repositories
if args[1] in pkg_list: if args[1] in pkg_list:
PackageManager(None).list(args[1]) PackageManager(None).list(args[1])
else: else:
usage() usage()
elif len(args) == 3 and args[0] == "-c": elif len(args) == 3 and args[0] == "-c" and args[2] == "--upgrade":
if args[1] == repository[0] and args[2] == "--upgrade": pkg = Case("")
SBoCheck().start() upgrade = {
elif args[1] == repository[1] and args[2] == "--upgrade": "sbo": pkg.sbo_upgrade,
version = "stable" "slack": pkg.slack_upgrade,
Patches(version).start() "rlw": pkg.rlw_upgrade,
elif args[1] == repository[2] and args[2] == "--upgrade": "alien": pkg.alien_upgrade,
OthersUpgrade(repository[2], "").start() "slacky": pkg.slacky_upgrade
elif args[1] == repository[3] and args[2] == "--upgrade": }
OthersUpgrade(repository[3], "").start() if args[1] in repositories:
elif args[1] == repository[4] and args[2] == "--upgrade": upgrade[args[1]]()
OthersUpgrade(repository[4], "").start()
else:
usage()
elif len(args) == 4 and args[0] == "-c":
if args[1] == repository[1] and args[3] == "--current":
Patches("current").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":
if args[1] == repository[0]: pkg = Case(args[2])
SBoInstall(args[2]).start() if args[1] in repositories:
elif args[1] == repository[1]: install = {
Slack(args[2], "stable").start() "sbo": pkg.sbo_install,
elif args[1] == repository[2]: "slack": pkg.slack_install,
OthersInstall(args[2], repository[2], "").start() "rlw": pkg.rlw_install,
elif args[1] == repository[3]: "alien": pkg.alien_install,
OthersInstall(args[2], repository[3], "").start() "slacky": pkg.slacky_install
elif args[1] == repository[4]: }
OthersInstall(args[2], repository[4], "").start() install[args[1]]()
else: else:
usage() usage()
elif len(args) == 4 and args[0] == "-s": elif len(args) == 3 and args[0] == "-t" and args[1] in ["sbo", "alien",
if args[1] == repository[1] and args[3] == "--current": "rlw", "slacky"]:
Slack(args[2], "current").start() track_dep(args[2], args[1])
elif args[1] == repository[3] and args[3] == "--current":
OthersInstall(args[2], repository[3], "current").start()
else:
usage()
elif len(args) == 2 and args[0] == "-t":
track_dep(args[1])
elif len(args) == 2 and args[0] == "-n": elif len(args) == 2 and args[0] == "-n":
SBoNetwork(args[1]).view() SBoNetwork(args[1]).view()
elif len(args) == 2 and args[0] == "-b" and args[1] == "--list": elif len(args) == 2 and args[0] == "-b" and args[1] == "--list":
@ -144,8 +172,25 @@ def main():
PackageManager(args[1:]).remove() PackageManager(args[1:]).remove()
elif len(args) > 1 and args[0] == "-f": elif len(args) > 1 and args[0] == "-f":
PackageManager(args[1:]).find() PackageManager(args[1:]).find()
elif len(args) == 3 and args[0] == "-p" and args[1] in repositories:
PkgDesc(args[2], args[1], "").view()
elif len(args) == 4 and args[0] == "-p" and args[3].startswith("--color="):
colors = ['red', 'green', 'yellow', 'cyan', 'grey']
tag = args[3][len("--color="):]
if args[1] in repositories and tag in colors:
PkgDesc(args[2], args[1], tag).view()
else:
usage()
elif len(args) > 1 and args[0] == "-d": elif len(args) > 1 and args[0] == "-d":
PackageManager(args[1:]).display() PackageManager(args[1:]).display()
elif len(args) == 2 and args[0] == "-g" and args[1].startswith("--config"):
editor = args[1][len("--config="):]
if args[1] == "--config":
Config().view()
elif editor:
Config().edit(editor)
else:
usage()
else: else:
usage() usage()

View file

@ -22,7 +22,12 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
import sys import sys
from colors import RED, CYAN, ENDC
from colors import (
RED,
CYAN,
ENDC
)
def pkg_not_found(bol, pkg, message, eol): def pkg_not_found(bol, pkg, message, eol):

View file

@ -30,9 +30,16 @@ from slpkg.messages import template
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from slpkg.init import Initialization from slpkg.init import Initialization
from slpkg.splitting import split_package from slpkg.splitting import split_package
from slpkg.colors import YELLOW, GREY, ENDC from slpkg.colors import (
from slpkg.__metadata__ import slpkg_tmp, pkg_path, lib_path YELLOW,
GREY,
ENDC
)
from slpkg.__metadata__ import (
pkg_path,
lib_path,
slpkg_tmp_packages
)
from slpkg.pkg.manager import PackageManager from slpkg.pkg.manager import PackageManager
@ -48,7 +55,7 @@ class OthersUpgrade(object):
def __init__(self, repo, version): def __init__(self, repo, version):
self.repo = repo self.repo = repo
self.version = version self.version = version
self.tmp_path = slpkg_tmp + "packages/" self.tmp_path = slpkg_tmp_packages
self.repo_init() self.repo_init()
repos = Repo() repos = Repo()
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC)) sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
@ -78,10 +85,6 @@ class OthersUpgrade(object):
''' '''
Initialization repository if only use 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 = { repository = {
'rlw': Initialization().rlw, 'rlw': Initialization().rlw,
'alien': Initialization().alien, 'alien': Initialization().alien,
@ -96,12 +99,12 @@ class OthersUpgrade(object):
try: try:
dwn_links, upgrade_all, comp_sum, uncomp_sum = self.store() dwn_links, upgrade_all, comp_sum, uncomp_sum = self.store()
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC)) sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
print # new line at start print("") # new line at start
if upgrade_all: if upgrade_all:
template(78) template(78)
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format( print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
"| Package", " " * 17, "| Package", " " * 17,
"Version", " " * 12, "New version", " " * 8,
"Arch", " " * 4, "Arch", " " * 4,
"Build", " " * 2, "Build", " " * 2,
"Repos", " " * 10, "Repos", " " * 10,
@ -123,12 +126,13 @@ class OthersUpgrade(object):
if read in ['Y', 'y']: if read in ['Y', 'y']:
upgrade_all.reverse() upgrade_all.reverse()
packages_dwn(self.tmp_path, dwn_links) packages_dwn(self.tmp_path, dwn_links)
upgrade(upgrade_all) upgrade(self.tmp_path, upgrade_all)
delete(self.tmp_path, upgrade_all) delete(self.tmp_path, upgrade_all)
else: else:
print("There are no packages for upgrade\n") print("No new updates in the repository '{0}'\n".format(
self.repo))
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()
def store(self): def store(self):
@ -209,10 +213,11 @@ def msgs(upgrade_all):
return msg_pkg return msg_pkg
def upgrade(upgrade_all): def upgrade(tmp_path, upgrade_all):
''' '''
Install or upgrade packages Install or upgrade packages
''' '''
for pkg in upgrade_all: for pkg in upgrade_all:
package = (tmp_path + pkg).split()
print("[ {0}upgrading{1} ] --> {2}".format(YELLOW, ENDC, pkg[:-4])) print("[ {0}upgrading{1} ] --> {2}".format(YELLOW, ENDC, pkg[:-4]))
PackageManager(pkg).upgrade() PackageManager(package).upgrade()

View file

@ -23,9 +23,9 @@
import sys import sys
from slpkg.colors import GREY, ENDC from slpkg.toolbar import status
from greps import repo_requires from greps import Requires
dep_results = [] dep_results = []
@ -36,18 +36,19 @@ def dependencies_pkg(name, repo):
''' '''
try: try:
dependencies = [] dependencies = []
requires = repo_requires(name, repo) requires = Requires(name, repo).get_deps()
toolbar_width, index = 2, 0
if requires: if requires:
for req in requires: for req in requires:
index += 1
toolbar_width = status(index, toolbar_width, 1)
if req: if req:
dependencies.append(req) dependencies.append(req)
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(GREY, ENDC))
sys.stdout.flush()
dependencies_pkg(dep, repo) dependencies_pkg(dep, repo)
return dep_results return dep_results
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()

View file

@ -29,6 +29,8 @@ from slpkg.splitting import split_package
from slpkg.slack.slack_version import slack_ver from slpkg.slack.slack_version import slack_ver
len_deps = 0
def repo_data(PACKAGES_TXT, step, repo, version): def repo_data(PACKAGES_TXT, step, repo, version):
''' '''
@ -103,21 +105,87 @@ def alien_filter(name, location, size, unsize, version):
return [fname, flocation, fsize, funsize] return [fname, flocation, fsize, funsize]
def repo_requires(name, repo): class Requires(object):
'''
Grap package requirements from alien repository def __init__(self, name, repo):
''' self.name = name
lib = { self.repo = repo
'alien': lib_path + "alien_repo/PACKAGES.TXT", lib = lib_path + "slack_repo/PACKAGES.TXT"
'slacky': lib_path + "slacky_repo/PACKAGES.TXT" f = open(lib, "r")
} self.SLACK_PACKAGES_TXT = f.read()
f = open(lib[repo], "r") f.close()
PACKAGES_TXT = f.read()
f.close() def get_deps(self):
for line in PACKAGES_TXT.splitlines(): '''
if line.startswith("PACKAGE NAME: "): Grap package requirements from repositories
pkg = line[14:].strip() '''
pkg_name = split_package(pkg)[0] if self.repo in ["alien", "slacky"]:
if line.startswith("PACKAGE REQUIRED: "): lib = {
if pkg_name == name: 'alien': lib_path + "alien_repo/PACKAGES.TXT",
return line[18:].strip().split(",") 'slacky': lib_path + "slacky_repo/PACKAGES.TXT"
}
f = open(lib[self.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 == self.name:
if line[17:].strip():
if self.repo == "slacky":
return self.slacky_req_fix(line)
else:
return line[18:].strip().split(",")
elif self.repo == "rlw":
# 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 self.name in dependencies.keys():
return dependencies[self.name].split()
else:
return ""
def slacky_req_fix(self, line):
'''
Fix slacky requirements because many dependencies splitting
with ',' and others with '|'
'''
slacky_deps = []
for dep in line[18:].strip().split(","):
dep = dep.split("|")
if len(dep) > 1:
for d in dep:
slacky_deps.append(d.split()[0])
dep = "".join(dep)
slacky_deps.append(dep.split()[0])
slacky_deps = self.remove_slack_deps(slacky_deps)
return slacky_deps
def remove_slack_deps(self, dependencies):
'''
Because the repository slacky mentioned packages and dependencies
that exist in the distribution Slackware, this feature is intended
to remove them and return only those needed.
'''
global len_deps
name, slacky_deps = [], []
index, toolbar_width, step = 0, 700, (len_deps * 500)
for line in self.SLACK_PACKAGES_TXT.splitlines():
index += 1
toolbar_width = status(index, toolbar_width, step)
if line.startswith("PACKAGE NAME:"):
name.append("-".join(line[15:].split("-")[:-3]))
for deps in dependencies:
if deps not in name:
slacky_deps.append(deps)
return slacky_deps

View file

@ -29,10 +29,24 @@ from slpkg.repositories import Repo
from slpkg.init import Initialization from slpkg.init import Initialization
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from slpkg.splitting import split_package from slpkg.splitting import split_package
from slpkg.messages import pkg_not_found, template from slpkg.messages import (
from slpkg.colors import RED, GREEN, CYAN, YELLOW, GREY, ENDC pkg_not_found,
from slpkg.__metadata__ import slpkg_tmp, pkg_path, lib_path, log_path template
)
from slpkg.colors import (
RED,
GREEN,
CYAN,
YELLOW,
GREY,
ENDC
)
from slpkg.__metadata__ import (
pkg_path,
lib_path,
log_path,
slpkg_tmp_packages
)
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
@ -51,7 +65,7 @@ class OthersInstall(object):
self.package = package self.package = package
self.repo = repo self.repo = repo
self.version = version self.version = version
self.tmp_path = slpkg_tmp + "packages/" self.tmp_path = slpkg_tmp_packages
self.repo_init() self.repo_init()
repos = Repo() repos = Repo()
print("\nPackages with name matching [ {0}{1}{2} ]\n".format( print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
@ -84,10 +98,10 @@ class OthersInstall(object):
''' '''
Initialization repository if only use Initialization repository if only use
''' '''
if not os.path.exists(slpkg_tmp): # initialization Slackware repository needed to compare
os.mkdir(slpkg_tmp) # slacky dependencies
if not os.path.exists(self.tmp_path): if not os.path.isfile(lib_path + "slack_repo/PACKAGES.TXT"):
os.mkdir(self.tmp_path) Initialization().slack()
repository = { repository = {
"rlw": Initialization().rlw, "rlw": Initialization().rlw,
"alien": Initialization().alien, "alien": Initialization().alien,
@ -104,7 +118,7 @@ class OthersInstall(object):
(dwn_links, install_all, comp_sum, uncomp_sum, (dwn_links, install_all, comp_sum, uncomp_sum,
matching) = self.store(dependencies) matching) = self.store(dependencies)
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC)) sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
print # new line at start print("") # new line at start
if install_all: if install_all:
template(78) template(78)
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format( print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
@ -153,7 +167,7 @@ class OthersInstall(object):
else: else:
pkg_not_found("", self.package, "No matching", "\n") pkg_not_found("", self.package, "No matching", "\n")
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()
def store(self, deps): def store(self, deps):
@ -172,7 +186,7 @@ class OthersInstall(object):
for pkg in deps: for pkg in deps:
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
data[3]): data[3]):
if name.startswith(pkg) and pkg not in black: if name.startswith(pkg + "-") and pkg not in black:
# store downloads packages by repo # store downloads packages by repo
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name)) dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
install.append(name) install.append(name)
@ -182,7 +196,7 @@ class OthersInstall(object):
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
data[3]): data[3]):
package = "".join(deps) package = "".join(deps)
if package in name and package not in BlackList().packages(): if package in name and package not in black:
# store downloads packages by repo # store downloads packages by repo
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name)) dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
install.append(name) install.append(name)
@ -227,7 +241,7 @@ def views(install_all, comp_sum, repository, dependencies):
" " * (8-len(pkg_split[2])), pkg_split[3], " " * (8-len(pkg_split[2])), pkg_split[3],
" " * (7-len(pkg_split[3])), repository, " " * (7-len(pkg_split[3])), repository,
comp, " K")) comp, " K"))
if len(dependencies) > 1 and count == 0: if len(dependencies) > 1 and len(install_all) > 1 and count == 0:
print("Installing for dependencies:") print("Installing for dependencies:")
count += 1 count += 1
return [pkg_sum, upg_sum, uni_sum] return [pkg_sum, upg_sum, uni_sum]
@ -263,18 +277,18 @@ def install(tmp_path, install_all):
PackageManager(package).upgrade() PackageManager(package).upgrade()
def repo_deps(name, repo): def resolving_deps(name, repo):
''' '''
Return package dependencies Return package dependencies
''' '''
deps = dependencies_pkg(name, repo)
requires, dependencies = [], [] requires, dependencies = [], []
sys.stdout.write("{0}Resolving dependencies ...{1}".format(GREY, ENDC))
sys.stdout.flush()
deps = dependencies_pkg(name, repo)
requires.append(name) requires.append(name)
# Create one list for all packages # Create one list for all packages
for pkg in deps: for pkg in deps:
requires += pkg requires += pkg
if repo == "slacky":
requires = slacky_req_check(name, requires)
requires.reverse() requires.reverse()
# Remove double dependencies # Remove double dependencies
for duplicate in requires: for duplicate in requires:
@ -283,59 +297,6 @@ def repo_deps(name, repo):
return dependencies 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): def write_deps(dependencies):
''' '''
Write dependencies in a log file Write dependencies in a log file

52
slpkg/others/search.py Executable file
View file

@ -0,0 +1,52 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# search.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.blacklist import BlackList
from slpkg.__metadata__ import lib_path
from slpkg.splitting import split_package
def search_pkg(name, repo):
'''
Search if package exists in PACKAGES.TXT file
and return the name.
'''
try:
blacklist = BlackList().packages()
repo_dir = {
"rlw": "rlw_repo/PACKAGES.TXT",
"alien": "alien_repo/PACKAGES.TXT",
"slacky": "slacky_repo/PACKAGES.TXT"
}
with open(lib_path + repo_dir[repo], "r") as PACKAGES_TXT:
for line in PACKAGES_TXT:
if line.startswith("PACKAGE NAME: "):
pkg_name = split_package(line[15:])[0].strip()
if name == pkg_name and name not in blacklist:
PACKAGES_TXT.close()
return pkg_name
except KeyboardInterrupt:
print("") # new line at exit
sys.exit()

View file

@ -30,9 +30,20 @@ import tarfile
import subprocess import subprocess
from slpkg.checksum import md5sum from slpkg.checksum import md5sum
from slpkg.__metadata__ import log_path from slpkg.colors import (
from slpkg.colors import RED, GREEN, ENDC RED,
from slpkg.messages import pkg_not_found, template GREEN,
ENDC
)
from slpkg.messages import (
pkg_not_found,
template
)
from slpkg.__metadata__ import (
log_path,
sbo_build_log,
sbo_check_md5
)
from slpkg.sbo.greps import SBoGrep from slpkg.sbo.greps import SBoGrep
@ -55,8 +66,6 @@ class BuildPackage(object):
os.mkdir(self.sbo_logs) os.mkdir(self.sbo_logs)
if not os.path.exists(self.build_logs): if not os.path.exists(self.build_logs):
os.mkdir(self.build_logs) os.mkdir(self.build_logs)
if os.path.isfile(self.build_logs + self.log_file):
os.remove(self.build_logs + self.log_file)
def build(self): def build(self):
''' '''
@ -72,27 +81,34 @@ class BuildPackage(object):
for src, sbo_md5 in zip(self.sources, sbo_md5_list): for src, sbo_md5 in zip(self.sources, sbo_md5_list):
# fix build sources with spaces # fix build sources with spaces
src = src.replace("%20", " ") src = src.replace("%20", " ")
check_md5(sbo_md5, src) if sbo_check_md5 == "on":
check_md5(sbo_md5, src)
shutil.copy2(src, self.prgnam) shutil.copy2(src, self.prgnam)
os.chdir(self.path + self.prgnam) os.chdir(self.path + self.prgnam)
# change permissions # change permissions
subprocess.call("chmod +x {0}.SlackBuild".format(self.prgnam), subprocess.call("chmod +x {0}.SlackBuild".format(self.prgnam),
shell=True) shell=True)
# start log write if sbo_build_log == "on":
log_head(self.build_logs, self.log_file, self.start_log_time) if os.path.isfile(self.build_logs + self.log_file):
subprocess.Popen("./{0}.SlackBuild 2>&1 | tee -a {1}{2}".format( os.remove(self.build_logs + self.log_file)
self.prgnam, self.build_logs, self.log_file), shell=True, # start log write
stdout=sys.stdout).communicate() log_head(self.build_logs, self.log_file, self.start_log_time)
sum_time = build_time(self.start_time) subprocess.Popen("./{0}.SlackBuild 2>&1 | tee -a {1}{2}".format(
# write end in log file self.prgnam, self.build_logs, self.log_file), shell=True,
log_end(self.build_logs, self.log_file, sum_time) stdout=sys.stdout).communicate()
sum_time = build_time(self.start_time)
# write end in log file
log_end(self.build_logs, self.log_file, sum_time)
print("Total build time for package {0} : {1}\n".format(
self.prgnam, sum_time))
else:
subprocess.call("./{0}.SlackBuild".format(self.prgnam,
shell=True))
os.chdir(self.path) os.chdir(self.path)
print("Total build time for package {0} : {1}\n".format(self.prgnam,
sum_time))
except (OSError, IOError): except (OSError, IOError):
pkg_not_found("\n", self.prgnam, "Wrong file", "\n") pkg_not_found("\n", self.prgnam, "Wrong file", "\n")
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()
@ -118,7 +134,7 @@ def check_md5(sbo_md5, src):
print("| MD5SUM check for {0} [ {1}PASSED{2} ]".format(src, GREEN, print("| MD5SUM check for {0} [ {1}PASSED{2} ]".format(src, GREEN,
ENDC)) ENDC))
template(78) template(78)
print # new line after pass checksum print("") # new line after pass checksum
def log_head(path, log_file, log_time): def log_head(path, log_file, log_time):

View file

@ -25,9 +25,22 @@ import os
import sys import sys
import subprocess import subprocess
from slpkg.messages import pkg_not_found, template from slpkg.messages import (
from slpkg.colors import RED, GREEN, CYAN, GREY, ENDC pkg_not_found,
from slpkg.__metadata__ import pkg_path, sp, log_path template
)
from slpkg.colors import (
RED,
GREEN,
CYAN,
GREY,
ENDC
)
from slpkg.__metadata__ import (
pkg_path,
sp,
log_path
)
from find import find_package from find import find_package
@ -70,9 +83,8 @@ class PackageManager(object):
''' '''
for pkg in self.binary: for pkg in self.binary:
try: try:
print( print(subprocess.check_output(
subprocess.check_output("upgradepkg --reinstall {0}".format( "upgradepkg --reinstall {0}".format(pkg), shell=True))
pkg), shell=True))
print("Completed!\n") print("Completed!\n")
except subprocess.CalledProcessError: except subprocess.CalledProcessError:
self.not_found("Can't reinstall", self.binary, pkg) self.not_found("Can't reinstall", self.binary, pkg)
@ -93,7 +105,7 @@ class PackageManager(object):
dependencies, rmv_list = [], [] 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
else: else:
msg = "package" msg = "package"
if len(removed) > 1: if len(removed) > 1:
@ -103,7 +115,7 @@ class PackageManager(object):
"\nAre you sure to remove {0} {1} [Y/n]? ".format( "\nAre you sure to remove {0} {1} [Y/n]? ".format(
str(len(removed)), msg)) str(len(removed)), msg))
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()
if remove_pkg in ['y', 'Y']: if remove_pkg in ['y', 'Y']:
for rmv in removed: for rmv in removed:
@ -117,7 +129,7 @@ class PackageManager(object):
"\nRemove dependencies (maybe used by other " "\nRemove dependencies (maybe used by other "
"packages) [Y/n]? ") "packages) [Y/n]? ")
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()
if remove_dep in ['y', 'Y']: if remove_dep in ['y', 'Y']:
rmv_list += self.rmv_deps(self.binary, rmv_list += self.rmv_deps(self.binary,
@ -157,7 +169,7 @@ class PackageManager(object):
with open(path + package, "r") as f: with open(path + package, "r") as f:
dependencies = f.read().split() dependencies = f.read().split()
f.close() f.close()
print # new line at start print("") # new line at start
template(78) template(78)
print("| Found dependencies for package {0}:".format(package)) print("| Found dependencies for package {0}:".format(package))
template(78) template(78)
@ -205,7 +217,7 @@ class PackageManager(object):
else: else:
print("| Package {0} not found".format(pkg)) print("| Package {0} not found".format(pkg))
template(78) template(78)
print # new line at end print("") # new line at end
def find(self): def find(self):
''' '''
@ -253,7 +265,7 @@ class PackageManager(object):
with open(pkg_path + "".join(find), "r") as package: with open(pkg_path + "".join(find), "r") as package:
for line in package: for line in package:
print(line).strip() print(line).strip()
print # new line per file print("") # new line per file
else: else:
message = "Can't dislpay" message = "Can't dislpay"
if len(self.binary) > 1: if len(self.binary) > 1:
@ -292,9 +304,9 @@ class PackageManager(object):
"continue... ".format(CYAN, ENDC)) "continue... ".format(CYAN, ENDC))
if read in ['Q', 'q']: if read in ['Q', 'q']:
break 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
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()

View file

@ -24,8 +24,16 @@
import os import os
from downloader import Download from downloader import Download
from colors import GREEN, RED, ENDC from colors import (
from __metadata__ import lib_path, build_path, tmp GREEN,
RED,
ENDC
)
from __metadata__ import (
lib_path,
build_path,
tmp
)
from sbo.greps import SBoGrep from sbo.greps import SBoGrep
from pkg.find import find_package from pkg.find import find_package
@ -85,7 +93,7 @@ class QueuePkgs(object):
print("{0}{1}{2}".format(GREEN, pkg, ENDC)) print("{0}{1}{2}".format(GREEN, pkg, ENDC))
self.quit = True self.quit = True
if self.quit: if self.quit:
print # new line at exit print("") # new line at exit
def add(self, pkgs): def add(self, pkgs):
''' '''
@ -106,7 +114,7 @@ class QueuePkgs(object):
self.quit = True self.quit = True
queue.close() queue.close()
if self.quit: if self.quit:
print # new line at exit print("") # new line at exit
def remove(self, pkgs): def remove(self, pkgs):
''' '''
@ -124,7 +132,7 @@ class QueuePkgs(object):
self.quit = True self.quit = True
queue.close() queue.close()
if self.quit: if self.quit:
print # new line at exit print("") # new line at exit
def build(self): def build(self):
''' '''
@ -155,7 +163,7 @@ class QueuePkgs(object):
''' '''
packages = self.packages() packages = self.packages()
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 /tmp # check if package exist in /tmp
find = find_package(pkg, tmp) find = find_package(pkg, tmp)

View file

@ -32,11 +32,26 @@ 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 (
from slpkg.colors import RED, GREEN, GREY, YELLOW, ENDC template,
from slpkg.__metadata__ import tmp, pkg_path, build_path, sp build_FAILED
)
from slpkg.colors import (
RED,
GREEN,
GREY,
YELLOW,
ENDC
)
from slpkg.__metadata__ import (
tmp,
pkg_path,
build_path,
sp
)
from greps import SBoGrep from greps import SBoGrep
from remove import delete
from compressed import SBoLink from compressed import SBoLink
from search import sbo_search_pkg from search import sbo_search_pkg
from dependency import sbo_dependencies_pkg from dependency import sbo_dependencies_pkg
@ -46,9 +61,9 @@ class SBoCheck(object):
def __init__(self): def __init__(self):
self.done = "{0}Done{1}\n".format(GREY, ENDC) self.done = "{0}Done{1}\n".format(GREY, ENDC)
Initialization().sbo()
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().sbo()
self.installed = [] self.installed = []
self.index, self.toolbar_width = 0, 3 self.index, self.toolbar_width = 0, 3
@ -84,7 +99,6 @@ class SBoCheck(object):
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 in ['y', 'Y']: if read in ['y', 'Y']:
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]):
prgnam = ("{0}-{1}".format(name, version)) prgnam = ("{0}-{1}".format(name, version))
@ -116,6 +130,7 @@ class SBoCheck(object):
PackageManager(binary).upgrade() PackageManager(binary).upgrade()
reference(data[0], data[1], data[2], count[0], count[1], reference(data[0], data[1], data[2], count[0], count[1],
msg[0], msg[1], self.installed) msg[0], msg[1], self.installed)
delete(build_path)
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(self.sbo_list()))) len(self.sbo_list())))
@ -123,7 +138,7 @@ class SBoCheck(object):
sys.stdout.write(self.done) sys.stdout.write(self.done)
print("\nNo SBo packages found\n") print("\nNo SBo packages found\n")
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()
def sbo_list(self): def sbo_list(self):
@ -281,14 +296,6 @@ def view_packages(package_for_upgrade, upgrade_version, upgrade_arch):
return [count_installed, count_upgraded], [msg_ins, msg_upg] return [count_installed, count_upgraded], [msg_ins, msg_upg]
def create_build_path():
'''
Create build directory if not exists
'''
if not os.path.exists(build_path):
os.mkdir(build_path)
def dwn_sources(sources): def dwn_sources(sources):
''' '''
Download sources and return filenames Download sources and return filenames

View file

@ -23,7 +23,7 @@
import sys import sys
from slpkg.colors import GREY, ENDC from slpkg.toolbar import status
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from greps import SBoGrep from greps import SBoGrep
@ -39,8 +39,11 @@ def sbo_dependencies_pkg(name):
dependencies = [] dependencies = []
blacklist = BlackList().packages() blacklist = BlackList().packages()
requires = SBoGrep(name).requires() requires = SBoGrep(name).requires()
toolbar_width, index = 2, 0
if requires: if requires:
for req in requires: for req in requires:
index += 1
toolbar_width = status(index, toolbar_width, 1)
# avoid to add %README% as dependency and # avoid to add %README% as dependency and
# if require in blacklist # if require in blacklist
if "%README%" not in req and req not in blacklist: if "%README%" not in req and req not in blacklist:
@ -48,10 +51,8 @@ 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(GREY, ENDC))
sys.stdout.flush()
sbo_dependencies_pkg(dep) sbo_dependencies_pkg(dep)
return dep_results return dep_results
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()

View file

@ -21,7 +21,10 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# 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, lib_path from slpkg.__metadata__ import (
arch,
lib_path
)
class SBoGrep(object): class SBoGrep(object):

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

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

View file

@ -48,5 +48,5 @@ def sbo_search_pkg(name):
SLACKBUILDS_TXT.close() SLACKBUILDS_TXT.close()
return (sbo_url + line[23:].strip() + "/") return (sbo_url + line[23:].strip() + "/")
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()

View file

@ -28,18 +28,35 @@ 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.__metadata__ import (tmp, pkg_path, build_path, from slpkg.__metadata__ import (
log_path, lib_path, sp) tmp,
pkg_path,
from slpkg.colors import RED, GREEN, GREY, YELLOW, CYAN, ENDC build_path,
from slpkg.messages import (pkg_found, template, build_FAILED, log_path,
pkg_not_found) lib_path,
sp
)
from slpkg.colors import (
RED,
GREEN,
GREY,
YELLOW,
CYAN,
ENDC
)
from slpkg.messages import (
pkg_found,
template,
build_FAILED,
pkg_not_found
)
from slpkg.pkg.find import find_package from slpkg.pkg.find import find_package
from slpkg.pkg.build import BuildPackage from slpkg.pkg.build import BuildPackage
from slpkg.pkg.manager import PackageManager from slpkg.pkg.manager import PackageManager
from greps import SBoGrep from greps import SBoGrep
from remove import delete
from compressed import SBoLink from compressed import SBoLink
from search import sbo_search_pkg from search import sbo_search_pkg
from dependency import sbo_dependencies_pkg from dependency import sbo_dependencies_pkg
@ -49,9 +66,9 @@ class SBoInstall(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
Initialization().sbo()
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().sbo()
self.UNST = ["UNSUPPORTED", "UNTESTED"] self.UNST = ["UNSUPPORTED", "UNTESTED"]
self.dependencies_list = sbo_dependencies_pkg(name) self.dependencies_list = sbo_dependencies_pkg(name)
@ -64,12 +81,12 @@ 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:
dependencies = self.remove_dbs() dependencies = self.remove_dbs()
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
# sbo versions = idata[0] # sbo versions = idata[0]
# package arch = idata[1] # package arch = idata[1]
# package sum = idata[2] # package sum = idata[2]
# sources = idata[3] # sources = idata[3]
idata = installing_data(dependencies, self.UNST) idata = installing_data(dependencies, self.UNST)
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
# count upgraded = cnt[0] # count upgraded = cnt[0]
# count installed = cnt[1] # count installed = cnt[1]
(PKG_COLOR, count) = pkg_colors_tag(self.name, idata[0], 0, 0) (PKG_COLOR, count) = pkg_colors_tag(self.name, idata[0], 0, 0)
@ -110,6 +127,7 @@ class SBoInstall(object):
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(dependencies) write_deps(dependencies)
delete(build_path)
else: else:
count_installed = count_uninstalled = 0 count_installed = count_uninstalled = 0
# sbo matching = mdata[0] # sbo matching = mdata[0]
@ -143,7 +161,7 @@ class SBoInstall(object):
else: else:
pkg_not_found("\n", self.name, "No matching", "\n") pkg_not_found("\n", self.name, "No matching", "\n")
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()
def one_for_all(self): def one_for_all(self):
@ -176,7 +194,12 @@ def installing_data(dependencies, support):
''' '''
package_sum = 0 package_sum = 0
sbo_versions, package_arch = [], [] sbo_versions, package_arch = [], []
sys.stdout.write("{0}Resolving dependencies ...{1}".format(GREY, ENDC))
sys.stdout.flush()
toolbar_width, index = 2, 0
for pkg in dependencies: for pkg in dependencies:
index += 1
toolbar_width = status(index, toolbar_width, 1)
version = SBoGrep(pkg).version() version = SBoGrep(pkg).version()
sbo_versions.append(version) sbo_versions.append(version)
sources = SBoGrep(pkg).source() sources = SBoGrep(pkg).source()
@ -184,6 +207,7 @@ def installing_data(dependencies, support):
sbo_package = ("{0}-{1}".format(pkg, version)) sbo_package = ("{0}-{1}".format(pkg, version))
if find_package(sbo_package, pkg_path): if find_package(sbo_package, pkg_path):
package_sum += 1 package_sum += 1
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
return [sbo_versions, package_arch, package_sum, sources] return [sbo_versions, package_arch, package_sum, sources]
@ -277,14 +301,6 @@ def arch_support(source, support, package_sum, dependencies):
return read return read
def create_build_path():
'''
Create build directory if not exists
'''
if not os.path.exists(build_path):
os.mkdir(build_path)
def dwn_sources(sources): def dwn_sources(sources):
''' '''
Download sources and return filenames Download sources and return filenames
@ -315,7 +331,6 @@ def build_install(dependencies, sbo_versions):
tag 2 or 3 will fit most tag 2 or 3 will fit most
''' '''
installs, upgraded, versions = [], [], [] installs, upgraded, versions = [], [], []
create_build_path()
os.chdir(build_path) os.chdir(build_path)
for pkg, ver in zip(dependencies, sbo_versions): for pkg, ver in zip(dependencies, sbo_versions):
prgnam = ("{0}-{1}".format(pkg, ver)) prgnam = ("{0}-{1}".format(pkg, ver))

View file

@ -27,16 +27,33 @@ 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 (
from slpkg.colors import RED, GREEN, GREY, CYAN, YELLOW, ENDC tmp,
from slpkg.messages import (pkg_found, pkg_not_found, template, build_path,
build_FAILED) pkg_path,
sp
)
from slpkg.colors import (
RED,
GREEN,
GREY,
CYAN,
YELLOW,
ENDC
)
from slpkg.messages import (
pkg_found,
pkg_not_found,
template,
build_FAILED
)
from slpkg.pkg.find import find_package from slpkg.pkg.find import find_package
from slpkg.pkg.build import BuildPackage from slpkg.pkg.build import BuildPackage
from slpkg.pkg.manager import PackageManager from slpkg.pkg.manager import PackageManager
from read import Read from read import Read
from remove import delete
from greps import SBoGrep from greps import SBoGrep
from compressed import SBoLink from compressed import SBoLink
from search import sbo_search_pkg from search import sbo_search_pkg
@ -46,16 +63,17 @@ class SBoNetwork(object):
def __init__(self, name): def __init__(self, name):
self.name = name self.name = name
Initialization().sbo()
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().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] if self.sbo_url:
self.sbo_req = grep.requires() self.sbo_desc = grep.description()[len(self.name) + 2:-1]
self.source_dwn = grep.source().split() self.source_dwn = grep.source().split()
self.sbo_dwn = SBoLink(self.sbo_url).tar_gz() self.sbo_req = grep.requires()
self.sbo_version = grep.version() self.sbo_dwn = SBoLink(self.sbo_url).tar_gz()
self.sbo_version = grep.version()
self.space = ("\n" * 50) self.space = ("\n" * 50)
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC)) sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
@ -92,11 +110,13 @@ class SBoNetwork(object):
pydoc.pager(SlackBuild + fill) pydoc.pager(SlackBuild + fill)
elif choice in ['B', 'b']: elif choice in ['B', 'b']:
self.build(FAULT) self.build(FAULT)
delete(build_path)
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):
self.build(FAULT) self.build(FAULT)
self.install(prgnam) self.install(prgnam)
delete(build_path)
break break
else: else:
template(78) template(78)
@ -113,7 +133,7 @@ class SBoNetwork(object):
''' '''
View slackbuild.org View slackbuild.org
''' '''
print # new line at start print("") # new line at start
template(78) template(78)
print("| {0}Package {1}{2}{3} --> {4}".format(GREEN, CYAN, args[0], print("| {0}Package {1}{2}{3} --> {4}".format(GREEN, CYAN, args[0],
GREEN, ENDC + args[1])) GREEN, ENDC + args[1]))
@ -160,7 +180,7 @@ class SBoNetwork(object):
try: try:
choice = raw_input(" {0}Choose an option: {1}".format(GREY, ENDC)) choice = raw_input(" {0}Choose an option: {1}".format(GREY, ENDC))
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()
return choice return choice
@ -188,8 +208,6 @@ class SBoNetwork(object):
if FAULT: if FAULT:
print("\n{0}The package {1} {2}\n".format(RED, FAULT, ENDC)) print("\n{0}The package {1} {2}\n".format(RED, FAULT, ENDC))
sys.exit() sys.exit()
if not os.path.exists(build_path):
os.mkdir(build_path)
sources = [] sources = []
os.chdir(build_path) os.chdir(build_path)
Download(build_path, self.sbo_dwn).start() Download(build_path, self.sbo_dwn).start()

View file

@ -33,9 +33,9 @@ def slack_data(PACKAGES_TXT, step):
for line in PACKAGES_TXT.splitlines(): for line in PACKAGES_TXT.splitlines():
index += 1 index += 1
toolbar_width = status(index, toolbar_width, step) toolbar_width = status(index, toolbar_width, step)
if line.startswith("PACKAGE NAME"): if line.startswith("PACKAGE NAME:"):
name.append(line[15:].strip()) name.append(line[15:].strip())
if line.startswith("PACKAGE LOCATION"): if line.startswith("PACKAGE LOCATION:"):
location.append(line[21:].strip()) location.append(line[21:].strip())
if line.startswith("PACKAGE SIZE (compressed): "): if line.startswith("PACKAGE SIZE (compressed): "):
size.append(line[28:-2].strip()) size.append(line[28:-2].strip())

View file

@ -25,12 +25,26 @@ import os
import sys import sys
from slpkg.sizes import units from slpkg.sizes import units
from slpkg.url_read import URL
from slpkg.blacklist import BlackList from slpkg.blacklist import BlackList
from slpkg.init import Initialization
from slpkg.splitting import split_package from slpkg.splitting import split_package
from slpkg.messages import pkg_not_found, template from slpkg.messages import (
from slpkg.__metadata__ import slpkg_tmp, pkg_path pkg_not_found,
from slpkg.colors import RED, GREEN, CYAN, YELLOW, GREY, ENDC template
)
from slpkg.colors import (
RED,
GREEN,
CYAN,
YELLOW,
GREY,
ENDC
)
from slpkg.__metadata__ import (
pkg_path,
lib_path,
slpkg_tmp_packages
)
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
@ -46,20 +60,17 @@ class Slack(object):
def __init__(self, slack_pkg, version): def __init__(self, slack_pkg, version):
self.slack_pkg = slack_pkg self.slack_pkg = slack_pkg
self.version = version self.version = version
self.tmp_path = slpkg_tmp + "packages/" self.tmp_path = slpkg_tmp_packages
Initialization().slack()
print("\nPackages with name matching [ {0}{1}{2} ]\n".format( print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
CYAN, self.slack_pkg, ENDC)) CYAN, self.slack_pkg, 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()
if not os.path.exists(slpkg_tmp): Initialization().slack()
os.mkdir(slpkg_tmp) lib = lib_path + "slack_repo/PACKAGES.TXT"
if not os.path.exists(self.tmp_path): f = open(lib, "r")
os.mkdir(self.tmp_path) self.PACKAGES_TXT = f.read()
PACKAGES = URL(mirrors("PACKAGES.TXT", "", self.version)).reading() f.close()
EXTRA = URL(mirrors("PACKAGES.TXT", "extra/", self.version)).reading()
PASTURE = URL(mirrors("PACKAGES.TXT", "pasture/",
self.version)).reading()
self.PACKAGES_TXT = PACKAGES + EXTRA + PASTURE
def start(self): def start(self):
''' '''
@ -101,7 +112,7 @@ class Slack(object):
else: else:
pkg_not_found("", self.slack_pkg, "No matching", "\n") pkg_not_found("", self.slack_pkg, "No matching", "\n")
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()
def store(self): def store(self):

View file

@ -30,8 +30,15 @@ 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
from slpkg.splitting import split_package from slpkg.splitting import split_package
from slpkg.colors import GREY, YELLOW, ENDC from slpkg.colors import (
from slpkg.__metadata__ import pkg_path, slpkg_tmp GREY,
YELLOW,
ENDC
)
from slpkg.__metadata__ import (
pkg_path,
slpkg_tmp_patches
)
from slpkg.pkg.manager import PackageManager from slpkg.pkg.manager import PackageManager
@ -46,13 +53,9 @@ class Patches(object):
def __init__(self, version): def __init__(self, version):
self.version = version self.version = version
self.patch_path = slpkg_tmp + "patches/" self.patch_path = slpkg_tmp_patches
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()
if not os.path.exists(slpkg_tmp):
os.mkdir(slpkg_tmp)
if not os.path.exists(self.patch_path):
os.mkdir(self.patch_path)
if version == "stable": if version == "stable":
self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "patches/", self.PACKAGES_TXT = URL(mirrors("PACKAGES.TXT", "patches/",
version)).reading() version)).reading()
@ -104,7 +107,7 @@ class Patches(object):
print("\nSlackware{0} '{1}' v{2} distribution is up to " print("\nSlackware{0} '{1}' v{2} distribution is up to "
"date\n".format(slack_arch, self.version, slack_ver())) "date\n".format(slack_arch, self.version, slack_ver()))
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()
def store(self): def store(self):

View file

@ -23,23 +23,14 @@
import os import os
from slpkg.__metadata__ import del_all
def delete(path, packages): def delete(path, packages):
''' '''
Remove downloaded packages Remove downloaded packages
''' '''
read = raw_input("Removal downloaded packages [Y/n]? ") if del_all == "on":
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")
is_empty(path)
else:
is_empty(path)
def is_empty(path):
if not os.listdir(path):
print("Packages removed")
else:
print("\nThere are packages in direcrory {0}\n".format(path))

View file

@ -24,7 +24,10 @@
import sys import sys
import time import time
from colors import GREY, ENDC from colors import (
GREY,
ENDC
)
def status(index, width, step): def status(index, width, step):

View file

@ -23,30 +23,55 @@
import sys import sys
from slpkg.messages import template from messages import template
from slpkg.init import Initialization from init import Initialization
from slpkg.__metadata__ import pkg_path, sp from __metadata__ import (
from slpkg.colors import RED, GREEN, GREY, YELLOW, CYAN, ENDC pkg_path,
sp
)
from colors import (
RED,
GREEN,
GREY,
YELLOW,
CYAN,
ENDC
)
from slpkg.pkg.find import find_package from pkg.find import find_package
from search import sbo_search_pkg from sbo.search import sbo_search_pkg
from dependency import sbo_dependencies_pkg from sbo.dependency import sbo_dependencies_pkg
from others.search import search_pkg
from others.dependency import dependencies_pkg
def track_dep(name): def track_dep(name, repo):
''' '''
View tree of dependencies and also View tree of dependencies and also
highlight packages with color green highlight packages with color green
if allready installed and color red if allready installed and color red
if not installed. if not installed.
''' '''
init_repos = {
'sbo': Initialization().sbo,
'slack': Initialization().slack,
'rlw': Initialization().rlw,
'alien': Initialization().alien,
'slacky': Initialization().slacky
}
init_repos[repo]()
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().sbo() if repo == "sbo":
dependencies_list = sbo_dependencies_pkg(name) dependencies_list = sbo_dependencies_pkg(name)
find_pkg = sbo_search_pkg(name)
else:
dependencies_list = dependencies_pkg(name, repo)
find_pkg = search_pkg(name, repo)
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC)) sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
if sbo_search_pkg(name): if find_pkg:
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:
@ -59,7 +84,7 @@ def track_dep(name):
if dependencies == []: if dependencies == []:
dependencies = ["No dependencies"] dependencies = ["No dependencies"]
pkg_len = len(name) + 24 pkg_len = len(name) + 24
print # new line at start print("") # new line at start
template(pkg_len) template(pkg_len)
print("| Package {0}{1}{2} dependencies :".format(CYAN, name, ENDC)) print("| Package {0}{1}{2} dependencies :".format(CYAN, name, ENDC))
template(pkg_len) template(pkg_len)
@ -75,6 +100,6 @@ def track_dep(name):
else: else:
print(" |") print(" |")
print(" {0}{1}: {2}{3}{4}".format("+--", index, RED, pkg, ENDC)) print(" {0}{1}: {2}{3}{4}".format("+--", index, RED, pkg, ENDC))
print # new line at end print("") # new line at end
else: else:
print("\nNo package was found to match\n") print("\nNo package was found to match\n")

View file

@ -38,8 +38,8 @@ class URL(object):
f = urllib2.urlopen(self.link) f = urllib2.urlopen(self.link)
return f.read() return f.read()
except urllib2.URLError: except urllib2.URLError:
print ("\nslpkg: error: connection refused\n") print("\nslpkg: error: connection refused\n")
sys.exit() sys.exit()
except KeyboardInterrupt: except KeyboardInterrupt:
print # new line at exit print("") # new line at exit
sys.exit() sys.exit()

View file

@ -21,7 +21,11 @@
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# 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 __metadata__ import __version__, __license__, __email__ from __metadata__ import (
__version__,
__license__,
__email__
)
def prog_version(): def prog_version():