makecygwinpkg.in 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/bin/sh
  2. set -u
  3. set -e
  4. trap onexit INT
  5. trap onexit TERM
  6. trap onexit EXIT
  7. TMPDIR=
  8. onexit()
  9. {
  10. if [ ! "$TMPDIR" = "" ]; then
  11. rm -rf $TMPDIR
  12. fi
  13. }
  14. safedirmove ()
  15. {
  16. if [ "$1" = "$2" ]; then
  17. return 0
  18. fi
  19. if [ "$1" = "" -o ! -d "$1" ]; then
  20. echo safedirmove: source dir $1 is not valid
  21. return 1
  22. fi
  23. if [ "$2" = "" -o -e "$2" ]; then
  24. echo safedirmove: dest dir $2 is not valid
  25. return 1
  26. fi
  27. if [ "$3" = "" -o -e "$3" ]; then
  28. echo safedirmove: tmp dir $3 is not valid
  29. return 1
  30. fi
  31. mkdir -p $3
  32. mv $1/* $3/
  33. rmdir $1
  34. mkdir -p $2
  35. mv $3/* $2/
  36. rmdir $3
  37. return 0
  38. }
  39. PKGNAME=@PKGNAME@
  40. VERSION=@VERSION@
  41. BUILD=@BUILD@
  42. PREFIX=@CMAKE_INSTALL_PREFIX@
  43. DOCDIR=@CMAKE_INSTALL_FULL_DOCDIR@
  44. LIBDIR=@CMAKE_INSTALL_FULL_LIBDIR@
  45. umask 022
  46. rm -f $PKGNAME-$VERSION-$BUILD.tar.bz2
  47. TMPDIR=`mktemp -d /tmp/ljtbuild.XXXXXX`
  48. __PWD=`pwd`
  49. make install DESTDIR=$TMPDIR/pkg
  50. if [ "$PREFIX" = "@CMAKE_INSTALL_DEFAULT_PREFIX@" -a "$DOCDIR" = "@CMAKE_INSTALL_DEFAULT_PREFIX@/doc" ]; then
  51. safedirmove $TMPDIR/pkg$DOCDIR $TMPDIR/pkg/usr/share/doc/$PKGNAME-$VERSION $TMPDIR/__tmpdoc
  52. ln -fs /usr/share/doc/$PKGNAME-$VERSION $TMPDIR/pkg$DOCDIR
  53. fi
  54. cd $TMPDIR/pkg
  55. tar cfj ../$PKGNAME-$VERSION-$BUILD.tar.bz2 *
  56. cd $__PWD
  57. mv $TMPDIR/*.tar.bz2 .
  58. exit 0