[c5c522c] | 1 | #!/bin/sh |
---|
| 2 | |
---|
| 3 | # Copyright 2005-2014 Patrick J. Volkerding, Sebeka, Minnesota, 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 | # Modified 2011, 2012 by Eric Hameleers <alien at slackware.com> for ARM port. |
---|
| 24 | |
---|
| 25 | |
---|
| 26 | # Set initial variables: |
---|
| 27 | CWD=`pwd` |
---|
| 28 | if [ "$TMP" = "" ]; then |
---|
| 29 | TMP=/tmp |
---|
| 30 | fi |
---|
| 31 | PKG=$TMP/package-bash |
---|
| 32 | |
---|
| 33 | VERSION=${VERSION:-$(echo bash-*.tar.?z* | rev | cut -f 3- -d . | cut -f 1 -d - | rev)} |
---|
| 34 | BUILD=${BUILD:-1} |
---|
| 35 | |
---|
| 36 | # Automatically determine the architecture we're building on: |
---|
| 37 | MARCH=$( uname -m ) |
---|
| 38 | if [ -z "$ARCH" ]; then |
---|
| 39 | case "$MARCH" in |
---|
| 40 | i?86) export ARCH=i486 ;; |
---|
| 41 | armv7hl) export ARCH=$MARCH ;; |
---|
| 42 | arm*) export ARCH=arm ;; |
---|
| 43 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
| 44 | *) export ARCH=$MARCH ;; |
---|
| 45 | esac |
---|
| 46 | fi |
---|
| 47 | |
---|
| 48 | if [ "$ARCH" = "i386" ]; then |
---|
| 49 | SLKCFLAGS="-O2 -march=i386 -mcpu=i686" |
---|
| 50 | elif [ "$ARCH" = "i486" ]; then |
---|
| 51 | SLKCFLAGS="-O2 -march=i486 -mtune=i686" |
---|
| 52 | elif [ "$ARCH" = "s390" ]; then |
---|
| 53 | SLKCFLAGS="-O2" |
---|
| 54 | elif [ "$ARCH" = "x86_64" ]; then |
---|
| 55 | SLKCFLAGS="-O2 -fPIC" |
---|
| 56 | elif [ "$ARCH" = "armv7hl" ]; then |
---|
| 57 | SLKCFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16" |
---|
| 58 | else |
---|
| 59 | SLKCFLAGS="-O2" |
---|
| 60 | fi |
---|
| 61 | |
---|
| 62 | case "$ARCH" in |
---|
| 63 | arm*) TARGET=$ARCH-slackware-linux-gnueabi ;; |
---|
| 64 | *) TARGET=$ARCH-slackware-linux ;; |
---|
| 65 | esac |
---|
| 66 | |
---|
| 67 | if [ ! -d $TMP ]; then |
---|
| 68 | mkdir -p $TMP # location to build the source |
---|
| 69 | fi |
---|
| 70 | rm -rf $PKG |
---|
| 71 | mkdir -p $PKG |
---|
| 72 | |
---|
| 73 | # Determine bash patchlevel: |
---|
| 74 | PATCHLEVEL="$( cd $CWD/bash-${VERSION}-patches ; /bin/ls bash4?-??? | tail -1 | cut -f 2 -d - 2> /dev/null )" |
---|
| 75 | if [ "$PATCHLEVEL" = "" ]; then |
---|
| 76 | PATCHLEVEL=0 |
---|
| 77 | fi |
---|
| 78 | |
---|
| 79 | cd $TMP |
---|
| 80 | rm -rf bash-$VERSION |
---|
| 81 | tar xvf $CWD/bash-$VERSION.tar.?z* || exit 1 |
---|
| 82 | cd bash-$VERSION || exit 1 |
---|
| 83 | chown -R root:root . |
---|
| 84 | find . -perm 664 | xargs chmod 644 |
---|
| 85 | find . -perm 775 | xargs chmod 755 |
---|
| 86 | |
---|
| 87 | if [ -d $CWD/bash-${VERSION}-patches ]; then |
---|
| 88 | ( cd $CWD/bash-${VERSION}-patches ; cat bash4?-??? ) | patch -p0 --verbose || exit 1 |
---|
| 89 | fi |
---|
| 90 | |
---|
| 91 | # End of preparations |
---|
| 92 | if echo "$*" | grep -qw -- --prep ; then |
---|
| 93 | exit 0 |
---|
| 94 | fi |
---|
| 95 | |
---|
| 96 | CFLAGS="$SLKCFLAGS" \ |
---|
| 97 | ./configure \ |
---|
| 98 | --prefix=/usr \ |
---|
| 99 | --mandir=/usr/man \ |
---|
| 100 | --infodir=/usr/info \ |
---|
| 101 | --build=$TARGET |
---|
| 102 | |
---|
| 103 | make -j4 || make || exit 1 |
---|
| 104 | make install DESTDIR=$PKG |
---|
| 105 | mv $PKG/usr/share/doc $PKG/usr |
---|
| 106 | mkdir -p $PKG/bin |
---|
| 107 | mv $PKG/usr/bin/bash $PKG/bin/bash4.new |
---|
| 108 | # We don't include the "bashbug" script. |
---|
| 109 | rm -rf $PKG/usr/bin $PKG/usr/man/man1/bashbug.1 |
---|
| 110 | |
---|
| 111 | # Strip binaries: |
---|
| 112 | ( cd $PKG |
---|
| 113 | find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
| 114 | find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
| 115 | ) |
---|
| 116 | |
---|
| 117 | # Compress and link manpages, if any: |
---|
| 118 | if [ -d $PKG/usr/man ]; then |
---|
| 119 | ( cd $PKG/usr/man |
---|
| 120 | for manpagedir in $(find . -type d -name "man*") ; do |
---|
| 121 | ( cd $manpagedir |
---|
| 122 | for eachpage in $( find . -type l -maxdepth 1) ; do |
---|
| 123 | ln -s $( readlink $eachpage ).gz $eachpage.gz |
---|
| 124 | rm $eachpage |
---|
| 125 | done |
---|
| 126 | gzip -9 *.? |
---|
| 127 | ) |
---|
| 128 | done |
---|
| 129 | ) |
---|
| 130 | fi |
---|
| 131 | |
---|
| 132 | # bash.1 is already installed by "make install" |
---|
| 133 | ( cd doc |
---|
| 134 | for page in builtins.1 rbash.1 ; do |
---|
| 135 | cat $page | gzip -9c > $PKG/usr/man/man1/$page.gz |
---|
| 136 | done |
---|
| 137 | ) |
---|
| 138 | |
---|
| 139 | # Compress info files, if any: |
---|
| 140 | if [ -d $PKG/usr/info ]; then |
---|
| 141 | ( cd $PKG/usr/info |
---|
| 142 | rm -f dir |
---|
| 143 | gzip -9 * |
---|
| 144 | ) |
---|
| 145 | fi |
---|
| 146 | |
---|
| 147 | mkdir -p $PKG/usr/doc/bash-$VERSION |
---|
| 148 | cp -a AUTHORS CHANGES COMPAT COPYING INSTALL MANIFEST NEWS NOTES \ |
---|
| 149 | README Y2K doc/FAQ doc/INTRO \ |
---|
| 150 | $PKG/usr/doc/bash-$VERSION |
---|
| 151 | ( cd doc ; groff -ms -Tascii article.ms > $PKG/usr/doc/bash-$VERSION/article.txt ) |
---|
| 152 | |
---|
| 153 | # If there's a ChangeLog, installing at least part of the recent history |
---|
| 154 | # is useful, but don't let it get totally out of control: |
---|
| 155 | if [ -r ChangeLog ]; then |
---|
| 156 | DOCSDIR=$(echo $PKG/usr/doc/*-$VERSION) |
---|
| 157 | cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog |
---|
| 158 | touch -r ChangeLog $DOCSDIR/ChangeLog |
---|
| 159 | fi |
---|
| 160 | |
---|
| 161 | mkdir -p $PKG/install |
---|
| 162 | zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh |
---|
| 163 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
| 164 | |
---|
| 165 | # Build the package: |
---|
| 166 | cd $PKG |
---|
| 167 | makepkg -l y -c n $TMP/bash-$VERSION.$PATCHLEVEL-$ARCH-$BUILD.txz |
---|
| 168 | |
---|