+ # 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'):
+ alternative = shlex.split(alternative)
+ print >>f, safeCall('update-alternatives', '--install', alternative[0], alternative[1], alternative[2], alternative[3])
+ 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'):
+ alternative = shlex.split(alternative)
+ print >>f, safeCall('update-alternatives', '--remove', alternative[1], alternative[2])
+ print >>f, 'fi'
+ print >>f, ''
+ print >>f, '#DEBHELPER#'
+ print >>f, ''
+ print >>f, 'exit 0'