+function write_eclipse_control {
+ # $1: package name
+ cat <<CONTROL >debian/$1.control
+Source: projects
+Section: main
+Priority: optional
+Maintainer: Michael Wagner <michael@wagnertech.de>
+Build-Depends: git, mbuild
+
+Package: $1
+Architecture: _DEB_HOST_ARCH
+Depends: $2
+Description: http://eclipse.org
+CONTROL
+}
+
+function write_eclipse_cp {
+ # $1: package name
+ cat <<CP >debian/$1.cp
+#!/bin/bash
+set -e
+
+mkdir -p \$1/opt/$1/
+cp -a Downloads/eclipse/* \$1/opt/$1/
+CP
+}
+
+function write_eclipse_postinst {
+ # $1: package name
+ cat <<POSTINST >debian/$1.postinst
+#!/bin/bash
+set -e
+
+for user in user nutzer kurs; do
+ if [ -d /home/\$user ]; then
+ echo "Install eclipse for user \$user"
+ pushd /home/\$user >/dev/null
+
+ if [ -d Schreibtisch ]; then
+ pushd Schreibtisch >/dev/null
+ su \$user -c "ln -sf /opt/eclipse-cpp/eclipse ."
+ popd >/dev/null
+ fi
+
+ if [ -d Desktop ]; then
+ pushd Desktop >/dev/null
+ su \$user -c "ln -sf /opt/eclipse-cpp/eclipse ."
+ popd >/dev/null
+ fi
+ popd >/dev/null
+ fi
+done
+POSTINST
+}
+
+function write_eclipse_prepare {
+ # $1: package name
+ # $2: ECLIPSE_PATTERN
+ cat <<PREPARE >debian/$1.prepare
+#!/bin/bash
+set -e
+
+debian/eclipse.prepare $2
+PREPARE
+}
+
+function configure_eclipse {
+ # $1: package name
+ # $2: ECLIPSE_PATTERN
+ # $3: additional dependencies
+
+ write_deb $1 NONE
+ write_changelog $1
+ write_eclipse_control $1 "$3"
+ write_eclipse_cp $1
+ chmod 755 debian/$1.cp
+ write_eclipse_postinst $1
+ chmod 755 debian/$1.postinst
+ write_eclipse_prepare $1 $2
+ chmod 755 debian/$1.prepare
+ mconfigure -V $1
+}
+