aboutsummaryrefslogtreecommitdiff
path: root/patches/openssl/openssl.SlackBuild
blob: 979ebf373ee91c3ddb0caf0fd573adff202dee49 (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
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
#!/bin/bash
#
#  openssl.SlackBuild is free software; you can redistribute it and/or modify it under the
#  terms of the GNU General Public License as published by the Free Software
#  Foundation; either version 2 of the License, or any later version.
#
#  openssl.SlackBuild is distributed in the hope that it will be useful, but WITHOUT ANY
#  WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
#  A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License along with
#  this program; if not, write to the Free Software Foundation, Inc., 59 Temple
#  Place - Suite 330, Boston, MA 02111-1307, USA
# Copyright 2000 BSDi, Inc. Concord, CA, USA
# Copyright 2001, 2002 Slackware Linux, Inc.  Concord, CA, USA
# Copyright 2005 Patrick J. Volkerding, Sebeka, MN, USA
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
#
#  THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
#  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
#  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
#  EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
#  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
#  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
#  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
#  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Small changes by rhatto
# 

CWD="`pwd`"

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

PACKAGE="openssl"
VERSION=${VERSION:=0.9.7l}
ARCH=${ARCH:=i486}
BUILD=${BUILD:=1rha}
SRC_DIR=${SRC:=$CWD}
TMP=${TMP:=/tmp}
REPOS=${REPOS:=$TMP}

RTOOL="wget"
PACKAGE_EXT="gz"
SRC="openssl-$VERSION.tar.$PACKAGE_EXT"
URL="http://www.openssl.org/source/$SRC"

if [ "$PACKAGE_EXT" == "bz2" ]; then
  tarflag="j"
else
  tarflag="z"
fi

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

if [ "$RTOOL" == "wget" ] && [ ! -f "$SRC_DIR/$SRC" ]; then 
  rm -f $SRC_DIR/$SRC.asc
  wget "$URL" -O "$SRC_DIR/$SRC"
  wget "$URL.asc" -O "$SRC_DIR/$SRC.asc"
fi

gpg --import << EOGPG
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: PGP Key Server 0.9.6

mQGiBD+T8ZcRBAC5vVAcK1C/RIgL4tzwfU4k3vWEGHt4Ukt4nIctAMYJkfuzq9FS
AL4c4xEpVTHRxDXNoSC+ialnJfX5qfhjrixE7wRR01TG7kvpbr76v8x88+LiBpwN
QTZlsz2OmbHeeWRxnCOgw79+5umLOWRmjDY9om6+8JbG4DtCiZokq4UoRwCgyFrG
T8ov4iBf0lUkd+/lS5MmPT8D/0fRaM3LrT8/3kWBZd9bT6UwqK9c3AT1JthZH5GI
5Bl4xL2JcL0paLLDbGRErIf+BrAHEioYdFlR3f4GlFEs6n9LwBfew/46Tz5Z42is
R5eSmYpPgv8cSl+fhw0ff78TQ8hoOlTCwzB2aLcdLlQB+j7joqk2zITLuYkyntyY
xle8A/9XFMEOg90bbqgUyBI8OF/aYFRLDffGd2BEJcytC5dgPJv+/RRn0QSlUAyq
jiws1JAV3Q9fvJMhxg6aO4/6Ab+lK1SwlTC71r24kxv+nQsot495b4AS4ns54MeY
7Zot7/zrgQ7MjXutb/oOg1le1hjTS2ONJjGv2aNUxpYtiZqzc7QfUmljaGFyZCBM
ZXZpdHRlIDxsZXZpdHRlQGxwLnNlPokBHAQQAQIABgUCQjymlQAKCRCi0pt78pXH
WfILB/9Ti9I34nli2O37oWFek1A5hVxCuh5T7vOjtQ501yi0YG+SJIqKprZD96Oh
Tc49qQhOaXWD6SSyVxZPuj2tTYPRe07qZol1Fn6SA2QgBNix2nNLNeDhaJny+gdT
JGRgcURcBR31hTsWFb3abGk7TBZp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pg --verify $SRC_DIR/$SRC.asc $SRC_DIR/$SRC || echo WARNING: Could not check signature or WRONG signature found.
sleep 3

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

TMP="$TMP/$PACKAGE"
rm -rf $TMP
mkdir -p $TMP

PKG1=$TMP/package-openssl
PKG2=$TMP/package-ossllibs
NAME1=openssl-$VERSION-$ARCH-$BUILD
NAME2=openssl-solibs-$VERSION-$ARCH-$BUILD

# So that ls has the right field counts for parsing...
export LC_ALL=C

# This is used to fix manpage links:
relink() {
  ORIGLINE=`/bin/ls -l $1`
  LINK=`echo $ORIGLINE | cut -f 9 -d ' '`.gz
  FILE=`echo $ORIGLINE | cut -f 11 -d ' '`.gz
  rm $1
  if [ -r $FILE ]; then
    ln -sf $FILE $LINK
  fi
}

cd $TMP
tar xvf$tarflag $SRC_DIR/$SRC
cd openssl-$VERSION
# Use .so.0, not .so.0.9.7:
zcat $CWD/openssl.soname.diff.gz | patch -p1 --backup --verbose --suffix=.orig || exit

# Fix CAN-2005-2969 (SSL 2.0 rollback bug):
for vulnerable in 0.9.7g 0.9.7f 0.9.7e 0.9.7d 0.9.7c 0.9.7b 0.9.7a 0.9.7 0.9.8; do
  if [ "$VERSION" == "$vulnerable" ]; then
    zcat $CWD/patch-CAN-2005-2969.diff.gz | patch -p0 --backup --verbose --suffix=.orig || exit
  fi
done

if [ "$ARCH" = "i486" ]; then
  # Build with -march=i486 -mcpu=i686:
  zcat $CWD/openssl.optsx86.diff.gz | patch -p1 --backup --verbose --suffix=.orig || exit
fi
chown -R root.root .
mkdir -p $PKG1/usr/doc/openssl-$VERSION
cp -a CHANGES CHANGES.SSLeay FAQ INSTALL INSTALL.MacOS INSTALL.VMS INSTALL.W32 \
  LICENSE NEWS README README.ENGINE doc $PKG1/usr/doc/openssl-$VERSION
find $PKG1/usr/doc/openssl-$VERSION -type d -exec chmod 755 {} \;
find $PKG1/usr/doc/openssl-$VERSION -type f -exec chmod 644 {} \;
# These are the known patent issues with OpenSSL:
# name   #         expires
# MDC-2: 4,908,861 13/03/2007, not included.
# IDEA:  5,214,703 25/05/2010, not included.
# RC5:   5,724,428 03/03/2015, not included.
./config --prefix=/usr --openssldir=/etc/ssl no-mdc2 no-idea no-rc5 shared
make -j4
make install INSTALL_PREFIX=$PKG1
mv $PKG1/etc/ssl/openssl.cnf $PKG1/etc/ssl/openssl.cnf.new

if [ "$ARCH" == "x86_64" ]; then
  ( cd $PKG1/usr; mv lib lib64; mkdir lib; mv lib64/pkgconfig lib/pkgconfig )
  strip --strip-unneeded $PKG1/usr/lib64/lib*.so.*.*.* $PKG1/usr/bin/*
  ( cd $PKG1/usr/lib64 ; ln -sf libcrypto.so.0 libcrypto.so )
  ( cd $PKG1/usr/lib64 ; ln -sf libssl.so.0 libssl.so )
else
  strip --strip-unneeded $PKG1/usr/lib/lib*.so.*.*.* $PKG1/usr/bin/*
  ( cd $PKG1/usr/lib ; ln -sf libcrypto.so.0 libcrypto.so )
  ( cd $PKG1/usr/lib ; ln -sf libssl.so.0 libssl.so )
fi

chown -R root.bin $PKG1/usr/bin
mv $PKG1/etc/ssl/man $PKG1/usr
( cd $PKG1/usr/man/man1 ; mv passwd.1 ssl_passwd.1 )
( cd $PKG1/usr/man/man3 ; mv rand.3 ssl_rand.3 )
gzip -9 $PKG1/usr/man/man?/*
for mandir in man1 man3 man7 ; do
  ( cd $PKG1/usr/man/$mandir
    for page in *.? ; do
      relink $page
    done
  )
done
cd $PKG1
chmod 755 usr/lib/pkgconfig
mkdir -p install
zcat $CWD/doinst.sh.gz > install/doinst.sh
cat $CWD/slack-desc.openssl > install/slack-desc
makepkg -l y -c n $REPOS/${NAME1}.tgz

# Make runtime package:

if [ "$ARCH" == "x86_64" ]; then
  mkdir -p $PKG2/usr/lib64
  ( cd usr/lib64 ; cp -a lib*.so.*.*.* $PKG2/usr/lib64 )
  ( cd $PKG2/usr/lib64 ; ldconfig -l * )
else
  mkdir -p $PKG2/usr/lib
  ( cd usr/lib ; cp -a lib*.so.*.*.* $PKG2/usr/lib )
  ( cd $PKG2/usr/lib ; ldconfig -l * )
fi

mkdir -p $PKG2/etc
( cd $PKG2/etc ; cp -a $PKG1/etc/ssl . )
mkdir -p $PKG2/usr/doc/openssl-$VERSION
( cd $TMP/openssl-$VERSION
  cp -a CHANGES CHANGES.SSLeay FAQ INSTALL INSTALL.MacOS INSTALL.VMS INSTALL.W32 \
  LICENSE NEWS README README.ENGINE $PKG2/usr/doc/openssl-$VERSION
)
find $PKG2/usr/doc/openssl-$VERSION -type d -exec chmod 755 {} \;
find $PKG2/usr/doc/openssl-$VERSION -type f -exec chmod 644 {} \;
cd $PKG2
mkdir -p install
zcat $CWD/doinst.sh.gz > install/doinst.sh
cat $CWD/slack-desc.openssl-solibs > install/slack-desc
makepkg -l y -c n $REPOS/${NAME2}.tgz

if [ "$CLEANUP" == "yes" ]; then
  rm -rf $TMP
fi