From 5026e9f9c692f9670d9a3ee8a9c516872bd17c91 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Sat, 31 Mar 2018 21:06:49 +0200 Subject: [PATCH] Updated setup file for pip install Signed-off-by: Dimitris Zlatanidis --- setup.py | 67 ++++++++++++++++--------------------- slackbuild/slpkg.SlackBuild | 16 ++++++++- slpkg/blacklist.py | 1 + 3 files changed, 44 insertions(+), 40 deletions(-) diff --git a/setup.py b/setup.py index ef177a42..4c40a770 100755 --- a/setup.py +++ b/setup.py @@ -54,32 +54,6 @@ def print_logo(): print(logo) time.sleep(1) - -current = os.getcwd() + "/" -print current -conf_file = [ - "conf/slpkg.conf", - "conf/repositories.conf", - "conf/blacklist", - "conf/slackware-mirrors", - "conf/default-repositories", - "conf/custom-repositories", - "conf/rlworkman.deps", - "conf/pkg_security" -] -if not os.path.exists(_meta_.conf_path): - os.makedirs(_meta_.conf_path) -for i, conf in enumerate(conf_file): - filename = conf.split("/")[-1] - if os.path.isfile(_meta_.conf_path + filename): - old = md5(_meta_.conf_path + filename) - new = md5(conf) - if old != new: - 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() setup( @@ -95,18 +69,10 @@ setup( author_email=_meta_.__email__, url="https://github.com/dslackw/slpkg", package_data={"": ["LICENSE", "README.rst", "CHANGELOG"]}, - install_requires=INSTALLATION_REQUIREMENTS, data_files=[("man/man8", ["man/slpkg.8"]), ("/etc/bash_completion.d", ["conf/slpkg.bash-completion"]), - ("/etc/fish/completions", ["conf/slpkg.fish"]), - (_meta_.conf_path, [conf_file[0]]), - (_meta_.conf_path, ["conf/repositories.conf"]), - (_meta_.conf_path, ["conf/blacklist"]), - (_meta_.conf_path, ["conf/slackware-mirrors"]), - (_meta_.conf_path, ["conf/default-repositories"]), - (_meta_.conf_path, ["conf/custom-repositories"]), - (_meta_.conf_path, ["conf/rlworkman.deps"]), - (_meta_.conf_path, ["conf/pkg_security"])], + ("/etc/fish/completions", ["conf/slpkg.fish"])], + install_requires=INSTALLATION_REQUIREMENTS, extras_require={ "optional": OPTIONAL_REQUIREMENTS, "docs": DOCS_REQUIREMENTS, @@ -129,6 +95,29 @@ setup( 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]) +# Install man page and configuration files with pip. +if "install" in sys.argv: + conf_file = [ + "conf/slpkg.conf", + "conf/repositories.conf", + "conf/blacklist", + "conf/slackware-mirrors", + "conf/default-repositories", + "conf/custom-repositories", + "conf/rlworkman.deps", + "conf/pkg_security" + ] + if not os.path.exists(_meta_.conf_path): + os.makedirs(_meta_.conf_path) + for conf in conf_file: + filename = conf.split("/")[-1] + print("Installing '{0}' file".format(filename)) + if os.path.isfile(_meta_.conf_path + filename): + old = md5(_meta_.conf_path + filename) + new = md5(conf) + if old != new: + 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 ceca89f9..68cdc7ee 100755 --- a/slackbuild/slpkg.SlackBuild +++ b/slackbuild/slpkg.SlackBuild @@ -80,7 +80,10 @@ find -L . \ \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; -# Python 3 support temporarily is out until new Slackware version release +# avoid pip installs +sed -i 's/if "install"/if ""/' setup.py + +# Python 3 support temporarily is out until new Slackware version # will be release # if [ "$PYTHON3" = "yes" ]; then # sh convert-py3k @@ -92,6 +95,17 @@ $PYTHON setup.py install --root=$PKG find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \ | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true +mkdir -p $PKG/etc/slpkg +# install configurations files +CONFIGS="slpkg.conf repositories.conf blacklist slackware-mirrors default-repositories \ + custom-repositories rlworkman.deps pkg_security" +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 + mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION cp -a README.rst ChangeLog.txt LICENSE TESTING ISSUES KNOWN_ISSUES REPOSITORIES \ requirements.txt $PKG/usr/doc/$PRGNAM-$VERSION diff --git a/slpkg/blacklist.py b/slpkg/blacklist.py index c72a29e7..cb93b769 100644 --- a/slpkg/blacklist.py +++ b/slpkg/blacklist.py @@ -21,6 +21,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . + import os from slpkg.utils import Utils