mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-18 10:26:29 +01:00
Added reset slpkg config file
This commit is contained in:
parent
d17b6a5c2a
commit
5fa9ce0f81
8 changed files with 32 additions and 11 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
2
setup.py
2
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")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
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"]))
|
||||
|
|
|
@ -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("")
|
||||
|
||||
|
|
Loading…
Reference in a new issue