source: npl/overig/file/file.SlackBuild.orig

Last change on this file was 30f002a, checked in by Edwin Eefting <edwin@datux.nl>, 4 years ago

new file command, fixes a issue with certain jpegs. this causes trouble in amavis when scanning mails

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