Added checklist option

This commit is contained in:
Dimitris Zlatanidis 2015-09-08 02:29:07 +03:00
parent 89bd045d11
commit d96f64081d
12 changed files with 119 additions and 24 deletions

View file

@ -241,7 +241,8 @@ Combine with the command 'grep' to catch the results you want.
Check and upgrade the distribution of your upgrade your packages with command '# slpkg -c <repository>
--upgrade'. Don't forget to update packages list before (for 'slack' repository don't is necessary).
This command except upgrade packages will fix packages with broken dependencies. Switch off automatic
resolve dependensies with additional option '--resolve-off'.
resolve dependensies with additional option '--resolve-off'. Use '--checklist' option to help you
to choose easy packages. For advanced users, option '--skip' give them more power (see man page).
The most famous command is '# slpkg -s <repository> <packages>' , this command downloads and
installs packages with resolve all the dependencies or switch of resolve with additional option
@ -418,8 +419,9 @@ Command Line Tool Usage
--installed packages repository, index or print
only packages installed on the
system.
-c, --check, [repository], --upgrade, Check, view and install updated
--skip=[...] --resolve--off packages from repositories.
-c, --check, [repository], --upgrade, Check for updated packages from the
--skip=[...], --resolve--off repositories and install with all
--checklist dependencies.
-s, --sync, [repository] [package...], Sync packages. Install packages
--resolve-off directly from remote repositories
with all dependencies.

View file

@ -36,7 +36,8 @@ Usage: slpkg Commands:
[-q [build, install, build-install]]
[-g [print, edit=[editor], reset]]
[-l [repository], --index, --installed]
[-c [repository], --upgrade, --skip=[...], --resolve-off]
[-c [repository], --upgrade, --skip=[...], --resolve-off,
--checklist]
[-s [repository] [package...], --resolve-off]
[-t [repository] [package], --check-deps, --graph=[type]]
[-p [repository] [package], --color=[]]
@ -188,7 +189,7 @@ system. Support command "grep" like "# slpkg -l sbo | grep python".
.SS -c, --check, check if your packages is up to date
\fBslpkg\fP \fB-c\fP <\fIrepository\fP> \fB--upgrade\fP \fB--skip=[packages...]\fP,
\fB--resolve-off\fP
\fB--resolve-off\fP, \fB--checklist\fP
.PP
Check your packages if up to date. Slackware patches repository works independently of the
others i.e not need before updating the list of packages by choosing "# slpkg update", works
@ -202,7 +203,9 @@ Additional options:
.PP
\fB--resolve-off\fP : Switch off automatic resolve dependencies.
.PP
\fB--skip=[packages...]\fP : Skip packages from upgrade separate by comma like "slpkg -c sbo --skip=jdk,pep8,pip".
\fB--skip=[packages...]\fP : Skip packages from upgrade separate by comma like "slpkg -c sbo --skip=jdk,pep8,pip" (See REGEX).
.PP
\fB--checklist\fP : Enable dialog utility and checklist option. (Require python2-pythondialog)
.SS -s, --sync, synchronize packages, download, build and install package with all dependencies
\fBslpkg\fP \fB-s\fP <\fIrepository\fP> <\fInames of packages\fP>, \fB--resolve-off\fP

View file

@ -88,8 +88,9 @@ Optional arguments:
--installed packages repository, index or print
only packages installed on the
system.
-c, --check, [repository], --upgrade, Check, view and install updated
--skip=[...], --resolve--off packages from repositories.
-c, --check, [repository], --upgrade, Check for updated packages from the
--skip=[...], --resolve--off repositories and install with all
--checklist dependencies.
-s, --sync, [repository] [package...], Sync packages. Install packages
--resolve-off directly from remote repositories
with all dependencies.
@ -155,7 +156,8 @@ def usage(repo):
[-q [build, install, build-install]]
[-g [print, edit=[editor], reset]]
[-l [repository], --index, --installed]
[-c [repository], --upgrade, --skip=[...], --resolve-off]
[-c [repository], --upgrade, --skip=[...], --resolve-off,
--checklist]
[-s [repository] [package...], --resolve-off]
[-t [repository] [package], --check-deps, --graph=[type]]
[-p [repository] [package], --color=[]]

View file

@ -27,6 +27,7 @@ from distutils.version import LooseVersion
from slpkg.messages import Msg
from slpkg.toolbar import status
from slpkg.splitting import split_package
from slpkg.upgrade_checklist import choose_upg
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.pkg.find import find_package
@ -35,7 +36,7 @@ from slpkg.binary.greps import repo_data
from slpkg.binary.repo_init import RepoInit
def pkg_upgrade(repo, skip):
def pkg_upgrade(repo, skip, flag):
"""
Checking packages for upgrade
"""
@ -61,6 +62,8 @@ def pkg_upgrade(repo, skip):
repo_pkg[1] != "blacklist"):
pkgs_for_upgrade.append(repo_pkg[0])
Msg().done()
if "--checklist" in flag:
pkgs_for_upgrade = choose_upg(pkgs_for_upgrade)
return pkgs_for_upgrade
except KeyboardInterrupt:
print("") # new line at exit

View file

@ -44,7 +44,7 @@ class Dependencies(object):
"""
Build all dependencies of a package
"""
if self.meta.rsl_deps in ["on", "ON"] and flag != "--resolve-off":
if self.meta.rsl_deps in ["on", "ON"] and "--resolve-off" not in flag:
try:
sys.setrecursionlimit(10000)
dependencies = []

View file

@ -37,7 +37,7 @@ def repo_data(PACKAGES_TXT, repo, flag):
(name, location, size, unsize,
rname, rlocation, rsize, runsize) = ([] for i in range(8))
for line in PACKAGES_TXT.splitlines():
if _meta_.rsl_deps in ["on", "ON"] and flag != "--resolve-off":
if _meta_.rsl_deps in ["on", "ON"] and "--resolve-off" not in flag:
status(0.000005)
if line.startswith("PACKAGE NAME:"):
name.append(line[15:].strip())

View file

@ -87,7 +87,7 @@ class BinaryInstall(object):
(self.dwn, self.install, self.comp_sum,
self.uncomp_sum) = self.store(self.packages)
if (self.meta.rsl_deps in ["on", "ON"] and
self.flag != "--resolve-off"):
"--resolve-off" not in self.flag):
self.msg.done()
if self.install:
print("\nThe following packages will be automatically "

View file

@ -260,22 +260,22 @@ class ArgParse(object):
"""Check and upgrade packages by repository
"""
options = ["-c", "--check"]
flags = ["--upgrade", "--skip=", "--resolve-off"]
flags = ["--upgrade", "--skip=", "--resolve-off", "--checklist"]
flag, skip = self.__pkg_upgrade_flags(flags)
if (len(self.args) == 3 and self.args[0] in options and
self.args[2] == flags[0] and
self.args[1] in self.meta.repositories):
if self.args[1] not in ["slack", "sbo"]:
BinaryInstall(pkg_upgrade(self.args[1], skip),
BinaryInstall(pkg_upgrade(self.args[1], skip, flag),
self.args[1], flag).start(if_upgrade=True)
elif self.args[1] == "slack":
if self.meta.only_installed in ["on", "ON"]:
BinaryInstall(pkg_upgrade("slack", skip),
BinaryInstall(pkg_upgrade("slack", skip, flag),
"slack", flag).start(if_upgrade=True)
else:
Patches(skip, flag).start()
elif self.args[1] == "sbo":
SBoInstall(sbo_upgrade(skip), flag).start(if_upgrade=True)
SBoInstall(sbo_upgrade(skip, flag), flag).start(if_upgrade=True)
else:
usage(self.args[1])
elif len(self.args) == 2 and self.args[0] in options:
@ -292,15 +292,15 @@ class ArgParse(object):
def __pkg_upgrade_flags(self, flags):
"""Manage flags for package upgrade option
"""
flag, skip = "", ""
flag, skip = [], ""
if flags[0] in self.args:
if flags[2] in self.args:
flag = flags[2]
self.args.remove(flags[2])
for arg in self.args:
for arg in self.args[3:]:
if arg.startswith(flags[1]):
skip = Regex(arg.split("=")[1]).get()
self.args.remove(arg)
if arg in flags:
flag.append(arg)
self.args.remove(arg)
return flag, skip
def pkg_install(self):

View file

@ -29,12 +29,13 @@ from slpkg.messages import Msg
from slpkg.toolbar import status
from slpkg.blacklist import BlackList
from slpkg.splitting import split_package
from slpkg.upgrade_checklist import choose_upg
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.sbo.greps import SBoGrep
def sbo_upgrade(skip):
def sbo_upgrade(skip, flag):
"""
Return packages for upgrade
"""
@ -53,6 +54,8 @@ def sbo_upgrade(skip):
if LooseVersion(sbo_package) > LooseVersion(package):
upgrade_names.append(name)
Msg().done()
if "--checklist" in flag:
upgrade_names = choose_upg(upgrade_names)
return upgrade_names
except KeyboardInterrupt:
print("") # new line at exit

View file

@ -46,7 +46,8 @@ class Requires(object):
"""
Build all dependencies of a package
"""
if self.meta.rsl_deps in ["on", "ON"] and self.flag != "--resolve-off":
if (self.meta.rsl_deps in ["on", "ON"] and
"--resolve-off" not in self.flag):
try:
sys.setrecursionlimit(10000)
dependencies = []

View file

@ -37,6 +37,7 @@ from slpkg.blacklist import BlackList
from slpkg.downloader import Download
from slpkg.remove import delete_package
from slpkg.grep_md5 import pkg_checksum
from slpkg.dialog_box import DialogUtil
from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _meta_
@ -85,6 +86,8 @@ class Patches(object):
self.store()
self.msg.done()
if self.upgrade_all:
if "--checklist" in self.flag:
self.dialog_checklist()
print("\nThese packages need upgrading:\n")
self.msg.template(78)
print("{0}{1}{2}{3}{4}{5}{6}{7}{8}{9}{10}".format(
@ -157,6 +160,29 @@ class Patches(object):
self.count_upg -= 1
return self.count_upg
def dialog_checklist(self):
"""Create checklist to choose packages for upgrade
"""
text = "Press 'spacebar' to unchoose packages from upgrade"
title = "Upgrade"
backtitle = "{0} {1}".format(self.meta.__all__,
self.meta.__version__)
status = True
pkgs = DialogUtil(self.upgrade_all, text, title, backtitle,
status).checklist()
index = 0
for pkg, comp, uncomp in zip(self.upgrade_all, self.comp_sum,
self.uncomp_sum):
if pkg not in pkgs:
self.dwn_links.pop(index)
self.upgrade_all.pop(index)
self.comp_sum.pop(index)
self.uncomp_sum.pop(index)
self.count_upg -= 1
index += 1
if not self.upgrade_all:
raise SystemExit()
def views(self):
"""
Views packages

View file

@ -0,0 +1,55 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# upgrade_checklist.py file is part of slpkg.
# Copyright 2014-2015 Dimitris Zlatanidis <d.zlatanidis@gmail.com>
# 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 <http://www.gnu.org/licenses/>.
from slpkg.dialog_box import DialogUtil
from slpkg.splitting import split_package
from slpkg.__metadata__ import MetaData as _meta_
from slpkg.pkg.find import find_package
from slpkg.pkg.installed import GetFromInstalled
def choose_upg(packages):
"""Create checklist to choose packages for upgrade
"""
selected_packages, data = [], []
for pkg in packages:
name = GetFromInstalled(pkg).name()
ver = GetFromInstalled(pkg).version()
binary = "{0}{1}".format(name, ver)
installed = find_package(binary + _meta_.sp, _meta_.pkg_path)[0]
data.append(installed)
text = "Press 'spacebar' to unchoose packages from upgrade"
title = "Upgrade"
backtitle = "{0} {1}".format(_meta_.__all__, _meta_.__version__)
status = True
pkgs = DialogUtil(data, text, title, backtitle,
status).checklist()
for pkg in pkgs:
name = split_package(pkg)[0]
if name in packages:
selected_packages.append(name)
if not selected_packages:
raise SystemExit()
return selected_packages