On Sun, 2008-01-06 at 21:35 +0000, Dr J A Gow wrote: > I think this issue may always be a problem unless we provide a script in > the sync-engine distribution, something like 'install-plugins.py' which > will (re)generate the appropriate file/symlink in the OpenSync plugin > directory. We could run this post-install, and instruct users to run > this file if they delete and reinstall OpenSync.
What do you think of the attached? I feel the opensync-plugin*.py files should be renamed to something better too -- synce-opensync-plugin*.py even? -- Jonny Lamb, UK [EMAIL PROTECTED] http://jonnylamb.com GPG: 0x2E039402
diff --git a/setup.py b/setup.py index 6a968c8..82eccca 100644 --- a/setup.py +++ b/setup.py @@ -1,19 +1,14 @@ #!/usr/bin/env python from setuptools import setup, find_packages -import commands -import sys +from synce_install_plugins import get_plugindir, get_opensync_version -(exitstatus, plugindir) = commands.getstatusoutput('pkg-config opensync-1.0 --variable=plugindir') -if plugindir == '': - if exitstatus == 0: - print 'Could not get OpenSync plugin directory, even though OpenSync is installed..' - else: - print 'Could not get OpenSync plugin directory; is the OpenSync dev package installed?' - sys.exit(1) -elif exitstatus == 32512: - print 'Could not get OpenSync plugin directory; pkg-config is not installed.' - sys.exit(1) +if get_opensync_version() >= 0.30: + pluginfile = ['opensync-plugin-0.30later.py'] + otherplugin = ['opensync-plugin.py'] +else: + pluginfile = ['opensync-plugin.py'] + otherplugin = ['opensync-plugin-0.30later.py'] setup( name = "SyncEngine", @@ -24,12 +19,14 @@ setup( 'tools/create_partnership.py', 'tools/delete_partnership.py', 'tools/list_partnerships.py', - 'tools/configure_bindings.py'], + 'tools/configure_bindings.py', + 'synce_install_plugins.py'], package_data = { '': ['*.xsl'], }, data_files = [ - (plugindir+'/python-plugins', ['opensync-plugin-0.30later.py', 'opensync-plugin.py']) + (get_plugindir()+'/python-plugins', pluginfile), + ('/usr/share/sync-engine', otherplugin) ] ) diff --git a/synce_install_plugins.py b/synce_install_plugins.py new file mode 100755 index 0000000..347699d --- /dev/null +++ b/synce_install_plugins.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python + +import commands +import sys +import os +from optparse import OptionParser + +def get_plugindir(): + (exitstatus, plugindir) = commands.getstatusoutput('pkg-config opensync-1.0 --variable=plugindir') + if plugindir == '': + if exitstatus == 0: + print 'Could not get OpenSync plugin directory, even though OpenSync is installed..' + else: + print 'Could not get OpenSync plugin directory; is the OpenSync dev package installed?' + sys.exit(1) + elif exitstatus == 32512: + print 'Could not get OpenSync plugin directory; pkg-config is not installed.' + sys.exit(1) + + return plugindir + +def get_opensync_version(): + return commands.getoutput('pkg-config opensync-1.0 --modversion') + +if __name__ == '__main__': + parser = OptionParser() + parser.add_option('-i', '--ignore-root', action='store_true', dest='ignore_root', default=False, help='Check for root') + (options, args) = parser.parse_args() + + user = commands.getoutput('whoami') + if user != 'root' and not options.ignore_root: + print 'Error: must be run as root. To ignore this, use --ignore-root' + sys.exit(1) + + opensync_version = get_opensync_version() + plugindir = get_plugindir() + print 'Resetting python-plugins directory...' + + os.system('mv %s/python-plugins/opensync-plugin-0.30later.py %s/python-plugins/opensync-plugin.py /usr/share/sync-engine/ 2> /dev/null' % (plugindir, plugindir)) + + print 'OpenSync version %s installed.' % opensync_version + + if opensync_version >= 0.30: + driver = 'opensync-plugin-0.30later.py' + else: + driver = 'opensync-plugin.py' + print 'Using driver %s' % driver + + os.system('mv /usr/share/sync-engine/%s %s/python-plugins/' % (driver, plugindir)) + print 'Done.'
signature.asc
Description: This is a digitally signed message part
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2005. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________ SynCE-Devel mailing list SynCE-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synce-devel