Linux HOWTOs

About | Home | Search

HOWTO: file
Description: Determines file types
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything

# file 5.03
# =========
# Slackware 11.0: 4.17 is included in the 'bin' package
# Slackware 12.0, 12.1, 12.2: file 4.21

# Prerequisites:
# zlib

test -f installed/file-5.03.tar.gz && mv installed/file-5.03.tar.gz .
test ! -f file-5.03.tar.gz &&
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "file-*" -exec rm -r {} \;
tar xzvf ~/file-5.03.tar.gz
cd file-5.03
test $UID = 0 && chown -R root:root .
./configure --prefix=/usr --datadir=/etc --mandir=/usr/man \

# Become root to clean up old files and to install it

# If you run Slackware >= 12.0, remove the 'file' package:
test -x /sbin/removepkg && /sbin/removepkg file

# Various versions of file put the magic related files in
# various places, look around in these places to see if you
# need to clean up any old files
# /etc/magic*
# /etc/file/
# /etc/misc/

# Remove old files
# (back up your old ones first if you've customized them)
( cd /etc ; rm -f magic magic.mgc magic.mime magic.mime.mgc )
test -d /etc/file && rm -r /etc/file
test -d /etc/misc && rm -r /etc/misc
rm -f /usr/lib/libmagic.*

# Install the new version
make install

# There are new Python bindings as of 4.06  To build and install them, do this.
# You should probably read python/README too, and don't forget to re-do this
# if you upgrade Python.
cd python
python build
PYDIR=`find /usr/lib -maxdepth 1 -type d -name "python?.*" | sort | tail -1`
test -n "$PYDIR" && cp build/lib.*/ $PYDIR/lib-dynload/
unset PYDIR
chown -R $USER .

# Make sure your non-root user can remove the source later
chown -R $USER .
chmod -R u+w .

# Become yourself again

mkdir -p -m 0700 installed
rm -f installed/file-*.tar.*
mv file-5.03.tar.gz installed/

# If you ever want to uninstall file, this should do it:
test -d src/file-* && ( cd src/file-* ; make uninstall )
test -L /etc/magic && rm -f /etc/magic
test -d /etc/file && rm -r /etc/file
test -d /etc/misc && rm -r /etc/misc
rm -f /usr/bin/file /usr/include/magic.h /usr/lib/libmagic.*
find /usr/doc -type d -name "file-*" -exec rm -r {} \;
( cd /usr/man/man1 ; rm -f file.1 file.1.gz )
( cd /usr/man/man3 ; rm -f libmagic.3 libmagic.3.gz )
( cd /usr/man/man5 ; rm -f magic.5 magic.5.gz )
find ~/src -maxdepth 1 -type d -name "file-*" -exec rm -r {} \;
rm -f ~/installed/file-*.tar.*

Back to the list

Last updated: Wed, 29 Apr 2020 22:04:50 -0400
Jason Englander <jason at englanders dot us>