rpmbuild.sh 853 B

12345678910111213141516171819202122232425262728293031323334
  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. tar czf $BUILD/buildroot/SOURCES/${APP_NAME}-$VERSION.tgz * .[!.]*
  17. sed -e "s/%VERSION%/$VERSION/g" ${SPEC_FILE}.in > ${SPEC_FILE}
  18. sed -i "s/%APP_NAME%/$APP_NAME/g" ${SPEC_FILE}
  19. sed -i "s/%$APP_NAME%/$APP_NAME/g" ${SPEC_FILE}
  20. rpmbuild -bb ${SPEC_FILE} --define "_topdir $BUILD/buildroot/"
  21. rm -rf ./dist
  22. mkdir ./dist
  23. cp -rf $BUILD/buildroot/RPMS/* ./dist
  24. rm -rf $BUILD