From afc9ec0d7bd4dc550889018bee4a24fd471f64dc Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 8 Jan 2015 09:26:58 +0200 Subject: [PATCH] Bump to version 2.2.0 --- CHANGELOG | 14 +++++ CHECKSUMS.md5 | 13 +++++ PKG-INFO | 2 +- README.rst | 90 ++++++++++++++++++++----------- REPOSITORIES | 21 ++++++-- conf/custom-repositories | 31 +++++++++++ conf/slpkg.conf | 7 ++- install.sh | 2 +- man/slpkg.8 | 87 ++++++++++++++++++++---------- setup.py | 3 +- slackbuild/doinst.sh | 2 +- slackbuild/slpkg.SlackBuild | 4 +- slpkg/__metadata__.py | 39 ++++++++++++-- slpkg/arguments.py | 39 ++++++++------ slpkg/config.py | 3 +- slpkg/downloader.py | 9 ++-- slpkg/file_size.py | 3 +- slpkg/grep_md5.py | 3 ++ slpkg/init.py | 90 ++++++++++++++++++++++++++----- slpkg/main.py | 33 ++++++++---- slpkg/others/check.py | 17 +++++- slpkg/others/greps.py | 44 ++++++--------- slpkg/others/install.py | 56 ++++++++++++++----- slpkg/pkg/manager.py | 105 ++++++++++++++++++------------------ slpkg/queue.py | 7 +-- slpkg/repoinfo.py | 40 ++++++++------ slpkg/repolist.py | 28 ++++++---- slpkg/repositories.py | 79 ++++++++++++++++++++++++++- slpkg/sbo/check.py | 2 +- slpkg/slack/install.py | 2 +- slpkg/slack/patches.py | 3 +- slpkg/slpkg_update.py | 9 +++- slpkg/url_read.py | 7 ++- 33 files changed, 641 insertions(+), 253 deletions(-) create mode 100644 CHECKSUMS.md5 create mode 100644 conf/custom-repositories diff --git a/CHANGELOG b/CHANGELOG index 32d6800d..ba14552e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,17 @@ +Version 2.2.0 +08-1-2015 + +[Updated] - Fix queue downloads. + - Update find argument. + - Rename commands repolist and repoinfo to repo-list, repo-info. + - Update installed package list. + +[Feature] - Added custom binary repository. + - Added Slackware 'patches' repository in PACKAGES.txt file. + - Added Alien's restricted repository. + - Added wget option. + - Added view default repositories in repo-list. + Version 2.1.5 27-12-2014 diff --git a/CHECKSUMS.md5 b/CHECKSUMS.md5 new file mode 100644 index 00000000..79b76f24 --- /dev/null +++ b/CHECKSUMS.md5 @@ -0,0 +1,13 @@ +These are the MD5 message digests for the files in this directory. +If you want to test your files, use 'md5sum' and compare the values to +the ones listed here. + +To test all these files, use this command: + +tail +13 CHECKSUMS.md5 | md5sum -c --quiet - | less + +'md5sum' can be found in the GNU coreutils package on ftp.gnu.org in +/pub/gnu, or at any GNU mirror site. + +MD5 message digest Filename +74d79364aef2717c00eae3a37c0e7479 ./slpkg-2.1.5.tar.gz diff --git a/PKG-INFO b/PKG-INFO index b642005f..b75d7d7d 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.1 Name: slpkg -Version: 2.1.5 +Version: 2.1.x-dev Author: dslackw Author-email: d zlatanidis at gmail com Maintainer: dslackw diff --git a/README.rst b/README.rst index a2237bf2..f8bb6a8b 100644 --- a/README.rst +++ b/README.rst @@ -11,9 +11,9 @@ Latest Release: -- Version: 2.1.5 +- Version: 2.1.dev - `Package `_ -- `Source `_ +- `Source `_ - `CHANGELOG `_ .. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/logo.png @@ -29,11 +29,11 @@ packages. Slpkg is `Open Source `_ software written in Python language. It's use is for managing packages in Slackware linux distribution. -Supported Repositories: +Default available Repositories: - SBo - `Reposiory `_ Arch: {x86, x86_64} - Versions: {11.0, 12.0, 12.1, 12.2, 13.0, 13.1, 13.37, 14.0, 14.1} + Versions: {13.1, 13.37, 14.0, 14.1} - Slack - `Repository `_ Arch: {x86, x86_64} Versions: {3.3, 8.1, 9.0, 9.1, 10.0, 10.1, 10.2, 11.0, 12.0, 12.2, 13.0, 13.37, 14.0, 14.1, current} @@ -70,10 +70,15 @@ Supported Repositories: - Slackel - `Repository `_ Arch: {x86, x86_64} Versions: {current} +- Restricted - `Repository `_ + Arch: {x86, x86_64} + Versions: {11.0, 12.0, 12.1, 12.2, 13.0, 13.1, 13.37, 14.0, 14,1, current} -* Choose repositories you need to work from file '/etc/slpkg/slpkg.conf' default is +* Choose default repositories you need to work from file '/etc/slpkg/slpkg.conf' default is 'slack' and 'sbo' repositories and read REPOSITORIES file for each of the particularities. + If a repository is not in the above list, manage custom repositories with commands 'repo-add' + and 'repo-remove'. Slpkg works in accordance with the standards of the organization slackbuilds.org to builds packages. Also uses the Slackware linux instructions for installation, @@ -135,8 +140,8 @@ Untar the archive and run install.sh script: .. code-block:: bash - $ tar xvf slpkg-2.1.5.tar.gz - $ cd slpkg-2.1.5 + $ tar xvf slpkg-2.1.dev.tar.gz + $ cd slpkg-2.1.dev $ ./install.sh From SourceForge: @@ -172,6 +177,8 @@ Configuration files /etc/slpkg/slackware-mirrors List of Slackware Mirrors + /etc/slpkg/custom-repositories + List of custom repositories Slackware Current ----------------- @@ -214,7 +221,7 @@ before proceeding to any installation or upgrade a new package. Issues ------ -Please report any bugs in "https://github.com/dslackw/slpkg/issues" +Please report any bugs in `ISSUES `_ Command Line Tool Usage @@ -227,25 +234,27 @@ Command Line Tool Usage Commands: update update all package lists re-create recreate package lists - repolist list all repositories - repoinfo [repository] repository information + repo-add [repository name] [URL] add custom repository + repo-remove [repository] remove custom repository + repo-list list all repositories + repo-info [repository] repository information update slpkg check and update slpkg Optional arguments: -h, --help show this help message and exit -v, --version print version and exit - -a, script.tar.gz [source...] auto build SBo packages + -a, [script.tar.gz] [source...] auto build SBo packages -b, --list, [package...] --add, --remove add, remove packages in blacklist -q, --list, [package...] --add, --remove add, remove SBo packages in queue - --build, --install, --build-install build, install packages from queue + -q, --build, --install, --build-install build, install packages from queue -g, --config, --config=[editor] configuration file management -l, [repository], all list of installed packages -c, [repository] --upgrade check for updated packages -s, [repository] [package] download, build & install -t, [repository] [package] tracking dependencies -p, [repository] [package], --color=[] print package description - -f, [package] find installed packages -n, [package] view SBo packages through network + -f, [package...] find installed packages -i, [package...] install binary packages -u, [package...] upgrade binary packages -o, [package...] reinstall binary packages @@ -277,33 +286,50 @@ and update the package lists: Update repository multi ...Done -Take information repositories with commands: +Add and remove custom repositories: + +.. code-block:: bash + + $ slpkg repo-add ponce http://ponce.cc/slackware/slackware64-14.1/packages/ + + Repository 'ponce' successfully added + + + $ slpkg repo-remove ponce + + Repository 'ponce' successfully removed + + +View information about the repositories: .. code-block:: bash - $ slpkg repolist - + $ slpkg repo-list + +============================================================================== - | Repo id Repo name Status + | Repo id Repo URL Default Status +============================================================================== - alien http://www.slackware.com/~alien/slackbuilds/ enabled - ktown http://alien.slackbook.org/ktown/ enabled - multi http://www.slackware.com/~alien/multilib/ enabled - rlw http://rlworkman.net/pkgs/ enabled - salix http://download.salixos.org/ enabled - sbo http://slackbuilds.org/slackbuilds/ enabled - slack http://mirrors.slackware.com/slackware/ enabled - slacke http://ngc891.blogdns.net/pub/ enabled - slackl http://www.slackel.gr/repo/ enabled - slackr http://www.slackers.it/repository/ disabled - slacky http://repository.slacky.eu/ enabled - slonly https://slackonly.com/pub/packages/ enabled - studio http://studioware.org/files/packages/ enabled + alien http://www.slackware.com/~alien/slackbuilds/ yes disabled + ktown http://alien.slackbook.org/ktown/ yes disabled + multi http://www.slackware.com/~alien/multilib/ yes disabled + ponce http://ponce.cc/slackware/slackware64-14.1/packa~ no enabled + rested http://taper.alienbase.nl/mirrors/people/alien/r~ yes disabled + rlw http://rlworkman.net/pkgs/ yes disabled + salix http://download.salixos.org/ yes disabled + sbo http://slackbuilds.org/slackbuilds/ yes enabled + slack http://ftp.cc.uoc.gr/mirrors/linux/slackware/ yes enabled + slacke http://ngc891.blogdns.net/pub/ yes disabled + slackl http://www.slackel.gr/repo/ yes disabled + slackr http://www.slackers.it/repository/ yes disabled + slacky http://repository.slacky.eu/ yes disabled + slonly https://slackonly.com/pub/packages/ yes disabled + studio http://studioware.org/files/packages/ yes disabled - For enable or disable repositories edit '/etc/slpkg/slpkg.conf' file + For enable or disable default repositories edit '/etc/slpkg/slpkg.conf' file - $ slpkg repoinfo alien + $ slpkg repo-info alien + Default: yes Last updated: Tue Dec 23 11:48:31 UTC 2014 Number of packages: 3149 Repo id: alien diff --git a/REPOSITORIES b/REPOSITORIES index a3ff89f1..43e671de 100644 --- a/REPOSITORIES +++ b/REPOSITORIES @@ -2,6 +2,9 @@ This file was created to explain some peculiarities of repositories used by the slpkg. -------------------------------------------------------------------------------------- + +Default repositories: +--------------------- SlackBuilds.org (sbo) FAQ(15): Slackware current is not supported, but as a general rule, the scripts should work on it as well. @@ -21,12 +24,22 @@ dependence 'ffmpeg' but that is not available from the repository itself). Slackonly (slonly) repository contains no dependencies on file PACKAGES.TXT and this makes it difficult to automatically resolve dependencies and in the file PACKAGES.TXT and some lines with 'PACKAGE NAME:' there is no package so 'slpkg' can not find package. -Users with Slackware x86_64 will use this repository should establish from the beginning -the list of packages with the command 'slpkg re-create' to be updated with new packages -and it's because the repository has not 'ChangeLog.txt' file. Studioware (studio), Alien's ktown (ktown), Alien's multilib (multi), Slacke E17 and E18 -repository has no reference dependencies. +and Alien's restricted repository has no reference dependencies. Slackel.gr (slackl) repository must be used only from Slackware current users and has the same peculiarities in the repository 'slackr'. + + +Custom repositories: +-------------------- +There is the possibility of adding the repository directly from the user enough to address +up to be the 'PACKAGES.TXT' files and 'CHECKSUMS.md5' least. If not is there for file +'ChangeLog.txt' will get warning messages that the 'ChangeLog.txt' file can not be read but do +not worry, the process is completed normally have each time you run the command 'slpkg update' +the package lists for such a repository will be recreated from start automatically. + +Sometimes you may experience some problems with these repositories such as the not correctly +resolve dependencies, and this may happen some specificities separate list which unfortunately +can not be calculated, good is the purpose of mentioning these problems. diff --git a/conf/custom-repositories b/conf/custom-repositories new file mode 100644 index 00000000..f2c126f7 --- /dev/null +++ b/conf/custom-repositories @@ -0,0 +1,31 @@ +# List File Repositories: +# +# custom-repositories file is part of slpkg. +# +# Copyright 2014 Dimitris Zlatanidis +# All rights reserved. +# +# Slpkg is a user-friendly package manager for Slackware installations. +# +# 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 . +# +# END OF LEGAL NOTICE +# +# This file is used to read, write and remove custom repositories by +# the user. The repositories will be added here should have a different +# name from existing repositories and the default. Also, the link must +# contain the PACKAGES.TXT files, CHECKSUMS.md5 and optional ChangeLog.txt. +# ------------------------------------------------------------------------- +# +# NAME URL diff --git a/conf/slpkg.conf b/conf/slpkg.conf index 0e28a3be..0fa70a1e 100644 --- a/conf/slpkg.conf +++ b/conf/slpkg.conf @@ -25,7 +25,7 @@ VERSION=stable # Choose repositories want to work. Read first REPOSITORIES file. # Available repositories : slack,sbo,alien,rlw,slacky,studio,slackr,slonly, -# ktown{latest},multi,slacke{18},salix,slackl +# ktown{latest},multi,slacke{18},salix,slackl,rested # slackr (slackers.it) repository must used from Slackware64 current. # Ktown (Alien's ktown) repository. Default ktown{latest}. # Slacke (Enlightenment E17 and E18) repository. Default slacke{18}. @@ -36,7 +36,7 @@ REPOSITORIES=slack,sbo BUILD=/tmp/slpkg/build/ # If SBO_CHECK_MD5 is 'on' the system will check all downloaded -# sources from SBo repository. +# sources. SBO_CHECK_MD5=on # Download directory for others repositories that use binaries files @@ -73,3 +73,6 @@ DEL_DEPS=off # Use colors for highlighting. Choose 'on' or 'off'. USE_COLORS=on + +# Wget [OPTION]. Pass wget options. Default is '-c -N'. +WGET_OPTION=-c -N diff --git a/install.sh b/install.sh index b0599e2d..fc0c419f 100755 --- a/install.sh +++ b/install.sh @@ -21,7 +21,7 @@ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PRGNAM=slpkg -VERSION=${VERSION:-2.1.5} +VERSION=${VERSION:-2.1.x-dev} TAG=${TAG:-_dsw} # Installation script. diff --git a/man/slpkg.8 b/man/slpkg.8 index 74009cb7..db51142a 100644 --- a/man/slpkg.8 +++ b/man/slpkg.8 @@ -15,18 +15,24 @@ .SH NAME Slpkg is a user-friendly package manager for Slackware installations .SH SYNOPSIS -Usage: slpkg [-h] [-v] [-a script.tar.gz [sources...]] - [-b --list, --add, --remove [...]] - [-q --list, [...] --add, --remove] - [ --build, --install, --build-install] - [-g --config, --config=[editor]] - [-l [repository], all] - [-c [repository] --upgrade] - [-s [repository] [package][ - [-t [repository] [package]] - [-p [repository] [package], --color=[]] - [-f] [-n] [-i [...]] [-u [...]] - [-o [...]] [-r [...]] [-d [...]] +Usage: slpkg Commands: + [update] [re-create] [repo-add [repository name] [URL]] + [repo-remove [repository]] [repo-list] + [repo-info [repository]] [update [slpkg]] + + Optional arguments: + [-h] [-v] [-a [script.tar.gz] [sources...]] + [-b --list, [...] --add, --remove] + [-q --list, [...] --add, --remove] + [-q --build, --install, --build-install] + [-g --config, --config=[editor]] + [-l all, official, non-official, --index] + [-c [repository] --upgrade] + [-s [repository] [package] + [-t [repository] [package] + [-p [repository] [package], --color=[]] + [-n] [-f [...]] [-i [...]] [-u [...]] + [-o [...]] [-r [...]] [-d [...]] .SH DESCRIPTION \fBslpkg\fP is a terminal multitool in order to easy use Slackware packages. @@ -38,6 +44,8 @@ Slpkg is a user-friendly package manager for Slackware installations Commands: update update all package lists re-create recreate package lists + repo-add [repository name] [URL] add custom repository + repo-remove [repository] remove custom repository repolist list all repositories repoinfo [repository] repository information update slpkg check and update slpkg @@ -45,25 +53,25 @@ Commands: Optional arguments: -h, --help show this help message and exit -v, --version print version and exit - -a, script.tar.gz [source...] auto build SBo packages + -a, [script.tar.gz] [source...] auto build SBo packages -b, --list, [package...] --add, --remove add, remove packages in blacklist -q, --list, [package...] --add, --remove add, remove SBo packages in queue - --build, --install, --build-install build, install packages from queue + -q, --build, --install, --build-install build, install packages from queue -g, --config, --config= configuration file management - -l, [repository], all list of installed packages + -l, all, official, non-official, --index list of installed packages -c, [repository] --upgrade check for updated packages -s, [repository] [package] download, build & install -t, [repository] [package] tracking dependencies -p, [repository] [package], --color=[] print package description - -f, [package] find installed packages -n, [package] view SBo packages through network + -f, [package...] find installed packages -i, [package...] install binary packages -u, [package...] upgrade binary packages -o, [package...] reinstall binary packages -r, [package...] remove binary packages -d, [package...] display the contents -.SH REPOSITORIES +.SH DEFAULT REPOSITORIES slackware.com = 'slack' SlackBuilds.org = 'sbo' Alien's = 'alien' @@ -77,9 +85,11 @@ Optional arguments: Slacke E17 and E18 = 'slacke{18}' SalixOS = 'salix' Slackel.gr = 'slackel' + Alien's restricted = 'rested' Default enable repository is 'slack' and 'sbo'. - Add or remove repository in configuration file '/etc/slpkg/slpkg.conf' + Add or remove default repository in configuration file '/etc/slpkg/slpkg.conf'. + Read REPOSITORIES file for explanations. .SH COLORS red, green, yellow, cyan, grey @@ -92,25 +102,37 @@ Print the version of program and exit. .PP The following commands are available. -.SS update +.SS update, create and update packages list \fBslpkg\fP \fBupdate\fP .PP Used to re-synchronize the package lists and create some important files. This command must run every new repository is added or new updates is available. -.SS re-create +.SS re-create, recreate packages list \fBslpkg\fP \fBre-create\fP .PP It is sometimes useful to create all of the base file from the beginning so this command deletes all the packages lists and re-created. -.SS repolist -\fBslpkg\fP \fBrepolist\fP +.SS repo-add, add custom repository +\fBslpkg\fP \fBrepo-add\fP <\fIrepository name\fP> <\fIURL\fP> +.PP +Add custom binary repository. The repositories will be added to this command should +contain at least the files 'PACKAGES.TXT' and 'CHECKSUMS.md5' and optional file +ChangeLog.txt. + +.SS repo-remove, remove custom repository +\fBslpkg\fP \fBrepo-remove\fP <\fIrepository\fP> +.PP +Remove custom repository by name. + +.SS repo-list, repositories list +\fBslpkg\fP \fBrepo-list\fP .PP Lists all enabled or disabled repositories. -.SS repoinfo -\fBslpkg\fP \fBrepoinfo\fP <\fBrepository\fP> +.SS repo-info, repository information +\fBslpkg\fP \fBrepo-info\fP <\fBrepository\fP> .PP View repository information. @@ -144,10 +166,11 @@ Build or install or build and install packages are queued. .PP Print configuration file or edit with editor. -.SS -l , list of installed packages per repository -\fBslpkg\fP \fB-l\fP <\fIrepository\fP> \fIall\fP \fInoarch\fP +.SS -l , list of installed packages +\fBslpkg\fP \fB-l\fP <\fIall\fP> \fIofficial\fP \fInon-official\fP \fI--index\fP .PP -List of installed packages per repository or all. +List of installed packages by category official or non-official. The repository 'slack' must +be enabled to work properly 'official' and 'non-official' lists. .SS -c , check if your packages is up to date \fBslpkg\fP \fB-c\fP <\fIrepository\fP> \fI--upgrade\f @@ -174,7 +197,7 @@ The sequence shown is that you must follow to correctly install package. Print package description with color. Available colors: red, green, yellow, cyan, grey .SS -f find packages -\fBslpkg\fP \fB-f\fP <\fIname of package\fP> +\fBslpkg\fP \fB-f\fP <\fIname of packages\fP> .PP Find installed packages with view total file size. @@ -241,12 +264,18 @@ For example: /etc/slpkg/slackware-mirrors List of Slackware Mirrors +/etc/slpkg/custom-repositories + List of custom repositories + /var/log/slpkg ChangeLog.txt repositories files SlackBuilds logs and dependencies files /var/lib/slpkg - PACKAGES.TXT files and SLACKBUILDS.TXT file + PACKAGES.TXT files + SLACKBUILDS.TXT files + CHECKSUMS.md5 files + FILELIST.TXT files /tmp/slpkg Slpkg temponary donwloaded files and build packages diff --git a/setup.py b/setup.py index 4a6fe267..93bcafac 100755 --- a/setup.py +++ b/setup.py @@ -90,7 +90,8 @@ if "install" in sys.argv: conf_file = [ 'conf/slpkg.conf', 'conf/blacklist', - 'conf/slackware-mirrors' + 'conf/slackware-mirrors', + 'conf/custom-repositories' ] if not os.path.exists(conf_path): os.system("mkdir -p {0}".format(conf_path)) diff --git a/slackbuild/doinst.sh b/slackbuild/doinst.sh index f64c9d0d..165cdcbc 100644 --- a/slackbuild/doinst.sh +++ b/slackbuild/doinst.sh @@ -8,7 +8,7 @@ config() { fi } -CONFIGS="slpkg.conf blacklist slackware-mirrors" +CONFIGS="slpkg.conf blacklist slackware-mirrors custom-repositories" for file in $CONFIGS; do config etc/slpkg/${file}.new done diff --git a/slackbuild/slpkg.SlackBuild b/slackbuild/slpkg.SlackBuild index 4cf562fd..4951d5d3 100755 --- a/slackbuild/slpkg.SlackBuild +++ b/slackbuild/slpkg.SlackBuild @@ -23,7 +23,7 @@ # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. PRGNAM=slpkg -VERSION=${VERSION:-2.1.5} +VERSION=${VERSION:-2.1.x-dev} BUILD=${BUILD:-1} TAG=${TAG:-_dsw} @@ -79,7 +79,7 @@ find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | gr mkdir -p $PKG/etc/slpkg # install configurations files -CONFIGS="slpkg.conf blacklist slackware-mirrors" +CONFIGS="slpkg.conf blacklist slackware-mirrors custom-repositories" for file in $CONFIGS; do install -D -m0644 conf/$file $PKG/etc/slpkg/${file}.new done diff --git a/slpkg/__metadata__.py b/slpkg/__metadata__.py index e971a2e4..61926984 100644 --- a/slpkg/__metadata__.py +++ b/slpkg/__metadata__.py @@ -30,11 +30,13 @@ __version__ = "{0}.{1}.{2}".format(*__version_info__) __license__ = "GNU General Public License v3 (GPLv3)" __email__ = "d.zlatanidis@gmail.com" -# temponary path -tmp = "/tmp/" # Default configuration values slack_rel = "stable" + +# Configuration path +conf_path = "/etc/{0}/".format(__all__) + repositories = [ 'slack', 'sbo', @@ -48,9 +50,30 @@ repositories = [ 'multi', 'slacke{18}', 'salix', - 'slackl' + 'slackl', + 'rested' ] +default_repositories = repositories[8] = 'ktown' +default_repositories = repositories[10] = 'slacke' +default_repositories = repositories + + +def update_repositories(repositories): + ''' + Upadate with user custom repositories + ''' + repo_file = "{0}custom-repositories".format(conf_path) + if os.path.isfile(repo_file): + f = open(repo_file, "r") + repositories_list = f.read() + f.close() + for line in repositories_list.splitlines(): + line = line.lstrip() + if line and not line.startswith("#"): + repositories.append(line.split()[0]) + return repositories + def ktown_repo(repositories): ''' @@ -75,6 +98,8 @@ def slacke_repo(repositories): repositories[i] = 'slacke' return sub +tmp = "/tmp/" +tmp_path = "{0}{1}/".format(tmp, __all__) build_path = "/tmp/slpkg/build/" slpkg_tmp_packages = tmp + "slpkg/packages/" slpkg_tmp_patches = tmp + "slpkg/patches/" @@ -87,6 +112,7 @@ remove_deps_answer = "n" skip_unst = "n" del_deps = "on" use_colors = "on" +wget_option = '-c -N' if os.path.isfile("/etc/slpkg/slpkg.conf"): f = open("/etc/slpkg/slpkg.conf", "r") @@ -124,9 +150,13 @@ if os.path.isfile("/etc/slpkg/slpkg.conf"): del_deps = line[9:].strip() if line.startswith("USE_COLORS"): use_colors = line[11:].strip() + if line.startswith("WGET_OPTION"): + wget_option = line[12:].strip() + ktown_kde_repo = ktown_repo(repositories) slacke_sub_repo = slacke_repo(repositories) +update_repositories(repositories) color = { 'RED': '\x1b[31m', @@ -147,6 +177,9 @@ if use_colors == "off": 'ENDC': '' } +CHECKSUMS_link = ("https://raw.githubusercontent.com/{0}/{1}/" + "master/CHECKSUMS.md5".format(__author__, __all__)) + # file spacer sp = "-" diff --git a/slpkg/arguments.py b/slpkg/arguments.py index 1047b87a..8894438f 100644 --- a/slpkg/arguments.py +++ b/slpkg/arguments.py @@ -33,38 +33,40 @@ from __metadata__ import ( def options(): arguments = [ "\nslpkg - version {0}\n".format(__version__), - "Slpkg is a user-friendly package manager for Slackware " + + "Slpkg is a user-friendly package manager for Slackware " "installations\n", "Commands:", - " update update all package " + + " update update all package " "lists", " re-create recreate package lists", - " repolist list all repositories", - " repoinfo [repository] repository information", + " repo-add [repository name] [URL] add custom repository", + " repo-remove [repository] remove custom repository", + " repo-list list all repositories", + " repo-info [repository] repository information", " update slpkg check and update slpkg\n", "Optional arguments:", - " -h, --help show this help message " + + " -h, --help show this help message " "and exit", " -v, --version print version and exit", - " -a, script.tar.gz [source...] auto build SBo packages", - " -b, --list, [package...] --add, --remove add, remove packages in " + + " -a, [script.tar.gz] [source...] auto build SBo packages", + " -b, --list, [package...] --add, --remove add, remove packages in " "blacklist", " -q, --list, [package...] --add, --remove add, remove SBo packages " "in queue", - " --build, --install, --build-install build, install packages " + " -q, --build, --install, --build-install build, install packages " "from queue", - " -g, --config, --config=[editor] configuration file " + + " -g, --config, --config=[editor] configuration file " "management", - " -l, [repository], all list of installed " + + " -l, all, official, non-official, --index list of installed " "packages", - " -c, [repository] --upgrade check for updated " + + " -c, [repository] --upgrade check for updated " "packages", " -s, [repository] [package] download, build & install", " -t, [repository] [package] tracking dependencies", " -p, [repository] [package], --color=[] print package description", - " -f, [package] find installed packages", " -n, [package] view SBo packages " "through network", + " -f, [package...] find installed packages", " -i, [package...] install binary packages", " -u, [package...] upgrade binary packages", " -o, [package...] reinstall binary packages", @@ -89,17 +91,22 @@ def usage(repo): "\n".format(repo)) view = [ "slpkg - version {0}\n".format(__version__), - "Usage: slpkg [-h] [-v] [-a script.tar.gz [sources...]]", + "Usage: slpkg Commands:", + " [update] [re-create] [repo-add [repository name] [URL]]", + " [repo-remove [repository]] [repo-list]", + " [repo-info [repository]] [update [slpkg]]\n", + " Optional arguments:", + " [-h] [-v] [-a [script.tar.gz] [sources...]]", " [-b --list, [...] --add, --remove]", " [-q --list, [...] --add, --remove]", - " [ --build, --install, --build-install]", + " [-q --build, --install, --build-install]", " [-g --config, --config=[editor]]", - " [-l [repository], all]", + " [-l all, official, non-official, --index]", " [-c [repository] --upgrade]", " [-s [repository] [package]", " [-t [repository] [package]", " [-p [repository] [package], --color=[]]", - " [-f] [-n] [-i [...]] [-u [...]]", + " [-n] [-f [...]] [-i [...]] [-u [...]]", " [-o [...]] [-r [...]] [-d [...]]\n", error_repo, "For more information try 'slpkg --help' or view manpage\n" diff --git a/slpkg/config.py b/slpkg/config.py index d2f052ca..44188a85 100644 --- a/slpkg/config.py +++ b/slpkg/config.py @@ -50,7 +50,8 @@ class Config(object): 'REMOVE_DEPS_ANSWER', 'SKIP_UNST', 'DEL_DEPS', - 'USE_COLORS' + 'USE_COLORS', + 'WGET_OPTION' ] f = open(self.config_file, "r") read_conf = f.read() diff --git a/slpkg/downloader.py b/slpkg/downloader.py index b91c1819..1f2110af 100644 --- a/slpkg/downloader.py +++ b/slpkg/downloader.py @@ -24,7 +24,10 @@ import sys import subprocess -from __metadata__ import color +from __metadata__ import ( + color, + wget_option +) class Download(object): @@ -45,8 +48,8 @@ class Download(object): color['ENDC'], file_name)) try: - subprocess.call("wget -c -N --directory-prefix={0} {1}".format( - self.path, dwn), shell=True) + subprocess.call("wget {0} --directory-prefix={1} {2}".format( + wget_option, self.path, dwn), shell=True) except KeyboardInterrupt: print # new line at cancel sys.exit(0) diff --git a/slpkg/file_size.py b/slpkg/file_size.py index 19e5ae07..cc33bf88 100644 --- a/slpkg/file_size.py +++ b/slpkg/file_size.py @@ -40,8 +40,7 @@ class FileSize(object): meta = tar.info() return int(meta.getheaders("Content-Length")[0]) except (urllib2.URLError, IndexError): - print("\nError: connection refused\n") - sys.exit(0) + return ' ' except KeyboardInterrupt: print("") # new line at cancel sys.exit(0) diff --git a/slpkg/grep_md5.py b/slpkg/grep_md5.py index 329e1292..dffecd38 100644 --- a/slpkg/grep_md5.py +++ b/slpkg/grep_md5.py @@ -25,6 +25,7 @@ from slack.mirrors import mirrors from url_read import URL from __metadata__ import ( + CHECKSUMS_link, lib_path, slack_rel ) @@ -39,6 +40,8 @@ def pkg_checksum(binary, repo): CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "patches/")).reading() elif repo == "slack_patches" and slack_rel == "current": CHECKSUMS_md5 = URL(mirrors("CHECKSUMS.md5", "")).reading() + elif repo == "slpkg": + CHECKSUMS_md5 = URL(CHECKSUMS_link).reading() else: lib = '{0}{1}_repo/CHECKSUMS.md5'.format(lib_path, repo) f = open(lib, "r") diff --git a/slpkg/init.py b/slpkg/init.py index 5f88ec7b..091176d5 100644 --- a/slpkg/init.py +++ b/slpkg/init.py @@ -32,11 +32,14 @@ from __metadata__ import ( color, log_path, lib_path, + tmp_path, + conf_path, build_path, repositories, slpkg_tmp_packages, slpkg_tmp_patches, - slacke_sub_repo + slacke_sub_repo, + default_repositories ) from slack.mirrors import mirrors @@ -46,14 +49,14 @@ from slack.slack_version import slack_ver class Initialization(object): def __init__(self): - if not os.path.exists("/etc/slpkg/"): - os.mkdir("/etc/slpkg/") + if not os.path.exists(conf_path): + os.mkdir(conf_path) if not os.path.exists(log_path): os.mkdir(log_path) if not os.path.exists(lib_path): os.mkdir(lib_path) - if not os.path.exists("/tmp/slpkg/"): - os.mkdir("/tmp/slpkg/") + if not os.path.exists(tmp_path): + os.mkdir(tmp_path) if not os.path.exists(build_path): os.makedirs(build_path) if not os.path.exists(slpkg_tmp_packages): @@ -61,6 +64,32 @@ class Initialization(object): if not os.path.exists(slpkg_tmp_patches): os.makedirs(slpkg_tmp_patches) + def custom(self, name): + ''' + Creating user select repository local library + ''' + repo = Repo().custom_repository()[name] + log = log_path + name + "/" + lib = lib_path + "{0}_repo/".format(name) + lib_file = "PACKAGES.TXT" + lst_file = "" + md5_file = "CHECKSUMS.md5" + log_file = "ChangeLog.txt" + if not os.path.exists(log): + os.mkdir(log) + if not os.path.exists(lib): + os.mkdir(lib) + packages_txt = "{0}{1}".format(repo, lib_file) + filelist_txt = "" + checksums_md5 = "{0}{1}".format(repo, md5_file) + changelog_txt = "{0}{1}".format(repo, log_file) + self.write(lib, lib_file, packages_txt) + self.write(lib, md5_file, checksums_md5) + self.write(log, log_file, changelog_txt) + self.remote(log, log_file, changelog_txt, lib, lib_file, + packages_txt, md5_file, checksums_md5, lst_file, + filelist_txt) + def slack(self): ''' Creating slack local libraries @@ -82,10 +111,12 @@ class Initialization(object): ext_checksums = mirrors(md5_file, "extra/") pasture = mirrors(lib_file, "pasture/") pas_checksums = mirrors(md5_file, "pasture/") - packages_txt = ("{0} {1} {2}".format(packages, extra, pasture)) - - checksums_md5 = ("{0} {1} {2}".format(pkg_checksums, ext_checksums, - pas_checksums)) + patches_txt = mirrors(lib_file, "patches/") + patches_md5 = mirrors(md5_file, "patches/") + packages_txt = ("{0} {1} {2} {3}".format(packages, extra, pasture, + patches_txt)) + checksums_md5 = ("{0} {1} {2} {3}".format(pkg_checksums, ext_checksums, + pas_checksums, patches_md5)) changelog_txt = mirrors(log_file, "") self.write(lib, lib_file, packages_txt) self.write(lib, md5_file, checksums_md5) @@ -431,6 +462,31 @@ class Initialization(object): self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt, md5_file, checksums_md5, lst_file, filelist_txt) + def rested(self): + ''' + Creating alien local library + ''' + repo = Repo().restricted() + log = log_path + "rested/" + lib = lib_path + "rested_repo/" + lib_file = "PACKAGES.TXT" + lst_file = "" + md5_file = "CHECKSUMS.md5" + log_file = "ChangeLog.txt" + if not os.path.exists(log): + os.mkdir(log) + if not os.path.exists(lib): + os.mkdir(lib) + packages_txt = "{0}{1}".format(repo, lib_file) + filelist_txt = "" + checksums_md5 = "{0}{1}".format(repo, md5_file) + changelog_txt = "{0}{1}".format(repo, log_file) + self.write(lib, lib_file, packages_txt) + self.write(lib, md5_file, checksums_md5) + self.write(log, log_file, changelog_txt) + self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt, + md5_file, checksums_md5, lst_file, filelist_txt) + @staticmethod def write(path, data_file, file_url): ''' @@ -481,6 +537,7 @@ class Initialization(object): # remove FILELIST.TXT if args[8]: os.remove("{0}{1}".format(args[3], args[8])) + # read URL's for fu in args[5].split(): PACKAGES_TXT += URL(fu).reading() CHANGELOG_TXT = URL(args[2]).reading() @@ -547,7 +604,10 @@ class Update(object): sys.stdout.write("{0}Update repository {1} ...{2}".format( color['GREY'], repo, color['ENDC'])) sys.stdout.flush() - exec('{0}.{1}()'.format(self._init, repo)) + if repo in default_repositories: + exec('{0}.{1}()'.format(self._init, repo)) + else: + Initialization().custom(repo) sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC'])) print("") # new line at end @@ -556,12 +616,16 @@ class Update(object): def check_exists_repositories(): ''' - Checking if repositories exists by ChangeLog.txt file + Checking if repositories exists by PACKAGES.TXT file ''' update = False + pkg_list = "PACKAGES.TXT" for repo in repositories: - if not os.path.isfile("{0}{1}{2}".format(log_path, repo, - "/ChangeLog.txt")): + pkg_list = "PACKAGES.TXT" + if repo == "sbo": + pkg_list = "SLACKBUILDS.TXT" + if not os.path.isfile("{0}{1}{2}".format(lib_path, repo, + "_repo/{0}".format(pkg_list))): update = True if update: print("\n Please update packages lists. Run 'slpkg update'.\n" + diff --git a/slpkg/main.py b/slpkg/main.py index da79ab8f..f4f0f6a1 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -24,13 +24,13 @@ import sys import getpass -from repoinfo import RepoInfo -from repolist import RepoList - from desc import PkgDesc from config import Config from queue import QueuePkgs from messages import s_user +from repoinfo import RepoInfo +from repolist import RepoList +from repositories import Repo from tracking import track_dep from blacklist import BlackList from version import prog_version @@ -94,7 +94,8 @@ def main(): queue = QueuePkgs() # all_args = [ - # 'update', 're-create', 'repolist', 'repoinfo', + # 'update', 're-create', 'repo-add', 'repo-remove', + # 'repo-list', 'repo-info', # '-h', '--help', '-v', '-a', '-b', # '-q', '-g', '-l', '-c', '-s', '-t', '-p', '-f', # '-n', '-i', '-u', '-o', '-r', '-d' @@ -112,7 +113,7 @@ def main(): if len(args) == 2 and args[0] == "update" and args[1] == "slpkg": it_self_update() - if len(args) == 1 and args[0] == "repolist": + if len(args) == 1 and args[0] == "repo-list": RepoList().repos() if len(args) == 0: @@ -125,26 +126,36 @@ def main(): args[0] == "--version" and args[1:] == []): prog_version() + if len(args) == 3 and args[0] == "repo-add": + Repo().add(args[1], args[2]) + + if len(args) == 2 and args[0] == "repo-remove": + Repo().remove(args[1]) + # checking if repositories exists check_exists_repositories() if len(args) == 1 and args[0] == "re-create": Initialization().re_create() - if (len(args) == 2 and args[0] == "repoinfo" and + if (len(args) == 2 and args[0] == "repo-info" and args[1] in RepoList().all_repos): del RepoList().all_repos RepoInfo().view(args[1]) - elif (len(args) == 2 and args[0] == "repoinfo" and + elif (len(args) == 2 and args[0] == "repo-info" and args[1] not in RepoList().all_repos): usage(args[1]) if len(args) == 3 and args[0] == "-a": BuildPackage(args[1], args[2:], path).build() elif len(args) == 2 and args[0] == "-l": - pkg_list = ["all"] + repositories - if args[1] in pkg_list: - PackageManager(None).list(args[1]) + if args[1] in ['all', 'official', 'non-official']: + PackageManager(None).list(args[1], False) + else: + usage('') + elif len(args) == 3 and args[0] == "-l" and args[2] == '--index': + if args[1] in ['all', 'official', 'non-official']: + PackageManager(None).list(args[1], True) else: usage('') elif len(args) == 3 and args[0] == "-c" and args[2] == "--upgrade": @@ -200,7 +211,7 @@ def main(): PackageManager(args[1:]).reinstall() elif len(args) > 1 and args[0] == "-r": PackageManager(args[1:]).remove() - elif len(args) == 2 and args[0] == "-f": + elif len(args) > 1 and args[0] == "-f": PackageManager(args[1:]).find() elif len(args) == 3 and args[0] == "-p" and args[1] in repositories: PkgDesc(args[2], args[1], "").view() diff --git a/slpkg/others/check.py b/slpkg/others/check.py index 80b2e9c6..284dd580 100644 --- a/slpkg/others/check.py +++ b/slpkg/others/check.py @@ -40,7 +40,8 @@ from slpkg.__metadata__ import ( slpkg_tmp_packages, default_answer, color, - slacke_sub_repo + slacke_sub_repo, + default_repositories ) from slpkg.pkg.find import find_package @@ -62,12 +63,19 @@ class OthersUpgrade(object): sys.stdout.flush() self.step = 700 - exec('self._init_{0}()'.format(self.repo)) + if repo in default_repositories: + exec('self._init_{0}()'.format(self.repo)) + else: + exec('self._init_custom()') f = open(self.lib, "r") self.PACKAGES_TXT = f.read() f.close() + def _init_custom(self): + self.lib = lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo) + self.mirror = "{0}".format(Repo().custom_repository()[self.repo]) + def _init_rlw(self): self.lib = lib_path + "rlw_repo/PACKAGES.TXT" self.mirror = "{0}{1}/".format(Repo().rlw(), slack_ver()) @@ -145,6 +153,11 @@ class OthersUpgrade(object): self.mirror = "{0}{1}/current/".format(Repo().slackel(), arch) self.step = self.step * 2 + def _init_rested(self): + self.lib = lib_path + "rested_repo/PACKAGES.TXT" + self.mirror = Repo().restricted() + self.step = self.step * 2 + def start(self): ''' Install packages from official Slackware distribution diff --git a/slpkg/others/greps.py b/slpkg/others/greps.py index fa6aaf97..b32045db 100644 --- a/slpkg/others/greps.py +++ b/slpkg/others/greps.py @@ -24,7 +24,6 @@ import os from slpkg.toolbar import status -from slpkg.splitting import split_package from slpkg.slack.slack_version import slack_ver from slpkg.__metadata__ import ( lib_path, @@ -59,7 +58,7 @@ def repo_data(PACKAGES_TXT, step, repo, version): rsize, runsize ) = rlw_filter(name, location, size, unsize) - elif repo == "alien": + elif repo == "alien" or repo == "rested": (rname, rlocation, rsize, @@ -77,8 +76,7 @@ def repo_data(PACKAGES_TXT, step, repo, version): rsize, runsize ) = multi_filter(name, location, size, unsize, version) - elif repo in ["slacky", "studio", "slackr", "slonly", "slacke", - "salix", "slackl"]: + else: rname, rlocation, rsize, runsize = name, location, size, unsize return [rname, rlocation, rsize, runsize] @@ -187,29 +185,7 @@ class Requires(object): ''' Grap package requirements from repositories ''' - if self.repo in ["alien", "slacky", "slackr", "salix", "slackl"]: - lib = '{0}{1}_repo/PACKAGES.TXT'.format(lib_path, self.repo) - f = open(lib, "r") - PACKAGES_TXT = f.read() - f.close() - for line in PACKAGES_TXT.splitlines(): - if line.startswith("PACKAGE NAME: "): - if self.repo == "slackr": - pkg_name = line[14:].strip() - else: - 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 in ["slacky", "salix", "slackl"]: - return self._req_fix(line) - elif self.repo == "alien": - return line[18:].strip().split(",") - else: - return line[18:].strip().split() - - elif self.repo == "rlw": + if self.repo == "rlw": # Robby's repository dependencies as shown in the central page # http://rlworkman.net/pkgs/ dependencies = { @@ -224,6 +200,18 @@ class Requires(object): return dependencies[self.name].split() else: return "" + else: + lib = '{0}{1}_repo/PACKAGES.TXT'.format(lib_path, self.repo) + f = open(lib, "r") + PACKAGES_TXT = f.read() + f.close() + for line in PACKAGES_TXT.splitlines(): + if line.startswith("PACKAGE NAME: "): + pkg_name = line[14:].strip().split('-')[0] + if line.startswith("PACKAGE REQUIRED: "): + if pkg_name == self.name: + if line[17:].strip(): + return self._req_fix(line) def _req_fix(self, line): ''' @@ -231,7 +219,7 @@ class Requires(object): with ',' and others with '|' ''' deps = [] - for dep in line[18:].strip().split(","): + for dep in line[18:].strip().split(','): dep = dep.split("|") if self.repo == 'slacky': if len(dep) > 1: diff --git a/slpkg/others/install.py b/slpkg/others/install.py index 2468da11..e0c96a78 100644 --- a/slpkg/others/install.py +++ b/slpkg/others/install.py @@ -43,7 +43,8 @@ from slpkg.__metadata__ import ( slpkg_tmp_packages, default_answer, color, - slacke_sub_repo + slacke_sub_repo, + default_repositories ) from slpkg.pkg.find import find_package @@ -69,13 +70,20 @@ class OthersInstall(object): sys.stdout.flush() self.step = 700 - exec('self._init_{0}()'.format(self.repo)) + if repo in default_repositories: + exec('self._init_{0}()'.format(self.repo)) + else: + exec('self._init_custom()') f = open(self.lib, "r") self.PACKAGES_TXT = f.read() f.close() sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC'])) + def _init_custom(self): + self.lib = lib_path + "{0}_repo/PACKAGES.TXT".format(self.repo) + self.mirror = "{0}".format(Repo().custom_repository()[self.repo]) + def _init_rlw(self): self.lib = lib_path + "rlw_repo/PACKAGES.TXT" self.mirror = "{0}{1}/".format(Repo().rlw(), slack_ver()) @@ -153,6 +161,11 @@ class OthersInstall(object): self.mirror = "{0}{1}/current/".format(Repo().slackel(), arch) self.step = self.step * 2 + def _init_rested(self): + self.lib = lib_path + "rested_repo/PACKAGES.TXT" + self.mirror = Repo().restricted() + self.step = self.step * 2 + def start(self): ''' Install packages from official Slackware distribution @@ -161,6 +174,7 @@ class OthersInstall(object): dependencies = resolving_deps(self.package, self.repo) (dwn_links, install_all, comp_sum, uncomp_sum ) = self.store(dependencies) + dependencies = equal_deps_and_install(dependencies, install_all) sys.stdout.write("{0}Done{1}\n".format(color['GREY'], color['ENDC'])) print("") # new line at start @@ -246,6 +260,21 @@ class OthersInstall(object): return [dwn, install, comp_sum, uncomp_sum] +def equal_deps_and_install(dependencies, install_all): + ''' + This fixes be written dependencies equal to those that + will be installed because some repositories like 'salix' + said dependencies that exist in the distribution but not + in the repository itself. + ''' + deps = [] + for dep in dependencies: + for inst in install_all: + if inst.startswith(dep + '-'): + deps.append(dep) + return deps + + def views(install_all, comp_sum, repository, dependencies): ''' Views packages @@ -347,15 +376,16 @@ def write_deps(dependencies): Write dependencies in a log file into directory `/var/log/slpkg/dep/` ''' - name = dependencies[-1] - if find_package(name + "-", pkg_path): - dep_path = log_path + "dep/" - if not os.path.exists(dep_path): - os.mkdir(dep_path) - if os.path.isfile(dep_path + name): - os.remove(dep_path + name) - if len(dependencies[:-1]) > 0: - with open(dep_path + name, "w") as f: - for dep in dependencies[:-1]: - f.write(dep + "\n") + if len(dependencies) > 1: + name = dependencies[-1] + if find_package(name + "-", pkg_path): + dep_path = log_path + "dep/" + if not os.path.exists(dep_path): + os.mkdir(dep_path) + if os.path.isfile(dep_path + name): + os.remove(dep_path + name) + if len(dependencies[:-1]) > 0: + with open(dep_path + name, "w") as f: + for dep in dependencies[:-1]: + f.write(dep + "\n") f.close() diff --git a/slpkg/pkg/manager.py b/slpkg/pkg/manager.py index 27b21ad6..0b18fecd 100644 --- a/slpkg/pkg/manager.py +++ b/slpkg/pkg/manager.py @@ -30,6 +30,7 @@ from slpkg.messages import ( template ) from slpkg.__metadata__ import ( + lib_path, pkg_path, sp, log_path, @@ -40,7 +41,6 @@ from slpkg.__metadata__ import ( ) from slpkg.pkg.find import find_package -from slpkg.slack.slack_version import slack_ver class PackageManager(object): @@ -230,34 +230,35 @@ class PackageManager(object): ''' matching = size = 0 print("\nPackages with matching name [ {0}{1}{2} ]\n".format( - color['CYAN'], ''.join(self.binary), color['ENDC'])) - for match in find_package(''.join(self.binary), pkg_path): - if ''.join(self.binary) in match: - matching += 1 - print("[ {0}installed{1} ] - {2}".format( - color['GREEN'], color['ENDC'], match)) - with open(pkg_path + match, "r") as f: - data = f.read() - f.close() - for line in data.splitlines(): - if line.startswith("UNCOMPRESSED PACKAGE SIZE:"): - if "M" in line[26:]: - size += float(line[26:-1]) * 1024 - else: - size += float(line[26:-1]) - break + color['CYAN'], ', '.join(self.binary), color['ENDC'])) + for pkg in self.binary: + for match in find_package(pkg, pkg_path): + if pkg in match: + matching += 1 + print("[ {0}installed{1} ] - {2}".format( + color['GREEN'], color['ENDC'], match)) + with open(pkg_path + match, "r") as f: + data = f.read() + f.close() + for line in data.splitlines(): + if line.startswith("UNCOMPRESSED PACKAGE SIZE:"): + if "M" in line[26:]: + size += float(line[26:-1]) * 1024 + else: + size += float(line[26:-1]) + break if matching == 0: message = "Can't find" - pkg_not_found("", self.binary, message, "\n") + pkg_not_found("", pkg, message, "\n") else: print("\n{0}Total found {1} matching packages.{2}".format( - color['GREY'], matching, color['ENDC'])) + color['GREY'], matching, color['ENDC'])) unit = "Kb" if size > 1024: unit = "Mb" size = (size / 1024) print("{0}Size of installed packages {1} {2}.{3}\n".format( - color['GREY'], round(size, 2), unit, color['ENDC'])) + color['GREY'], round(size, 2), unit, color['ENDC'])) def display(self): ''' @@ -278,46 +279,44 @@ class PackageManager(object): bol = eol = "\n" pkg_not_found(bol, pkg, message, eol) - def list(self, pattern): + def list(self, pattern, INDEX): ''' List with the installed packages ''' tty_size = os.popen('stty size', 'r').read().split() row = int(tty_size[0]) - 2 + pkg_list = [] try: - pkg_list = { - 'sbo': ['_SBo'], - 'slack': ['_slack{0}'.format(slack_ver())], - 'rlw': ['_rlw'], - 'alien': ['alien'], - 'slacky': ['sl'], - 'studio': ['se'], - 'slackr': ['cf'], - 'slonly': ['_slack'], - 'ktown': ['alien'], - 'multi': ['alien', 'alien_slack{0}'.format(slack_ver()), - 'compat32'], - 'slacke': ['jp'], - 'salix': ['gv', 'rl', 'msb', 'dj', 'tg', 'cp', 'tjb', 'alien'], - 'slackl': [''], - 'all': [''] - } - search = pkg_list[pattern] - index, page = 0, row + index, page, official, r = 0, row, [], '' + if os.path.isfile(lib_path + 'slack_repo/PACKAGES.TXT'): + f = open(lib_path + 'slack_repo/PACKAGES.TXT', 'r') + r = f.read() + f.close() + for line in r.splitlines(): + if line.startswith("PACKAGE NAME: "): + official.append(line[15:-4].strip()) for pkg in find_package("", pkg_path): - for tag in search: - if pkg.endswith(tag): - index += 1 - print("{0}{1}:{2} {3}".format(color['GREY'], index, - color['ENDC'], pkg)) - if index == page: - read = raw_input("\nPress {0}Enter{1} to " - "continue... ".format( - color['CYAN'], color['ENDC'])) - if read in ['Q', 'q']: - break - print("") # new line after page - page += row + if pattern == 'all': + pkg_list.append(pkg) + elif pattern == 'official' and pkg in official: + pkg_list.append(pkg) + elif pattern == 'non-official' and pkg not in official: + pkg_list.append(pkg) + for pkg in sorted(pkg_list): + if INDEX: + index += 1 + print("{0}{1}:{2} {3}".format(color['GREY'], index, + color['ENDC'], pkg)) + if index == page: + read = raw_input("\nPress {0}Enter{1} to " + "continue... ".format(color['CYAN'], + color['ENDC'])) + if read in ['Q', 'q']: + break + print("") # new line after page + page += row + else: + print pkg print("") # new line at end except KeyboardInterrupt: print("") # new line at exit diff --git a/slpkg/queue.py b/slpkg/queue.py index 8c0662fa..6bc648ba 100644 --- a/slpkg/queue.py +++ b/slpkg/queue.py @@ -22,6 +22,7 @@ # along with this program. If not, see . import os +from collections import OrderedDict from downloader import Download from __metadata__ import ( @@ -96,7 +97,7 @@ class QueuePkgs(object): Add packages in queue if not exist ''' queue_list = self.packages() - pkgs = set(pkgs) + pkgs = list(OrderedDict.fromkeys(pkgs)) print("\nAdd packages in queue:\n") with open(self.queue_list, "a") as queue: for pkg in pkgs: @@ -146,9 +147,9 @@ class QueuePkgs(object): sources = [] os.chdir(build_path) script = sbo_dwn.split("/")[-1] - Download(build_path, sbo_dwn).start() + Download(build_path, sbo_dwn.split()).start() for src in source_dwn: - Download(build_path, src).start() + Download(build_path, src.split()).start() sources.append(src.split("/")[-1]) BuildPackage(script, sources, build_path).build() else: diff --git a/slpkg/repoinfo.py b/slpkg/repoinfo.py index 652f27ca..6f4e6787 100644 --- a/slpkg/repoinfo.py +++ b/slpkg/repoinfo.py @@ -24,9 +24,11 @@ import os import sys +from repositories import Repo from sizes import units from repolist import RepoList from __metadata__ import ( + default_repositories, lib_path, log_path, repositories, @@ -41,6 +43,7 @@ class RepoInfo(object): 'Last updated:': '', 'Number of packages:': '', 'Repo id:': '', + 'Default:': '', 'Repo url:': '', 'Status:': '', 'Total compressed packages:': '', @@ -48,6 +51,7 @@ class RepoInfo(object): } self.all_repos = RepoList().all_repos + self.all_repos.update(Repo().custom_repository()) del RepoList().all_repos def view(self, repo): @@ -56,8 +60,12 @@ class RepoInfo(object): ''' status = '{0}disabled{1}'.format(color['RED'], color['ENDC']) self.form['Status:'] = status + self.form['Default:'] = 'no' + if repo in default_repositories: + self.form['Default:'] = 'yes' if (repo in repositories and - os.path.isfile(log_path + '{0}/ChangeLog.txt'.format(repo))): + os.path.isfile(lib_path + '{0}_repo/PACKAGES.TXT'.format( + repo))): status = '{0}enabled{1}'.format(color['GREEN'], color['ENDC']) if repo != 'sbo': data = self.repository_data(repo) @@ -71,20 +79,22 @@ class RepoInfo(object): self.form['Number of packages:'] = data[0] self.form['Status:'] = status self.form['Last updated:'] = data[3] - elif repo == 'sbo': - sum_sbo_pkgs = 0 - for line in open(lib_path + 'sbo_repo/SLACKBUILDS.TXT', 'r'): - if line.startswith('SLACKBUILD NAME: '): - sum_sbo_pkgs += 1 - with open(log_path + 'sbo/ChangeLog.txt', 'r') as changelog_txt: - last_upd = changelog_txt.readline().replace('\n', '') - self.form['Repo id:'] = repo - self.form['Repo url:'] = self.all_repos[repo] - self.form['Total compressed packages:'] = '' - self.form['Total uncompressed packages:'] = '' - self.form['Number of packages:'] = sum_sbo_pkgs - self.form['Status:'] = status - self.form['Last updated:'] = last_upd + elif (repo == 'sbo' and os.path.isfile(lib_path + '{0}_repo/' + 'SLACKBUILDS.TXT'.format(repo))): + status = '{0}enabled{1}'.format(color['GREEN'], color['ENDC']) + sum_sbo_pkgs = 0 + for line in open(lib_path + 'sbo_repo/SLACKBUILDS.TXT', 'r'): + if line.startswith('SLACKBUILD NAME: '): + sum_sbo_pkgs += 1 + with open(log_path + 'sbo/ChangeLog.txt', 'r') as changelog_txt: + last_upd = changelog_txt.readline().replace('\n', '') + self.form['Repo id:'] = repo + self.form['Repo url:'] = self.all_repos[repo] + self.form['Total compressed packages:'] = '' + self.form['Total uncompressed packages:'] = '' + self.form['Number of packages:'] = sum_sbo_pkgs + self.form['Status:'] = status + self.form['Last updated:'] = last_upd print('') for key, value in sorted(self.form.iteritems()): print color['GREY'] + key + color['ENDC'], value diff --git a/slpkg/repolist.py b/slpkg/repolist.py index 1a1e46ee..1130e347 100644 --- a/slpkg/repolist.py +++ b/slpkg/repolist.py @@ -27,6 +27,7 @@ import sys from repositories import Repo from messages import template from __metadata__ import ( + default_repositories, repositories, color ) @@ -48,8 +49,10 @@ class RepoList(object): 'multi': Repo().multi(), 'slacke': Repo().slacke(), 'salix': Repo().salix(), - 'slackl': Repo().slackel() + 'slackl': Repo().slackel(), + 'rested': Repo().restricted() } + self.all_repos.update(Repo().custom_repository()) def repos(self): ''' @@ -57,19 +60,26 @@ class RepoList(object): ''' print('') template(78) - print('{0}{1}{2}{3}{4}'.format( - '| Repo id', ' ' * 10, - 'Repo name', ' ' * 45, + print('{0}{1}{2}{3}{4}{5}{6}'.format( + '| Repo id', ' ' * 2, + 'Repo URL', ' ' * 44, + 'Default', ' ' * 3, 'Status')) template(78) - for repo_id, repo_name in sorted(self.all_repos.iteritems()): + for repo_id, repo_URL in sorted(self.all_repos.iteritems()): status, COLOR = 'disabled', color['RED'] + default = 'yes' + if len(repo_URL) > 49: + repo_URL = repo_URL[:48] + '~' if repo_id in repositories: status, COLOR = 'enabled', color['GREEN'] - print(' {0}{1}{2}{3}{4}{5:>15}{6}'.format( - repo_id, ' ' * (17 - len(repo_id)), - repo_name, ' ' * (45 - len(repo_name)), + if repo_id not in default_repositories: + default = 'no' + print(' {0}{1}{2}{3}{4}{5}{6}{7:>8}{8}'.format( + repo_id, ' ' * (9 - len(repo_id)), + repo_URL, ' ' * (52 - len(repo_URL)), + default, ' ' * (8 - len(default)), COLOR, status, color['ENDC'])) - print("\nFor enable or disable repositories edit " + print("\nFor enable or disable default repositories edit " "'/etc/slpkg/slpkg.conf' file\n") sys.exit(0) diff --git a/slpkg/repositories.py b/slpkg/repositories.py index ddd74de5..9d1bb3f4 100644 --- a/slpkg/repositories.py +++ b/slpkg/repositories.py @@ -23,12 +23,82 @@ import os +import sys + +from __metadata__ import ( + default_repositories, + repositories +) class Repo(object): def __init__(self): - pass + self.repo_file = "/etc/slpkg/custom-repositories" + f = open(self.repo_file, "r") + self.repositories_list = f.read() + f.close() + + def add(self, repo, url): + ''' + Write custom repository name and url in a file + ''' + repo_name = [] + if not url.endswith('/'): + url = url + '/' + for line in self.repositories_list.splitlines(): + line = line.lstrip() + if line and not line.startswith("#"): + repo_name.append(line.split()[0]) + if (repo in repositories or repo in repo_name or + repo in default_repositories): + print("\nRepository name '{0}' exist, select different name.\n" + "View all repositories with command 'repo-list'.\n".format( + repo)) + sys.exit(0) + elif len(repo) > 6: + print("\nMaximum repository name length must be six (6) " + "characters\n") + sys.exit(0) + elif not url.startswith('http') or url.startswith('ftp'): + print("\nWrong type URL '{0}'\n".format(url)) + sys.exit(0) + with open(self.repo_file, "a") as repos: + new_line = " {0}{1}{2}\n".format(repo, ' ' * (10 - len(repo)), url) + repos.write(new_line) + repos.close() + print("\nRepository '{0}' successfully added\n".format(repo)) + sys.exit(0) + + def remove(self, repo): + ''' + Remove custom repository + ''' + rem_repo = False + with open(self.repo_file, "w") as repos: + for line in self.repositories_list.splitlines(): + repo_name = line.split()[0] + if repo_name != repo: + repos.write(line + "\n") + else: + print("\nRepository '{0}' successfully " + "removed\n".format(repo)) + rem_repo = True + repos.close() + if not rem_repo: + print("\nRepository '{0}' doesn't exist\n".format(repo)) + sys.exit(0) + + def custom_repository(self): + ''' + Return dictionary with repo name and url + ''' + dict_repo = {} + for line in self.repositories_list.splitlines(): + line = line.lstrip() + if not line.startswith("#"): + dict_repo[line.split()[0]] = line.split()[1] + return dict_repo def slack(self): ''' @@ -116,3 +186,10 @@ class Repo(object): Slackel.gr slackel repository ''' return "http://www.slackel.gr/repo/" + + def restricted(self): + ''' + Slackel.gr slackel repository + ''' + return ("http://taper.alienbase.nl/mirrors/people/alien/" + "restricted_slackbuilds/") diff --git a/slpkg/sbo/check.py b/slpkg/sbo/check.py index f68777f2..a0447a0a 100644 --- a/slpkg/sbo/check.py +++ b/slpkg/sbo/check.py @@ -151,7 +151,7 @@ class SBoCheck(object): def exists(self): ''' - search packages if exists in the repository + Search packages if exists in the repository and it gets to avoidable modified packages from the user with the tag _SBo ''' diff --git a/slpkg/slack/install.py b/slpkg/slack/install.py index 13ce55de..254784be 100644 --- a/slpkg/slack/install.py +++ b/slpkg/slack/install.py @@ -134,7 +134,7 @@ def views(install_all, comp_sum): Views packages ''' pkg_sum = uni_sum = upg_sum = 0 - for pkg, comp in zip(install_all, comp_sum): + for pkg, comp in sorted(zip(install_all, comp_sum)): pkg_split = split_package(pkg[:-4]) if os.path.isfile(pkg_path + pkg[:-4]): pkg_sum += 1 diff --git a/slpkg/slack/patches.py b/slpkg/slack/patches.py index 61418560..c7bafe55 100644 --- a/slpkg/slack/patches.py +++ b/slpkg/slack/patches.py @@ -142,7 +142,8 @@ def views(pkg_for_upgrade, upgrade_all, comp_sum): ''' Views packages ''' - for upg, upgrade, size in zip(pkg_for_upgrade, upgrade_all, comp_sum): + for upg, upgrade, size in sorted(zip(pkg_for_upgrade, upgrade_all, + comp_sum)): pkg_split = split_package(upgrade[:-4]) print(" {0}{1}{2}{3} {4}{5} {6}{7}{8}{9}{10}{11:>12}{12}".format( color['YELLOW'], upg, color['ENDC'], diff --git a/slpkg/slpkg_update.py b/slpkg/slpkg_update.py index a57648e8..c35f133e 100644 --- a/slpkg/slpkg_update.py +++ b/slpkg/slpkg_update.py @@ -28,6 +28,8 @@ import sys import tarfile import subprocess +from checksum import check_md5 +from grep_md5 import pkg_checksum from url_read import URL from downloader import Download from __metadata__ import ( @@ -60,7 +62,7 @@ def it_self_update(): else: print("\nNew version '{0}-{1}' is available !\n".format( __all__, __new_version__)) - answer = raw_input("Would you like to continue [Y/n]? ") + answer = raw_input("Would you like to upgrade [Y/n]? ") if answer in ['y', 'Y']: print("") # new line after answer else: @@ -70,11 +72,14 @@ def it_self_update(): __new_version__)] Download(build_path, dwn_link).start() os.chdir(build_path) - tar = tarfile.open('v' + __new_version__ + '.tar.gz') + slpkg_tar_file = 'v' + __new_version__ + '.tar.gz' + tar = tarfile.open(slpkg_tar_file) tar.extractall() tar.close() file_name = '{0}-{1}'.format(__all__, __new_version__) os.chdir(file_name) + check_md5(pkg_checksum(slpkg_tar_file, "slpkg"), + build_path + slpkg_tar_file) subprocess.call('chmod +x {0}'.format(file_name), shell=True) subprocess.call('sh install.sh', shell=True) else: diff --git a/slpkg/url_read.py b/slpkg/url_read.py index 4c05a2c6..efd28092 100644 --- a/slpkg/url_read.py +++ b/slpkg/url_read.py @@ -24,6 +24,8 @@ import sys import urllib2 +from __metadata__ import color + class URL(object): @@ -38,8 +40,9 @@ class URL(object): f = urllib2.urlopen(self.link) return f.read() except (urllib2.URLError, ValueError): - print("\nslpkg: error: connection refused\n") - sys.exit(0) + print("\n{0}Can't read file '{1}'{2}".format( + color['RED'], self.link.split('/')[-1], color['ENDC'])) + return ' ' except KeyboardInterrupt: print("") # new line at exit sys.exit(0)