mkrelease.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #!/bin/bash
  2. INSTALLPREFIX="/usr/local/freetdm"
  3. VERSION=""
  4. NODOCS="NO"
  5. for i in $*
  6. do
  7. case $i in
  8. --version=*)
  9. VERSION=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
  10. ;;
  11. --prefix=*)
  12. INSTALLPREFIX=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
  13. ;;
  14. --nodocs)
  15. NODOCS="YES"
  16. ;;
  17. *)
  18. # unknown option
  19. echo "Unknown option $i"
  20. exit
  21. ;;
  22. esac
  23. done
  24. if [ "x$VERSION" = "x" ]
  25. then
  26. echo "Provide a version number with --version=<version>"
  27. exit 1
  28. fi
  29. arch=$(uname -m)
  30. # defs
  31. LIBSNG_ISDN_URL=ftp://ftp.sangoma.com/linux/libsng_isdn
  32. LIBSNG_ISDN_NAME=libsng_isdn-7-current
  33. LIBSNG_SS7_URL=ftp://ftp.sangoma.com/linux/libsng_ss7
  34. LIBSNG_SS7_NAME=libsng_ss7-3-current
  35. LIBSNG_ISDN_DIR="$LIBSNG_ISDN_NAME.$arch"
  36. LIBSNG_SS7_DIR="$LIBSNG_SS7_NAME.$arch"
  37. # download and decompress a tarball
  38. # $1 = prefix_url, such as ftp://ftp.sangoma.com/foo/bar
  39. # $2 = package name, such as libsng_isdn-7.0.0.x86_64
  40. function download() {
  41. wget $1/$2.tgz
  42. if [ $? = 0 ]
  43. then
  44. tardir=$(tar -tf $2.tgz | head -n1 | sed 's,\/,,g')
  45. tar -xvzf $2.tgz || echo "FAILED to decompress $2.tgz"
  46. if [ "$tardir" != "$2" ]
  47. then
  48. mv $tardir $2 || echo "FAILED to move $tardir to $2"
  49. fi
  50. echo "SUCCESSFULLY downloaded $2"
  51. else
  52. echo "FAILED to download $1/$2.tgz"
  53. fi
  54. }
  55. # download and build libsng-ss7
  56. fullname="$LIBSNG_ISDN_NAME.$arch"
  57. if [ -d $fullname ]
  58. then
  59. echo "skipping isdn download since $fullname directory already exists ... remove if you want this step to be performed"
  60. else
  61. download $LIBSNG_ISDN_URL $fullname
  62. fi
  63. cd $LIBSNG_ISDN_DIR
  64. make DESTDIR=$INSTALLPREFIX install || echo "Failed to build libsng-isdn"
  65. cd ..
  66. # download and build libsng-ss7
  67. fullname="$LIBSNG_SS7_NAME.$arch"
  68. if [ -d $fullname ]
  69. then
  70. echo "skipping ss7 download since $fullname directory already exists ... remove if you want this step to be performed"
  71. else
  72. download $LIBSNG_SS7_URL $fullname
  73. fi
  74. cd $LIBSNG_SS7_DIR
  75. make DESTDIR=$INSTALLPREFIX install || echo "Failed to build libsng-ss7"
  76. cd ..
  77. if [ ! -d $INSTALLPREFIX ]
  78. then
  79. mkdir -p $INSTALLPREFIX || exit 1
  80. fi
  81. if [ ! -d $INSTALLPREFIX/bin-releases ]
  82. then
  83. mkdir -p $INSTALLPREFIX/bin-releases || exit 1
  84. fi
  85. # attempt to compile freetdm
  86. echo "Build freetdm and mod_freetdm now..."
  87. make all mod_freetdm || exit 1
  88. echo "freetdm built OK"
  89. major=$(echo "$VERSION" | cut -d. -f1)
  90. minor=$(echo "$VERSION" | cut -d. -f2)
  91. micro=$(echo "$VERSION" | cut -d. -f3)
  92. release="freetdm-$VERSION"
  93. # ABI compatibility check
  94. if [ -x /usr/local/bin/ftdm_abi_check.py ]; then
  95. /usr/local/bin/ftdm_abi_check.py --release_path=$(pwd) --archive_path=$INSTALLPREFIX/bin-releases --version=$VERSION
  96. if [ $? -ne 0 ]; then
  97. echo "ABI compabitility test failed, not creating release. Either increment the major version number or fix the interface."
  98. exit 1
  99. fi
  100. else
  101. echo -ne "\n\nWARNING: /usr/local/bin/ftdm_abi_check.py not found, skipping ABI compatibility test\n\n"
  102. fi
  103. if [ $NODOCS = "NO" ]
  104. then
  105. make dox || exit 1
  106. fi
  107. echo "Creating $release ($major.$minor.$micro) at $INSTALLPREFIX/$release (directory will be removed if exists already) ... "
  108. mkdir -p $INSTALLPREFIX/$release $INSTALLPREFIX/bin-releases/$major/$release
  109. cp -r ./* $INSTALLPREFIX/bin-releases/$major/$release
  110. cp -r ./.libs $INSTALLPREFIX/bin-releases/$major/$release
  111. make clean
  112. make mod_freetdm-clean
  113. cp -r ./* $INSTALLPREFIX/$release
  114. # copy ABI compatibility reports to release
  115. if [ -d compat_reports ]; then
  116. mv ./compat_reports $INSTALLPREFIX/$release
  117. fi
  118. rm -rf $INSTALLPREFIX/$release/{$LIBSNG_ISDN_DIR,$LIBSNG_SS7_DIR,*.tgz}
  119. rm -rf $INSTALLPREFIX/bin-releases/$major/$release/{$LIBSNG_ISDN_DIR,$LIBSNG_SS7_DIR,*.tgz}
  120. tar -C $INSTALLPREFIX -czf $INSTALLPREFIX/$release.tar.gz $release/