prepare_release.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/bash
  2. # Copies sources from SVN tree and prepare a release package.
  3. # JLBC, 2008-2011
  4. #set -o verbose # echo on
  5. set +o verbose # echo off
  6. APPEND_SVN_NUM=0
  7. IS_FOR_UBUNTU=0
  8. APPEND_LINUX_DISTRO=""
  9. while getopts "sud:" OPTION
  10. do
  11. case $OPTION in
  12. s)
  13. APPEND_SVN_NUM=1
  14. ;;
  15. u)
  16. IS_FOR_UBUNTU=1
  17. ;;
  18. d)
  19. APPEND_LINUX_DISTRO=$OPTARG
  20. ;;
  21. ?)
  22. echo "Unknown command line argument!"
  23. exit 1
  24. ;;
  25. esac
  26. done
  27. # Checks
  28. # --------------------------------
  29. if [ -f version ];
  30. then
  31. NANOFLANN_VERSION_STR=`cat version`
  32. NANOFLANN_VERSION_MAJOR=${NANOFLANN_VERSION_STR:0:1}
  33. NANOFLANN_VERSION_MINOR=${NANOFLANN_VERSION_STR:2:1}
  34. NANOFLANN_VERSION_PATCH=${NANOFLANN_VERSION_STR:4:1}
  35. NANOFLANN_VER_MM="${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}"
  36. NANOFLANN_VER_MMP="${NANOFLANN_VERSION_MAJOR}.${NANOFLANN_VERSION_MINOR}.${NANOFLANN_VERSION_PATCH}"
  37. echo "nanoflann version: ${NANOFLANN_VER_MMP}"
  38. else
  39. echo "ERROR: Run this script from the nanoflann root directory."
  40. exit 1
  41. fi
  42. NANOFLANNSRC=`pwd`
  43. NANOFLANN_DEB_DIR="$HOME/nanoflann_release"
  44. NANOFLANN_EXTERN_DEBIAN_DIR="$NANOFLANNSRC/packaging/debian/"
  45. if [ -f ${NANOFLANN_EXTERN_DEBIAN_DIR}/control ];
  46. then
  47. echo "Using debian dir: ${NANOFLANN_EXTERN_DEBIAN_DIR}"
  48. else
  49. echo "ERROR: Cannot find ${NANOFLANN_EXTERN_DEBIAN_DIR}"
  50. exit 1
  51. fi
  52. # Prepare a directory for building the debian package:
  53. #
  54. rm -fR $NANOFLANN_DEB_DIR
  55. mkdir $NANOFLANN_DEB_DIR
  56. # Are we in svn?
  57. NANOFLANN_SVN_VERSION=`svnversion -n`
  58. if [ $NANOFLANN_SVN_VERSION = "exported" ];
  59. then
  60. echo "Copying sources to $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}"
  61. cp -R . $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}
  62. else
  63. # Strip the last "M", if any:
  64. if [ ${NANOFLANN_SVN_VERSION:(-1)} = "M" ];
  65. then
  66. NANOFLANN_SVN_VERSION=${NANOFLANN_SVN_VERSION:0:${#NANOFLANN_SVN_VERSION}-1}
  67. fi
  68. if [ $APPEND_SVN_NUM == "1" ];
  69. then
  70. NANOFLANN_VERSION_STR="${NANOFLANN_VERSION_STR}svn${NANOFLANN_SVN_VERSION}${APPEND_LINUX_DISTRO}"
  71. else
  72. NANOFLANN_VERSION_STR="${NANOFLANN_VERSION_STR}${APPEND_LINUX_DISTRO}"
  73. fi
  74. echo "Exporting to $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}"
  75. svn export . $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}
  76. fi
  77. cd $NANOFLANN_DEB_DIR/nanoflann-${NANOFLANN_VERSION_STR}
  78. # Orig tarball:
  79. cd ..
  80. echo "Creating orig tarball: nanoflann-${NANOFLANN_VERSION_STR}.tar.gz"
  81. tar czf nanoflann-${NANOFLANN_VERSION_STR}.tar.gz nanoflann-${NANOFLANN_VERSION_STR}
  82. # Create zip with Windows line feeds:
  83. find nanoflann-${NANOFLANN_VERSION_STR} -name '*.hpp' | xargs -I FIL todos FIL
  84. find nanoflann-${NANOFLANN_VERSION_STR} -name '*.txt' | xargs -I FIL todos FIL
  85. zip -r nanoflann-${NANOFLANN_VERSION_STR}.zip nanoflann-${NANOFLANN_VERSION_STR}
  86. exit 0