1 | #!/bin/bash |
---|
2 | |
---|
3 | # Copyright 2008, 2009, 2010, 2011, 2013, 2014, 2016, 2017, 2018, 2020, 2021 Patrick J. Volkerding, Sebeka, MN, USA |
---|
4 | # All rights reserved. |
---|
5 | # |
---|
6 | # Redistribution and use of this script, with or without modification, is |
---|
7 | # permitted provided that the following conditions are met: |
---|
8 | # |
---|
9 | # 1. Redistributions of this script must retain the above copyright |
---|
10 | # notice, this list of conditions and the following disclaimer. |
---|
11 | # |
---|
12 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
---|
13 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
---|
14 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
---|
15 | # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
---|
16 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
---|
17 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
---|
18 | # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
---|
19 | # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
---|
20 | # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
---|
21 | # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
---|
22 | |
---|
23 | cd $(dirname $0) ; CWD=$(pwd) |
---|
24 | |
---|
25 | PKGNAM=curl |
---|
26 | VERSION=${VERSION:-$(echo curl-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
27 | BUILD=${BUILD:-1} |
---|
28 | |
---|
29 | # Automatically determine the architecture we're building on: |
---|
30 | if [ -z "$ARCH" ]; then |
---|
31 | case "$( uname -m )" in |
---|
32 | i?86) export ARCH=i586 ;; |
---|
33 | arm*) export ARCH=arm ;; |
---|
34 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
35 | *) export ARCH=$( uname -m ) ;; |
---|
36 | esac |
---|
37 | fi |
---|
38 | |
---|
39 | # If the variable PRINT_PACKAGE_NAME is set, then this script will report what |
---|
40 | # the name of the created package would be, and then exit. This information |
---|
41 | # could be useful to other scripts. |
---|
42 | if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then |
---|
43 | echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz" |
---|
44 | exit 0 |
---|
45 | fi |
---|
46 | |
---|
47 | NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "} |
---|
48 | |
---|
49 | TMP=${TMP:-/tmp} |
---|
50 | PKG=$TMP/package-curl |
---|
51 | |
---|
52 | # Set this variable to "--without-ssl" to build a no-SSL version: |
---|
53 | SSLOPT=${SSLOPT:-"--with-openssl"} |
---|
54 | |
---|
55 | if [ "$ARCH" = "i586" ]; then |
---|
56 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
57 | LIBDIRSUFFIX="" |
---|
58 | elif [ "$ARCH" = "s390" ]; then |
---|
59 | SLKCFLAGS="-O2" |
---|
60 | LIBDIRSUFFIX="" |
---|
61 | elif [ "$ARCH" = "x86_64" ]; then |
---|
62 | SLKCFLAGS="-O2 -fPIC" |
---|
63 | LIBDIRSUFFIX="64" |
---|
64 | else |
---|
65 | SLKCFLAGS="-O2" |
---|
66 | LIBDIRSUFFIX="" |
---|
67 | fi |
---|
68 | |
---|
69 | rm -rf $PKG |
---|
70 | mkdir -p $PKG |
---|
71 | cd $TMP |
---|
72 | rm -rf curl-$VERSION |
---|
73 | tar xvf $CWD/curl-$VERSION.tar.xz || exit 1 |
---|
74 | cd curl-$VERSION || exit 1 |
---|
75 | |
---|
76 | chown -R root:root . |
---|
77 | find . \ |
---|
78 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
79 | -exec chmod 755 {} \+ -o \ |
---|
80 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
81 | -exec chmod 644 {} \+ |
---|
82 | |
---|
83 | CFLAGS="$SLKCFLAGS" \ |
---|
84 | ./configure \ |
---|
85 | --prefix=/usr \ |
---|
86 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
87 | --mandir=/usr/man \ |
---|
88 | --with-gssapi \ |
---|
89 | --enable-static=no \ |
---|
90 | --without-ca-bundle \ |
---|
91 | --with-ca-path=/etc/ssl/certs \ |
---|
92 | $SSLOPT || exit 1 |
---|
93 | |
---|
94 | make $NUMJOBS || make || exit 1 |
---|
95 | make install DESTDIR=$PKG || exit 1 |
---|
96 | |
---|
97 | # Don't ship .la files: |
---|
98 | rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la |
---|
99 | |
---|
100 | # We have always installed the man3 documentation, so we'll keep doing it |
---|
101 | # even though these are no longer installed by default. No || exit 1, if |
---|
102 | # it works, it works, and if it doesn't, we tried. |
---|
103 | ( cd docs/libcurl |
---|
104 | make install-man3 DESTDIR=$PKG |
---|
105 | cd opts |
---|
106 | make install-man3 DESTDIR=$PKG |
---|
107 | ) |
---|
108 | |
---|
109 | # We don't ship the related perl script (yet): |
---|
110 | rm -f $PKG/usr/man/man1/mk-ca-bundle.1 |
---|
111 | |
---|
112 | find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ |
---|
113 | | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
114 | |
---|
115 | #strip -g $PKG/usr/lib${LIBDIRSUFFIX}/libcurl.a |
---|
116 | |
---|
117 | mkdir -p $PKG/usr/doc/curl-$VERSION |
---|
118 | cp -a \ |
---|
119 | COPYING* README* \ |
---|
120 | $PKG/usr/doc/curl-$VERSION |
---|
121 | # Get rid of .deps cruft: |
---|
122 | rm -rf $PKG/usr/doc/curl-$VERSION/examples/.deps || true |
---|
123 | |
---|
124 | # If there's a CHANGES file, installing at least part of the recent history |
---|
125 | # is useful, but don't let it get totally out of control: |
---|
126 | if [ -r CHANGES ]; then |
---|
127 | DOCSDIR=$(echo $PKG/usr/doc/${PKGNAM}-$VERSION) |
---|
128 | cat CHANGES | head -n 1000 > $DOCSDIR/ChangeLog |
---|
129 | touch -r CHANGES $DOCSDIR/ChangeLog |
---|
130 | fi |
---|
131 | |
---|
132 | # Compress and if needed symlink the man pages: |
---|
133 | if [ -d $PKG/usr/man ]; then |
---|
134 | ( cd $PKG/usr/man |
---|
135 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
136 | ( cd $manpagedir |
---|
137 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
138 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
139 | rm $eachpage |
---|
140 | done |
---|
141 | gzip -9 *.? |
---|
142 | ) |
---|
143 | done |
---|
144 | ) |
---|
145 | fi |
---|
146 | |
---|
147 | mkdir -p $PKG/install |
---|
148 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
149 | |
---|
150 | cd $PKG |
---|
151 | /sbin/makepkg -l y -c n $TMP/curl-$VERSION-$ARCH-$BUILD.txz |
---|
152 | |
---|