[c5c522c] | 1 | #!/bin/sh |
---|
| 2 | |
---|
[072d3d5] | 3 | # Copyright 2005-2008, 2009, 2010, 2013, 2015 Patrick J. Volkerding, Sebeka, MN, USA |
---|
[c5c522c] | 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 | VERSION=${VERSION:-$(echo file-*.tar.?z* | cut -d - -f 2 | rev | cut -f 3- -d . | rev)} |
---|
| 24 | BUILD=${BUILD:-1} |
---|
| 25 | |
---|
| 26 | NUMJOBS=${NUMJOBS:--j7} |
---|
| 27 | |
---|
| 28 | # Automatically determine the architecture we're building on: |
---|
| 29 | if [ -z "$ARCH" ]; then |
---|
| 30 | case "$( uname -m )" in |
---|
[072d3d5] | 31 | i?86) export ARCH=i586 ;; |
---|
[c5c522c] | 32 | arm*) export ARCH=arm ;; |
---|
| 33 | # Unless $ARCH is already set, use uname -m for all other archs: |
---|
| 34 | *) export ARCH=$( uname -m ) ;; |
---|
| 35 | esac |
---|
| 36 | fi |
---|
| 37 | |
---|
[072d3d5] | 38 | if [ "$ARCH" = "i586" ]; then |
---|
| 39 | SLKCFLAGS="-O2 -march=i586 -mtune=i686" |
---|
[c5c522c] | 40 | LIBDIRSUFFIX="" |
---|
| 41 | elif [ "$ARCH" = "i686" ]; then |
---|
| 42 | SLKCFLAGS="-O2 -march=i686 -mtune=i686" |
---|
| 43 | LIBDIRSUFFIX="" |
---|
| 44 | elif [ "$ARCH" = "x86_64" ]; then |
---|
| 45 | SLKCFLAGS="-O2 -fPIC" |
---|
| 46 | LIBDIRSUFFIX="64" |
---|
| 47 | else |
---|
| 48 | SLKCFLAGS="-O2" |
---|
| 49 | LIBDIRSUFFIX="" |
---|
| 50 | fi |
---|
| 51 | |
---|
| 52 | CWD=$(pwd) |
---|
| 53 | TMP=${TMP:-/tmp} |
---|
| 54 | PKG=$TMP/package-file |
---|
| 55 | |
---|
| 56 | rm -rf $PKG |
---|
| 57 | mkdir -p $TMP $PKG |
---|
| 58 | cd $TMP |
---|
| 59 | rm -rf file-$VERSION |
---|
| 60 | tar xvf $CWD/file-$VERSION.tar.?z* || exit 1 |
---|
| 61 | cd file-$VERSION || exit 1 |
---|
| 62 | chown -R root:root . |
---|
| 63 | find . \ |
---|
| 64 | \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ |
---|
| 65 | -exec chmod 755 {} \; -o \ |
---|
| 66 | \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ |
---|
| 67 | -exec chmod 644 {} \; |
---|
| 68 | |
---|
| 69 | # Make the default data directory /etc/file like it has always been: |
---|
| 70 | zcat $CWD/file.etc.file.diff.gz | patch -p1 --verbose || exit 1 |
---|
| 71 | # This is needed after the patch above: |
---|
| 72 | autoreconf || exit 1 |
---|
| 73 | |
---|
| 74 | # Since we're going to include the compiled magic database now (otherwise |
---|
| 75 | # there seem to be libmagic related crashes), this patch probably doesn't |
---|
| 76 | # need to be applied. |
---|
| 77 | # |
---|
| 78 | ## Don't spew warnings about using the flat text files |
---|
| 79 | #zcat $CWD/file.quiet.diff.gz | patch -p1 -E --verbose || exit 1 |
---|
| 80 | |
---|
| 81 | # Keep the output format for ELF binaries the same as it was in earlier |
---|
| 82 | # versions of file to avoid breaking existing scripts: |
---|
| 83 | zcat $CWD/file.short.diff.gz | patch -p1 -E --verbose || exit 1 |
---|
| 84 | |
---|
| 85 | # Add zisofs and crda regulatory bin detection |
---|
| 86 | zcat $CWD/file.zisofs.magic.gz >> magic/Magdir/compress |
---|
| 87 | zcat $CWD/file.crdaregbin.magic.gz >> magic/Magdir/crdaregbin |
---|
| 88 | |
---|
| 89 | CFLAGS="$SLKCFLAGS" \ |
---|
| 90 | ./configure \ |
---|
| 91 | --prefix=/usr \ |
---|
| 92 | --libdir=/usr/lib${LIBDIRSUFFIX} \ |
---|
| 93 | --sysconfdir=/etc \ |
---|
| 94 | --datadir=/etc \ |
---|
| 95 | --mandir=/usr/man \ |
---|
| 96 | --infodir=/usr/info \ |
---|
| 97 | --docdir=/usr/doc/file-$VERSION \ |
---|
| 98 | --enable-fsect-man5 \ |
---|
| 99 | --disable-static \ |
---|
[072d3d5] | 100 | --build=$ARCH-slackware-linux || exit 1 |
---|
[c5c522c] | 101 | |
---|
| 102 | # The generated $TMP/file-$VERSION/libtool is buggy. I don't know if this is supposed |
---|
| 103 | # to work, but it certainly does, so... :-) |
---|
| 104 | cat $(which libtool) > libtool |
---|
| 105 | |
---|
| 106 | make $NUMJOBS || make || exit 1 |
---|
| 107 | make install DESTDIR=$PKG || exit 1 |
---|
| 108 | |
---|
[072d3d5] | 109 | # Ignore for now - still labeled as experimental |
---|
| 110 | # Actually, let's ignore it until something needs it :) <volkerdi> |
---|
| 111 | #cd python/ |
---|
| 112 | # python setup.py build |
---|
| 113 | # python setup.py install --root=$PKG |
---|
| 114 | #cd .. |
---|
| 115 | |
---|
[c5c522c] | 116 | # Seems --disable-static has been ignored lately: |
---|
| 117 | rm -f $PKG/usr/lib${LIBDIRSUFFIX}/libmagic.a |
---|
| 118 | |
---|
| 119 | # Install the flat files. |
---|
| 120 | # We'll generate /etc/file/magic.mgc in the doinst.sh. |
---|
| 121 | rm -f $PKG/etc/file/magic.mgc |
---|
| 122 | mkdir -p $PKG/etc/file/magic |
---|
| 123 | cp -a magic/Magdir/* $PKG/etc/file/magic |
---|
| 124 | |
---|
| 125 | # Add a script to recompile the flat files in the obvious location. |
---|
| 126 | # The package install script will compile the flat files initially. |
---|
| 127 | cp -a $CWD/recompile_magic.mgc.sh.gz $PKG/etc/file |
---|
| 128 | gzip -d $PKG/etc/file/recompile_magic.mgc.sh.gz |
---|
| 129 | chown root:root $PKG/etc/file/recompile_magic.mgc.sh |
---|
| 130 | chmod 755 $PKG/etc/file/recompile_magic.mgc.sh |
---|
| 131 | |
---|
| 132 | # IMHO, moving this sort of thing does not make sense. |
---|
| 133 | # We'll support both the traditional and new locations. |
---|
| 134 | # I hate to squat on a name as generic as "/etc/misc/", |
---|
| 135 | # but it wasn't my idea. |
---|
| 136 | ( cd $PKG/etc ; ln -sf file misc ) |
---|
| 137 | |
---|
| 138 | # Strip everything for good measure: |
---|
| 139 | find $PKG | xargs file | grep -e "executable" -e "shared object" \ |
---|
| 140 | | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
---|
| 141 | |
---|
| 142 | ( cd $PKG/usr/man || exit 1 |
---|
| 143 | find . -type f -exec gzip -9 {} \; |
---|
| 144 | for i in $(find . -type l) ; do ln -s $(readlink $i).gz $i.gz ; rm $i ; done |
---|
| 145 | ) |
---|
| 146 | |
---|
| 147 | mkdir -p $PKG/usr/doc/file-$VERSION |
---|
| 148 | cp -a \ |
---|
| 149 | AUTHORS COPYING* INSTALL MAINT NEWS README* TODO \ |
---|
| 150 | $PKG/usr/doc/file-$VERSION |
---|
| 151 | |
---|
| 152 | mkdir -p $PKG/install |
---|
| 153 | cat $CWD/slack-desc > $PKG/install/slack-desc |
---|
| 154 | zcat $CWD/doinst.sh.gz > $PKG/install/doinst.sh |
---|
| 155 | |
---|
| 156 | # Build the package: |
---|
| 157 | cd $PKG |
---|
| 158 | /sbin/makepkg -l y -c n $TMP/file-$VERSION-$ARCH-$BUILD.txz |
---|
| 159 | |
---|