maketarball.in 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/sh
  2. set -u
  3. set -e
  4. trap onexit INT
  5. trap onexit TERM
  6. trap onexit EXIT
  7. TMPDIR=
  8. SUDO=
  9. onexit()
  10. {
  11. if [ ! "$TMPDIR" = "" ]; then
  12. rm -rf $TMPDIR
  13. fi
  14. }
  15. uid()
  16. {
  17. id | cut -f2 -d = | cut -f1 -d \(;
  18. }
  19. PKGNAME=@PKGNAME@
  20. VERSION=@VERSION@
  21. ARCH=@CPU_TYPE@
  22. OS=@CMAKE_SYSTEM_NAME@
  23. PREFIX=@CMAKE_INSTALL_PREFIX@
  24. umask 022
  25. rm -f $PKGNAME-$VERSION-$OS-$ARCH.tar.bz2
  26. TMPDIR=`mktemp -d /tmp/$PKGNAME-build.XXXXXX`
  27. mkdir -p $TMPDIR/install
  28. make install DESTDIR=$TMPDIR/install
  29. echo tartest >$TMPDIR/tartest
  30. GNUTAR=0
  31. BSDTAR=0
  32. tar cf $TMPDIR/tartest.tar --owner=root --group=root -C $TMPDIR tartest >/dev/null 2>&1 && GNUTAR=1
  33. if [ "$GNUTAR" = "1" ]; then
  34. tar cf - --owner=root --group=root -C $TMPDIR/install .$PREFIX | bzip2 -c >$PKGNAME-$VERSION-$OS-$ARCH.tar.bz2
  35. else
  36. tar cf $TMPDIR/tartest.tar --uid 0 --gid 0 -C $TMPDIR tartest >/dev/null 2>&1 && BSDTAR=1
  37. if [ "$BSDTAR" = "1" ]; then
  38. tar cf - --uid=0 --gid=0 -C $TMPDIR/install .$PREFIX | bzip2 -c >$PKGNAME-$VERSION-$OS-$ARCH.tar.bz2
  39. else
  40. tar cf - -C $TMPDIR/install .$PREFIX | bzip2 -c >$PKGNAME-$VERSION-$OS-$ARCH.tar.bz2
  41. fi
  42. fi
  43. exit