rpmbuild.sh 987 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #!/bin/bash
  2. set -e
  3. PROJECT_PATH=$(cd `dirname $0`; pwd)
  4. APP_NAME="${PROJECT_PATH##*/}"
  5. VERSION=`cat VERSION`
  6. make version=$VERSION
  7. SPEC_FILE=app.spec
  8. APP_SERVICE=conf/app.service
  9. SH_APP=sh/app
  10. TOOLS_ROOT=`pwd`
  11. BUILD="${TOOLS_ROOT}/build"
  12. sed -e "s/%APP_NAME%/$APP_NAME/g" ${APP_SERVICE}.in > conf/${APP_NAME}.service
  13. sed -e "s/%APP_NAME%/$APP_NAME/g" ${SH_APP}.in > ${SH_APP}
  14. mkdir -p $BUILD/buildroot/{BUILD,RPMS,S{RPMS,PECS,OURCES}}
  15. rm -f $BUILD/buildroot/SOURCES/*.tgz
  16. set +e
  17. tar -zc --warning=no-file-changed -f $BUILD/buildroot/SOURCES/${APP_NAME}-$VERSION.tgz * .[!.]*
  18. exitcode=$?
  19. if [ "$exitcode" != "1" ] && [ "$exitcode" != "0" ]; then
  20. exit $exitcode
  21. fi
  22. set -e
  23. sed -e "s/%VERSION%/$VERSION/g" ${SPEC_FILE}.in > ${SPEC_FILE}
  24. sed -i "s/%APP_NAME%/$APP_NAME/g" ${SPEC_FILE}
  25. sed -i "s/%$APP_NAME%/$APP_NAME/g" ${SPEC_FILE}
  26. rpmbuild -bb ${SPEC_FILE} --define "_topdir $BUILD/buildroot/"
  27. rm -rf ./dist
  28. mkdir ./dist
  29. cp -rf $BUILD/buildroot/RPMS/* ./dist
  30. rm -rf $BUILD