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,30 +55,32 @@ def print_logo():
time.sleep(1) time.sleep(1)
def setup_configurations(): current = os.getcwd() + "/"
conf_file = [ print current
"conf/slpkg.conf", conf_file = [
"conf/repositories.conf", "conf/slpkg.conf",
"conf/blacklist", "conf/repositories.conf",
"conf/slackware-mirrors", "conf/blacklist",
"conf/default-repositories", "conf/slackware-mirrors",
"conf/custom-repositories", "conf/default-repositories",
"conf/rlworkman.deps", "conf/custom-repositories",
"conf/pkg_security" "conf/rlworkman.deps",
] "conf/pkg_security"
if not os.path.exists(_meta_.conf_path): ]
os.makedirs(_meta_.conf_path) if not os.path.exists(_meta_.conf_path):
for conf in conf_file: os.makedirs(_meta_.conf_path)
filename = conf.split("/")[-1] for i, conf in enumerate(conf_file):
if os.path.isfile(_meta_.conf_path + filename): filename = conf.split("/")[-1]
old = md5(_meta_.conf_path + filename) if os.path.isfile(_meta_.conf_path + filename):
new = md5(conf) old = md5(_meta_.conf_path + filename)
if old != new: new = md5(conf)
shutil.copy2(_meta_.conf_path + filename, if old != new:
_meta_.conf_path + filename + ".old") shutil.move(_meta_.conf_path + filename,
_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])