diff --git a/ChangeLog.txt b/ChangeLog.txt index 12bdef9e..5e200e3c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,7 @@ 2.8.3 - 05/09/2015 Added: - Update package lists for repository 'slack' after upgrade distribution +- Reset slpkg configuration file in the default values Fixed: - pip install diff --git a/README.rst b/README.rst index f6b1e5cb..4f044025 100644 --- a/README.rst +++ b/README.rst @@ -411,9 +411,9 @@ Command Line Tool Usage --remove, list, build, install, Add or remove and print the list build-install of packages. Build and then install the packages from the queue. - -g, --config, print, edit=[editor] Configuration file management. - Print the configuration file or - edit. + -g, --config, print, edit=[editor], Configuration file management. + reset Print, edit the configuration file + or reset in the default values. -l, --list, [repository], --index, Print a list of all available --installed packages repository, index or print only packages installed on the diff --git a/man/slpkg.8 b/man/slpkg.8 index 832c9fce..baed83dc 100644 --- a/man/slpkg.8 +++ b/man/slpkg.8 @@ -34,7 +34,7 @@ Usage: slpkg Commands: [-b [package...] --add, --remove, list] [-q [package...] --add, --remove, list] [-q [build, install, build-install]] - [-g [print, edit=[editor]]] + [-g [print, edit=[editor], reset]] [-l [repository], --index, --installed] [-c [repository], --upgrade, --skip=[...], --resolve-off] [-s [repository] [package...], --resolve-off] @@ -176,9 +176,9 @@ dependencies. If you want to remove all the packages from the list run "# slpkg Build or install or build and install packages are queued. .SS -g, --config, configuration file management -\fBslpkg\fP \fB-g\fP \fBprint\fP, \fBedit=[editor]\fP +\fBslpkg\fP \fB-g\fP \fBprint\fP, \fBedit=[editor]\fP, \fBreset\fP .PP -Print configuration file or edit with your favorite editor. +Print, reset or edit configuration file with your favorite editor. .SS -l, --list, list of installed packages \fBslpkg\fP \fB-l\fP <\fIrepository\fP>, \fB--index\fP, \fB--installed\fP diff --git a/setup.py b/setup.py index 58c4c028..2b005876 100755 --- a/setup.py +++ b/setup.py @@ -131,3 +131,5 @@ if "install" in sys.argv: shutil.copy2(conf, _meta_.conf_path + filename + ".new") else: shutil.copy2(conf, _meta_.conf_path) + shutil.copy2(conf_file[0], + _meta_.conf_path + conf_file[0].split("/")[-1] + ".orig") diff --git a/slackbuild/slpkg.SlackBuild b/slackbuild/slpkg.SlackBuild index a5ae4c13..470360f1 100755 --- a/slackbuild/slpkg.SlackBuild +++ b/slackbuild/slpkg.SlackBuild @@ -90,6 +90,8 @@ CONFIGS="slpkg.conf repositories.conf blacklist slackware-mirrors custom-reposit for file in $CONFIGS; do install -D -m0644 conf/$file $PKG/etc/slpkg/${file}.new done +# keep original configuration file for reset +cp -p conf/slpkg.conf $PKG/etc/slpkg/slpkg.conf.orig # install bash completion file mkdir -p $PKG/etc/bash_completion.d diff --git a/slpkg/arguments.py b/slpkg/arguments.py index 4a6e359c..315f038e 100644 --- a/slpkg/arguments.py +++ b/slpkg/arguments.py @@ -81,9 +81,9 @@ Optional arguments: --remove, list, build, install, Add or remove and print the list build-install of packages. Build and then install the packages from the queue. - -g, --config, print, edit=[editor] Configuration file management. - Print the configuration file or - edit. + -g, --config, print, edit=[editor], Configuration file management. + reset Print, edit the configuration file + or reset in the default values. -l, --list, [repository], --index, Print a list of all available --installed packages repository, index or print only packages installed on the @@ -153,7 +153,7 @@ def usage(repo): [-b [package...] --add, --remove, list] [-q [package...] --add, --remove, list] [-q [build, install, build-install]] - [-g [print, edit=[editor]]] + [-g [print, edit=[editor], reset]] [-l [repository], --index, --installed] [-c [repository], --upgrade, --skip=[...], --resolve-off] [-s [repository] [package...], --resolve-off] diff --git a/slpkg/config.py b/slpkg/config.py index a4502bb5..45923949 100644 --- a/slpkg/config.py +++ b/slpkg/config.py @@ -22,6 +22,8 @@ # along with this program. If not, see . +import shutil +import filecmp import subprocess from slpkg.utils import Utils @@ -80,3 +82,14 @@ class Config(object): Edit configuration file """ subprocess.call("{0} {1}".format(editor, self.config_file), shell=True) + + def reset(self): + """Reset slpkg.conf file with default values + """ + shutil.copy2(self.config_file + ".orig", self.config_file) + if filecmp.cmp(self.config_file + ".orig", self.config_file): + print("{0}The reset was done{1}".format( + self.meta.color["GREEN"], self.meta.color["ENDC"])) + else: + print("{0}Reset failed{1}".format(self.meta.color["RED"], + self.meta.color["ENDC"])) diff --git a/slpkg/main.py b/slpkg/main.py index fc5eadc5..62fd7cba 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -535,7 +535,7 @@ class ArgParse(object): """Manage slpkg configuration file """ options = ["-g", "--config"] - command = ["print", "edit="] + command = ["print", "edit=", "reset"] if (len(self.args) == 2 and self.args[0] in options and self.args[1].startswith(command[1])): editor = self.args[1][len(command[1]):] @@ -543,6 +543,9 @@ class ArgParse(object): elif (len(self.args) == 2 and self.args[0] in options and self.args[1] == (command[0])): Config().view() + elif (len(self.args) == 2 and self.args[0] in options and + self.args[1] == (command[2])): + Config().reset() else: usage("")