1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-23 06:37:59 +01:00

Added support for manual distro detection in setup.py.

This commit is contained in:
Andrew Psaltis
2009-05-07 00:30:25 -04:00
parent a66a9b5946
commit dffed496a8
2 changed files with 66 additions and 29 deletions

View File

@@ -2,6 +2,7 @@
# #
# Copyright (C) 2007 - 2009 Adam Blackburn # Copyright (C) 2007 - 2009 Adam Blackburn
# Copyright (C) 2007 - 2009 Dan O'Reilly # Copyright (C) 2007 - 2009 Dan O'Reilly
# Copyright (C) 2009 Andrew Psaltis
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License Version 2 as # it under the terms of the GNU General Public License Version 2 as
@@ -84,6 +85,7 @@ class configure(Command):
('initfile=', None, 'set the init file to use'), ('initfile=', None, 'set the init file to use'),
('initfilename=', None, "set the name of the init file (don't use)"), ('initfilename=', None, "set the name of the init file (don't use)"),
('wicdgroup=', None, "set the name of the group used for wicd"), ('wicdgroup=', None, "set the name of the group used for wicd"),
('distro=', None, 'set the distribution for which wicd will be installed'),
# Configure switches # Configure switches
('no-install-init', None, "do not install the init file"), ('no-install-init', None, "do not install the init file"),
@@ -120,6 +122,7 @@ class configure(Command):
self.docdir = '/usr/share/doc/wicd/' self.docdir = '/usr/share/doc/wicd/'
self.mandir = '/usr/share/man/' self.mandir = '/usr/share/man/'
self.kdedir = '/usr/share/autostart/' self.kdedir = '/usr/share/autostart/'
self.distro = 'auto'
self.no_install_init = False self.no_install_init = False
self.no_install_man = False self.no_install_man = False
@@ -131,49 +134,38 @@ class configure(Command):
self.no_use_notifications = False self.no_use_notifications = False
# Determine the default init file location on several different distros # Determine the default init file location on several different distros
self.distro_detect_failed = False self.distro_detect_failed = False
self.initfile = 'init/default/wicd' self.initfile = 'init/default/wicd'
# ddistro is the detected distro
if os.path.exists('/etc/redhat-release'): if os.path.exists('/etc/redhat-release'):
self.init = '/etc/rc.d/init.d/' self.ddistro = 'redhat'
self.initfile = 'init/redhat/wicd'
elif os.path.exists('/etc/SuSE-release'): elif os.path.exists('/etc/SuSE-release'):
self.init = '/etc/init.d/' self.ddistro = 'suse'
self.initfile = 'init/suse/wicd'
elif os.path.exists('/etc/fedora-release'): elif os.path.exists('/etc/fedora-release'):
self.init = '/etc/rc.d/init.d/' self.ddistro = 'redhat'
self.initfile = 'init/redhat/wicd'
elif os.path.exists('/etc/gentoo-release'): elif os.path.exists('/etc/gentoo-release'):
self.init = '/etc/init.d/' self.ddistro = 'gentoo'
self.initfile = 'init/gentoo/wicd'
elif os.path.exists('/etc/debian_version'): elif os.path.exists('/etc/debian_version'):
self.init = '/etc/init.d/' self.ddistro = 'debian'
self.initfile = 'init/debian/wicd'
elif os.path.exists('/etc/arch-release'): elif os.path.exists('/etc/arch-release'):
self.init = '/etc/rc.d/' self.ddistro = 'arch'
self.initfile = 'init/arch/wicd'
elif os.path.exists('/etc/slackware-version') or \ elif os.path.exists('/etc/slackware-version') or \
os.path.exists('/etc/slamd64-version'): os.path.exists('/etc/slamd64-version') or \
self.init = '/etc/rc.d/' os.path.exists('/etc/bluewhite64-version'):
self.initfile = 'init/slackware/rc.wicd' self.ddistro = 'slackware'
self.docdir = '/usr/doc/wicd-%s' % VERSION_NUM
self.mandir = '/usr/man/'
self.no_install_acpi = True
elif os.path.exists('/etc/pld-release'): elif os.path.exists('/etc/pld-release'):
self.init = '/etc/rc.d/init.d/' self.ddistro = 'pld'
self.initfile = 'init/pld/wicd'
elif os.path.exists('/usr/bin/crux'): elif os.path.exists('/usr/bin/crux'):
self.init = '/etc/rc.d/' self.ddistro = 'crux'
elif os.path.exists('/etc/lunar.release'): elif os.path.exists('/etc/lunar.release'):
self.init='/etc/init.d/' self.distro = 'lunar'
self.initfile = 'init/lunar/wicd'
else: else:
self.init = 'FAIL' self.ddistro = 'FAIL'
self.no_install_init = True #self.no_install_init = True
self.distro_detect_failed = True #self.distro_detect_failed = True
print 'WARNING: Unable to detect the distribution in use. ' + \ print 'WARNING: Unable to detect the distribution in use. ' + \
'If you have specified --init and --initfile, configure will continue. ' + \ 'If you have specified --distro or --init and --initfile, configure will continue. ' + \
'Please report this warning, along with the name of your ' + \ 'Please report this warning, along with the name of your ' + \
'distribution, to the wicd developers.' 'distribution, to the wicd developers.'
@@ -229,7 +221,52 @@ class configure(Command):
self.initfilename = os.path.basename(self.initfile) self.initfilename = os.path.basename(self.initfile)
self.wicdgroup = 'users' self.wicdgroup = 'users'
def distro_check(self):
print "Distro is: "+self.distro
if self.distro in ['sles','suse']:
self.init = '/etc/init.d/'
self.initfile = 'init/suse/wicd'
elif self.distro in ['redhat','centos','fedora']:
self.init = '/etc/rc.d/init.d/'
self.initfile = 'init/redhat/wicd'
elif self.distro in ['slackware','slamd64','bluewhite64']:
self.init = '/etc/rc.d/'
self.initfile = 'init/slackware/rc.wicd'
self.docdir = '/usr/doc/wicd-%s' % VERSION_NUM
self.mandir = '/usr/man/'
self.no_install_acpi = True
elif self.distro in ['debian']:
self.init = '/etc/init.d/'
self.initfile = 'init/debian/wicd'
elif self.distro in ['arch']:
self.init = '/etc/rc.d/'
self.initfile = 'init/arch/wicd'
elif self.distro in ['gentoo']:
self.init = '/etc/init.d/'
self.initfile = 'init/gentoo/wicd'
elif self.distro in ['pld']:
self.init = '/etc/rc.d/init.d/'
self.initfile = 'init/pld/wicd'
elif self.distro in ['crux']:
self.init = '/etc/rc.d/'
elif self.distro in ['lunar']:
self.init='/etc/init.d/'
self.initfile = 'init/lunar/wicd'
else :
if self.distro == 'auto':
print "NOTICE: Automatic distro detection found: "+self.ddistro+", retrying with that..."
self.distro = self.ddistro
self.distro_check()
else:
print "WARNING: Distro detection failed!"
self.init='init/default/wicd'
self.no_install_init = True
self.distro_detect_failed = True
def finalize_options(self): def finalize_options(self):
self.distro_check()
if self.distro_detect_failed and not self.no_install_init and \ if self.distro_detect_failed and not self.no_install_init and \
'FAIL' in [self.init, self.initfile]: 'FAIL' in [self.init, self.initfile]:
print 'ERROR: Failed to detect distro. Configure cannot continue. ' + \ print 'ERROR: Failed to detect distro. Configure cannot continue. ' + \

View File

@@ -52,7 +52,7 @@ try:
print 'could not initalize pynotify' print 'could not initalize pynotify'
HAS_NOTIFY = False HAS_NOTIFY = False
except ImportError: except ImportError:
print 'import failed print 'import failed'
HAS_NOTIFY = False HAS_NOTIFY = False
# Wicd specific imports # Wicd specific imports