# Maintainer: PktSurf <smlinux@pktsurf.in>
app=file
version=5.44
build=4sml
homepage="https://www.darwinsys.com/file/"
download="http://astron.com/pub/file/file-$version.tar.gz"
desc="Utility to determine file types"
requires="bzip2 zlib"

prepbuilddir() {
  mkandenterbuilddir
  rm -rf $app-$version

  tar xf $srcdir/$app-$version.tar.?z*
  cd $app-$version
  fixbuilddirpermissions

  #applypatch $srcdir/file.etc.file.diff
  #applypatch $srcdir/file.short.diff
}

build() {
  # linking against libseccomp causes weird "Bad system call" issues
  CFLAGS+=" --std=c99" \
  ./configure \
    --prefix="" \
    --datadir=/etc \
    --enable-fsect-man5 \
    --disable-libseccomp

  make
  make install DESTDIR=$pkg

  # Install the flat files
  # We'll regenerate /etc/file/magic.mgc in the doinst.sh
  #rm $pkg/etc/file/magic.mgc
  mkdir -p $pkg/etc/file/magic
  cp -a magic/Magdir/* $pkg/etc/file/magic/
  chmod 0644 $pkg/etc/file/magic/* 

  install -Dm 755 $srcdir/recompile_magic.mgc.sh $pkg/etc/file/recompile_magic.mgc.sh

  cp COPYING $pkgdocs/

  ( cd $pkg/etc ; ln -sf file misc )

  mkfinalpkg
}

sha512sums="
706f52abe8a4140983c03bc9403987153e3996a8bfbfd20d94f82fc7781c710a54e57b8967c8885e0ceec83f86ff0acca14b6d051b854f79df7aaa626d7068b8  file-5.39.tar.lz
26c3b9c7a6950649d0b2de896bfeca54289febe4cd487c0f91aa6ff1857fa49f9077f8738a17b86100125668a31dae05b586615c564f78da47ac20a1e4a74f63  file-5.44.tar.gz
"