+ # shim packages
+ for shim in config.get('binaryShims', []):
+ print >>f, ""
+ print >>f, "Package:",shim
+ print >>f, "Section:",config.getstr('section', 'misc')
+ print >>f, "Priority: extra"
+ print >>f, "Architecture:",packageArchitecture
+ writeDependency(f, "Depends", ["${misc:Depends}", binaryName+" (= ${binary:Version})"])
+ print >>f, "Description:",sourceName,"shim for",shim,"(auto-debuild)"
+ print >>f, " Package pretending to be "+shim+", auto-generated by auto-debuild."
+ files.append(os.path.join(debDir, "%s_%s_%s.deb" % (shim, version, arch)))
+ # 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'