[4933918] | 1 | #!/bin/sh |
---|
[c5c522c] | 2 | |
---|
| 3 | # Copyright 2000 BSDi, Inc. Concord, CA, USA |
---|
| 4 | # Copyright 2001, 2002 Slackware Linux, Inc. Concord, CA, USA |
---|
[4933918] | 5 | # Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Patrick J. Volkerding, Sebeka, MN, USA |
---|
[c5c522c] | 6 | # All rights reserved. |
---|
| 7 | # |
---|
| 8 | # Redistribution and use of this script, with or without modification, is |
---|
| 9 | # permitted provided that the following conditions are met: |
---|
| 10 | # |
---|
| 11 | # 1. Redistributions of this script must retain the above copyright |
---|
| 12 | # notice, this list of conditions and the following disclaimer. |
---|
| 13 | # |
---|
| 14 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
---|
| 15 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
| 16 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
---|
| 17 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
| 18 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
| 19 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
| 20 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
| 21 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
| 22 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
| 23 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
| 24 | |
---|
[4933918] | 25 | |
---|
[c5c522c] | 26 | # Set initial variables: |
---|
[4933918] | 27 | CWD=$(pwd) |
---|
[c5c522c] | 28 | TMP=${TMP:-/tmp} |
---|
| 29 | |
---|
| 30 | VERSION=${VERSION:-$(echo openssl-*.tar.gz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
[4933918] | 31 | BUILD=${BUILD:-1_slack14.2} |
---|
[c5c522c] | 32 | |
---|
| 33 | # Automatically determine the architecture we're building on: |
---|
| 34 | if [ -z "$ARCH" ]; then |
---|
| 35 | case "$( uname -m )" in |
---|
| 36 | i?86) export ARCH=i586 ;; |
---|
| 37 | arm*) export ARCH=arm ;; |
---|
| 38 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
| 39 | *) export ARCH=$( uname -m ) ;; |
---|
| 40 | esac |
---|
| 41 | fi |
---|
| 42 | |
---|
| 43 | PKG1=$TMP/package-openssl |
---|
| 44 | PKG2=$TMP/package-ossllibs |
---|
| 45 | NAME1=openssl-$VERSION-$ARCH-$BUILD |
---|
| 46 | NAME2=openssl-solibs-$VERSION-$ARCH-$BUILD |
---|
| 47 | |
---|
| 48 | # Parallel build doesn't link properly. |
---|
| 49 | #NUMJOBS=${NUMJOBS:--j6} |
---|
| 50 | |
---|
| 51 | # So that ls has the right field counts for parsing... |
---|
| 52 | export LC_ALL=C |
---|
| 53 | |
---|
| 54 | cd $TMP |
---|
| 55 | rm -rf $PKG1 $PKG2 openssl-$VERSION |
---|
| 56 | |
---|
| 57 | tar xvf $CWD/openssl-$VERSION.tar.gz || exit 1 |
---|
| 58 | cd openssl-$VERSION |
---|
| 59 | |
---|
| 60 | # Fix pod syntax errors which are fatal wih a newer perl: |
---|
| 61 | find . -name "*.pod" -exec sed -i "s/^\=item \([0-9]\)\(\ \|$\)/\=item C<\1>/g" {} \; |
---|
| 62 | |
---|
[4933918] | 63 | # Use .so.1, not .so.1.0.0: |
---|
| 64 | sed -i "s/soname=\$\$SHLIB\$\$SHLIB_SOVER\$\$SHLIB_SUFFIX/soname=\$\$SHLIB.1/g" Makefile.shared |
---|
[a1525ed] | 65 | |
---|
[c5c522c] | 66 | if [ "$ARCH" = "i586" ]; then |
---|
| 67 | # Build with -march=i586 -mtune=i686: |
---|
[a1525ed] | 68 | sed -i "/linux-elf/s/fomit-frame-pointer/fomit-frame-pointer -march=i586 -mtune=i686/g" Configure |
---|
| 69 | LIBDIRSUFFIX="" |
---|
| 70 | elif [ "$ARCH" = "i686" ]; then |
---|
| 71 | # Build with -march=i686 -mtune=i686: |
---|
| 72 | sed -i "/linux-elf/s/fomit-frame-pointer/fomit-frame-pointer -march=i686 -mtune=i686/g" Configure |
---|
[c5c522c] | 73 | LIBDIRSUFFIX="" |
---|
| 74 | elif [ "$ARCH" = "x86_64" ]; then |
---|
| 75 | LIBDIRSUFFIX="64" |
---|
| 76 | fi |
---|
| 77 | |
---|
| 78 | # OpenSSL has a (nasty?) habit of bumping the internal version number with |
---|
| 79 | # every release. This wouldn't be so bad, but some applications are so |
---|
| 80 | # paranoid that they won't run against a different OpenSSL version than |
---|
| 81 | # what they were compiled against, whether or not the ABI has changed. |
---|
| 82 | # |
---|
[4933918] | 83 | # So, we will use the OPENSSL_VERSION_NUMBER from openssl-1.0.2e unless ABI |
---|
[c5c522c] | 84 | # breakage forces it to change. Yes, we're finally using this old trick. :) |
---|
[4933918] | 85 | sed -i "s/#define OPENSSL_VERSION_NUMBER.*/\/* Use 0x1000205fL (1.0.2e) below to avoid pointlessly breaking the ABI *\/\n#define OPENSSL_VERSION_NUMBER 0x1000205fL/g" crypto/opensslv.h || exit 1 |
---|
[c5c522c] | 86 | |
---|
| 87 | chown -R root:root . |
---|
| 88 | mkdir -p $PKG1/usr/doc/openssl-$VERSION |
---|
[4933918] | 89 | cp -a CHANGES CHANGES.SSLeay FAQ INSTALL INSTALL.MacOS INSTALL.VMS INSTALL.W32 \ |
---|
| 90 | LICENSE NEWS README README.ENGINE doc $PKG1/usr/doc/openssl-$VERSION |
---|
[c5c522c] | 91 | find $PKG1/usr/doc/openssl-$VERSION -type d -exec chmod 755 {} \; |
---|
| 92 | find $PKG1/usr/doc/openssl-$VERSION -type f -exec chmod 644 {} \; |
---|
| 93 | |
---|
| 94 | # If there's a CHANGES file, installing at least part of the recent history |
---|
| 95 | # is useful, but don't let it get totally out of control: |
---|
| 96 | if [ -r CHANGES ]; then |
---|
| 97 | DOCSDIR=$(echo $PKG1/usr/doc/*-$VERSION) |
---|
| 98 | cat CHANGES | head -n 2000 > $DOCSDIR/CHANGES |
---|
| 99 | touch -r CHANGES $DOCSDIR/CHANGES |
---|
| 100 | fi |
---|
| 101 | |
---|
| 102 | # These are the known patent issues with OpenSSL: |
---|
| 103 | # name # expires |
---|
[a1525ed] | 104 | # MDC-2: 4,908,861 2007-03-13, not included. |
---|
[c5c522c] | 105 | # IDEA: 5,214,703 2010-05-25, not included. |
---|
[4933918] | 106 | # RC5: 5,724,428 2015-03-03, not included. |
---|
[a1525ed] | 107 | # |
---|
| 108 | # Although all of the above are expired, it's still probably |
---|
| 109 | # not a good idea to include them as there are better |
---|
| 110 | # algorithms to use. |
---|
[c5c522c] | 111 | |
---|
| 112 | ./config \ |
---|
| 113 | --prefix=/usr \ |
---|
| 114 | --openssldir=/etc/ssl \ |
---|
[a1525ed] | 115 | no-mdc2 \ |
---|
[c5c522c] | 116 | no-idea \ |
---|
[4933918] | 117 | no-rc5 \ |
---|
[c5c522c] | 118 | no-sse2 \ |
---|
[4933918] | 119 | no-ssl2 \ |
---|
| 120 | no-weak-ssl-ciphers \ |
---|
[c5c522c] | 121 | shared |
---|
| 122 | |
---|
[a1525ed] | 123 | make $NUMJOBS depend || make depend || exit 1 |
---|
[c5c522c] | 124 | |
---|
[a1525ed] | 125 | make $NUMJOBS || make || exit 1 |
---|
| 126 | |
---|
[4933918] | 127 | make install INSTALL_PREFIX=$PKG1 || exit 1 |
---|
[c5c522c] | 128 | |
---|
| 129 | # Make the .so.? library symlinks: |
---|
| 130 | ( cd $PKG1/usr/lib${LIBDIRSUFFIX} ; ldconfig -l lib*.so.* ) |
---|
| 131 | |
---|
| 132 | # Move libraries, as they might be needed by programs that bring a network |
---|
| 133 | # mounted /usr online: |
---|
| 134 | |
---|
| 135 | mkdir $PKG1/lib${LIBDIRSUFFIX} |
---|
| 136 | ( cd $PKG1/usr/lib${LIBDIRSUFFIX} |
---|
| 137 | for file in lib*.so.?.* ; do |
---|
| 138 | mv $file ../../lib${LIBDIRSUFFIX} |
---|
| 139 | ln -sf ../../lib${LIBDIRSUFFIX}/$file . |
---|
[4933918] | 140 | done |
---|
| 141 | cp -a lib*.so.? ../../lib${LIBDIRSUFFIX} |
---|
[c5c522c] | 142 | ) |
---|
| 143 | |
---|
| 144 | # Add a cron script to warn root if a certificate is going to expire soon: |
---|
| 145 | mkdir -p $PKG1/etc/cron.daily |
---|
| 146 | zcat $CWD/certwatch.gz > $PKG1/etc/cron.daily/certwatch.new |
---|
| 147 | chmod 755 $PKG1/etc/cron.daily/certwatch.new |
---|
| 148 | |
---|
| 149 | mv $PKG1/etc/ssl/openssl.cnf $PKG1/etc/ssl/openssl.cnf.new |
---|
| 150 | |
---|
| 151 | ( cd $PKG1 |
---|
| 152 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
| 153 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
| 154 | ) |
---|
| 155 | |
---|
[4933918] | 156 | mv $PKG1/etc/ssl/man $PKG1/usr |
---|
| 157 | ( cd $PKG1/usr/man/man1 ; mv passwd.1 ssl_passwd.1 ) |
---|
| 158 | ( cd $PKG1/usr/man/man3 ; mv rand.3 ssl_rand.3 ) |
---|
| 159 | ( cd $PKG1/usr/man/man3 ; mv err.3 ssl_err.3 ) |
---|
[c5c522c] | 160 | # Compress and symlink the man pages: |
---|
| 161 | if [ -d $PKG1/usr/man ]; then |
---|
| 162 | ( cd $PKG1/usr/man |
---|
| 163 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
| 164 | ( cd $manpagedir |
---|
| 165 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
| 166 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
| 167 | rm $eachpage |
---|
| 168 | done |
---|
| 169 | gzip -9 *.? |
---|
| 170 | ) |
---|
| 171 | done |
---|
| 172 | ) |
---|
| 173 | fi |
---|
| 174 | |
---|
[4933918] | 175 | # If there's an openssl0 directory, then build openssl-0 shared libraries for |
---|
[c5c522c] | 176 | # compatibility with programs linked to those: |
---|
[4933918] | 177 | if [ -d $CWD/openssl0 ]; then |
---|
| 178 | ( cd $CWD/openssl0 |
---|
| 179 | ./openssl0.build || exit 1 |
---|
[c5c522c] | 180 | ) || exit 1 |
---|
| 181 | # Don't put these in the openssl package... openssl-solibs is enough. |
---|
| 182 | #mkdir -p $PKG1/lib${LIBDIRSUFFIX} |
---|
[4933918] | 183 | #cp -a $TMP/package-openssl0/usr/lib/lib*.so.?.?.? $PKG1/lib${LIBDIRSUFFIX} |
---|
[c5c522c] | 184 | #( cd $PKG1/lib${LIBDIRSUFFIX} ; ldconfig -l lib*.so.?.?.? ) |
---|
| 185 | mkdir -p $PKG2/lib${LIBDIRSUFFIX} |
---|
[4933918] | 186 | cp -a $TMP/package-openssl0/usr/lib/lib*.so.?.?.? $PKG2/lib${LIBDIRSUFFIX} |
---|
[c5c522c] | 187 | ( cd $PKG2/lib${LIBDIRSUFFIX} ; ldconfig -l lib*.so.?.?.? ) |
---|
| 188 | fi |
---|
| 189 | |
---|
| 190 | cd $PKG1 |
---|
| 191 | chmod 755 usr/lib${LIBDIRSUFFIX}/pkgconfig |
---|
| 192 | sed -i -e "s#lib\$#lib${LIBDIRSUFFIX}#" usr/lib${LIBDIRSUFFIX}/pkgconfig/*.pc |
---|
| 193 | mkdir -p install |
---|
| 194 | zcat $CWD/doinst.sh-openssl.gz > install/doinst.sh |
---|
| 195 | cat $CWD/slack-desc.openssl > install/slack-desc |
---|
| 196 | /sbin/makepkg -l y -c n $TMP/${NAME1}.txz |
---|
| 197 | |
---|
| 198 | # Make runtime package: |
---|
| 199 | mkdir -p $PKG2/lib${LIBDIRSUFFIX} |
---|
| 200 | ( cd lib${LIBDIRSUFFIX} ; cp -a lib*.so.* $PKG2/lib${LIBDIRSUFFIX} ) |
---|
| 201 | ( cd $PKG2/lib${LIBDIRSUFFIX} ; ldconfig -l * ) |
---|
| 202 | mkdir -p $PKG2/etc |
---|
| 203 | ( cd $PKG2/etc ; cp -a $PKG1/etc/ssl . ) |
---|
| 204 | mkdir -p $PKG2/usr/doc/openssl-$VERSION |
---|
| 205 | ( cd $TMP/openssl-$VERSION |
---|
[4933918] | 206 | cp -a CHANGES CHANGES.SSLeay FAQ INSTALL INSTALL.MacOS INSTALL.VMS INSTALL.W32 \ |
---|
| 207 | LICENSE NEWS README README.ENGINE $PKG2/usr/doc/openssl-$VERSION |
---|
[c5c522c] | 208 | # If there's a CHANGES file, installing at least part of the recent history |
---|
| 209 | # is useful, but don't let it get totally out of control: |
---|
| 210 | if [ -r CHANGES ]; then |
---|
| 211 | DOCSDIR=$(echo $PKG2/usr/doc/*-$VERSION) |
---|
| 212 | cat CHANGES | head -n 2000 > $DOCSDIR/CHANGES |
---|
| 213 | touch -r CHANGES $DOCSDIR/CHANGES |
---|
| 214 | fi |
---|
| 215 | ) |
---|
| 216 | |
---|
| 217 | find $PKG2/usr/doc/openssl-$VERSION -type d -exec chmod 755 {} \; |
---|
| 218 | find $PKG2/usr/doc/openssl-$VERSION -type f -exec chmod 644 {} \; |
---|
| 219 | cd $PKG2 |
---|
| 220 | mkdir -p install |
---|
| 221 | zcat $CWD/doinst.sh-openssl-solibs.gz > install/doinst.sh |
---|
| 222 | cat $CWD/slack-desc.openssl-solibs > install/slack-desc |
---|
| 223 | /sbin/makepkg -l y -c n $TMP/${NAME2}.txz |
---|