Updated setup file

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2018-03-25 21:24:23 +02:00
parent e62ad0b8e4
commit 14063a87e2

View file

@ -55,7 +55,8 @@ def print_logo():
time.sleep(1) time.sleep(1)
def setup_configurations(): current = os.getcwd() + "/"
print current
conf_file = [ conf_file = [
"conf/slpkg.conf", "conf/slpkg.conf",
"conf/repositories.conf", "conf/repositories.conf",
@ -68,17 +69,18 @@ def setup_configurations():
] ]
if not os.path.exists(_meta_.conf_path): if not os.path.exists(_meta_.conf_path):
os.makedirs(_meta_.conf_path) os.makedirs(_meta_.conf_path)
for conf in conf_file: for i, conf in enumerate(conf_file):
filename = conf.split("/")[-1] filename = conf.split("/")[-1]
if os.path.isfile(_meta_.conf_path + filename): if os.path.isfile(_meta_.conf_path + filename):
old = md5(_meta_.conf_path + filename) old = md5(_meta_.conf_path + filename)
new = md5(conf) new = md5(conf)
if old != new: if old != new:
shutil.copy2(_meta_.conf_path + filename, shutil.move(_meta_.conf_path + filename,
_meta_.conf_path + filename + ".old") _meta_.conf_path + filename + ".old")
shutil.move(current + conf, current + conf + ".new")
conf_file[i] = conf + ".new"
print_logo() print_logo()
setup_configurations()
setup( setup(
name="slpkg", name="slpkg",
@ -97,7 +99,7 @@ setup(
data_files=[("man/man8", ["man/slpkg.8"]), data_files=[("man/man8", ["man/slpkg.8"]),
("/etc/bash_completion.d", ["conf/slpkg.bash-completion"]), ("/etc/bash_completion.d", ["conf/slpkg.bash-completion"]),
("/etc/fish/completions", ["conf/slpkg.fish"]), ("/etc/fish/completions", ["conf/slpkg.fish"]),
(_meta_.conf_path, ["conf/slpkg.conf"]), (_meta_.conf_path, [conf_file[0]]),
(_meta_.conf_path, ["conf/repositories.conf"]), (_meta_.conf_path, ["conf/repositories.conf"]),
(_meta_.conf_path, ["conf/blacklist"]), (_meta_.conf_path, ["conf/blacklist"]),
(_meta_.conf_path, ["conf/slackware-mirrors"]), (_meta_.conf_path, ["conf/slackware-mirrors"]),
@ -126,3 +128,7 @@ setup(
"Topic :: Utilities"], "Topic :: Utilities"],
long_description=open("README.rst").read() long_description=open("README.rst").read()
) )
for f in os.listdir(_meta_.conf_path):
if f.endswith(".old"):
shutil.move(_meta_.conf_path + f, _meta_.conf_path + f[:-4])