-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate-opensmtpd-deb.sh
executable file
·125 lines (105 loc) · 3.54 KB
/
create-opensmtpd-deb.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/sh
set -e
# Set directory variables.
sdir="%%OpenSMTPD%%"
pdir="%%packages%%"
edir="%%sysconfdir%%/OpenSMTPD-deb"
tdir="$(mktemp -d --tmpdir=$HOME/tmp)"
idir="$tdir/installdir"
mkdir -p "$pdir"
# Check to see if the most recent commit is new by comparing timestamp with
# previously built packages.
cd "$sdir"
git pull -q
cdate=$(git log -n 1 --date=iso --format=%ci)
version=$(date --date="$cdate" -u +%Y%m%d%H%M%S)"-gitp"
test ! -f "$pdir"/opensmtpd-${version}_amd64.deb
# At this point, the package doesn't exist: announce the package version so
# it shows up at the top of the cron email.
echo -n Building OpenSMTPD debian package based on git repository
echo with latest commit:
echo
git log -n 1
echo
# Build everything.
./bootstrap
./configure --prefix=/usr \
--sysconfdir=/etc \
--libexecdir=/usr/lib/x86_64-linux-gnu \
CFLAGS="$(dpkg-buildflags --get CFLAGS)" \
CPPFLAGS="$(dpkg-buildflags --get CPPFLAGS)" \
CXXFLAGS="$(dpkg-buildflags --get CXXFLAGS)" \
LDFLAGS="$(dpkg-buildflags --get LDFLAGS)"
make clean
make
mkdir "$idir"
make install DESTDIR="$idir"
# Remove mailq link.
rm -f "$idir"/usr/sbin/mailq
# Add sendmail link.
cd "$idir"/usr/sbin
ln -s smtpctl sendmail
cd "$sdir"
# Place files in etc.
mkdir -p "$idir"/etc/init.d
cp "$edir"/etc/init.d/opensmtpd "$idir"/etc/init.d/opensmtpd
# Change config file location of aliases.
patch "$idir"/etc/smtpd.conf < "$edir"/10_smtpd.conf.diff
# Place files in usr.
mkdir -p "$idir"/usr/share/doc/opensmtpd
cp "$edir"/usr/share/doc/opensmtpd/* "$idir"/usr/share/doc/opensmtpd/
mkdir -p "$idir"/usr/share/lintian/overrides
cp "$edir"/usr/share/lintian/overrides/opensmtpd \
"$idir"/usr/share/lintian/overrides
# Add README file from the git repository.
cp "$sdir"/README.md "$idir"/usr/share/doc/opensmtpd/
gzip -9 "$idir"/usr/share/doc/opensmtpd/README.md
# Add and rename LICENSE file from the git repository.
cp "$sdir"/LICENSE "$idir"/usr/share/doc/opensmtpd/copyright
# Add a changelog for the snapshot.
cat <<EOF > "$idir"/usr/share/doc/opensmtpd/changelog.Debian
opensmtpd ($version) wheezy; urgency=low
* new snapshot
-- An Author $(date -R)
EOF
gzip -9 "$idir"/usr/share/doc/opensmtpd/changelog.Debian
# Strip executables.
find "$idir"/usr -type f -executable -exec strip {} \;
# Compress man pages.
find "$idir"/usr/share/man/man? -type f -exec gzip -9 {} \;
# Create directories in the /var heirarchy.
mkdir -p "$idir"/var/lib/opensmtpd/empty
mkdir -p -m 711 "$idir"/var/spool/smtpd
mkdir -p -m 1777 "$idir"/var/spool/smtpd/offline
env EDITOR="sed -i -r -e '/^(Vendor: |License: ).*$/d'" /usr/local/bin/fpm \
-ef -s dir -t deb -n opensmtpd -v "$version" -C "$idir" \
-p "$pdir"/opensmtpd-VERSION_ARCH.deb \
-d "libasr" \
-d "libc6" \
-d "libdb5.3" \
-d "libevent-2.0-5" \
-d "libpam0g" \
-d "libssl1.0.0" \
-d "zlib1g" \
-d "debconf | debconf-2.0" \
-d "adduser" \
-m "David J. Weller-Fahy <dave@weller-fahy.com>" \
--deb-user root \
--deb-group root \
--deb-config "$edir"/config \
--category mail \
--config-files /etc/init.d/opensmtpd \
--config-files /etc/smtpd.conf \
--after-install "$edir"/postinst \
--before-install "$edir"/preinst \
--after-remove "$edir"/postrm \
--before-remove "$edir"/prerm \
--provides mail-transport-agent \
--conflicts mail-transport-agent \
--replaces mail-transport-agent \
--url https://github.com/OpenSMTPD/OpenSMTPD \
--description "OpenSMTPD portable
This is a snapshot of the OpenSMTPD git repository portable branch: it is not
stable and should not be used unless you want your mail server to break." \
.
rm -r "$tdir"