From 0ef443f97c1016aa24e63c48e8e85cfa232379d9 Mon Sep 17 00:00:00 2001 From: gryf Date: Mon, 31 Aug 2020 21:07:30 +0200 Subject: [PATCH] Removed bin/sbin out of config options. Let's do this in pythonic way, optionally leave the decision to package maintainers, where to put binaries. --- data/init/arch/wicd | 2 +- data/init/debian/wicd | 2 +- data/init/gentoo/wicd | 2 +- data/init/pld/wicd | 2 +- data/init/redhat/wicd | 2 +- data/init/slackware/rc.wicd | 2 +- data/init/suse/wicd | 2 +- setup.py | 75 +++++++++++++------------------------ wicd/config.py | 16 ++++---- wicd/misc.py | 2 +- 10 files changed, 42 insertions(+), 65 deletions(-) diff --git a/data/init/arch/wicd b/data/init/arch/wicd index 4500eb4..9d06a25 100755 --- a/data/init/arch/wicd +++ b/data/init/arch/wicd @@ -5,7 +5,7 @@ . /etc/rc.conf . /etc/rc.d/functions -WICD_BIN="/usr/sbin/wicd" +WICD_BIN="/usr/bin/wicd" if [ -f /var/run/wicd/wicd.pid ]; then PID="$(cat /var/run/wicd/wicd.pid)" diff --git a/data/init/debian/wicd b/data/init/debian/wicd index 783044b..92cd449 100755 --- a/data/init/debian/wicd +++ b/data/init/debian/wicd @@ -19,7 +19,7 @@ PATH=/usr/sbin:/usr/bin:/sbin:/bin DESC="Network connection manager" NAME=wicd RUNDIR=/var/run/$NAME -DAEMON=/usr/sbin/$NAME +DAEMON=/usr/bin/$NAME DAEMON_ARGS="" PIDFILE=$RUNDIR/wicd.pid SCRIPTNAME=/etc/init.d/wicd diff --git a/data/init/gentoo/wicd b/data/init/gentoo/wicd index 4f8dba1..a88bd3e 100755 --- a/data/init/gentoo/wicd +++ b/data/init/gentoo/wicd @@ -2,7 +2,7 @@ # Copyright 1999-2020 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -WICD_DAEMON=/usr/sbin/wicd +WICD_DAEMON=/usr/bin/wicd WICD_PIDFILE=/run/wicd/wicd.pid depend() { diff --git a/data/init/pld/wicd b/data/init/pld/wicd index 607580e..c555d15 100755 --- a/data/init/pld/wicd +++ b/data/init/pld/wicd @@ -19,7 +19,7 @@ # Get service config - may override defaults # [ -f /etc/sysconfig/wicd ] && . /etc/sysconfig/wicd -WICD_BIN=/usr/sbin/wicd +WICD_BIN=/usr/bin/wicd start() { # Check if the service is already running? diff --git a/data/init/redhat/wicd b/data/init/redhat/wicd index 11b10de..4f222e0 100755 --- a/data/init/redhat/wicd +++ b/data/init/redhat/wicd @@ -9,7 +9,7 @@ . /etc/rc.d/init.d/functions -WICD_BIN=/usr/sbin/wicd +WICD_BIN=/usr/bin/wicd pidfile=/var/run/wicd/wicd.pid servicename=wicd diff --git a/data/init/slackware/rc.wicd b/data/init/slackware/rc.wicd index 6c92c2e..b128565 100755 --- a/data/init/slackware/rc.wicd +++ b/data/init/slackware/rc.wicd @@ -5,7 +5,7 @@ # This is defined in /usr/lib/python2.6/site-packages/wicd/wpath.py PIDFILE="/var/run/wicd/wicd.pid" -DAEMON="/usr/sbin/wicd" +DAEMON="/usr/bin/wicd" # Define start and stop functions diff --git a/data/init/suse/wicd b/data/init/suse/wicd index 8d12fe1..86ab264 100755 --- a/data/init/suse/wicd +++ b/data/init/suse/wicd @@ -9,7 +9,7 @@ # Description: wicd, a wired and wireless connection manager. ### END INIT INFO -WICD_BIN=/usr/sbin/wicd +WICD_BIN=/usr/bin/wicd test -x $WICD_BIN || exit 5 . /etc/rc.status diff --git a/setup.py b/setup.py index 3d154e7..2102b44 100755 --- a/setup.py +++ b/setup.py @@ -28,9 +28,7 @@ import subprocess from distutils import log from distutils.command import build as _build -import pkg_resources import setuptools -from setuptools.command import install_scripts as _install_scripts from setuptools.command import install as _install import wicd @@ -71,29 +69,29 @@ empty_file = 'other/.empty_on_purpose' # change to the directory setup.py is contained in os.chdir(os.path.abspath(os.path.split(__file__)[0])) -BUILD_OPTS = {'bin': '/usr/bin/', - 'dbus': '/etc/dbus-1/system.d/', +BUILD_OPTS = {'dbus': '/etc/dbus-1/system.d/', 'dbus_service': '/usr/share/dbus-1/system-services/', 'distro': None, - 'docdir': '/usr/share/doc/wicd/', - 'logrotate': '/etc/logrotate.d/', - 'mandir': '/usr/share/man/', - 'scripts': '/etc/wicd/scripts/', - 'systemd': '/lib/systemd/system/', - 'resume': '/etc/acpi/resume.d/', - 'suspend': '/etc/acpi/suspend.d/', - 'pmutils': '/usr/lib/pm-utils/sleep.d/', - 'no_install_init': False, - 'no_install_man': False, - 'no_install_i18n': False, - 'no_install_i18n_man': False, - 'no_install_acpi': False, - 'no_install_pmutils': False, - 'no_install_docs': False, 'distro_detect_failed': False, + 'docdir': '/usr/share/doc/wicd/', 'init': '', 'initfile': '', - 'initfilename': ''} + 'initfilename': '', + 'logrotate': '/etc/logrotate.d/', + 'mandir': '/usr/share/man/', + 'no_install_acpi': False, + 'no_install_docs': False, + 'no_install_i18n': False, + 'no_install_i18n_man': False, + 'no_install_init': False, + 'no_install_man': False, + 'no_install_pmutils': False, + 'pmutils': '/usr/lib/pm-utils/sleep.d/', + 'resume': '/etc/acpi/resume.d/', + 'scripts': '/etc/wicd/scripts/', + 'suspend': '/etc/acpi/suspend.d/', + 'systemd': '/lib/systemd/system/', + 'translations': '/usr/share/locale'} class build(_build.build): @@ -110,8 +108,6 @@ class configure(setuptools.Command): user_options = [ ('encryption=', None, 'set the encryption template directory'), - ('bin=', None, 'set the bin directory'), - ('sbin=', None, 'set the sbin directory'), ('networks=', None, 'set the encryption configuration directory'), ('log=', None, 'set the log directory'), ('resume=', None, 'set the directory the resume from suspend script ' @@ -319,28 +315,6 @@ class configure(setuptools.Command): pass -class install_scripts(_install_scripts.install_scripts): - def write_script(self, script_name, contents, mode="t", *ignored): - """Write an executable file to the scripts directory""" - from setuptools.command.easy_install import chmod, current_umask - - log.info("Installing %s script to %s", script_name, self.install_dir) - install_dir = self.install_dir - if script_name == 'wicd': - install_dir = os.path.join( - self.install_dir[:self.install_dir.rfind('bin')], 'sbin') - target = os.path.join(install_dir, script_name) - self.outfiles.append(target) - - mask = current_umask() - if not self.dry_run: - pkg_resources.ensure_directory(target) - f = open(target, "w" + mode) - f.write(contents) - f.close() - chmod(target, 0o777 - mask) - - class clear_generated(setuptools.Command): description = 'clears out files generated by configure' @@ -386,6 +360,9 @@ class install(_install.install): (wpath.preconnectscripts, [empty_file]), (wpath.postconnectscripts, [empty_file])]) + if os.path.exists('data/etc/wicd.conf'): + data.append((wpath.etc, ['data/etc/wicd.conf'])) + if not wpath.no_install_docs: data.append((wpath.docdir, ['AUTHORS', 'CHANGES', 'INSTALL', 'LICENSE', 'README.cli', @@ -427,15 +404,16 @@ class install(_install.install): log.info('Using pid path %s', os.path.basename(wpath.pidfile)) if not wpath.no_install_i18n: - for language in sorted(glob('translations/*')): - language = language.replace('translations/', '') + for language in sorted(os.listdir('translations')): log.info('Language support for %s', language) data.append((os.path.join(wpath.translations, language, - '/LC_MESSAGES/'), - [os.path.join('translations/', language, + 'LC_MESSAGES'), + [os.path.join('translations', language, 'LC_MESSAGES', 'wicd.mo')])) for dir_ in (os.listdir('data')): + if dir_ == 'init': + continue path = os.path.join('data', dir_) for fname in os.listdir(path): data.append((wpath[dir_], [os.path.join(path, fname)])) @@ -584,7 +562,6 @@ class uninstall(setuptools.Command): setuptools.setup(cmdclass={'build': build, 'configure': configure, 'install': install, - 'install_scripts': install_scripts, 'test': test, 'clear_generated': clear_generated, 'update_message_catalog': update_message_catalog, diff --git a/wicd/config.py b/wicd/config.py index 0d433ca..e4234f2 100644 --- a/wicd/config.py +++ b/wicd/config.py @@ -2,24 +2,24 @@ import configparser import os -DEFAULTS = {'daemon': '/usr/share/wicd/daemon', +DEFAULTS = {'bin': '/usr/bin', + 'daemon': '/usr/share/wicd/daemon', 'encryption': '/etc/wicd/encryption-templates', 'etc': '/etc/wicd', + 'log': '/var/log/wicd', + 'loggroup': '', + 'logperms': '0600', 'networks': '/var/lib/wicd/configurations', 'pidfile': '/var/run/wicd.pid', 'postconnectscripts': '/etc/wicd/scripts/postconnect', 'postdisconnectscripts': '/etc/wicd/scripts/postdisconnect', 'preconnectscripts': '/etc/wicd/scripts/preconnect', 'predisconnectscripts': '/etc/wicd/scripts/predisconnect', - 'sbin': '/usr/sbin', + 'python': 'python', + 'revision': '', 'translations': '/usr/share/locale', 'varlib': '/var/lib/wicd', - 'log': '/var/log/wicd/', - 'loggroup': '', - 'logperms': '0600', - 'revision': '', - 'wicdgroup': 'users', - 'python': 'python'} + 'wicdgroup': 'users'} SECTION = 'wicd' CFG_FILE = 'wicd.conf' diff --git a/wicd/misc.py b/wicd/misc.py index d6c850d..0a077e1 100644 --- a/wicd/misc.py +++ b/wicd/misc.py @@ -212,7 +212,7 @@ def IsValidIPv6(ip): def PromptToStartDaemon(): """Prompt the user to start the daemon""" - daemonloc = os.path.join(CFG.sbin, 'wicd') + daemonloc = os.path.join(CFG.bin, 'wicd') sudo_prog = choose_sudo_prog() if not sudo_prog: return False