+ # install file
+ with open('debian/'+binaryName+'.install', 'w') as f:
+ for line in config.get('binaryInstallFiles', []):
+ if line.startswith('/'): # a file from within the package, not from the source tree
+ line = 'debian/'+binaryName+line
+ print >>f, line
+ # maintainer scripts for alternatives
+ if 'alternatives' in config:
+ with open('debian/'+binaryName+'.postinst', 'w') as f:
+ print >>f, "#!/bin/sh"
+ print >>f, "set -e"
+ print >>f, 'if [ "$1" = "configure" ]; then'
+ for alternative in config.get('alternatives'):
+ print >>f, safeCall('update-alternatives', '--install', alternative['link'], alternative['name'], alternative['target'],
+ str(alternative['priority']))
+ print >>f, 'fi'
+ print >>f, ''
+ print >>f, '#DEBHELPER#'
+ print >>f, ''
+ print >>f, 'exit 0'
+ with open('debian/'+binaryName+'.prerm', 'w') as f:
+ print >>f, "#!/bin/sh"
+ print >>f, "set -e"
+ print >>f, 'if [ "$1" = "remove" ]; then'
+ for alternative in config.get('alternatives'):
+ print >>f, safeCall('update-alternatives', '--remove', alternative['name'], alternative['target'])
+ print >>f, 'fi'
+ print >>f, ''
+ print >>f, '#DEBHELPER#'
+ print >>f, ''
+ print >>f, 'exit 0'