# Maintainer: PktSurf <smlinux@pktsurf.in>
app=id3lib
version=3.8.3
build=1sml
homepage="http://id3lib.sourceforge.net/"
download="https://sourceforge.net/projects/id3lib/files/id3lib/$version/id3lib-$version.tar.gz"
desc="ID3 tag manipulation library"
requires="gcc-libs zlib"

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

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

  applypatch $srcdir/10-fix-compilation-with-cpp-headers.patch
  applypatch $srcdir/30-fix-utf16.patch
  applypatch $srcdir/50-remove-outdated-check.patch
  applypatch $srcdir/60-id3lib-missing-nullpointer-check.patch
  applypatch $srcdir/61-fix_vbr_stack_smash.patch
  applypatch $srcdir/CVE-2007-4460.patch

  libtoolize -fc
  aclocal
  autoconf
  automake --add-missing --copy
}

build() {
  ./configure \
    --prefix= \
    $builddist

  make
  make install DESTDIR=$pkg

  cp COPYING $pkgdocs/

  mkfinalpkg
}

sha512sums="
51bcf7249d174b48d33bced8a814a08ce084e3d31894f6673cd0d80092fa745bcb26afdfce767c38ce4dc1c593c4eddcb8cd5ac2e1a3a0d3196647f6bc7f1181  id3lib-3.8.3.tar.lz
a21024c20abb918081ea87be2114d9dc957cfe5d776e0942d2ef2ae450fa73f36236eaf5d50e1a14e293ca927bb95328da8c65a4ae6af6f43574ace3be0ad260  10-fix-compilation-with-cpp-headers.patch
811e1cc121a965fd0b6162a8937475e3d7dc2a477289707a28f6961ca2b9886b98508a954b12a36c27206202673ebd9ae6ec37d175c947e4e560ac112309ec6d  30-fix-utf16.patch
137732ceee8ec7fc8b686e46bd43276fba6bdcbdce166e85108e7c4b456523b4a29b11ff3101a37489e2386c92dfbe7f088f79c9c054f30515095f2b68c89f48  50-remove-outdated-check.patch
ebb536a3bce83ee8752905766f93c7920d548e85262704d617b3e608a020bca0909f5c59525caa2bbc2f034e2d11fb3eb0842d2b167e00c3ef4551c9eb57adf9  60-id3lib-missing-nullpointer-check.patch
debecda3ace7b8ced35d06f33cee922b5f0c43bcf17b9bc7c859e1910a54d4ddb69930b31104ed66702d5bc011859c6724d3df6ece153cc836a992ff19300d70  61-fix_vbr_stack_smash.patch
d534a1b4ce2fa186c089969c245ffc30c75d3e2b4c67b5a5d4b61fc9a8df04f9b2d5f1e13504b0e2f45540d774d5653c3dfa6e7dee9a12c99e7668a0b35fe8b2  CVE-2007-4460.patch
"
