Imported Debian patch 4.84-8
[hcoop/debian/exim4.git] / debian / config-custom / create-custom-config-package
1 #!/bin/bash
2
3 if [ -n "$1" ]; then
4 PACKAGESUFFIX="$1"
5 else
6 PACKAGESUFFIX="custom"
7 fi
8
9 TARGETDIR="../exim4-config-$PACKAGESUFFIX"
10 #DEBUG=1
11
12 # copy over -changelog, generating a proper changelog entry
13 # copy over update-exim4defaults, ip-up.d, email-addresses
14
15 dh_testdir
16
17 set -e
18
19 copytextreplace() {
20 FILE="$1"
21 DSTFILE="$2"
22 DIR="${FILE%/*}"
23 FILE="${FILE##*/}"
24 if [ -z "$DSTFILE" ]; then
25 DSTFILE="$FILE"
26 fi
27 [ $DEBUG ] && echo >&2 "DBG: source $DIR/$FILE"
28 [ $DEBUG ] && echo >&2 "DBG: dst $TARGETDIR/$DIR/$DSTFILE"
29 mkdir -p $TARGETDIR/$DIR
30 if ! [ -e "$TARGETDIR/$DIR/$FILE" ]; then
31 < $DIR/$FILE \
32 sed -e "s/exim4-config/exim4-config-$PACKAGESUFFIX/g" \
33 -e "s/orig-exim4-config-$PACKAGESUFFIX/exim4-config/g" \
34 > $TARGETDIR/$DIR/$DSTFILE
35 chmod --reference=$DIR/$FILE $TARGETDIR/$DIR/$DSTFILE
36 else
37 echo >&2 "ERR: can't write to $TARGETDIR/$DIR/$DSTFILE, file exists"
38 exit 1
39 fi
40 }
41
42 for file in manpages config templates postinst postrm dirs; do
43 copytextreplace debian/exim4-config.$file exim4-config-$PACKAGESUFFIX.$file
44 done
45
46 for file in `cat debian/exim4-config.manpages` \
47 `find debian/debconf \( -path '*/.svn/*' -prune \) -or \( -type f -print \)`; do
48 copytextreplace $file
49 done
50
51 for file in compat control copyright rules install; do
52 copytextreplace debian/config-custom/debian/$file
53 done
54
55 for file in ip-up.d update-exim4defaults email-addresses; do
56 copytextreplace debian/$file
57 done
58
59 # manual corrections in target directory
60
61 mv $TARGETDIR/debian/config-custom/debian/* $TARGETDIR/debian
62 rm -rf $TARGETDIR/debian/config-custom
63 chmod 775 $TARGETDIR/debian/rules
64
65 # hack changelog
66
67 < debian/changelog sed -n "/^exim4/{s/exim4/exim4-config-$PACKAGESUFFIX/p;q;}" > $TARGETDIR/debian/changelog
68 echo -e "\n * automatically generated changelog" >> $TARGETDIR/debian/changelog
69 < debian/changelog sed -n '/^ --/{p;q;}' >> $TARGETDIR/debian/changelog
70 cd $TARGETDIR
71 dch --append "generated source package by create-custom-package"