From 7ff62d7ca7ec72f77ee25ac88d742cfa3f15a068 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Wed, 22 Feb 2017 22:12:49 +0200 Subject: [PATCH] Added support special packages who need attention --- ChangeLog.txt | 8 ++++++++ conf/pkg_security | 34 ++++++++++++++++++++++++++++++++ setup.py | 3 ++- slpkg/binary/install.py | 3 +++ slpkg/messages.py | 12 ++++++++++++ slpkg/sbo/slackbuild.py | 3 +++ slpkg/security.py | 43 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 105 insertions(+), 1 deletion(-) create mode 100644 conf/pkg_security create mode 100644 slpkg/security.py diff --git a/ChangeLog.txt b/ChangeLog.txt index b665bddf..32fc226a 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,3 +1,11 @@ +3.2.6 - 22/02/2017 +Updated: +- Pattern for configuration file + +Added: +- Support the special packages who need attention (OpenGL 32-Bits Libs after +upgrade #81) Thanks to Edward W. Koenig and Inukaze for the report + 3.2.5 - 17/02/2017 Updated: - Url for mles/mled repository (Thanks Kiki Novak for the report) diff --git a/conf/pkg_security b/conf/pkg_security new file mode 100644 index 00000000..25ef26ac --- /dev/null +++ b/conf/pkg_security @@ -0,0 +1,34 @@ +# Security file: +# +# pkg_security file is part of slpkg. +# +# Copyright 2014-2017 Dimitris Zlatanidis +# All rights reserved. +# +# Slpkg is a user-friendly package manager for Slackware installations. +# +# https://github.com/dslackw/slpkg +# +# Slpkg is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# END OF LEGAL NOTICE +# +# ---------------------------------------------------------------------------- +# For some reasons some packages need extra management and attention before +# build, install or upgrade. So this list of packages will produce one warning +# message before action. +# You can add the packages you that believe need attention or please mention +# to me in the email dslackw@gmail.com +# ---------------------------------------------------------------------------- +# +nvidia-kernel +nvidia-driver diff --git a/setup.py b/setup.py index 47fe3d39..07a93883 100755 --- a/setup.py +++ b/setup.py @@ -126,7 +126,8 @@ if "install" in sys.argv: "conf/slackware-mirrors", "conf/default-repositories", "conf/custom-repositories", - "conf/rlworkman.deps" + "conf/rlworkman.deps", + "conf/pkg_security" ] if not os.path.exists(_meta_.conf_path): os.makedirs(_meta_.conf_path) diff --git a/slpkg/binary/install.py b/slpkg/binary/install.py index 8c9728ed..0e86e761 100644 --- a/slpkg/binary/install.py +++ b/slpkg/binary/install.py @@ -25,6 +25,8 @@ import os from distutils.version import LooseVersion +from slpkg.security import pkg_security + from slpkg.utils import Utils from slpkg.sizes import units from slpkg.messages import Msg @@ -53,6 +55,7 @@ class BinaryInstall(object): """ def __init__(self, packages, repo, flag): self.packages = packages + pkg_security(packages) self.repo = repo self.flag = flag self.meta = _meta_ diff --git a/slpkg/messages.py b/slpkg/messages.py index 89730feb..34e33aa2 100644 --- a/slpkg/messages.py +++ b/slpkg/messages.py @@ -131,6 +131,18 @@ class Msg(object): raise SystemExit() return answer + def security_pkg(self, pkg): + """Warning message for some special reasons + """ + self.template(78) + print("| {0}{1} *** WARNING ***{2}\n" + "| Before proceed with package '{3}' will you must read the\n" + "| README file. You can use command 'slpkg -n {4}'").format( + " " * 20, self.meta.color["RED"], self.meta.color["ENDC"], + pkg, pkg) + self.template(78) + print("") + def reference(self, install, upgrade): """Reference list with packages installed and upgraded diff --git a/slpkg/sbo/slackbuild.py b/slpkg/sbo/slackbuild.py index a3061eff..34eb49ce 100644 --- a/slpkg/sbo/slackbuild.py +++ b/slpkg/sbo/slackbuild.py @@ -25,6 +25,8 @@ import os from distutils.version import LooseVersion +from slpkg.security import pkg_security + from slpkg.utils import Utils from slpkg.messages import Msg from slpkg.toolbar import status @@ -52,6 +54,7 @@ class SBoInstall(object): """ def __init__(self, slackbuilds, flag): self.slackbuilds = slackbuilds + pkg_security(self.slackbuilds) self.flag = flag self.meta = _meta_ self.msg = Msg() diff --git a/slpkg/security.py b/slpkg/security.py new file mode 100644 index 00000000..86bba883 --- /dev/null +++ b/slpkg/security.py @@ -0,0 +1,43 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# security.py file is part of slpkg. + +# Copyright 2014-2017 Dimitris Zlatanidis +# All rights reserved. + +# Slpkg is a user-friendly package manager for Slackware installations + +# https://github.com/dslackw/slpkg + +# Slpkg is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + + +from slpkg.utils import Utils +from slpkg.messages import Msg + + +def pkg_security(pkgs): + """Check packages before install or upgrade for security + reasons""" + security_packages = Utils().read_file("/etc/slpkg/pkg_security") + packages = [] + for read in security_packages.splitlines(): + read = read.lstrip() + if not read.startswith("#"): + packages.append(read.replace("\n", "")) + for p in pkgs: + for pkg in packages: + if p == pkg: + Msg().security_pkg(p) + if not Msg().answer() in ["y", "Y"]: + raise SystemExit()