create_hmc_rpm.sh 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. #!/bin/bash
  2. #
  3. #/*
  4. # * Licensed to the Apache Software Foundation (ASF) under one
  5. # * or more contributor license agreements. See the NOTICE file
  6. # * distributed with this work for additional information
  7. # * regarding copyright ownership. The ASF licenses this file
  8. # * to you under the Apache License, Version 2.0 (the
  9. # * "License"); you may not use this file except in compliance
  10. # * with the License. You may obtain a copy of the License at
  11. # *
  12. # * http://www.apache.org/licenses/LICENSE-2.0
  13. # *
  14. # * Unless required by applicable law or agreed to in writing, software
  15. # * distributed under the License is distributed on an "AS IS" BASIS,
  16. # * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  17. # * See the License for the specific language governing permissions and
  18. # * limitations under the License.
  19. # */
  20. CUR_DIR=`pwd`
  21. BASEDIR="$( cd "$( dirname "$0" )" && pwd )"
  22. if [[ -z "${BUILD_DIR}" ]]; then
  23. BUILD_DIR="${BASEDIR}/build/"
  24. fi
  25. if [[ -z "${VERSION}" ]]; then
  26. VERSION="1.0.0"
  27. fi
  28. if [[ -z "${RELEASE}" ]]; then
  29. RELEASE="0"
  30. fi
  31. rm -rf ${BUILD_DIR}/*
  32. PKG_NAME="ambari"
  33. HMC_DIR="${BUILD_DIR}/${PKG_NAME}-$VERSION/"
  34. mkdir -p "${HMC_DIR}"
  35. cp -rf ${BASEDIR}/../../css ${HMC_DIR}
  36. cp -rf ${BASEDIR}/../../db ${HMC_DIR}
  37. cp -rf ${BASEDIR}/../../ShellScripts ${HMC_DIR}
  38. cp -rf ${BASEDIR}/../../html ${HMC_DIR}
  39. cp -rf ${BASEDIR}/../../images ${HMC_DIR}
  40. cp -rf ${BASEDIR}/../../licenses ${HMC_DIR}
  41. cp -rf ${BASEDIR}/../../js ${HMC_DIR}
  42. #cp -rf ${BASEDIR}/../../src/php ${HMC_DIR}
  43. #cp -rf ${BASEDIR}/../../src/puppet ${HMC_DIR}
  44. cp -rf ${BASEDIR}/../../puppet ${HMC_DIR}
  45. cp -rf ${BASEDIR}/../../php ${HMC_DIR}
  46. cp -rf ${BASEDIR}/../../conf ${HMC_DIR}
  47. cp -rf ${BASEDIR}/../../fonts ${HMC_DIR}
  48. cp -f ${BASEDIR}/../../fileCombinator.php ${HMC_DIR}
  49. cp -f ${BASEDIR}/../../../NOTICE.txt ${HMC_DIR}/licenses
  50. TAR_DEST="${BUILD_DIR}/${PKG_NAME}-$VERSION.tar.gz"
  51. cd ${BUILD_DIR};
  52. tar -zcf "${TAR_DEST}" "${PKG_NAME}-$VERSION/"
  53. RPM_BUILDDIR=${BUILD_DIR}/rpmbuild/
  54. mkdir -p ${RPM_BUILDDIR}
  55. mkdir -p ${RPM_BUILDDIR}/SOURCES/
  56. mkdir -p ${RPM_BUILDDIR}/SPECS/
  57. mkdir -p ${RPM_BUILDDIR}/BUILD/
  58. mkdir -p ${RPM_BUILDDIR}/RPMS/
  59. mkdir -p ${RPM_BUILDDIR}/SRPMS/
  60. cp -f ${BASEDIR}/SPECS/${PKG_NAME}.spec ${RPM_BUILDDIR}/SPECS/
  61. cp -f ${TAR_DEST} ${RPM_BUILDDIR}/SOURCES/
  62. cp -f ${BASEDIR}/SOURCES/${PKG_NAME}.init.in ${RPM_BUILDDIR}/SOURCES/
  63. cp -f ${BASEDIR}/SOURCES/${PKG_NAME}-agent.init.in ${RPM_BUILDDIR}/SOURCES/
  64. cd ${RPM_BUILDDIR}
  65. cmd="rpmbuild --define \"_topdir ${RPM_BUILDDIR}\" \
  66. -ba ${RPM_BUILDDIR}/SPECS/${PKG_NAME}.spec"
  67. echo $cmd
  68. eval $cmd
  69. ret=$?
  70. if [[ "$ret" != "0" ]]; then
  71. echo "Error: rpmbuild failed, error=$ret"
  72. exit 1
  73. fi
  74. cd ${CUR_DIR}
  75. RPM_DEST=`find ${RPM_BUILDDIR}/{SRPMS,RPMS} -name *.noarch.rpm`
  76. if [[ -z "${RPM_DEST}" ]]; then
  77. echo "Error: RPM_DEST dir is empty"
  78. exit 1
  79. fi
  80. exit 0