VERSION="2.0"
ARCH="i386"
RELEASE="1"

# --------- |-----handy-ruler------------------------------------------------------|
DESCRIPTION="cdrtools\n
             \n
             Tools for mastering and writing compact discs.\n
             \n
             cdda2wav -- CD audio sampling utility.\n
             cdrecord -- burn discs in most ATAPI and SCSI CD-R drives.\n
             mkisofs  -- create ISO9660/HFS/Joliet CD-ROM images.\n
             mkzftree -- compress a file tree to make a compressed CD-ROM."
# --------- |-----handy-ruler------------------------------------------------------|

ITERATION="_0 _1"

PREFIX="/usr"

PACKAGE_NAME="cdrtools-${VERSION}-${ARCH}-${RELEASE}"

INSTALL_MODE="normal"

DOWNLOAD () { return 0; }

EXTRACT ()
{
  do_extract "cdrtools-2.0.tar.gz"
  do_extract "zisofs-tools-1.0.4.tar.gz"
}

BUILD_0 ()
{
  ( cd cdrtools-2.0 && make )
  ( cd cdrtools-2.0 && make )
}

INSTALL_0 ()
{
  ( cd cdrtools-2.0
    make -e INS_BASE=${DESTDIR}${PREFIX} install )
}

POST_INSTALL_0 ()
{
  ( cd cdrtools-2.0
    do_copy AN-* BUILD COMPILE COPYING INSTALL README* ${DESTDIR}${PREFIX}/doc/cdrtools-${VERSION}
    (
      cd mkisofs
      do_copy COPYING ChangeLog README* TODO ${DESTDIR}${PREFIX}/doc/cdrtools-${VERSION}/mkisofs
    )
    (
      cd cdda2wav
      do_copy FAQ Frontends GPL HOWTOUSE NEEDED OtherProgs README THANKS TODO \
              Changelog ${DESTDIR}${PREFIX}/doc/cdrtools-${VERSION}/cdda2wav
    )
  )
}

POST_COLLECT_0 ()
{
  rm -rf ${DESTDIR}${PREFIX}/lib ${DESTDIR}${PREFIX}/include ${DESTDIR}${PREFIX}/man/man5

  # Next big hole? ;)
  rm -r ${DESTDIR}${PREFIX}/sbin
  rm -f ${DESTDIR}${PREFIX}/doc/cdrtools-${VERSION}/README.rscsi
}

CONFIGURE_1 ()
{
  ( cd zisofs-tools-1.0.4
    ./configure --prefix=${PREFIX} )
}

BUILD_1 ()
{
  ( cd zisofs-tools-1.0.4 && make )
}

INSTALL_1 ()
{
  ( cd zisofs-tools-1.0.4
    make -e INSTALLROOT=${DESTDIR} install )
}

POST_INSTALL_1 ()
{
  ( cd zisofs-tools-1.0.4
    do_copy CHANGES COPYING INSTALL README zisofs.magic \
            ${DESTDIR}${PREFIX}/doc/zisofs-tools-1.0.4
  )
  ( cd ${DESTDIR}${PREFIX}/bin && rm -f mkhybrid && ln -s mkisofs mkhybrid )
}

PRE_PACKAGE ()
{
  ( cd ${DESTDIR}${PREFIX}/man
    find . ! -type d | xargs chmod 644
    find . -type d | xargs chmod 755
  )
  ( cd ${DESTDIR}${PREFIX}/doc 
    find . ! -type d | xargs chmod 644
    find . -type d | xargs chmod 755
  )
  ( cd ${DESTDIR}${PREFIX}/bin
    chown -R root:bin . )
}
