mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-26 09:58:31 +01:00
updated for version 2.0.4
This commit is contained in:
parent
400f20bbca
commit
57b344a208
35 changed files with 1385 additions and 421 deletions
|
@ -1,3 +1,11 @@
|
|||
Version 2.0.4
|
||||
7-11-2014
|
||||
|
||||
[Feature] - Add Robby Workman, Alien Bob (Eric Hameleers) and
|
||||
slacky.eu repositories.
|
||||
|
||||
[Updated] - Fix remove list reference.
|
||||
|
||||
Version 2.0.3
|
||||
29-10-2014
|
||||
|
||||
|
|
2
PKG-INFO
2
PKG-INFO
|
@ -1,6 +1,6 @@
|
|||
Metadata-Version: 1.1
|
||||
Name: slpkg
|
||||
Version: 2.0.2
|
||||
Version: 2.0.4
|
||||
Author: dslackw
|
||||
Author-email: d zlatanidis at gmail com
|
||||
Maintainer: dslackw
|
||||
|
|
33
README.rst
33
README.rst
|
@ -11,9 +11,9 @@
|
|||
|
||||
Latest Release:
|
||||
|
||||
- Version: 2.0.3
|
||||
- Version: 2.0.4
|
||||
- `Package <https://sourceforge.net/projects/slpkg/files/slpkg/binary/>`_
|
||||
- `Source <https://github.com/dslackw/slpkg/archive/v2.0.3.tar.gz>`_
|
||||
- `Source <https://github.com/dslackw/slpkg/archive/v2.0.4.tar.gz>`_
|
||||
- `CHANGELOG <https://github.com/dslackw/slpkg/blob/master/CHANGELOG>`_
|
||||
|
||||
.. image:: https://raw.githubusercontent.com/dslackw/images/master/slpkg/logo.png
|
||||
|
@ -29,10 +29,13 @@ packages.
|
|||
|
||||
Slpkg is `Open Source <http://en.wikipedia.org/wiki/Open_source>`_ software written in
|
||||
Python language. It's use is for managing packages in Slackware linux distribution.
|
||||
Species are adapted to two repositories:
|
||||
Supported Repositories:
|
||||
|
||||
- SBo - `slackbuilds.org <http://slackbuilds.org/>`_
|
||||
- Slack - `slackware.com <http://www.slackware.com/>`_
|
||||
- Alien - `alien bob <http://www.slackware.com/~alien/slackbuilds/>`_
|
||||
- Slacky - `slacky.eu <http://repository.slacky.eu/>`_
|
||||
- Robby's - `rworkman's <http://rlworkman.net/pkgs/>`_
|
||||
|
||||
Slpkg works in accordance with the standards of the organization slackbuilds.org
|
||||
to builds packages. Also uses the Slackware linux instructions for installation,
|
||||
|
@ -65,9 +68,8 @@ Features
|
|||
--------
|
||||
|
||||
- Build third party packages from source with all dependencies
|
||||
- Install packages through from official `Slackware <http://www.slackware.com/>`_ mirrors
|
||||
- Find and Download packages from `slackbuilds.org <http://slackbuilds.org/>`_
|
||||
- Grabs packages from slackbuilds.org in real time
|
||||
- Grabs packages from repositories in real time
|
||||
- Find and Download packages from repositories
|
||||
- Automatic tool build and install packages
|
||||
- Check if your distribution is up to date
|
||||
- Remove packages with all dependencies
|
||||
|
@ -100,8 +102,8 @@ Untar the archive and run install.sh script:
|
|||
|
||||
.. code-block:: bash
|
||||
|
||||
$ tar xvf slpkg-2.0.3.tar.gz
|
||||
$ cd slpkg-2.0.3
|
||||
$ tar xvf slpkg-2.0.4.tar.gz
|
||||
$ cd slpkg-2.0.4
|
||||
$ ./install.sh
|
||||
|
||||
Using `pip <https://pip.pypa.io/en/latest/>`_ :
|
||||
|
@ -132,7 +134,7 @@ Command Line Tool Usage
|
|||
-b, --list, [package...] --add, --remove add, remove packages in blacklist
|
||||
-q, --list, [package...] --add, --remove add, remove packages in queue
|
||||
--build, --install, --build-install build or install from queue
|
||||
-l, all, sbo, slack, noarch list of installed packages
|
||||
-l, <repository>, all, noarch list of installed packages
|
||||
-c, <repository> --upgrade --current check for updated packages
|
||||
-s, <repository> <package> --current download, build & install
|
||||
-f, <package> find installed packages
|
||||
|
@ -143,10 +145,15 @@ Command Line Tool Usage
|
|||
-o, [package...] reinstall binary packages
|
||||
-r, [package...] remove binary packages
|
||||
-d, [package...] display the contents
|
||||
Repositories:
|
||||
SlackBuilds = sbo
|
||||
Slackware = slack '--current'
|
||||
|
||||
Note: '-q' options is working only for SBo repository
|
||||
|
||||
Repositories:
|
||||
Slackware = slack '--current'
|
||||
Alien = alien '--current'
|
||||
SlackBuilds = sbo
|
||||
Slacky = slacky
|
||||
Robby's = rlw
|
||||
|
||||
Slpkg Examples
|
||||
--------------
|
||||
|
@ -378,7 +385,7 @@ Auto tool to build package:
|
|||
|
||||
Searching for symbolic links:
|
||||
|
||||
No symbolic links were found, so we won't make an installation script.
|
||||
No symbolic links were found, so we wont make an installation script.
|
||||
You can make your own later in ./install/doinst.sh and rebuild the
|
||||
package if you like.
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
PRGNAM=slpkg
|
||||
VERSION=${VERSION:-2.0.3}
|
||||
VERSION=${VERSION:-2.0.4}
|
||||
TAG=${TAG:-_dsw}
|
||||
|
||||
cd ..
|
||||
|
@ -35,18 +35,21 @@ if [ -f $PRGNAM-$VERSION.zip ]; then
|
|||
chmod +x $PRGNAM.SlackBuild
|
||||
./$PRGNAM.SlackBuild
|
||||
rm $PRGNAM-$VERSION.zip
|
||||
|
||||
elif [ -f v$VERSION.zip ]; then
|
||||
cp v$VERSION.zip $PRGNAM-$VERSION/slackbuild
|
||||
cd $PRGNAM-$VERSION/slackbuild
|
||||
chmod +x $PRGNAM.SlackBuild
|
||||
./$PRGNAM.SlackBuild
|
||||
rm v$VERSION.zip
|
||||
|
||||
elif [ -f $PRGNAM-$VERSION.tar.gz ]; then
|
||||
cp $PRGNAM-$VERSION.tar.gz $PRGNAM-$VERSION/slackbuild
|
||||
cd $PRGNAM-$VERSION/slackbuild
|
||||
chmod +x $PRGNAM.SlackBuild
|
||||
./$PRGNAM.SlackBuild
|
||||
rm $PRGNAM-$VERSION.tar.gz
|
||||
|
||||
else
|
||||
cp v$VERSION.tar.gz $PRGNAM-$VERSION/slackbuild
|
||||
cd $PRGNAM-$VERSION/slackbuild
|
||||
|
|
|
@ -39,7 +39,7 @@ Optional arguments:
|
|||
-b, --list, [package...] --add, --remove add, remove packages in blacklist
|
||||
-q, --list, [package...] --add, --remove add, remove packages in queue
|
||||
--build, --install, --build-install build or install from queue
|
||||
-l, all, sbo, slack, noarch list of installed packages
|
||||
-l, <repository>, all, noarch list of installed packages
|
||||
-c, <repository> --upgrade --current check for updated packages
|
||||
-s, <repository> <package> --current download, build & install
|
||||
-f, <package> find installed packages
|
||||
|
@ -51,9 +51,14 @@ Optional arguments:
|
|||
-r, [package...] remove binary packages
|
||||
-d, [package...] display the contents
|
||||
|
||||
Note: '-q' options is working only for SBo repository
|
||||
|
||||
Repositories:
|
||||
Slackware = slack '--current'
|
||||
Alien = alien '--current'
|
||||
SlackBuilds = sbo
|
||||
Slackware = slack '--current'\fP
|
||||
Slacky = slacky
|
||||
Robby's = rlw\fP
|
||||
|
||||
.SH GLOBAL OPTIONS
|
||||
.TP
|
||||
|
|
3
setup.py
3
setup.py
|
@ -35,7 +35,8 @@ except ImportError:
|
|||
|
||||
setup(
|
||||
name="slpkg",
|
||||
packages=["slpkg", "slpkg/sbo", "slpkg/pkg", "slpkg/slack"],
|
||||
packages=["slpkg", "slpkg/sbo", "slpkg/pkg", "slpkg/slack",
|
||||
"slpkg/others"],
|
||||
scripts=["bin/slpkg"],
|
||||
version=__version__,
|
||||
description="Python tool to manage Slackware packages",
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
Slpkg is Open Source software written in Python language.
|
||||
It's use is for managing packages in Slackware linux
|
||||
distribution. Species are adapted to two repositories:
|
||||
distribution. Supported Repositories:
|
||||
|
||||
- SBo - slackbuilds.org
|
||||
- Slack - slackware.com
|
||||
- Slack - slackware.com
|
||||
- Alien - alien bob
|
||||
- Slacky - slacky.eu
|
||||
- Robby's - rworkman's
|
||||
|
||||
Slpkg works in accordance with the standards of the organization
|
||||
slackbuilds.org to builds packages. Also uses the Slackware linux
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
PRGNAM=slpkg
|
||||
VERSION=${VERSION:-2.0.3}
|
||||
VERSION=${VERSION:-2.0.4}
|
||||
BUILD=${BUILD:-1}
|
||||
TAG=${TAG:-_dsw}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
PRGNAM="slpkg"
|
||||
VERSION="2.0.3"
|
||||
VERSION="2.0.4"
|
||||
HOMEPAGE="https://github.com/dslackw/slpkg"
|
||||
DOWNLOAD="https://github.com/dslackw/slpkg/archive/v2.0.3.tar.gz"
|
||||
DOWNLOAD="https://github.com/dslackw/slpkg/archive/v2.0.4.tar.gz"
|
||||
MD5SUM=""
|
||||
DOWNLOAD_x86_64=""
|
||||
MD5SUM_x86_64=""
|
||||
|
|
|
@ -25,7 +25,7 @@ import os
|
|||
|
||||
__all__ = "slpkg"
|
||||
__author__ = "dslackw"
|
||||
__version_info__ = (2, 0, 3)
|
||||
__version_info__ = (2, 0, 4)
|
||||
__version__ = "{0}.{1}.{2}".format(*__version_info__)
|
||||
__license__ = "GNU General Public License v3 (GPLv3)"
|
||||
__email__ = "d.zlatanidis@gmail.com"
|
||||
|
|
|
@ -40,7 +40,7 @@ def options():
|
|||
"queue",
|
||||
" --build, --install, --build-install build or install from " +
|
||||
"queue",
|
||||
" -l, all, sbo, slack, noarch list of installed " +
|
||||
" -l, <repository>, all, noarch list of installed " +
|
||||
"packages",
|
||||
" -c, <repository> --upgrade --current check for updated " +
|
||||
"packages",
|
||||
|
@ -54,9 +54,13 @@ def options():
|
|||
" -o, [package...] reinstall binary packages",
|
||||
" -r, [package...] remove binary packages",
|
||||
" -d, [package...] display the contents\n",
|
||||
"Note: '-q' options is working only for SBo repository\n",
|
||||
"Repositories:",
|
||||
" Slackware = slack '--current'",
|
||||
" Alien = alien '--current'",
|
||||
" SlackBuilds = sbo",
|
||||
" Slackware = slack '--current'\n",
|
||||
" Slacky = slacky",
|
||||
" Robby's = rlw\n"
|
||||
]
|
||||
for opt in arguments:
|
||||
print(opt)
|
||||
|
|
206
slpkg/init.py
206
slpkg/init.py
|
@ -25,81 +25,143 @@ import os
|
|||
import sys
|
||||
|
||||
from url_read import URL
|
||||
from repositories import Repo
|
||||
from file_size import FileSize
|
||||
from __metadata__ import log_path, lib_path
|
||||
|
||||
from slack.slack_version import slack_ver
|
||||
|
||||
|
||||
def initialization():
|
||||
'''
|
||||
Slpkg initialization, creating directories and SLACKBUILDS.TXT in
|
||||
/var/lib/slpkg/sbo_repo/ and ChangeLog.txt in /var/log/slpkg/ from
|
||||
slackbuilds.org.
|
||||
'''
|
||||
sbo_log = log_path + "sbo/"
|
||||
sbo_lib = lib_path + "sbo_repo/"
|
||||
pkg_que = lib_path + "queue"
|
||||
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(sbo_log):
|
||||
os.mkdir(sbo_log)
|
||||
if not os.path.exists(sbo_lib):
|
||||
os.mkdir(sbo_lib)
|
||||
if not os.path.exists(pkg_que):
|
||||
os.mkdir(pkg_que)
|
||||
sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(slack_ver()))
|
||||
# Read SLACKBUILDS.TXT from slackbuilds.org and write in
|
||||
# /var/lib/slpkg/sbo_repo directory if not exist
|
||||
if not os.path.isfile(sbo_lib + "SLACKBUILDS.TXT"):
|
||||
print("\nslpkg ...initialization")
|
||||
sys.stdout.write("SLACKBUILDS.TXT read ...")
|
||||
sys.stdout.flush()
|
||||
SLACKBUILDS_TXT = URL((
|
||||
"http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format(
|
||||
slack_ver()))).reading()
|
||||
sys.stdout.write("Done\n")
|
||||
with open("{0}SLACKBUILDS.TXT".format(sbo_lib), "w") as sbo:
|
||||
sbo.write(SLACKBUILDS_TXT)
|
||||
sbo.close()
|
||||
print("File SLACKBUILDS.TXT created in {0}".format(sbo_lib))
|
||||
# Read ChangeLog.txt from slackbuilds.org and write in /var/log/slpkg/sbo/
|
||||
# directory if not exist
|
||||
if not os.path.isfile(sbo_log + "ChangeLog.txt"):
|
||||
print("\nslpkg initialization")
|
||||
sys.stdout.write("ChangeLog.txt read ...")
|
||||
sys.stdout.flush()
|
||||
ChangeLog_txt = URL((
|
||||
"http://slackbuilds.org/slackbuilds/{0}/ChangeLog.txt".format(
|
||||
slack_ver()))).reading()
|
||||
sys.stdout.write("Done\n")
|
||||
with open("{0}ChangeLog.txt".format(sbo_log), "w") as log:
|
||||
log.write(ChangeLog_txt)
|
||||
log.close()
|
||||
print("File ChangeLog.txt created in {0}".format(sbo_log))
|
||||
# We take the size of ChangeLog.txt from the server and locally
|
||||
server = FileSize(sbo_url + "ChangeLog.txt").server()
|
||||
local = FileSize(sbo_log + "ChangeLog.txt").local()
|
||||
# If the two files differ in size delete and replaced with new
|
||||
if server != local:
|
||||
os.remove("{0}{1}".format(sbo_lib, "SLACKBUILDS.TXT"))
|
||||
os.remove("{0}{1}".format(sbo_log, "ChangeLog.txt"))
|
||||
print("\nNEWS in ChangeLog.txt")
|
||||
print("slpkg ...initialization")
|
||||
sys.stdout.write("Files re-created ...")
|
||||
sys.stdout.flush()
|
||||
SLACKBUILDS_TXT = URL((
|
||||
"http://slackbuilds.org/slackbuilds/{0}/SLACKBUILDS.TXT".format(
|
||||
slack_ver()))).reading()
|
||||
ChangeLog_txt = URL((
|
||||
"http://slackbuilds.org/slackbuilds/{0}/ChangeLog.txt".format(
|
||||
slack_ver()))).reading()
|
||||
with open("{0}SLACKBUILDS.TXT".format(sbo_lib), "w") as sbo:
|
||||
sbo.write(SLACKBUILDS_TXT)
|
||||
sbo.close()
|
||||
with open("{0}ChangeLog.txt".format(sbo_log), "w") as log:
|
||||
log.write(ChangeLog_txt)
|
||||
log.close()
|
||||
sys.stdout.write("Done\n")
|
||||
class Initialization(object):
|
||||
|
||||
def __init__(self):
|
||||
if not os.path.exists(log_path):
|
||||
os.mkdir(log_path)
|
||||
if not os.path.exists(lib_path):
|
||||
os.mkdir(lib_path)
|
||||
|
||||
def sbo(self):
|
||||
'''
|
||||
Creating sbo local library
|
||||
'''
|
||||
repo = Repo().sbo()
|
||||
log = log_path + "sbo/"
|
||||
lib = lib_path + "sbo_repo/"
|
||||
lib_file = "SLACKBUILDS.TXT"
|
||||
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}/{2}".format(repo, slack_ver(), lib_file)
|
||||
changelog_txt = "{0}/{1}/{2}".format(repo, slack_ver(), log_file)
|
||||
self.write(lib, lib_file, packages_txt)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt)
|
||||
|
||||
def rlw(self):
|
||||
'''
|
||||
Creating rlw local library
|
||||
'''
|
||||
repo = Repo().rlw()
|
||||
log = log_path + "rlw/"
|
||||
lib = lib_path + "rlw_repo/"
|
||||
lib_file = "PACKAGES.TXT"
|
||||
log_file = "ChangeLog.txt"
|
||||
if not os.path.exists(log):
|
||||
os.mkdir(log)
|
||||
if not os.path.exists(lib):
|
||||
os.mkdir(lib)
|
||||
packages_txt = "{0}{1}/{2}".format(repo, slack_ver(), lib_file)
|
||||
changelog_txt = "{0}{1}/{2}".format(repo, slack_ver(), log_file)
|
||||
self.write(lib, lib_file, packages_txt)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt)
|
||||
|
||||
def alien(self):
|
||||
'''
|
||||
Creating alien local library
|
||||
'''
|
||||
repo = Repo().alien()
|
||||
log = log_path + "alien/"
|
||||
lib = lib_path + "alien_repo/"
|
||||
lib_file = "PACKAGES.TXT"
|
||||
log_file = "ChangeLog.txt"
|
||||
if not os.path.exists(log):
|
||||
os.mkdir(log)
|
||||
if not os.path.exists(lib):
|
||||
os.mkdir(lib)
|
||||
packages_txt = "{0}{1}".format(repo, lib_file)
|
||||
changelog_txt = "{0}{1}".format(repo, log_file)
|
||||
self.write(lib, lib_file, packages_txt)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt)
|
||||
|
||||
def slacky(self):
|
||||
'''
|
||||
Creating alien local library
|
||||
'''
|
||||
ar = ""
|
||||
arch = os.uname()[4]
|
||||
repo = Repo().slacky()
|
||||
log = log_path + "slacky/"
|
||||
lib = lib_path + "slacky_repo/"
|
||||
lib_file = "PACKAGES.TXT"
|
||||
log_file = "ChangeLog.txt"
|
||||
if not os.path.exists(log):
|
||||
os.mkdir(log)
|
||||
if not os.path.exists(lib):
|
||||
os.mkdir(lib)
|
||||
if arch == "x86_64":
|
||||
ar = "64"
|
||||
packages_txt = "{0}slackware{1}-{2}/{3}".format(repo, ar, slack_ver(),
|
||||
lib_file)
|
||||
changelog_txt = "{0}slackware{1}-{2}/{3}".format(repo, ar, slack_ver(),
|
||||
log_file)
|
||||
self.write(lib, lib_file, packages_txt)
|
||||
self.write(log, log_file, changelog_txt)
|
||||
self.remote(log, log_file, changelog_txt, lib, lib_file, packages_txt)
|
||||
|
||||
@staticmethod
|
||||
def write(path, files, file_url):
|
||||
'''
|
||||
Write files in /var/lib/slpkg/?_repo directory
|
||||
'''
|
||||
if not os.path.isfile(path + files):
|
||||
print("\nslpkg ...initialization")
|
||||
sys.stdout.write(files + " read ...")
|
||||
sys.stdout.flush()
|
||||
PACKAGES_TXT = URL(file_url).reading()
|
||||
sys.stdout.write("Done\n")
|
||||
with open("{0}{1}".format(path, files), "w") as f:
|
||||
f.write(PACKAGES_TXT)
|
||||
f.close()
|
||||
print("File {0} created in {1}".format(files, path))
|
||||
|
||||
@staticmethod
|
||||
def remote(*args):
|
||||
'''
|
||||
args[0]=log, args[1]=log_file, arg[2]=changelog_txt
|
||||
args[3]=lib, args[4]=lib_file, arg[5]=packages_txt
|
||||
|
||||
If the two files differ in size delete and replaced with new.
|
||||
We take the size of ChangeLog.txt from the server and locally
|
||||
'''
|
||||
server = FileSize(args[2]).server()
|
||||
local = FileSize(args[0] + args[1]).local()
|
||||
if server != local:
|
||||
os.remove("{0}{1}".format(args[3], args[4]))
|
||||
os.remove("{0}{1}".format(args[0], args[1]))
|
||||
print("\nNEWS in " + args[1])
|
||||
print("slpkg ...initialization")
|
||||
sys.stdout.write("Files re-created ...")
|
||||
sys.stdout.flush()
|
||||
PACKAGES_TXT = URL(args[5]).reading()
|
||||
CHANGELOG_TXT = URL(args[2]).reading()
|
||||
with open("{0}{1}".format(args[3], args[4]), "w") as f:
|
||||
f.write(PACKAGES_TXT)
|
||||
f.close()
|
||||
with open("{0}{1}".format(args[0], args[1]), "w") as f:
|
||||
f.write(CHANGELOG_TXT)
|
||||
f.close()
|
||||
sys.stdout.write("Done\n")
|
||||
|
|
|
@ -41,15 +41,16 @@ from sbo.slackbuild import SBoInstall
|
|||
|
||||
from slack.install import Slack
|
||||
from slack.patches import Patches
|
||||
from others.check import OthersUpgrade
|
||||
from others.install import OthersInstall
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
# root privileges required
|
||||
s_user(getpass.getuser())
|
||||
args = sys.argv
|
||||
args.pop(0)
|
||||
repository = ["sbo", "slack"]
|
||||
repository = ["sbo", "slack", "rlw", "alien", "slacky"]
|
||||
blacklist = BlackList()
|
||||
queue = QueuePkgs()
|
||||
|
||||
|
@ -64,8 +65,8 @@ def main():
|
|||
elif len(args) == 3 and args[0] == "-a":
|
||||
BuildPackage(args[1], args[2:], path).build()
|
||||
elif len(args) == 2 and args[0] == "-l":
|
||||
sbo_list = ["all", "sbo", "slack", "noarch"]
|
||||
if args[1] in sbo_list:
|
||||
pkg_list = ["all", "noarch"] + repository
|
||||
if args[1] in pkg_list:
|
||||
PackageManager(None).list(args[1])
|
||||
else:
|
||||
usage()
|
||||
|
@ -75,12 +76,19 @@ def main():
|
|||
elif args[1] == repository[1] and args[2] == "--upgrade":
|
||||
version = "stable"
|
||||
Patches(version).start()
|
||||
elif args[1] == repository[2] and args[2] == "--upgrade":
|
||||
OthersUpgrade(repository[2], "").start()
|
||||
elif args[1] == repository[3] and args[2] == "--upgrade":
|
||||
OthersUpgrade(repository[3], "").start()
|
||||
elif args[1] == repository[4] and args[2] == "--upgrade":
|
||||
OthersUpgrade(repository[4], "").start()
|
||||
else:
|
||||
usage()
|
||||
elif len(args) == 4 and args[0] == "-c":
|
||||
if args[1] == repository[1] and args[3] == "--current":
|
||||
version = "current"
|
||||
Patches(version).start()
|
||||
Patches("current").start()
|
||||
elif args[1] == repository[3] and args[3] == "--current":
|
||||
OthersUpgrade(repository[3], "current").start()
|
||||
else:
|
||||
usage()
|
||||
elif len(args) == 3 and args[0] == "-s":
|
||||
|
@ -88,11 +96,19 @@ def main():
|
|||
SBoInstall(args[2]).start()
|
||||
elif args[1] == repository[1]:
|
||||
Slack(args[2], "stable").start()
|
||||
elif args[1] == repository[2]:
|
||||
OthersInstall(args[2], repository[2], "").start()
|
||||
elif args[1] == repository[3]:
|
||||
OthersInstall(args[2], repository[3], "").start()
|
||||
elif args[1] == repository[4]:
|
||||
OthersInstall(args[2], repository[4], "").start()
|
||||
else:
|
||||
usage()
|
||||
elif len(args) == 4 and args[0] == "-s":
|
||||
if args[1] == repository[1] and args[3] == "--current":
|
||||
Slack(args[2], "current").start()
|
||||
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":
|
||||
|
|
1
slpkg/others/__init__.py
Normal file
1
slpkg/others/__init__.py
Normal file
|
@ -0,0 +1 @@
|
|||
# [ others ] directory
|
218
slpkg/others/check.py
Executable file
218
slpkg/others/check.py
Executable file
|
@ -0,0 +1,218 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# check.py file is part of slpkg.
|
||||
|
||||
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
|
||||
# All rights reserved.
|
||||
|
||||
# Utility for easy management packages in Slackware
|
||||
|
||||
# https://github.com/dslackw/slpkg
|
||||
|
||||
# Slpkg is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from slpkg.sizes import units
|
||||
from slpkg.repositories import Repo
|
||||
from slpkg.messages import template
|
||||
from slpkg.blacklist import BlackList
|
||||
from slpkg.init import Initialization
|
||||
from slpkg.splitting import split_package
|
||||
from slpkg.colors import YELLOW, GREY, ENDC
|
||||
from slpkg.__metadata__ import slpkg_tmp, pkg_path, lib_path
|
||||
|
||||
|
||||
from slpkg.pkg.manager import PackageManager
|
||||
|
||||
from slpkg.slack.remove import delete
|
||||
from slpkg.slack.slack_version import slack_ver
|
||||
|
||||
from greps import repo_data
|
||||
from download import packages_dwn
|
||||
|
||||
|
||||
class OthersUpgrade(object):
|
||||
|
||||
def __init__(self, repo, version):
|
||||
self.repo = repo
|
||||
self.version = version
|
||||
self.tmp_path = slpkg_tmp + "packages/"
|
||||
self.repo_init()
|
||||
repos = Repo()
|
||||
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
|
||||
sys.stdout.flush()
|
||||
self.step = 700
|
||||
repos = Repo()
|
||||
if self.repo == "rlw":
|
||||
lib = lib_path + "rlw_repo/PACKAGES.TXT"
|
||||
self.mirror = "{0}{1}/".format(repos.rlw(), slack_ver())
|
||||
elif self.repo == "alien":
|
||||
lib = lib_path + "alien_repo/PACKAGES.TXT"
|
||||
self.mirror = repos.alien()
|
||||
self.step = self.step * 2
|
||||
elif self.repo == "slacky":
|
||||
lib = lib_path + "slacky_repo/PACKAGES.TXT"
|
||||
arch = ""
|
||||
if os.uname()[4] == "x86_64":
|
||||
arch = "64"
|
||||
self.mirror = "{0}slackware{1}-{2}/".format(repos.slacky(), arch,
|
||||
slack_ver())
|
||||
self.step = self.step * 2
|
||||
f = open(lib, "r")
|
||||
self.PACKAGES_TXT = f.read()
|
||||
f.close()
|
||||
|
||||
def repo_init(self):
|
||||
'''
|
||||
Initialization repository if only use
|
||||
'''
|
||||
if not os.path.exists(slpkg_tmp):
|
||||
os.mkdir(slpkg_tmp)
|
||||
if not os.path.exists(self.tmp_path):
|
||||
os.mkdir(self.tmp_path)
|
||||
repository = {
|
||||
'rlw': Initialization().rlw,
|
||||
'alien': Initialization().alien,
|
||||
'slacky': Initialization().slacky
|
||||
}
|
||||
repository[self.repo]()
|
||||
|
||||
def start(self):
|
||||
'''
|
||||
Install packages from official Slackware distribution
|
||||
'''
|
||||
try:
|
||||
dwn_links, upgrade_all, comp_sum, uncomp_sum = self.store()
|
||||
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
|
||||
print # new line at start
|
||||
if upgrade_all:
|
||||
template(78)
|
||||
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
|
||||
"| Package", " " * 17,
|
||||
"Version", " " * 12,
|
||||
"Arch", " " * 4,
|
||||
"Build", " " * 2,
|
||||
"Repos", " " * 10,
|
||||
"Size"))
|
||||
template(78)
|
||||
print("Upgrading:")
|
||||
views(upgrade_all, comp_sum, self.repo)
|
||||
unit, size = units(comp_sum, uncomp_sum)
|
||||
msg = msgs(upgrade_all)
|
||||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print("{0}Total {1} {2} will be upgraded.".format(
|
||||
GREY, len(upgrade_all), msg))
|
||||
print("Need to get {0} {1} of archives.".format(size[0],
|
||||
unit[0]))
|
||||
print("After this process, {0} {1} of additional disk "
|
||||
"space will be used.{2}".format(size[1], unit[1], ENDC))
|
||||
read = raw_input("\nWould you like to upgrade [Y/n]? ")
|
||||
if read in ['Y', 'y']:
|
||||
upgrade_all.reverse()
|
||||
packages_dwn(self.tmp_path, dwn_links)
|
||||
upgrade(upgrade_all)
|
||||
delete(self.tmp_path, upgrade_all)
|
||||
else:
|
||||
print("There are no packages for upgrade\n")
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
||||
def store(self):
|
||||
'''
|
||||
Store and return packages for install
|
||||
'''
|
||||
dwn, install, comp_sum, uncomp_sum = ([] for i in range(4))
|
||||
black = BlackList().packages()
|
||||
# name = data[0]
|
||||
# location = data[1]
|
||||
# size = data[2]
|
||||
# unsize = data[3]
|
||||
installed = self.installed()
|
||||
data = repo_data(self.PACKAGES_TXT, self.step, self.repo, self.version)
|
||||
for pkg in installed:
|
||||
for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
|
||||
data[3]):
|
||||
inst_pkg = split_package(pkg)
|
||||
repo_pkg = split_package(name[:-4])
|
||||
if repo_pkg[0] == inst_pkg[0] and name[:-4] > pkg \
|
||||
and inst_pkg[0] not in black:
|
||||
# store downloads packages by repo
|
||||
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
|
||||
install.append(name)
|
||||
comp_sum.append(comp)
|
||||
uncomp_sum.append(uncomp)
|
||||
return [dwn, install, comp_sum, uncomp_sum]
|
||||
|
||||
def installed(self):
|
||||
'''
|
||||
Return all installed packages by repository
|
||||
'''
|
||||
packages = []
|
||||
repository = {
|
||||
'rlw': '_rlw',
|
||||
'alien': 'alien',
|
||||
'slacky': 'sl'
|
||||
}
|
||||
repo = repository[self.repo]
|
||||
for pkg in os.listdir(pkg_path):
|
||||
if pkg.endswith(repo):
|
||||
packages.append(pkg)
|
||||
return packages
|
||||
|
||||
|
||||
def views(upgrade_all, comp_sum, repository):
|
||||
'''
|
||||
Views packages
|
||||
'''
|
||||
upg_sum = 0
|
||||
# fix repositories align
|
||||
align = {
|
||||
'rlw': ' ' * 3,
|
||||
'alien': ' ',
|
||||
'slacky': ''
|
||||
}
|
||||
repository += align[repository]
|
||||
for pkg, comp in zip(upgrade_all, comp_sum):
|
||||
pkg_split = split_package(pkg[:-4])
|
||||
upg_sum += 1
|
||||
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11:>11}{12}".format(
|
||||
YELLOW, pkg_split[0], ENDC,
|
||||
" " * (25-len(pkg_split[0])), pkg_split[1],
|
||||
" " * (19-len(pkg_split[1])), pkg_split[2],
|
||||
" " * (8-len(pkg_split[2])), pkg_split[3],
|
||||
" " * (7-len(pkg_split[3])), repository,
|
||||
comp, " K"))
|
||||
return upg_sum
|
||||
|
||||
|
||||
def msgs(upgrade_all):
|
||||
'''
|
||||
Print singular plural
|
||||
'''
|
||||
msg_pkg = "package"
|
||||
if len(upgrade_all) > 1:
|
||||
msg_pkg = msg_pkg + "s"
|
||||
return msg_pkg
|
||||
|
||||
|
||||
def upgrade(upgrade_all):
|
||||
'''
|
||||
Install or upgrade packages
|
||||
'''
|
||||
for pkg in upgrade_all:
|
||||
print("[ {0}upgrading{1} ] --> {2}".format(YELLOW, ENDC, pkg[:-4]))
|
||||
PackageManager(pkg).upgrade()
|
53
slpkg/others/dependency.py
Executable file
53
slpkg/others/dependency.py
Executable file
|
@ -0,0 +1,53 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# dependency.py file is part of slpkg.
|
||||
|
||||
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
|
||||
# All rights reserved.
|
||||
|
||||
# Utility for easy management packages in Slackware
|
||||
|
||||
# https://github.com/dslackw/slpkg
|
||||
|
||||
# Slpkg is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import sys
|
||||
|
||||
from slpkg.colors import GREY, ENDC
|
||||
|
||||
from greps import repo_requires
|
||||
|
||||
dep_results = []
|
||||
|
||||
|
||||
def dependencies_pkg(name, repo):
|
||||
'''
|
||||
Build all dependencies of a package
|
||||
'''
|
||||
try:
|
||||
dependencies = []
|
||||
requires = repo_requires(name, repo)
|
||||
if requires:
|
||||
for req in requires:
|
||||
if req:
|
||||
dependencies.append(req)
|
||||
if dependencies:
|
||||
dep_results.append(dependencies)
|
||||
for dep in dependencies:
|
||||
sys.stdout.write("{0}.{1}".format(GREY, ENDC))
|
||||
sys.stdout.flush()
|
||||
dependencies_pkg(dep, repo)
|
||||
return dep_results
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
33
slpkg/others/download.py
Executable file
33
slpkg/others/download.py
Executable file
|
@ -0,0 +1,33 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# downloads.py file is part of slpkg.
|
||||
|
||||
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
|
||||
# All rights reserved.
|
||||
|
||||
# Utility for easy management packages in Slackware
|
||||
|
||||
# https://github.com/dslackw/slpkg
|
||||
|
||||
# Slpkg is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from slpkg.downloader import Download
|
||||
|
||||
|
||||
def packages_dwn(path, links):
|
||||
'''
|
||||
Download patches
|
||||
'''
|
||||
for dwn in links:
|
||||
Download(path, dwn).start()
|
||||
Download(path, dwn + ".asc").start()
|
123
slpkg/others/greps.py
Executable file
123
slpkg/others/greps.py
Executable file
|
@ -0,0 +1,123 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# greps.py file is part of slpkg.
|
||||
|
||||
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
|
||||
# All rights reserved.
|
||||
|
||||
# Utility for easy management packages in Slackware
|
||||
|
||||
# https://github.com/dslackw/slpkg
|
||||
|
||||
# Slpkg is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
|
||||
from slpkg.toolbar import status
|
||||
from slpkg.__metadata__ import lib_path
|
||||
from slpkg.splitting import split_package
|
||||
|
||||
from slpkg.slack.slack_version import slack_ver
|
||||
|
||||
|
||||
def repo_data(PACKAGES_TXT, step, repo, version):
|
||||
'''
|
||||
Grap data packages
|
||||
'''
|
||||
(name, location, size, unsize,
|
||||
rname, rlocation, rsize, runsize) = ([] for i in range(8))
|
||||
index, toolbar_width = 0, 700
|
||||
for line in PACKAGES_TXT.splitlines():
|
||||
index += 1
|
||||
toolbar_width = status(index, toolbar_width, step)
|
||||
if line.startswith("PACKAGE NAME"):
|
||||
name.append(line[15:].strip())
|
||||
if line.startswith("PACKAGE LOCATION"):
|
||||
location.append(line[21:].strip())
|
||||
if line.startswith("PACKAGE SIZE (compressed): "):
|
||||
size.append(line[28:-2].strip())
|
||||
if line.startswith("PACKAGE SIZE (uncompressed): "):
|
||||
unsize.append(line[30:-2].strip())
|
||||
if repo == "rlw":
|
||||
(rname,
|
||||
rlocation,
|
||||
rsize,
|
||||
runsize
|
||||
) = rlw_filter(name, location, size, unsize)
|
||||
elif repo == "alien":
|
||||
(rname,
|
||||
rlocation,
|
||||
rsize,
|
||||
runsize
|
||||
) = alien_filter(name, location, size, unsize, version)
|
||||
elif repo == "slacky":
|
||||
rname, rlocation, rsize, runsize = name, location, size, unsize
|
||||
return [rname, rlocation, rsize, runsize]
|
||||
|
||||
|
||||
def rlw_filter(name, location, size, unsize):
|
||||
'''
|
||||
Filter rlw repository data
|
||||
'''
|
||||
arch = os.uname()[4]
|
||||
if arch.startswith("i") and arch.endswith("86"):
|
||||
arch = "i486"
|
||||
(fname, flocation, fsize, funsize) = ([] for i in range(4))
|
||||
for n, l, s, u in zip(name, location, size, unsize):
|
||||
loc = l.split("/")
|
||||
if arch == loc[-1]:
|
||||
fname.append(n)
|
||||
flocation.append(l)
|
||||
fsize.append(s)
|
||||
funsize.append(u)
|
||||
return [fname, flocation, fsize, funsize]
|
||||
|
||||
|
||||
def alien_filter(name, location, size, unsize, version):
|
||||
'''
|
||||
Filter alien repository data
|
||||
'''
|
||||
ver = slack_ver()
|
||||
if version == "current":
|
||||
ver = "current"
|
||||
path_pkg = "pkg"
|
||||
if os.uname()[4] == "x86_64":
|
||||
path_pkg = "pkg64"
|
||||
(fname, flocation, fsize, funsize) = ([] for i in range(4))
|
||||
for n, l, s, u in zip(name, location, size, unsize):
|
||||
if path_pkg == l.split("/")[-2] and ver == l.split("/")[-1]:
|
||||
fname.append(n)
|
||||
flocation.append(l)
|
||||
fsize.append(s)
|
||||
funsize.append(u)
|
||||
return [fname, flocation, fsize, funsize]
|
||||
|
||||
|
||||
def repo_requires(name, repo):
|
||||
'''
|
||||
Grap package requirements from alien repository
|
||||
'''
|
||||
lib = {
|
||||
'alien': lib_path + "alien_repo/PACKAGES.TXT",
|
||||
'slacky': lib_path + "slacky_repo/PACKAGES.TXT"
|
||||
}
|
||||
f = open(lib[repo], "r")
|
||||
PACKAGES_TXT = f.read()
|
||||
f.close()
|
||||
for line in PACKAGES_TXT.splitlines():
|
||||
if line.startswith("PACKAGE NAME: "):
|
||||
pkg = line[14:].strip()
|
||||
pkg_name = split_package(pkg)[0]
|
||||
if line.startswith("PACKAGE REQUIRED: "):
|
||||
if pkg_name == name:
|
||||
return line[18:].strip().split(",")
|
357
slpkg/others/install.py
Executable file
357
slpkg/others/install.py
Executable file
|
@ -0,0 +1,357 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# install.py file is part of slpkg.
|
||||
|
||||
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
|
||||
# All rights reserved.
|
||||
|
||||
# Utility for easy management packages in Slackware
|
||||
|
||||
# https://github.com/dslackw/slpkg
|
||||
|
||||
# Slpkg is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
from slpkg.sizes import units
|
||||
from slpkg.repositories import Repo
|
||||
from slpkg.init import Initialization
|
||||
from slpkg.blacklist import BlackList
|
||||
from slpkg.splitting import split_package
|
||||
from slpkg.messages import pkg_not_found, template
|
||||
from slpkg.colors import RED, GREEN, CYAN, YELLOW, GREY, ENDC
|
||||
from slpkg.__metadata__ import slpkg_tmp, pkg_path, lib_path, log_path
|
||||
|
||||
|
||||
from slpkg.pkg.find import find_package
|
||||
from slpkg.pkg.manager import PackageManager
|
||||
|
||||
from slpkg.slack.remove import delete
|
||||
from slpkg.slack.slack_version import slack_ver
|
||||
|
||||
from greps import repo_data
|
||||
from download import packages_dwn
|
||||
from dependency import dependencies_pkg
|
||||
|
||||
|
||||
class OthersInstall(object):
|
||||
|
||||
def __init__(self, package, repo, version):
|
||||
self.package = package
|
||||
self.repo = repo
|
||||
self.version = version
|
||||
self.tmp_path = slpkg_tmp + "packages/"
|
||||
self.repo_init()
|
||||
repos = Repo()
|
||||
print("\nPackages with name matching [ {0}{1}{2} ]\n".format(
|
||||
CYAN, self.package, ENDC))
|
||||
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
|
||||
sys.stdout.flush()
|
||||
self.step = 700
|
||||
repos = Repo()
|
||||
if self.repo == "rlw":
|
||||
lib = lib_path + "rlw_repo/PACKAGES.TXT"
|
||||
self.mirror = "{0}{1}/".format(repos.rlw(), slack_ver())
|
||||
elif self.repo == "alien":
|
||||
lib = lib_path + "alien_repo/PACKAGES.TXT"
|
||||
self.mirror = repos.alien()
|
||||
self.step = self.step * 2
|
||||
elif self.repo == "slacky":
|
||||
lib = lib_path + "slacky_repo/PACKAGES.TXT"
|
||||
arch = ""
|
||||
if os.uname()[4] == "x86_64":
|
||||
arch = "64"
|
||||
self.mirror = "{0}slackware{1}-{2}/".format(repos.slacky(), arch,
|
||||
slack_ver())
|
||||
self.step = self.step * 2
|
||||
f = open(lib, "r")
|
||||
self.PACKAGES_TXT = f.read()
|
||||
f.close()
|
||||
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
|
||||
|
||||
def repo_init(self):
|
||||
'''
|
||||
Initialization repository if only use
|
||||
'''
|
||||
if not os.path.exists(slpkg_tmp):
|
||||
os.mkdir(slpkg_tmp)
|
||||
if not os.path.exists(self.tmp_path):
|
||||
os.mkdir(self.tmp_path)
|
||||
repository = {
|
||||
"rlw": Initialization().rlw,
|
||||
"alien": Initialization().alien,
|
||||
"slacky": Initialization().slacky
|
||||
}
|
||||
repository[self.repo]()
|
||||
|
||||
def start(self):
|
||||
'''
|
||||
Install packages from official Slackware distribution
|
||||
'''
|
||||
try:
|
||||
dependencies = resolving_deps(self.package, self.repo)
|
||||
(dwn_links, install_all, comp_sum, uncomp_sum,
|
||||
matching) = self.store(dependencies)
|
||||
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
|
||||
print # new line at start
|
||||
if install_all:
|
||||
template(78)
|
||||
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
|
||||
"| Package", " " * 17,
|
||||
"Version", " " * 12,
|
||||
"Arch", " " * 4,
|
||||
"Build", " " * 2,
|
||||
"Repos", " " * 10,
|
||||
"Size"))
|
||||
template(78)
|
||||
if not matching:
|
||||
print("Installing:")
|
||||
sums = views(install_all, comp_sum, self.repo, dependencies)
|
||||
unit, size = units(comp_sum, uncomp_sum)
|
||||
msg = msgs(install_all, sums[2])
|
||||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print("{0}Total {1} {2}.".format(GREY, len(install_all),
|
||||
msg[0]))
|
||||
print("{0} {1} will be installed, {2} will be upgraded and "
|
||||
"{3} will be resettled.".format(sums[2], msg[1],
|
||||
sums[1], sums[0]))
|
||||
print("Need to get {0} {1} of archives.".format(size[0],
|
||||
unit[0]))
|
||||
print("After this process, {0} {1} of additional disk "
|
||||
"space will be used.{2}".format(size[1], unit[1],
|
||||
ENDC))
|
||||
read = raw_input("\nWould you like to install [Y/n]? ")
|
||||
if read in ['Y', 'y']:
|
||||
install_all.reverse()
|
||||
packages_dwn(self.tmp_path, dwn_links)
|
||||
install(self.tmp_path, install_all)
|
||||
write_deps(dependencies)
|
||||
delete(self.tmp_path, install_all)
|
||||
else:
|
||||
print("Matching:")
|
||||
sums = views(install_all, comp_sum, self.repo, dependencies)
|
||||
msg = msgs(install_all, sums[2])
|
||||
print("\nInstalling summary")
|
||||
print("=" * 79)
|
||||
print("{0}Total found {1} matching {2}.".format(
|
||||
GREY, len(install_all), msg[1]))
|
||||
print("{0} installed {1} and {2} uninstalled {3}.{4}"
|
||||
"\n".format(sums[0] + sums[1], msg[0], sums[2],
|
||||
msg[1], ENDC))
|
||||
else:
|
||||
pkg_not_found("", self.package, "No matching", "\n")
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
|
||||
def store(self, deps):
|
||||
'''
|
||||
Store and return packages for install
|
||||
'''
|
||||
dwn, install, comp_sum, uncomp_sum = ([] for i in range(4))
|
||||
black = BlackList().packages()
|
||||
matching = False
|
||||
# name = data[0]
|
||||
# location = data[1]
|
||||
# size = data[2]
|
||||
# unsize = data[3]
|
||||
data = repo_data(self.PACKAGES_TXT, self.step, self.repo, self.version)
|
||||
if len(deps) > 1:
|
||||
for pkg in deps:
|
||||
for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
|
||||
data[3]):
|
||||
if name.startswith(pkg) and pkg not in black:
|
||||
# store downloads packages by repo
|
||||
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
|
||||
install.append(name)
|
||||
comp_sum.append(comp)
|
||||
uncomp_sum.append(uncomp)
|
||||
else:
|
||||
for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
|
||||
data[3]):
|
||||
package = "".join(deps)
|
||||
if package in name and package not in BlackList().packages():
|
||||
# store downloads packages by repo
|
||||
dwn.append("{0}{1}/{2}".format(self.mirror, loc, name))
|
||||
install.append(name)
|
||||
comp_sum.append(comp)
|
||||
uncomp_sum.append(uncomp)
|
||||
if len(install) > 1:
|
||||
matching = True
|
||||
dwn.reverse()
|
||||
install.reverse()
|
||||
comp_sum.reverse()
|
||||
uncomp_sum.reverse()
|
||||
return [dwn, install, comp_sum, uncomp_sum, matching]
|
||||
|
||||
|
||||
def views(install_all, comp_sum, repository, dependencies):
|
||||
'''
|
||||
Views packages
|
||||
'''
|
||||
count = pkg_sum = uni_sum = upg_sum = 0
|
||||
# fix repositories align
|
||||
align = {
|
||||
"rlw": ' ' * 3,
|
||||
"alien": ' ',
|
||||
"slacky": ''
|
||||
}
|
||||
repository += align[repository]
|
||||
for pkg, comp in zip(install_all, comp_sum):
|
||||
pkg_split = split_package(pkg[:-4])
|
||||
if find_package(pkg_split[0] + "-" + pkg_split[1], pkg_path):
|
||||
pkg_sum += 1
|
||||
COLOR = GREEN
|
||||
elif find_package(pkg_split[0] + "-", pkg_path):
|
||||
COLOR = YELLOW
|
||||
upg_sum += 1
|
||||
else:
|
||||
COLOR = RED
|
||||
uni_sum += 1
|
||||
print(" {0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}{11:>11}{12}".format(
|
||||
COLOR, pkg_split[0], ENDC,
|
||||
" " * (25-len(pkg_split[0])), pkg_split[1],
|
||||
" " * (19-len(pkg_split[1])), pkg_split[2],
|
||||
" " * (8-len(pkg_split[2])), pkg_split[3],
|
||||
" " * (7-len(pkg_split[3])), repository,
|
||||
comp, " K"))
|
||||
if len(dependencies) > 1 and count == 0:
|
||||
print("Installing for dependencies:")
|
||||
count += 1
|
||||
return [pkg_sum, upg_sum, uni_sum]
|
||||
|
||||
|
||||
def msgs(install_all, uni_sum):
|
||||
'''
|
||||
Print singular plural
|
||||
'''
|
||||
msg_pkg = "package"
|
||||
msg_2_pkg = msg_pkg
|
||||
if len(install_all) > 1:
|
||||
msg_pkg = msg_pkg + "s"
|
||||
if uni_sum > 1:
|
||||
msg_2_pkg = msg_2_pkg + "s"
|
||||
return [msg_pkg, msg_2_pkg]
|
||||
|
||||
|
||||
def install(tmp_path, install_all):
|
||||
'''
|
||||
Install or upgrade packages
|
||||
'''
|
||||
for install in install_all:
|
||||
package = (tmp_path + install).split()
|
||||
if os.path.isfile(pkg_path + install[:-4]):
|
||||
print("[ {0}reinstalling{1} ] --> {2}".format(GREEN, ENDC, install))
|
||||
PackageManager(package).reinstall()
|
||||
elif find_package(split_package(install)[0] + "-", pkg_path):
|
||||
print("[ {0}upgrading{1} ] --> {2}".format(YELLOW, ENDC, install))
|
||||
PackageManager(package).upgrade()
|
||||
else:
|
||||
print("[ {0}installing{1} ] --> {2}".format(GREEN, ENDC, install))
|
||||
PackageManager(package).upgrade()
|
||||
|
||||
|
||||
def repo_deps(name, repo):
|
||||
'''
|
||||
Return package dependencies
|
||||
'''
|
||||
deps = dependencies_pkg(name, repo)
|
||||
requires, dependencies = [], []
|
||||
requires.append(name)
|
||||
# Create one list for all packages
|
||||
for pkg in deps:
|
||||
requires += pkg
|
||||
if repo == "slacky":
|
||||
requires = slacky_req_check(name, requires)
|
||||
requires.reverse()
|
||||
# Remove double dependencies
|
||||
for duplicate in requires:
|
||||
if duplicate not in dependencies:
|
||||
dependencies.append(duplicate)
|
||||
return dependencies
|
||||
|
||||
|
||||
def rlw_deps(name):
|
||||
'''
|
||||
Robby's repository dependencies as shown in the central page
|
||||
http://rlworkman.net/pkgs/
|
||||
'''
|
||||
dependencies = {
|
||||
"abiword": "wv",
|
||||
"claws-mail": "libetpan bogofilter html2ps",
|
||||
"inkscape": "gtkmm atkmm pangomm cairomm mm-common libsigc++ libwpg" +
|
||||
"lxml gsl numpy BeautifulSoup",
|
||||
"texlive": "libsigsegv texi2html",
|
||||
"xfburn": "libburn libisofs"
|
||||
}
|
||||
if name in dependencies.keys():
|
||||
return dependencies[name]
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
def resolving_deps(name, repo):
|
||||
'''
|
||||
Return dependencies for one package from
|
||||
alien repository
|
||||
'''
|
||||
dependencies = []
|
||||
sys.stdout.write("{0}Resolving dependencies ...{1}".format(GREY, ENDC))
|
||||
sys.stdout.flush()
|
||||
if repo == "alien" or repo == "slacky":
|
||||
dependencies = repo_deps(name, repo)
|
||||
elif repo == "rlw":
|
||||
dependencies = rlw_deps(name).split()
|
||||
dependencies.append(name)
|
||||
return dependencies
|
||||
|
||||
|
||||
def slacky_req_check(name, requires):
|
||||
'''
|
||||
Checks if the requirement is installed or if it is
|
||||
smaller version
|
||||
'''
|
||||
new = []
|
||||
for req in requires[1:]:
|
||||
split_req = req.split() # split requirements
|
||||
req_name = split_req[0] # store name
|
||||
installed = find_package(req_name + "-", pkg_path)
|
||||
if not installed:
|
||||
new.append(req_name)
|
||||
requires = []
|
||||
requires.append(name)
|
||||
requires += new
|
||||
return requires
|
||||
|
||||
|
||||
def write_deps(dependencies):
|
||||
'''
|
||||
Write dependencies in a log file
|
||||
into directory `/var/log/slpkg/dep/`
|
||||
'''
|
||||
name = dependencies[-1]
|
||||
if find_package(name + "-", pkg_path):
|
||||
dep_path = log_path + "dep/"
|
||||
if not os.path.exists(log_path):
|
||||
os.mkdir(log_path)
|
||||
if not os.path.exists(dep_path):
|
||||
os.mkdir(dep_path)
|
||||
if os.path.isfile(dep_path + name):
|
||||
os.remove(dep_path + name)
|
||||
if len(dependencies[:-1]) > 0:
|
||||
with open(dep_path + name, "w") as f:
|
||||
for dep in dependencies[:-1]:
|
||||
f.write(dep + "\n")
|
||||
f.close()
|
|
@ -34,6 +34,6 @@ def find_package(find_pkg, directory):
|
|||
pkgs = []
|
||||
blacklist = BlackList().packages()
|
||||
for pkg in sorted(os.listdir(directory)):
|
||||
if pkg.startswith(find_pkg) and split_package(pkg)[0] not in blacklist:
|
||||
if pkg.startswith(find_pkg)and split_package(pkg)[0] not in blacklist:
|
||||
pkgs.append(pkg)
|
||||
return pkgs
|
||||
|
|
|
@ -90,7 +90,7 @@ class PackageManager(object):
|
|||
Remove Slackware binary packages
|
||||
'''
|
||||
dep_path = log_path + "dep/"
|
||||
dependencies = []
|
||||
dependencies, rmv_list = [], []
|
||||
removed = self.view_removed(self.binary)
|
||||
if not removed:
|
||||
print # new line at end
|
||||
|
@ -105,7 +105,7 @@ class PackageManager(object):
|
|||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
if remove_pkg == "y" or remove_pkg == "Y":
|
||||
if remove_pkg in ['y', 'Y']:
|
||||
for rmv in removed:
|
||||
# If package build and install with 'slpkg -s sbo <package>'
|
||||
# then look log file for dependencies in /var/log/slpkg/dep,
|
||||
|
@ -119,14 +119,15 @@ class PackageManager(object):
|
|||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
if remove_dep == "y" or remove_dep == "Y":
|
||||
rmv_list = self.rmv_deps(self.binary, dependencies,
|
||||
dep_path, rmv)
|
||||
if remove_dep in ['y', 'Y']:
|
||||
rmv_list += self.rmv_deps(self.binary,
|
||||
dependencies,
|
||||
dep_path, rmv)
|
||||
else:
|
||||
rmv_list = self.rmv_pkg(rmv)
|
||||
rmv_list += self.rmv_pkg(rmv)
|
||||
os.remove(dep_path + rmv)
|
||||
else:
|
||||
rmv_list = self.rmv_pkg(rmv)
|
||||
rmv_list += self.rmv_pkg(rmv)
|
||||
# Prints all removed packages
|
||||
self.reference_rmvs(rmv_list)
|
||||
|
||||
|
@ -188,16 +189,15 @@ class PackageManager(object):
|
|||
if find_package(package + sp, pkg_path):
|
||||
print(subprocess.check_output("removepkg {0}".format(package),
|
||||
shell=True))
|
||||
return package.split()
|
||||
return package.split()
|
||||
|
||||
@staticmethod
|
||||
def reference_rmvs(removes):
|
||||
'''
|
||||
Prints all removed packages
|
||||
'''
|
||||
if len(removes) > 1:
|
||||
template(78)
|
||||
print("| Total {0} packages removed".format(len(removes)))
|
||||
template(78)
|
||||
print("| Total {0} packages removed".format(len(removes)))
|
||||
template(78)
|
||||
for pkg in removes:
|
||||
if not find_package(pkg + sp, pkg_path):
|
||||
|
@ -269,22 +269,29 @@ class PackageManager(object):
|
|||
tty_size = os.popen('stty size', 'r').read().split()
|
||||
row = int(tty_size[0]) - 2
|
||||
try:
|
||||
if "sbo" in pattern:
|
||||
search = "_SBo"
|
||||
elif "slack" in pattern:
|
||||
search = "_slack"
|
||||
elif "noarch" in pattern:
|
||||
search = "-noarch-"
|
||||
elif "all" in pattern:
|
||||
search = ""
|
||||
pkg_list = {
|
||||
'sbo': '_SBo',
|
||||
'slack': '_slack',
|
||||
'noarch': '-noarch-',
|
||||
'rlw': '_rlw',
|
||||
'alien': 'alien',
|
||||
'slacky': 'sl',
|
||||
'all': ''
|
||||
}
|
||||
search = pkg_list[pattern]
|
||||
index, page = 0, row
|
||||
sl = search
|
||||
if search == "-noarch-":
|
||||
search = ""
|
||||
for pkg in find_package("", pkg_path):
|
||||
if search in pkg:
|
||||
if pkg.endswith(search) and sl in pkg:
|
||||
index += 1
|
||||
print("{0}{1}:{2} {3}".format(GREY, index, ENDC, pkg))
|
||||
if index == page:
|
||||
raw_input("\nPress {0}Enter{1} to continue...".format(
|
||||
CYAN, ENDC))
|
||||
read = raw_input("\nPress {0}Enter{1} to "
|
||||
"continue... ".format(CYAN, ENDC))
|
||||
if read in ['Q', 'q']:
|
||||
break
|
||||
print # new line after page
|
||||
page += row
|
||||
print # new line at end
|
||||
|
|
|
@ -157,7 +157,7 @@ class QueuePkgs(object):
|
|||
if packages:
|
||||
print # new line at start
|
||||
for pkg in packages:
|
||||
# check if package exist in repository
|
||||
# check if package exist in /tmp
|
||||
find = find_package(pkg, tmp)
|
||||
try:
|
||||
find = max(find)
|
||||
|
|
58
slpkg/repositories.py
Executable file
58
slpkg/repositories.py
Executable file
|
@ -0,0 +1,58 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# repositories.py file is part of slpkg.
|
||||
|
||||
# Copyright 2014 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
|
||||
# All rights reserved.
|
||||
|
||||
# Utility for easy management packages in Slackware
|
||||
|
||||
# https://github.com/dslackw/slpkg
|
||||
|
||||
# Slpkg is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
class Repo(object):
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def slack(self):
|
||||
'''
|
||||
Official slackware repository
|
||||
'''
|
||||
return "http://mirrors.slackware.com/slackware/"
|
||||
|
||||
def sbo(self):
|
||||
'''
|
||||
SlackBuilds.org repository
|
||||
'''
|
||||
return "http://slackbuilds.org/slackbuilds/"
|
||||
|
||||
def rlw(self):
|
||||
'''
|
||||
Robby's repoisitory
|
||||
'''
|
||||
return "http://rlworkman.net/pkgs/"
|
||||
|
||||
def alien(self):
|
||||
'''
|
||||
Alien repository
|
||||
'''
|
||||
return "http://www.slackware.com/~alien/slackbuilds/"
|
||||
|
||||
def slacky(self):
|
||||
'''
|
||||
Slacky.eu repository
|
||||
'''
|
||||
return "http://repository.slacky.eu/"
|
|
@ -29,7 +29,7 @@ from slpkg.pkg.build import BuildPackage
|
|||
from slpkg.pkg.manager import PackageManager
|
||||
|
||||
from slpkg.toolbar import status
|
||||
from slpkg.init import initialization
|
||||
from slpkg.init import Initialization
|
||||
from slpkg.downloader import Download
|
||||
from slpkg.splitting import split_package
|
||||
from slpkg.messages import template, build_FAILED
|
||||
|
@ -48,7 +48,7 @@ class SBoCheck(object):
|
|||
self.done = "{0}Done{1}\n".format(GREY, ENDC)
|
||||
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
|
||||
sys.stdout.flush()
|
||||
initialization()
|
||||
Initialization().sbo()
|
||||
self.installed = []
|
||||
self.index, self.toolbar_width = 0, 3
|
||||
|
||||
|
@ -62,23 +62,19 @@ class SBoCheck(object):
|
|||
some version in /tmp directory.
|
||||
'''
|
||||
try:
|
||||
if sbo_list():
|
||||
upg_name = exists(self.index, self.toolbar_width)
|
||||
if self.sbo_list():
|
||||
upg_name = self.exists()
|
||||
sys.stdout.write(self.done)
|
||||
data = []
|
||||
if upg_name:
|
||||
sys.stdout.write("{0}Resolving dependencies ...{1}".format(
|
||||
GREY, ENDC))
|
||||
sys.stdout.flush()
|
||||
dependencies = deps(upg_name)
|
||||
requires = one_for_all(dependencies)
|
||||
dependencies_list = order_list(upg_name,
|
||||
remove_dbs(requires))
|
||||
# upgrade name = data[0]
|
||||
# package for upgrade = data[1]
|
||||
# upgrade version = data[2]
|
||||
# upgrade arch = data[3]
|
||||
data = store(dependencies_list)
|
||||
data = store(order_list(upg_name))
|
||||
sys.stdout.write(self.done)
|
||||
if data:
|
||||
# count installed = count[0]
|
||||
|
@ -87,7 +83,7 @@ class SBoCheck(object):
|
|||
# message upgrade = msg[1]
|
||||
count, msg = view_packages(data[1], data[2], data[3])
|
||||
read = raw_input("Would you like to upgrade [Y/n]? ")
|
||||
if read == "Y" or read == "y":
|
||||
if read in ['y', 'Y']:
|
||||
create_build_path()
|
||||
os.chdir(build_path)
|
||||
for name, version in zip(data[0], data[2]):
|
||||
|
@ -122,7 +118,7 @@ class SBoCheck(object):
|
|||
msg[0], msg[1], self.installed)
|
||||
else:
|
||||
print("\nTotal {0} SBo packages are up to date\n".format(
|
||||
len(sbo_list())))
|
||||
len(self.sbo_list())))
|
||||
else:
|
||||
sys.stdout.write(self.done)
|
||||
print("\nNo SBo packages found\n")
|
||||
|
@ -130,35 +126,33 @@ class SBoCheck(object):
|
|||
print # new line at exit
|
||||
sys.exit()
|
||||
|
||||
def sbo_list(self):
|
||||
'''
|
||||
Return all SBo packages
|
||||
'''
|
||||
sbo_packages = []
|
||||
for pkg in os.listdir(pkg_path):
|
||||
if pkg.endswith("_SBo"):
|
||||
sbo_packages.append(pkg)
|
||||
return sbo_packages
|
||||
|
||||
def sbo_list():
|
||||
'''
|
||||
Return all SBo packages
|
||||
'''
|
||||
sbo_packages = []
|
||||
for pkg in os.listdir(pkg_path):
|
||||
if pkg.endswith("_SBo"):
|
||||
sbo_packages.append(pkg)
|
||||
return sbo_packages
|
||||
|
||||
|
||||
def exists(index, toolbar_width):
|
||||
'''
|
||||
search packages if exists in the repository
|
||||
and it gets to avoidable modified packages
|
||||
from the user with the tag _SBo
|
||||
'''
|
||||
upgrade_names = []
|
||||
for pkg in sbo_list():
|
||||
index += 1
|
||||
toolbar_width = status(index, toolbar_width, 4)
|
||||
name = split_package(pkg)[0]
|
||||
if sbo_search_pkg(name):
|
||||
sbo_package = ("{0}-{1}".format(name, SBoGrep(name).version()))
|
||||
package = ("{0}-{1}".format(name, split_package(pkg)[1]))
|
||||
if sbo_package > package:
|
||||
upgrade_names.append(name)
|
||||
return upgrade_names
|
||||
def exists(self):
|
||||
'''
|
||||
search packages if exists in the repository
|
||||
and it gets to avoidable modified packages
|
||||
from the user with the tag _SBo
|
||||
'''
|
||||
upgrade_names = []
|
||||
for pkg in self.sbo_list():
|
||||
self.index += 1
|
||||
self.toolbar_width = status(self.index, self.toolbar_width, 4)
|
||||
name = split_package(pkg)[0]
|
||||
if sbo_search_pkg(name):
|
||||
sbo_package = ("{0}-{1}".format(name, SBoGrep(name).version()))
|
||||
package = ("{0}-{1}".format(name, split_package(pkg)[1]))
|
||||
if sbo_package > package:
|
||||
upgrade_names.append(name)
|
||||
return upgrade_names
|
||||
|
||||
|
||||
def deps(upgrade_names):
|
||||
|
@ -172,13 +166,14 @@ def deps(upgrade_names):
|
|||
return dependencies
|
||||
|
||||
|
||||
def one_for_all(dependencies):
|
||||
def one_for_all(upgrade_names):
|
||||
'''
|
||||
Because there are dependencies that depend on other
|
||||
dependencies are created lists into other lists.
|
||||
Thus creating this loop create one-dimensional list.
|
||||
'''
|
||||
requires = []
|
||||
dependencies = deps(upgrade_names)
|
||||
for dep in dependencies:
|
||||
requires += dep
|
||||
# Inverting the list brings the
|
||||
|
@ -187,33 +182,35 @@ def one_for_all(dependencies):
|
|||
return requires
|
||||
|
||||
|
||||
def remove_dbs(requires):
|
||||
def remove_dbs(upgrade_names):
|
||||
'''
|
||||
Many packages use the same dependencies, in this loop
|
||||
creates a new list by removing duplicate dependencies but
|
||||
without spoiling the line must be installed.
|
||||
'''
|
||||
dependencies = []
|
||||
requires = one_for_all(upgrade_names)
|
||||
for duplicate in requires:
|
||||
if duplicate not in dependencies:
|
||||
dependencies.append(duplicate)
|
||||
return dependencies
|
||||
|
||||
|
||||
def order_list(upgrade_names, dependencies):
|
||||
def order_list(upgrade_names):
|
||||
'''
|
||||
Last and after the list is created with the correct number
|
||||
of dependencies that must be installed, and add the particular
|
||||
packages that need to be upgraded if they are not already on
|
||||
the list in end to list.
|
||||
'''
|
||||
dependencies = remove_dbs(upgrade_names)
|
||||
for upg in upgrade_names:
|
||||
if upg not in dependencies:
|
||||
dependencies.append(upg)
|
||||
return dependencies
|
||||
|
||||
|
||||
def store(dependencies_list):
|
||||
def store(dependencies):
|
||||
'''
|
||||
In the end lest a check of the packages that are on the list
|
||||
are already installed.
|
||||
|
@ -223,7 +220,7 @@ def store(dependencies_list):
|
|||
upgrade_version,
|
||||
upgrade_arch
|
||||
) = ([] for i in range(4))
|
||||
for pkg in dependencies_list:
|
||||
for pkg in dependencies:
|
||||
ver = SBoGrep(pkg).version()
|
||||
prgnam = ("{0}-{1}".format(pkg, ver))
|
||||
# if package not installed
|
||||
|
|
|
@ -48,8 +48,7 @@ def sbo_dependencies_pkg(name):
|
|||
if dependencies:
|
||||
dep_results.append(dependencies)
|
||||
for dep in dependencies:
|
||||
sys.stdout.write("{0}.{1}".format(
|
||||
GREY, ENDC))
|
||||
sys.stdout.write("{0}.{1}".format(GREY, ENDC))
|
||||
sys.stdout.flush()
|
||||
sbo_dependencies_pkg(dep)
|
||||
return dep_results
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
import sys
|
||||
|
||||
from slpkg.repositories import Repo
|
||||
from slpkg.blacklist import BlackList
|
||||
from slpkg.__metadata__ import lib_path
|
||||
|
||||
|
@ -34,9 +35,9 @@ def sbo_search_pkg(name):
|
|||
Search for package path from SLACKBUILDS.TXT file
|
||||
'''
|
||||
try:
|
||||
repo = Repo().sbo()
|
||||
blacklist = BlackList().packages()
|
||||
sbo_url = ("http://slackbuilds.org/slackbuilds/{0}/".format(
|
||||
slack_ver()))
|
||||
sbo_url = "{0}{1}/".format(repo, slack_ver())
|
||||
with open(lib_path + "sbo_repo/SLACKBUILDS.TXT",
|
||||
"r") as SLACKBUILDS_TXT:
|
||||
for line in SLACKBUILDS_TXT:
|
||||
|
|
|
@ -25,8 +25,9 @@ import os
|
|||
import sys
|
||||
|
||||
from slpkg.toolbar import status
|
||||
from slpkg.init import initialization
|
||||
from slpkg.init import Initialization
|
||||
from slpkg.downloader import Download
|
||||
from slpkg.splitting import split_package
|
||||
from slpkg.__metadata__ import (tmp, pkg_path, build_path,
|
||||
log_path, lib_path, sp)
|
||||
|
||||
|
@ -50,7 +51,7 @@ class SBoInstall(object):
|
|||
self.name = name
|
||||
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
|
||||
sys.stdout.flush()
|
||||
initialization()
|
||||
Initialization().sbo()
|
||||
self.UNST = ["UNSUPPORTED", "UNTESTED"]
|
||||
self.dependencies_list = sbo_dependencies_pkg(name)
|
||||
|
||||
|
@ -62,8 +63,7 @@ class SBoInstall(object):
|
|||
'''
|
||||
try:
|
||||
if self.dependencies_list or sbo_search_pkg(self.name) is not None:
|
||||
requires = one_for_all(self.name, self.dependencies_list)
|
||||
dependencies = remove_dbs(requires)
|
||||
dependencies = self.remove_dbs()
|
||||
# sbo versions = idata[0]
|
||||
# package arch = idata[1]
|
||||
# package sum = idata[2]
|
||||
|
@ -81,13 +81,14 @@ class SBoInstall(object):
|
|||
ARCH_COLOR = arch_colors_tag(self.UNST, idata[1])
|
||||
view_packages(PKG_COLOR, self.name, idata[0][-1], ARCH_COLOR,
|
||||
idata[1][-1])
|
||||
print("Installing for dependencies:")
|
||||
for dep, ver, dep_arch in zip(dependencies[:-1], idata[0][:-1],
|
||||
idata[1][:-1]):
|
||||
(DEP_COLOR, count) = pkg_colors_tag(dep, ver, count[0],
|
||||
count[1])
|
||||
ARCH_COLOR = arch_colors_tag(self.UNST, dep)
|
||||
view_packages(DEP_COLOR, dep, ver, ARCH_COLOR, dep_arch)
|
||||
if len(dependencies) > 1:
|
||||
print("Installing for dependencies:")
|
||||
for dep, ver, dep_arch in zip(dependencies[:-1],
|
||||
idata[0][:-1], idata[1][:-1]):
|
||||
(DEP_COLOR, count) = pkg_colors_tag(dep, ver, count[0],
|
||||
count[1])
|
||||
ARCH_COLOR = arch_colors_tag(self.UNST, dep)
|
||||
view_packages(DEP_COLOR, dep, ver, ARCH_COLOR, dep_arch)
|
||||
# insstall message = msg[0]
|
||||
# upgraded message = msg[1]
|
||||
# total message = msg[2]
|
||||
|
@ -101,14 +102,14 @@ class SBoInstall(object):
|
|||
msg[1]))
|
||||
print("will be upgraded.{0}\n".format(ENDC))
|
||||
read = arch_support(idata[3], self.UNST, idata[2], dependencies)
|
||||
if read == "Y" or read == "y":
|
||||
if read in['y', 'Y']:
|
||||
# installs = b_ins[0]
|
||||
# upgraded = b_ins[1]
|
||||
# versions = b_ins[2]
|
||||
b_ins = build_install(dependencies, idata[0], idata[1])
|
||||
b_ins = build_install(dependencies, idata[0])
|
||||
reference(count[1], msg[0], count[0], msg[1],
|
||||
b_ins[0], b_ins[2], b_ins[1])
|
||||
write_deps(self.name, dependencies)
|
||||
write_deps(dependencies)
|
||||
else:
|
||||
count_installed = count_uninstalled = 0
|
||||
# sbo matching = mdata[0]
|
||||
|
@ -145,28 +146,27 @@ class SBoInstall(object):
|
|||
print # new line at exit
|
||||
sys.exit()
|
||||
|
||||
def one_for_all(self):
|
||||
'''
|
||||
Create one list for all packages
|
||||
'''
|
||||
requires = []
|
||||
requires.append(self.name)
|
||||
for pkg in self.dependencies_list:
|
||||
requires += pkg
|
||||
requires.reverse()
|
||||
return requires
|
||||
|
||||
def one_for_all(name, dependencies):
|
||||
'''
|
||||
Create one list for all packages
|
||||
'''
|
||||
requires = []
|
||||
requires.append(name)
|
||||
for pkg in dependencies:
|
||||
requires += pkg
|
||||
requires.reverse()
|
||||
return requires
|
||||
|
||||
|
||||
def remove_dbs(requires):
|
||||
'''
|
||||
Remove double dependencies
|
||||
'''
|
||||
dependencies = []
|
||||
for duplicate in requires:
|
||||
if duplicate not in dependencies:
|
||||
dependencies.append(duplicate)
|
||||
return dependencies
|
||||
def remove_dbs(self):
|
||||
'''
|
||||
Remove double dependencies
|
||||
'''
|
||||
requires = self.one_for_all()
|
||||
dependencies = []
|
||||
for duplicate in requires:
|
||||
if duplicate not in dependencies:
|
||||
dependencies.append(duplicate)
|
||||
return dependencies
|
||||
|
||||
|
||||
def installing_data(dependencies, support):
|
||||
|
@ -308,7 +308,7 @@ def search_in_tmp(prgnam):
|
|||
return binary
|
||||
|
||||
|
||||
def build_install(dependencies, sbo_versions, packages_arch):
|
||||
def build_install(dependencies, sbo_versions):
|
||||
'''
|
||||
Searches the package name and version in /tmp to
|
||||
install. If find two or more packages e.g. to build
|
||||
|
@ -317,13 +317,12 @@ def build_install(dependencies, sbo_versions, packages_arch):
|
|||
installs, upgraded, versions = [], [], []
|
||||
create_build_path()
|
||||
os.chdir(build_path)
|
||||
for pkg, ver, ar in zip(dependencies, sbo_versions, packages_arch):
|
||||
for pkg, ver in zip(dependencies, sbo_versions):
|
||||
prgnam = ("{0}-{1}".format(pkg, ver))
|
||||
sbo_file = "".join(find_package(prgnam, pkg_path))
|
||||
if sbo_file:
|
||||
sbo_file_version = sbo_file[len(pkg) + 1:-len(ar) - 7]
|
||||
template(78)
|
||||
pkg_found(pkg, sbo_file_version)
|
||||
pkg_found(pkg, split_package(sbo_file)[1])
|
||||
template(78)
|
||||
else:
|
||||
sbo_url = sbo_search_pkg(pkg)
|
||||
|
@ -362,7 +361,7 @@ def reference(*args):
|
|||
for pkg, ver in zip(args[4], args[5]):
|
||||
installed = ("{0}-{1}".format(pkg, ver))
|
||||
if find_package(installed, pkg_path):
|
||||
if pkg in args[5]:
|
||||
if pkg in args[6]:
|
||||
print("| Package {0} upgraded successfully".format(installed))
|
||||
else:
|
||||
print("| Package {0} installed successfully".format(installed))
|
||||
|
@ -371,11 +370,12 @@ def reference(*args):
|
|||
template(78)
|
||||
|
||||
|
||||
def write_deps(name, dependencies):
|
||||
def write_deps(dependencies):
|
||||
'''
|
||||
Write dependencies in a log file
|
||||
into directory `/var/log/slpkg/dep/`
|
||||
'''
|
||||
name = dependencies[-1]
|
||||
if find_package(name + sp, pkg_path):
|
||||
dep_path = log_path + "dep/"
|
||||
if not os.path.exists(log_path):
|
||||
|
|
|
@ -24,12 +24,13 @@
|
|||
import sys
|
||||
|
||||
from slpkg.messages import template
|
||||
from slpkg.init import initialization
|
||||
from slpkg.init import Initialization
|
||||
from slpkg.__metadata__ import pkg_path, sp
|
||||
from slpkg.colors import RED, GREEN, GREY, YELLOW, CYAN, ENDC
|
||||
|
||||
from slpkg.pkg.find import find_package
|
||||
|
||||
from search import sbo_search_pkg
|
||||
from dependency import sbo_dependencies_pkg
|
||||
|
||||
|
||||
|
@ -42,10 +43,10 @@ def track_dep(name):
|
|||
'''
|
||||
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
|
||||
sys.stdout.flush()
|
||||
initialization()
|
||||
Initialization().sbo()
|
||||
dependencies_list = sbo_dependencies_pkg(name)
|
||||
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
|
||||
if dependencies_list:
|
||||
if sbo_search_pkg(name):
|
||||
requires, dependencies = [], []
|
||||
# Create one list for all packages
|
||||
for pkg in dependencies_list:
|
||||
|
|
|
@ -25,7 +25,7 @@ import os
|
|||
import sys
|
||||
import pydoc
|
||||
|
||||
from slpkg.init import initialization
|
||||
from slpkg.init import Initialization
|
||||
from slpkg.downloader import Download
|
||||
from slpkg.__metadata__ import tmp, build_path, pkg_path, sp
|
||||
from slpkg.colors import RED, GREEN, GREY, CYAN, YELLOW, ENDC
|
||||
|
@ -48,7 +48,7 @@ class SBoNetwork(object):
|
|||
self.name = name
|
||||
sys.stdout.write("{0}Reading package lists ...{1}".format(GREY, ENDC))
|
||||
sys.stdout.flush()
|
||||
initialization()
|
||||
Initialization().sbo()
|
||||
grep = SBoGrep(self.name)
|
||||
self.sbo_url = sbo_search_pkg(self.name)
|
||||
self.sbo_desc = grep.description()[len(self.name) + 2:-1]
|
||||
|
@ -66,36 +66,37 @@ class SBoNetwork(object):
|
|||
'''
|
||||
if self.sbo_url:
|
||||
prgnam = ("{0}-{1}".format(self.name, self.sbo_version))
|
||||
view_sbo(self.name, self.sbo_url, self.sbo_desc,
|
||||
self.sbo_dwn.split("/")[-1],
|
||||
", ".join([src.split("/")[-1] for src in self.source_dwn]),
|
||||
self.sbo_req)
|
||||
FAULT = error_uns(self.source_dwn)
|
||||
self.view_sbo(
|
||||
self.name, self.sbo_url, self.sbo_desc,
|
||||
self.sbo_dwn.split("/")[-1],
|
||||
", ".join([src.split("/")[-1] for src in self.source_dwn]),
|
||||
self.sbo_req)
|
||||
FAULT = self.error_uns()
|
||||
while True:
|
||||
choice = read_choice()
|
||||
if choice in ["D", "d"]:
|
||||
download("", self.sbo_dwn, self.source_dwn)
|
||||
choice = self.read_choice()
|
||||
if choice in ['D', 'd']:
|
||||
self.download(path="")
|
||||
break
|
||||
elif choice in ["R", "r"]:
|
||||
elif choice in ['R', 'r']:
|
||||
README = Read(self.sbo_url).readme("README")
|
||||
fill = fill_pager(README)
|
||||
fill = self.fill_pager(README)
|
||||
pydoc.pager(README + fill)
|
||||
elif choice in ["F", "f"]:
|
||||
elif choice in ['F', 'f']:
|
||||
info = Read(self.sbo_url).info(self.name, ".info")
|
||||
fill = fill_pager(info)
|
||||
fill = self.fill_pager(info)
|
||||
pydoc.pager(info + fill)
|
||||
elif choice in ["S", "s"]:
|
||||
elif choice in ['S', 's']:
|
||||
SlackBuild = Read(self.sbo_url).slackbuild(self.name,
|
||||
".SlackBuild")
|
||||
fill = fill_pager(SlackBuild)
|
||||
fill = self.fill_pager(SlackBuild)
|
||||
pydoc.pager(SlackBuild + fill)
|
||||
elif choice in ["B", "b"]:
|
||||
build(self.sbo_dwn, self.source_dwn, FAULT)
|
||||
elif choice in ['B', 'b']:
|
||||
self.build(FAULT)
|
||||
break
|
||||
elif choice in ["I", "i"]:
|
||||
elif choice in ['I', 'i']:
|
||||
if not find_package(prgnam + sp, pkg_path):
|
||||
build(self.sbo_dwn, self.source_dwn, FAULT)
|
||||
install(self.name, prgnam, self.sbo_url)
|
||||
self.build(FAULT)
|
||||
self.install(prgnam)
|
||||
break
|
||||
else:
|
||||
template(78)
|
||||
|
@ -107,110 +108,110 @@ class SBoNetwork(object):
|
|||
else:
|
||||
pkg_not_found("\n", self.name, "Can't view", "\n")
|
||||
|
||||
@staticmethod
|
||||
def view_sbo(*args):
|
||||
'''
|
||||
View slackbuild.org
|
||||
'''
|
||||
print # new line at start
|
||||
template(78)
|
||||
print("| {0}Package {1}{2}{3} --> {4}".format(GREEN, CYAN, args[0],
|
||||
GREEN, ENDC + args[1]))
|
||||
template(78)
|
||||
print("| {0}Description : {1}{2}".format(GREEN, ENDC, args[2]))
|
||||
print("| {0}SlackBuild : {1}{2}".format(GREEN, ENDC, args[3]))
|
||||
print("| {0}Sources : {1}{2}".format(GREEN, ENDC, args[4]))
|
||||
print("| {0}Requirements : {1}{2}".format(YELLOW, ENDC,
|
||||
", ".join(args[5])))
|
||||
template(78)
|
||||
print(" {0}R{1}EADME View the README file".format(RED,
|
||||
ENDC))
|
||||
print(" {0}S{1}lackBuild View the SlackBuild file".format(
|
||||
RED, ENDC))
|
||||
print(" In{0}f{1}o View the Info file".format(RED,
|
||||
ENDC))
|
||||
print(" {0}D{1}ownload Download this package".format(RED,
|
||||
ENDC))
|
||||
print(" {0}B{1}uild Download and build".format(RED,
|
||||
ENDC))
|
||||
print(" {0}I{1}nstall Download/Build/Install".format(
|
||||
RED, ENDC))
|
||||
print(" {0}Q{1}uit Quit\n".format(RED, ENDC))
|
||||
|
||||
def view_sbo(*args):
|
||||
'''
|
||||
View slackbuild.org
|
||||
'''
|
||||
print # new line at start
|
||||
template(78)
|
||||
print("| {0}Package {1}{2}{3} --> {4}".format(GREEN, CYAN, args[0], GREEN,
|
||||
ENDC + args[1]))
|
||||
template(78)
|
||||
print("| {0}Description : {1}{2}".format(GREEN, ENDC, args[2]))
|
||||
print("| {0}SlackBuild : {1}{2}".format(GREEN, ENDC, args[3]))
|
||||
print("| {0}Sources : {1}{2}".format(GREEN, ENDC, args[4]))
|
||||
print("| {0}Requirements : {1}{2}".format(YELLOW, ENDC, ", ".join(args[5])))
|
||||
template(78)
|
||||
print(" {0}R{1}EADME View the README file".format(RED, ENDC))
|
||||
print(" {0}S{1}lackBuild View the SlackBuild file".format(
|
||||
RED, ENDC))
|
||||
print(" In{0}f{1}o View the Info file".format(RED, ENDC))
|
||||
print(" {0}D{1}ownload Download this package".format(RED, ENDC))
|
||||
print(" {0}B{1}uild Download and build".format(RED, ENDC))
|
||||
print(" {0}I{1}nstall Download/Build/Install".format(
|
||||
RED, ENDC))
|
||||
print(" {0}Q{1}uit Quit\n".format(RED, ENDC))
|
||||
@staticmethod
|
||||
def fill_pager(page):
|
||||
'''
|
||||
Fix pager spaces
|
||||
'''
|
||||
tty_size = os.popen('stty size', 'r').read().split()
|
||||
rows = int(tty_size[0]) - 1
|
||||
lines = sum(1 for line in page.splitlines())
|
||||
diff = rows - lines
|
||||
fill = "\n" * diff
|
||||
if diff > 0:
|
||||
return fill
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
def fill_pager(page):
|
||||
'''
|
||||
Fix pager spaces
|
||||
'''
|
||||
tty_size = os.popen('stty size', 'r').read().split()
|
||||
rows = int(tty_size[0]) - 1
|
||||
lines = sum(1 for line in page.splitlines())
|
||||
diff = rows - lines
|
||||
fill = "\n" * diff
|
||||
if diff > 0:
|
||||
return fill
|
||||
else:
|
||||
return ""
|
||||
|
||||
|
||||
def read_choice():
|
||||
'''
|
||||
Return choice
|
||||
'''
|
||||
try:
|
||||
choice = raw_input(" {0}Choose an option: {1}".format(GREY, ENDC))
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
return choice
|
||||
|
||||
|
||||
def error_uns(source_dwn):
|
||||
'''
|
||||
Check if package supported by arch
|
||||
before proceed to install
|
||||
'''
|
||||
UNST = ["UNSUPPORTED", "UNTESTED"]
|
||||
if "".join(source_dwn) in UNST:
|
||||
return "".join(source_dwn)
|
||||
|
||||
|
||||
def download(path, sbo_dwn, source_dwn):
|
||||
'''
|
||||
Download sources
|
||||
'''
|
||||
Download(path, sbo_dwn).start()
|
||||
for src in source_dwn:
|
||||
Download(path, src).start()
|
||||
|
||||
|
||||
def build(sbo_dwn, source_dwn, FAULT):
|
||||
'''
|
||||
Only build and create Slackware package
|
||||
'''
|
||||
if FAULT:
|
||||
print("\n{0}The package {1} {2}\n".format(RED, FAULT, ENDC))
|
||||
sys.exit()
|
||||
if not os.path.exists(build_path):
|
||||
os.mkdir(build_path)
|
||||
sources = []
|
||||
os.chdir(build_path)
|
||||
Download(build_path, sbo_dwn).start()
|
||||
script = sbo_dwn.split("/")[-1]
|
||||
for src in source_dwn:
|
||||
Download(build_path, src).start()
|
||||
sources.append(src.split("/")[-1])
|
||||
BuildPackage(script, sources, build_path).build()
|
||||
|
||||
|
||||
def install(name, prgnam, sbo_url):
|
||||
'''
|
||||
Install Slackware package found in /tmp
|
||||
directory.
|
||||
'''
|
||||
binary_list = []
|
||||
for search in find_package(prgnam, tmp):
|
||||
if "_SBo" in search:
|
||||
binary_list.append(search)
|
||||
def read_choice(self):
|
||||
'''
|
||||
Return choice
|
||||
'''
|
||||
try:
|
||||
binary = (tmp + max(binary_list)).split()
|
||||
except ValueError:
|
||||
build_FAILED(sbo_url, prgnam)
|
||||
choice = raw_input(" {0}Choose an option: {1}".format(GREY, ENDC))
|
||||
except KeyboardInterrupt:
|
||||
print # new line at exit
|
||||
sys.exit()
|
||||
print("[ {0}Installing{1} ] --> {2}".format(GREEN, ENDC, name))
|
||||
PackageManager(binary).upgrade()
|
||||
return choice
|
||||
|
||||
def error_uns(self):
|
||||
'''
|
||||
Check if package supported by arch
|
||||
before proceed to install
|
||||
'''
|
||||
UNST = ["UNSUPPORTED", "UNTESTED"]
|
||||
if "".join(self.source_dwn) in UNST:
|
||||
return "".join(self.source_dwn)
|
||||
|
||||
def download(self, path):
|
||||
'''
|
||||
Download sources
|
||||
'''
|
||||
Download(path, self.sbo_dwn).start()
|
||||
for src in self.source_dwn:
|
||||
Download(path, src).start()
|
||||
|
||||
def build(self, FAULT):
|
||||
'''
|
||||
Only build and create Slackware package
|
||||
'''
|
||||
if FAULT:
|
||||
print("\n{0}The package {1} {2}\n".format(RED, FAULT, ENDC))
|
||||
sys.exit()
|
||||
if not os.path.exists(build_path):
|
||||
os.mkdir(build_path)
|
||||
sources = []
|
||||
os.chdir(build_path)
|
||||
Download(build_path, self.sbo_dwn).start()
|
||||
script = self.sbo_dwn.split("/")[-1]
|
||||
for src in self.source_dwn:
|
||||
Download(build_path, src).start()
|
||||
sources.append(src.split("/")[-1])
|
||||
BuildPackage(script, sources, build_path).build()
|
||||
|
||||
def install(self, prgnam):
|
||||
'''
|
||||
Install Slackware package found in /tmp
|
||||
directory.
|
||||
'''
|
||||
binary_list = []
|
||||
for search in find_package(prgnam, tmp):
|
||||
if "_SBo" in search:
|
||||
binary_list.append(search)
|
||||
try:
|
||||
binary = (tmp + max(binary_list)).split()
|
||||
except ValueError:
|
||||
build_FAILED(self.sbo_url, prgnam)
|
||||
sys.exit()
|
||||
print("[ {0}Installing{1} ] --> {2}".format(GREEN, ENDC, self.name))
|
||||
PackageManager(binary).upgrade()
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
import os
|
||||
import sys
|
||||
|
||||
from slpkg.sizes import units
|
||||
from slpkg.url_read import URL
|
||||
from slpkg.blacklist import BlackList
|
||||
from slpkg.splitting import split_package
|
||||
|
@ -34,7 +35,6 @@ from slpkg.colors import RED, GREEN, CYAN, YELLOW, GREY, ENDC
|
|||
from slpkg.pkg.find import find_package
|
||||
from slpkg.pkg.manager import PackageManager
|
||||
|
||||
from sizes import units
|
||||
from remove import delete
|
||||
from mirrors import mirrors
|
||||
from greps import slack_data
|
||||
|
@ -66,10 +66,7 @@ class Slack(object):
|
|||
Install packages from official Slackware distribution
|
||||
'''
|
||||
try:
|
||||
data = slack_data(self.PACKAGES_TXT, 700)
|
||||
(dwn_links, install_all,
|
||||
comp_sum, uncomp_sum) = store(data[0], data[1], data[2], data[3],
|
||||
self.slack_pkg, self.version)
|
||||
dwn_links, install_all, comp_sum, uncomp_sum = self.store()
|
||||
sys.stdout.write("{0}Done{1}\n\n".format(GREY, ENDC))
|
||||
if install_all:
|
||||
template(78)
|
||||
|
@ -97,7 +94,7 @@ class Slack(object):
|
|||
print("After this process, {0} {1} of additional disk space "
|
||||
"will be used.{2}".format(size[1], unit[1], ENDC))
|
||||
read = raw_input("\nWould you like to install [Y/n]? ")
|
||||
if read == "Y" or read == "y":
|
||||
if read in ['y', 'Y']:
|
||||
slack_dwn(self.tmp_path, dwn_links)
|
||||
install(self.tmp_path, install_all)
|
||||
delete(self.tmp_path, install_all)
|
||||
|
@ -107,19 +104,21 @@ class Slack(object):
|
|||
print # new line at exit
|
||||
sys.exit()
|
||||
|
||||
|
||||
def store(*args):
|
||||
'''
|
||||
Store and return packages for install
|
||||
'''
|
||||
dwn, install, comp_sum, uncomp_sum = ([] for i in range(4))
|
||||
for name, loc, comp, uncomp in zip(args[0], args[1], args[2], args[3]):
|
||||
if args[4] in name and args[4] not in BlackList().packages():
|
||||
dwn.append("{0}{1}/{2}".format(mirrors("", "", args[5]), loc, name))
|
||||
install.append(name)
|
||||
comp_sum.append(comp)
|
||||
uncomp_sum.append(uncomp)
|
||||
return [dwn, install, comp_sum, uncomp_sum]
|
||||
def store(self):
|
||||
'''
|
||||
Store and return packages for install
|
||||
'''
|
||||
dwn, install, comp_sum, uncomp_sum = ([] for i in range(4))
|
||||
data = slack_data(self.PACKAGES_TXT, 700)
|
||||
black = BlackList().packages()
|
||||
for name, loc, comp, uncomp in zip(data[0], data[1], data[2], data[3]):
|
||||
if self.slack_pkg in name and self.slack_pkg not in black:
|
||||
dwn.append("{0}{1}/{2}".format(mirrors("", "", self.version),
|
||||
loc, name))
|
||||
install.append(name)
|
||||
comp_sum.append(comp)
|
||||
uncomp_sum.append(uncomp)
|
||||
return [dwn, install, comp_sum, uncomp_sum]
|
||||
|
||||
|
||||
def views(install_all, comp_sum):
|
||||
|
@ -168,14 +167,11 @@ def install(tmp_path, install_all):
|
|||
for install in install_all:
|
||||
package = (tmp_path + install).split()
|
||||
if os.path.isfile(pkg_path + install[:-4]):
|
||||
print("[ {0}reinstalling{1} ] --> {2}".format(
|
||||
GREEN, ENDC, install))
|
||||
print("[ {0}reinstalling{1} ] --> {2}".format(GREEN, ENDC, install))
|
||||
PackageManager(package).reinstall()
|
||||
elif find_package(split_package(install)[0] + "-", pkg_path):
|
||||
print("[ {0}upgrading{1} ] --> {2}".format(
|
||||
YELLOW, ENDC, install))
|
||||
print("[ {0}upgrading{1} ] --> {2}".format(YELLOW, ENDC, install))
|
||||
PackageManager(package).upgrade()
|
||||
else:
|
||||
print("[ {0}installing{1} ] --> {2}".format(
|
||||
GREEN, ENDC, install))
|
||||
print("[ {0}installing{1} ] --> {2}".format(GREEN, ENDC, install))
|
||||
PackageManager(package).upgrade()
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from slpkg.__metadata__ import arch
|
||||
from slpkg.repositories import Repo
|
||||
|
||||
from slack_version import slack_ver
|
||||
|
||||
|
@ -31,18 +32,19 @@ def mirrors(name, location, version):
|
|||
Select Slackware official mirror packages
|
||||
based architecture and version.
|
||||
'''
|
||||
repo = Repo().slack()
|
||||
if arch == "x86_64":
|
||||
if version == "stable":
|
||||
http = ("http://mirrors.slackware.com/slackware/slackware64-"
|
||||
"{0}/{1}{2}".format(slack_ver(), location, name))
|
||||
http = repo + "slackware64-{0}/{1}{2}".format(slack_ver(),
|
||||
location, name)
|
||||
else:
|
||||
http = ("http://mirrors.slackware.com/slackware/slackware64-"
|
||||
"{0}/{1}{2}".format(version, location, name))
|
||||
http = repo + "slackware64-{0}/{1}{2}".format(version,
|
||||
location, name)
|
||||
else:
|
||||
if version == "stable":
|
||||
http = ("http://mirrors.slackware.com/slackware/slackware-"
|
||||
"{0}/{1}{2}".format(slack_ver(), location, name))
|
||||
http = repo + "slackware-{0}/{1}{2}".format(slack_ver(),
|
||||
location, name)
|
||||
else:
|
||||
http = ("http://mirrors.slackware.com/slackware/slackware-"
|
||||
"{0}/{1}{2}".format(version, location, name))
|
||||
http = repo + "slackware-{0}/{1}{2}".format(version,
|
||||
location, name)
|
||||
return http
|
||||
|
|
|
@ -25,6 +25,7 @@ import os
|
|||
import sys
|
||||
import subprocess
|
||||
|
||||
from slpkg.sizes import units
|
||||
from slpkg.url_read import URL
|
||||
from slpkg.messages import template
|
||||
from slpkg.blacklist import BlackList
|
||||
|
@ -34,7 +35,6 @@ from slpkg.__metadata__ import pkg_path, slpkg_tmp
|
|||
|
||||
from slpkg.pkg.manager import PackageManager
|
||||
|
||||
from sizes import units
|
||||
from remove import delete
|
||||
from mirrors import mirrors
|
||||
from greps import slack_data
|
||||
|
@ -67,10 +67,7 @@ class Patches(object):
|
|||
Install new patches from official Slackware mirrors
|
||||
'''
|
||||
try:
|
||||
data = slack_data(self.PACKAGES_TXT, self.step)
|
||||
(dwn_links, upgrade_all,
|
||||
comp_sum, uncomp_sum) = store(data[0], data[1], data[2], data[3],
|
||||
self.version)
|
||||
dwn_links, upgrade_all, comp_sum, uncomp_sum = self.store()
|
||||
sys.stdout.write("{0}Done{1}\n".format(GREY, ENDC))
|
||||
if upgrade_all:
|
||||
print("\nThese packages need upgrading:\n")
|
||||
|
@ -95,7 +92,7 @@ class Patches(object):
|
|||
print("After this process, {0} {1} of additional disk space "
|
||||
"will be used.{2}".format(size[1], unit[1], ENDC))
|
||||
read = raw_input("\nWould you like to upgrade [Y/n]? ")
|
||||
if read == "Y" or read == "y":
|
||||
if read in ['y', 'Y']:
|
||||
slack_dwn(self.patch_path, dwn_links)
|
||||
upgrade(self.patch_path, upgrade_all)
|
||||
kernel(upgrade_all)
|
||||
|
@ -110,42 +107,45 @@ class Patches(object):
|
|||
print # new line at exit
|
||||
sys.exit()
|
||||
|
||||
|
||||
def store(*args):
|
||||
'''
|
||||
Store and return packages for upgrading
|
||||
'''
|
||||
(dwn, upgrade, comp_sum, uncomp_sum) = ([] for i in range(4))
|
||||
if args[4] == "stable": # stables versions upgrade
|
||||
for name, loc, comp, uncomp in zip(args[0], args[1], args[2], args[3]):
|
||||
if (not os.path.isfile(pkg_path + name[:-4]) and split_package(
|
||||
name)[0] not in BlackList().packages()):
|
||||
dwn.append("{0}{1}/{2}".format(
|
||||
mirrors("", "", args[4]), loc, name))
|
||||
comp_sum.append(comp)
|
||||
uncomp_sum.append(uncomp)
|
||||
upgrade.append(name)
|
||||
else: # current version upgrade
|
||||
installed = []
|
||||
# get all installed packages and store the package name.
|
||||
for pkg in os.listdir(pkg_path):
|
||||
installed.append(split_package(pkg)[0])
|
||||
for name, loc, comp, uncomp in zip(args[0], args[1], args[2], args[3]):
|
||||
# If the package from the current repository is installed
|
||||
# (check with the name) but not is in the path (check with
|
||||
# all package like 'apr-1.5.0-x86_64-1') then add to list for
|
||||
# upgrade.
|
||||
# etc. 'apr' in list 'installed' ?? if yes 'apr-1.5.0-x86_64-1'
|
||||
# exist in /var/log/packages ?? if no add to upgrade.
|
||||
if split_package(name)[0] in installed:
|
||||
if (not os.path.isfile(pkg_path + name[:-4]) and
|
||||
split_package(name)[0] not in BlackList().packages()):
|
||||
def store(self):
|
||||
'''
|
||||
Store and return packages for upgrading
|
||||
'''
|
||||
(dwn, upgrade, comp_sum, uncomp_sum) = ([] for i in range(4))
|
||||
data = slack_data(self.PACKAGES_TXT, self.step)
|
||||
black = BlackList().packages()
|
||||
if self.version == "stable": # stables versions upgrade
|
||||
for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
|
||||
data[3]):
|
||||
if (not os.path.isfile(pkg_path + name[:-4]) and split_package(
|
||||
name)[0] not in black):
|
||||
dwn.append("{0}{1}/{2}".format(
|
||||
mirrors("", "", args[4]), loc, name))
|
||||
mirrors("", "", self.version), loc, name))
|
||||
comp_sum.append(comp)
|
||||
uncomp_sum.append(uncomp)
|
||||
upgrade.append(name)
|
||||
return [dwn, upgrade, comp_sum, uncomp_sum]
|
||||
else: # current version upgrade
|
||||
installed = []
|
||||
# get all installed packages and store the package name.
|
||||
for pkg in os.listdir(pkg_path):
|
||||
installed.append(split_package(pkg)[0])
|
||||
for name, loc, comp, uncomp in zip(data[0], data[1], data[2],
|
||||
data[3]):
|
||||
# If the package from the current repository is installed
|
||||
# (check with the name) but not is in the path (check with
|
||||
# all package like 'apr-1.5.0-x86_64-1') then add to list for
|
||||
# upgrade.
|
||||
# etc. 'apr' in list 'installed' ?? if yes 'apr-1.5.0-x86_64-1'
|
||||
# exist in /var/log/packages ?? if no add to upgrade.
|
||||
if split_package(name)[0] in installed:
|
||||
if (not os.path.isfile(pkg_path + name[:-4]) and
|
||||
split_package(name)[0] not in black):
|
||||
dwn.append("{0}{1}/{2}".format(
|
||||
mirrors("", "", self.version), loc, name))
|
||||
comp_sum.append(comp)
|
||||
uncomp_sum.append(uncomp)
|
||||
upgrade.append(name)
|
||||
return [dwn, upgrade, comp_sum, uncomp_sum]
|
||||
|
||||
|
||||
def views(upgrade_all, comp_sum):
|
||||
|
|
|
@ -29,7 +29,7 @@ def delete(path, packages):
|
|||
Remove downloaded packages
|
||||
'''
|
||||
read = raw_input("Removal downloaded packages [Y/n]? ")
|
||||
if read == "Y" or read == "y":
|
||||
if read in ['y', 'Y']:
|
||||
for pkg in packages:
|
||||
os.remove(path + pkg)
|
||||
os.remove(path + pkg + ".asc")
|
||||
|
|
|
@ -32,12 +32,20 @@ def split_package(package):
|
|||
split = package.split("-")
|
||||
sbo = "_SBo"
|
||||
slack = "_slack{0}".format(slack_ver())
|
||||
if sbo in package:
|
||||
build = split[-1][:-4] # remove .t?z extension
|
||||
if slack in package:
|
||||
rlw = "_rlw"
|
||||
alien = "alien"
|
||||
slacky = "sl"
|
||||
build = split[-1]
|
||||
if build.endswith(sbo):
|
||||
build = split[-1][:-4] # and remove .t?z extension
|
||||
if build.endswith(slack):
|
||||
build = split[-1][:-len(slack)]
|
||||
else:
|
||||
build = split[-1]
|
||||
elif build.endswith(rlw):
|
||||
build = split[-1][:-len(rlw)]
|
||||
elif build.endswith(alien):
|
||||
build = split[-1][:-len(alien)]
|
||||
elif build.endswith(slacky):
|
||||
build = split[-1][:-len(slacky)]
|
||||
arch = split[-2]
|
||||
ver = split[-3]
|
||||
name = "-".join(split[:-3])
|
||||
|
|
Loading…
Reference in a new issue