app=tar
version=1.29
build=1sml
homepage="https://www.gnu.org/software/tar/"
download="https://ftp.gnu.org/gnu/tar/tar-$version.tar.xz"
desc="GNU archiving utility"
requires="bzip2 gzip xz attr acl"

build() {
  mkandenterbuilddir

  rm -rf tar-1.13
  tar xf $srcdir/tar-1.13.tar.?z

  cd tar-1.13
  applypatch $srcdir/tar-1.13.bzip2.diff
  cp -p --verbose /usr/share/libtool/build-aux/config.{guess,sub} .
  fixbuilddirpermissions

  CFLAGS="-static" \
  ./configure \
    --prefix="" \
    --libexecdir=/lib \
    --disable-nls

  make CFLAGS="-static" V=s
  install -Dm 755 src/tar $pkg/bin/tar-1.13
  # that's it as far as 1.13 is concerned.

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

  # The "A lone zero block at %s" messages also cause problems:
  applypatch $srcdir/tar.nolonezero.diff

  FORCE_UNSAFE_CONFIGURE=1 \
  CFLAGS="-static" \
  ./configure \
    --prefix="" \
    --sbindir=/bin \
    --libexecdir=/lib \
    --enable-backup-scripts 

  make CFLAGS="-static"
  make install DESTDIR=$pkg

  cp ABOUT-NLS AUTHORS COPYING README THANKS TODO $pkgdocs/

  mkfinalpkg
}

sha512sums="
7c0f2dfb7708bd5fe7cc5b841f68cc4cc077b14200df337f1847ecc41dcafae3b8f3dd210b78bf0ebc3d3408444283f71705ba34b1c9153d93dc631e80da6f07  tar-1.13.tar.lz
f14a0f20dc514dda887299b9ecad3fd8482f39e6abb9238a5dff819a5600a7e424df642e38a6d17b57e34c5655eb0d50137a6b0857c429e353fc72cbb3546beb  tar-1.29.tar.lz
5e12ae7f99a3bc73cd9a57d5451b534cc02da98aee46a7d6073eac492070f94e55b266e2cadcfcff4f5e2048ead683dd796b92f689d8f8ee56bc5f34ff186cde  tar-1.13.bzip2.diff
90b764cd2128d6c316a0cd9e24ae734ee94b1e2794e6cf724e60592d23ca6dac2d9a44552054610747cadd733263ee56971062f4201227bfda93966f287984bd  tar.nolonezero.diff
"
