| [c5c522c] | 1 | #!/bin/sh |
|---|
| 2 | |
|---|
| 3 | # Copyright 2000 BSDi, Inc. Concord, CA, USA |
|---|
| 4 | # Copyright 2001, 2002 Slackware Linux, Inc. Concord, CA, USA |
|---|
| 5 | # Copyright 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014 Patrick J. Volkerding, Sebeka, MN, USA |
|---|
| 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 | |
|---|
| 25 | |
|---|
| 26 | # Set initial variables: |
|---|
| 27 | CWD=$(pwd) |
|---|
| 28 | TMP=${TMP:-/tmp} |
|---|
| 29 | |
|---|
| 30 | VERSION=${VERSION:-$(echo openssl-*.tar.gz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
|---|
| 31 | BUILD=${BUILD:-1} |
|---|
| 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 | NUMJOBS=-j1 |
|---|
| 51 | |
|---|
| 52 | # So that ls has the right field counts for parsing... |
|---|
| 53 | export LC_ALL=C |
|---|
| 54 | |
|---|
| 55 | cd $TMP |
|---|
| 56 | rm -rf $PKG1 $PKG2 openssl-$VERSION |
|---|
| 57 | |
|---|
| 58 | tar xvf $CWD/openssl-$VERSION.tar.gz || exit 1 |
|---|
| 59 | cd openssl-$VERSION |
|---|
| 60 | |
|---|
| 61 | # Fix pod syntax errors which are fatal wih a newer perl: |
|---|
| 62 | find . -name "*.pod" -exec sed -i "s/^\=item \([0-9]\)\(\ \|$\)/\=item C<\1>/g" {} \; |
|---|
| 63 | |
|---|
| 64 | # Use .so.1, not .so.1.0.0: |
|---|
| 65 | zcat $CWD/openssl.soname.diff.gz | patch -p1 --backup --verbose --suffix=.orig || exit 1 |
|---|
| 66 | if [ "$ARCH" = "i586" ]; then |
|---|
| 67 | # Build with -march=i586 -mtune=i686: |
|---|
| 68 | zcat $CWD/openssl.optsx86.diff.gz | patch -p1 --backup --verbose --suffix=.orig || exit 1 |
|---|
| 69 | LIBDIRSUFFIX="" |
|---|
| 70 | elif [ "$ARCH" = "x86_64" ]; then |
|---|
| 71 | LIBDIRSUFFIX="64" |
|---|
| 72 | fi |
|---|
| 73 | |
|---|
| 74 | # OpenSSL has a (nasty?) habit of bumping the internal version number with |
|---|
| 75 | # every release. This wouldn't be so bad, but some applications are so |
|---|
| 76 | # paranoid that they won't run against a different OpenSSL version than |
|---|
| 77 | # what they were compiled against, whether or not the ABI has changed. |
|---|
| 78 | # |
|---|
| 79 | # So, we will use the OPENSSL_VERSION_NUMBER from openssl-1.0.1c unless ABI |
|---|
| 80 | # breakage forces it to change. Yes, we're finally using this old trick. :) |
|---|
| 81 | sed -i "s/#define OPENSSL_VERSION_NUMBER.*/\/* Use 0x1000103fL (1.0.1c) below to avoid pointlessly breaking the ABI *\/\n#define OPENSSL_VERSION_NUMBER 0x1000103fL/g" crypto/opensslv.h || exit 1 |
|---|
| 82 | |
|---|
| 83 | chown -R root:root . |
|---|
| 84 | mkdir -p $PKG1/usr/doc/openssl-$VERSION |
|---|
| 85 | cp -a CHANGES CHANGES.SSLeay FAQ INSTALL INSTALL.MacOS INSTALL.VMS INSTALL.W32 \ |
|---|
| 86 | LICENSE NEWS README README.ENGINE doc $PKG1/usr/doc/openssl-$VERSION |
|---|
| 87 | find $PKG1/usr/doc/openssl-$VERSION -type d -exec chmod 755 {} \; |
|---|
| 88 | find $PKG1/usr/doc/openssl-$VERSION -type f -exec chmod 644 {} \; |
|---|
| 89 | |
|---|
| 90 | # If there's a CHANGES file, installing at least part of the recent history |
|---|
| 91 | # is useful, but don't let it get totally out of control: |
|---|
| 92 | if [ -r CHANGES ]; then |
|---|
| 93 | DOCSDIR=$(echo $PKG1/usr/doc/*-$VERSION) |
|---|
| 94 | cat CHANGES | head -n 2000 > $DOCSDIR/CHANGES |
|---|
| 95 | touch -r CHANGES $DOCSDIR/CHANGES |
|---|
| 96 | fi |
|---|
| 97 | |
|---|
| 98 | # These are the known patent issues with OpenSSL: |
|---|
| 99 | # name # expires |
|---|
| 100 | # MDC-2: 4,908,861 2007-03-13, included. :-) |
|---|
| 101 | # IDEA: 5,214,703 2010-05-25, not included. |
|---|
| 102 | # RC5: 5,724,428 2015-03-03, not included. |
|---|
| 103 | |
|---|
| 104 | ./config \ |
|---|
| 105 | --prefix=/usr \ |
|---|
| 106 | --openssldir=/etc/ssl \ |
|---|
| 107 | no-idea \ |
|---|
| 108 | no-rc5 \ |
|---|
| 109 | no-sse2 \ |
|---|
| 110 | shared |
|---|
| 111 | |
|---|
| 112 | make $NUMJOBS depend || make -j1 depend || exit 1 |
|---|
| 113 | |
|---|
| 114 | make $NUMJOBS || make -j 1 || exit 1 |
|---|
| 115 | |
|---|
| 116 | make install INSTALL_PREFIX=$PKG1 || exit 1 |
|---|
| 117 | |
|---|
| 118 | # Make the .so.? library symlinks: |
|---|
| 119 | ( cd $PKG1/usr/lib${LIBDIRSUFFIX} ; ldconfig -l lib*.so.* ) |
|---|
| 120 | |
|---|
| 121 | # Move libraries, as they might be needed by programs that bring a network |
|---|
| 122 | # mounted /usr online: |
|---|
| 123 | |
|---|
| 124 | mkdir $PKG1/lib${LIBDIRSUFFIX} |
|---|
| 125 | ( cd $PKG1/usr/lib${LIBDIRSUFFIX} |
|---|
| 126 | for file in lib*.so.?.* ; do |
|---|
| 127 | mv $file ../../lib${LIBDIRSUFFIX} |
|---|
| 128 | ln -sf ../../lib${LIBDIRSUFFIX}/$file . |
|---|
| 129 | done |
|---|
| 130 | cp -a lib*.so.? ../../lib${LIBDIRSUFFIX} |
|---|
| 131 | ) |
|---|
| 132 | |
|---|
| 133 | # Add a cron script to warn root if a certificate is going to expire soon: |
|---|
| 134 | mkdir -p $PKG1/etc/cron.daily |
|---|
| 135 | zcat $CWD/certwatch.gz > $PKG1/etc/cron.daily/certwatch.new |
|---|
| 136 | chmod 755 $PKG1/etc/cron.daily/certwatch.new |
|---|
| 137 | |
|---|
| 138 | mv $PKG1/etc/ssl/openssl.cnf $PKG1/etc/ssl/openssl.cnf.new |
|---|
| 139 | |
|---|
| 140 | ( cd $PKG1 |
|---|
| 141 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
|---|
| 142 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
|---|
| 143 | ) |
|---|
| 144 | |
|---|
| 145 | mv $PKG1/etc/ssl/man $PKG1/usr |
|---|
| 146 | ( cd $PKG1/usr/man/man1 ; mv passwd.1 ssl_passwd.1 ) |
|---|
| 147 | ( cd $PKG1/usr/man/man3 ; mv rand.3 ssl_rand.3 ) |
|---|
| 148 | ( cd $PKG1/usr/man/man3 ; mv err.3 ssl_err.3 ) |
|---|
| 149 | # Compress and symlink the man pages: |
|---|
| 150 | if [ -d $PKG1/usr/man ]; then |
|---|
| 151 | ( cd $PKG1/usr/man |
|---|
| 152 | for manpagedir in $(find . -type d -name "man*") ; do |
|---|
| 153 | ( cd $manpagedir |
|---|
| 154 | for eachpage in $( find . -type l -maxdepth 1) ; do |
|---|
| 155 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
|---|
| 156 | rm $eachpage |
|---|
| 157 | done |
|---|
| 158 | gzip -9 *.? |
|---|
| 159 | ) |
|---|
| 160 | done |
|---|
| 161 | ) |
|---|
| 162 | fi |
|---|
| 163 | |
|---|
| 164 | # If there's an openssl0 directory, then build openssl-0 shared libraries for |
|---|
| 165 | # compatibility with programs linked to those: |
|---|
| 166 | if [ -d $CWD/openssl0 ]; then |
|---|
| 167 | ( cd $CWD/openssl0 |
|---|
| 168 | ./openssl0.build || exit 1 |
|---|
| 169 | ) || exit 1 |
|---|
| 170 | # Don't put these in the openssl package... openssl-solibs is enough. |
|---|
| 171 | #mkdir -p $PKG1/lib${LIBDIRSUFFIX} |
|---|
| 172 | #cp -a $TMP/package-openssl0/usr/lib/lib*.so.?.?.? $PKG1/lib${LIBDIRSUFFIX} |
|---|
| 173 | #( cd $PKG1/lib${LIBDIRSUFFIX} ; ldconfig -l lib*.so.?.?.? ) |
|---|
| 174 | mkdir -p $PKG2/lib${LIBDIRSUFFIX} |
|---|
| 175 | cp -a $TMP/package-openssl0/usr/lib/lib*.so.?.?.? $PKG2/lib${LIBDIRSUFFIX} |
|---|
| 176 | ( cd $PKG2/lib${LIBDIRSUFFIX} ; ldconfig -l lib*.so.?.?.? ) |
|---|
| 177 | fi |
|---|
| 178 | |
|---|
| 179 | cd $PKG1 |
|---|
| 180 | chmod 755 usr/lib${LIBDIRSUFFIX}/pkgconfig |
|---|
| 181 | sed -i -e "s#lib\$#lib${LIBDIRSUFFIX}#" usr/lib${LIBDIRSUFFIX}/pkgconfig/*.pc |
|---|
| 182 | mkdir -p install |
|---|
| 183 | zcat $CWD/doinst.sh-openssl.gz > install/doinst.sh |
|---|
| 184 | cat $CWD/slack-desc.openssl > install/slack-desc |
|---|
| 185 | /sbin/makepkg -l y -c n $TMP/${NAME1}.txz |
|---|
| 186 | |
|---|
| 187 | # Make runtime package: |
|---|
| 188 | mkdir -p $PKG2/lib${LIBDIRSUFFIX} |
|---|
| 189 | ( cd lib${LIBDIRSUFFIX} ; cp -a lib*.so.* $PKG2/lib${LIBDIRSUFFIX} ) |
|---|
| 190 | ( cd $PKG2/lib${LIBDIRSUFFIX} ; ldconfig -l * ) |
|---|
| 191 | mkdir -p $PKG2/etc |
|---|
| 192 | ( cd $PKG2/etc ; cp -a $PKG1/etc/ssl . ) |
|---|
| 193 | mkdir -p $PKG2/usr/doc/openssl-$VERSION |
|---|
| 194 | ( cd $TMP/openssl-$VERSION |
|---|
| 195 | cp -a CHANGES CHANGES.SSLeay FAQ INSTALL INSTALL.MacOS INSTALL.VMS INSTALL.W32 \ |
|---|
| 196 | LICENSE NEWS README README.ENGINE $PKG2/usr/doc/openssl-$VERSION |
|---|
| 197 | # If there's a CHANGES file, installing at least part of the recent history |
|---|
| 198 | # is useful, but don't let it get totally out of control: |
|---|
| 199 | if [ -r CHANGES ]; then |
|---|
| 200 | DOCSDIR=$(echo $PKG2/usr/doc/*-$VERSION) |
|---|
| 201 | cat CHANGES | head -n 2000 > $DOCSDIR/CHANGES |
|---|
| 202 | touch -r CHANGES $DOCSDIR/CHANGES |
|---|
| 203 | fi |
|---|
| 204 | ) |
|---|
| 205 | |
|---|
| 206 | find $PKG2/usr/doc/openssl-$VERSION -type d -exec chmod 755 {} \; |
|---|
| 207 | find $PKG2/usr/doc/openssl-$VERSION -type f -exec chmod 644 {} \; |
|---|
| 208 | cd $PKG2 |
|---|
| 209 | mkdir -p install |
|---|
| 210 | zcat $CWD/doinst.sh-openssl-solibs.gz > install/doinst.sh |
|---|
| 211 | cat $CWD/slack-desc.openssl-solibs > install/slack-desc |
|---|
| 212 | /sbin/makepkg -l y -c n $TMP/${NAME2}.txz |
|---|