aboutsummaryrefslogtreecommitdiff
path: root/mail/mta/postfix/postfix.SlackBuild
blob: 874675e214dc25f8330b4cb600afc90e9877d5b8 (plain)
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
#!/bin/bash
#
# original script from http://www.slacky.it/download/network/tool/postfix/2.2.10/src/postfix.SlackBuild
# changes by rhatto at riseup.net
#

if [ -s "slack-required" ]; then
  echo Recomended and required packages for building postfix are:
  cat slack-required | sed -e 's/^/\t/'
  if [ "$INTERACT" != "no" ]; then
    echo If you dont have those installed, press Ctrl-C. Otherwise, hit ENTER.
    read crap
#  else
#    echo Sleeping 3 seconds...
#    sleep 3
  fi
fi

CWD=`pwd`

if [ -f ~/.slackbuildrc ]; then
  source ~/.slackbuildrc
elif [ -f /etc/slackbuildrc ]; then
  source /etc/slackbuildrc
fi

# default settings
PACKAGE=postfix
ARCH=${ARCH:=i486}
VERSION=${VERSION:=2.3.4}
BUILD=${BUILD:=2rha}
SRC_DIR=${SRC:=$CWD}
TMP=${TMP:=/tmp}
REPOS=${REPOS:=$TMP}

# -------  error codes for createpkg  --------------
ERROR_WGET=31;      ERROR_MAKE=32;      ERROR_INSTALL=33
ERROR_MD5=34;       ERROR_CONF=35;      ERROR_HELP=36
ERROR_TAR=37;       ERROR_MKPKG=38;     ERROR_GPG=39
ERROR_PATCH=40

if [ "$ARCH" == "x86_64" ]; then
  LIBDIR=/usr/lib64
else
  LIBDIR=/usr/lib
fi

# general definitions
PACKAGE_EXT="gz"
NAME=$PACKAGE
DOCDIR=/usr/doc/${NAME}-${VERSION}
READMEDIR=${DOCDIR}/README_FILES
HTMLDIR=${DOCDIR}/HTML
MANDIR=/usr/man
TMP="$TMP/$PACKAGE"
PKGDIR=${TMP}/package-${NAME}
SOURCEDIR=${TMP}/${NAME}-${VERSION}
RTOOL="wget"
SRC="$PACKAGE-$VERSION.tar.$PACKAGE_EXT"

# url definitions
VDA="$PACKAGE-$VERSION-vda.patch.gz"
VDA_URL="http://web.onda.com.br/nadal/postfix/VDA/$VDA"
ANON="postfix-anon-$VERSION.diff"
URL="ftp://ftp.pucpr.br/$PACKAGE/official/$SRC"

SRC_DIR="$SRC_DIR/$PACKAGE"
mkdir -p $SRC_DIR

# download sources
if [ "$RTOOL" == "wget" ]; then
 if [ ! -f "$SRC_DIR/$SRC" ]; then
   wget "$URL" -O "$SRC_DIR/$SRC" || exit $ERROR_WGET
 fi
 if [ ! -f "$SRC_DIR/$VDA" ]; then
   wget "$VDA_URL" -O "$SRC_DIR/$VDA" # || exit $ERROR_WGET
 fi
 if [ ! -f "$SRC_DIR/$SRC.sig" ]; then
   wget "$URL.sig" -O "$SRC_DIR/$SRC.sig" || exit $ERROR_WGET
 fi
fi

gpg --import << EOGPG
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: PGPfreeware 5.0i for non-commercial use

mQENA0Ije1oAAAEIALlEqB1UICFF3dfwDij9LHtBhtiEfGnv0P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kyZq+nja
aeE5si/TdvrzS580zGnye9uABdRbAKceOa91Rm/OEtmzeDjFPJ/pdcZ13FUDNBlQ
Shyt4P3abOb24kiL67MwJy+70Wbg+C71O7Hed2NVqFUEtkSg2hlV09kCxr4+aQIR
fQYVcr7R+YkAlQIFEC5t9dpsodCHBnntkQEBh5oD/1ozk6LmRoT0qN9VHDFKnJzZ
RagTBfA3JpsxWmnkdOpmMSeb+f7SCwH+FwtRYNLX+8Z54/dR8esPNy08FfDNGz6U
C2Eu4eLy330wei8QtfLdytcSIij2OJRJetg9xrzw5H7h2Hia3oWJ2CzHFmH2YWEx
QvYhDAIWTwektUQLYl+viQCVAgUQLmrlqOMR7qLvJ+dxAQGt3QP/WDFIlcxrgy1B
uxgvT9CkSjjJgKzV1D8z8iodPLul9s+1WxUGYTIYvdN67QXREYLV7yh0YRdBNVBr
NdtKutstdsbW/y6LHed4Id+sBuK4Y7OAN38mtjuaOpZLFGm8ex15KVvRJb/77u7y
LOixdFS7DpiSnaXoZpxC9vFMmm2R1Iu0JHdpZXRzZSB2ZW5lbWEgPHdpZXRzZUBw
b3JjdXBpbmUub3JnPokAlQMFEDTZBvTcgPKm1TJ8uQEBoRMD/RkjT4YtF/ltBN+V
eCLv272pxZo38JJZEGyWg4QTHXYQ7ayVc22RL3vQLEMRISvZnvl6pe2UMzgI8jOH
NWhTtvrKuvR/M/nvqTpFf8lp0SiF/ZVVeGCaSmS1Eoyp1dk76qPRCl6RcI6bTv2F
NT2RRKl3v4t4iEXnEjiyS6irzd2b
=o1uH
-----END PGP PUBLIC KEY BLOCK-----
EOGPG 

gpg --verify $SRC_DIR/$SRC.sig $SRC_DIR/$SRC || exit $ERROR_GPG

rm -rf ${PKGDIR}
mkdir -p ${PKGDIR}

cd  ${PKGDIR}
# install scripts

if [ -e ${CWD}/script_${NAME}.tgz ]; then
  tar zxvf ${CWD}/script_${NAME}.tgz || exit $ERROR_TAR
else
  mkdir -v install
fi
sleep 1
if [ -e ${CWD}/slack-desc ];then
  cat ${CWD}/slack-desc | grep ^${NAME} > ${PKGDIR}/install/slack-desc
fi

# Extract

cd  ${TMP}
rm -rf ${NAME}-${VERSION}  ${SOURCEDIR}
tar xzvf $SRC_DIR/${NAME}-$VERSION.tar.gz || exit $ERROR_TAR
# Patch

if [ -f "$SRC_DIR/$VDA" ]; then
  gzip -dc $SRC_DIR/$VDA | patch -p0
fi

if [ -f "$CWD/$ANON" ]; then
  patch -p0 < $CWD/$ANON
fi

cd  ${SOURCEDIR}
sleep 1

# Build

# make -f Makefile.init makefiles \
#    'CCARGS=-DUSE_TLS -DHAS_SSL -I/usr/include/openssl -DHAS_MYSQL -I/usr/include/mysql' \
#    'AUXLIBS=-L/usr/lib -lssl -lcrypto -L/usr/lib/mysql -lmysqlclient -lz -lm'

# db3 explicit
# make -f Makefile.init makefiles CCARGS="-DUSE_SASL_AUTH -I/usr/include/sasl/ -DHAS_MYSQL -I/usr/include/mysql/ -I/usr/include -DHAS_LDAP -DUSE_TLS -I/usr/include/gnutls/ -DHAS_PCRE -I/usr/include -DHAS_DB -I/usr/include/db3" AUXLIBS="-L/usr/lib -lsasl2 -L/usr/lib/mysql/ -lmysqlclient -lz -lm -L/usr/lib -lssl -lcrypto -L/usr/lib -lpcre -L/usr/lib -lldap -L/usr/lib -llber -L/usr/include/db3 -ldb3"

make -f Makefile.init makefiles CCARGS="-DUSE_SASL_AUTH -I/usr/include/sasl/ -DHAS_MYSQL -I/usr/include/mysql/ -I/usr/include -DHAS_LDAP -DUSE_TLS -I/usr/include/gnutls/ -DHAS_PCRE -I/usr/include" AUXLIBS="-L/usr/lib -lsasl2 -L/usr/lib/mysql/ -lmysqlclient -lz -lm -L/usr/lib -lssl -lcrypto -L/usr/lib -lpcre -L/usr/lib -lldap -L/usr/lib -llber" || exit $ERROR_CONF

make || exit $ERROR_MAKE
sleep 1

sh postfix-install						\
 install_root=${PKGDIR}						\
 tempdir=${SOURCE}						\
 manpage_directory=${MANDIR}					\
 readme_directory=${READMEDIR}					\
 html_directory=${HTMLDIR}					\
 config_directory=/etc/postfix					\
 sample_directory=/etc/postfix/sample				\
 daemon_directory=/usr/libexec/postfix				\
 command_directory=/usr/sbin/					\
 queue_directory=/var/spool/postfix				\
 sendmail_path=/usr/sbin/sendmail				\
 newaliases_path=/usr/sbin/newaliases				\
 mailq_path=/usr/sbin/mailq					\
 mail_owner=postfix						\
 setgid_group=postdrop						\
 -non-interactive || exit $ERROR_INSTALL

cd  ${PKGDIR}/etc/postfix 

for a in access aliases canonical header_checks main.cf makedefs.out master.cf postfix-files relocated transport virtual; do
   mv ${a} ${a}.new
done

sleep 2

mkdir -p ${PKGDIR}/${DOCDIR}

for file in AUTHORS COPYING HACKING NEWS README TODO INSTALL AAAREADME COMPATIBILITY COPYRIGHT HISTORY LICENSE RELEASE_NOTES* TLS_* US_PATENT_6321267; do
  if [ -e "${SOURCEDIR}/${file}" ]; then
    cp -v ${SOURCEDIR}/${file} ${PKGDIR}/${DOCDIR}/
  fi
done

( cd $PKGDIR
  find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
  find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
)

find ${PKGDIR}/${DOCDIR} ${PKGDIR}/${MANDIR} -type f | xargs gzip -v

find ${PKGDIR}/bin ${PKGDIR}/sbin ${PKGDIR}/usr/bin ${PKGDIR}/usr/sbin -type f | xargs chown -v root.bin
# Build the package:
cd $PKGDIR
#requiredbuilder -v -y -s $CWD $PKGDIR
/sbin/makepkg -l n -c n --prepend $REPOS/${NAME}-${VERSION}-${ARCH}-${BUILD}.tgz || exit $ERROR_MKPKG

# Clean up the extra stuff:
if [ "$CLEANUP" == "yes" ]; then
  rm -rf $TMP
fi