You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.3 KiB

8 years ago
  1. #!/usr/bin/env bash
  2. set -e
  3. show_help()
  4. {
  5. echo -e "`basename $0` [option] [argument]"
  6. echo
  7. echo -e "Options:"
  8. echo -e " -h show this help."
  9. echo -e " -v with argument version (2.6.0 by default)."
  10. echo -e " -f with argument format (tar.xz by default) used by git archive."
  11. echo
  12. echo -e "Examples:"
  13. echo -e " to build base on version \`2.4.1' with format \`tar.xz', run:"
  14. echo -e " `basename $0` -f tar.xz -v 2.4.1"
  15. }
  16. while getopts "hv:f:" opt
  17. do
  18. case ${opt} in
  19. h)
  20. show_help
  21. exit 0
  22. ;;
  23. v)
  24. if [ "${OPTARG}" = v* ]; then
  25. version=${OPTARG#"v"}
  26. else
  27. version=${OPTARG}
  28. fi
  29. ;;
  30. f)
  31. format=${OPTARG}
  32. ;;
  33. *)
  34. exit 1
  35. ;;
  36. esac
  37. done
  38. : ${version:=2.6.0}
  39. : ${format:=tar.gz}
  40. name="shadowsocks-libev"
  41. spec_name="shadowsocks-libev.spec"
  42. pushd `git rev-parse --show-toplevel`
  43. git archive "v${version}" --format="${format}" --prefix="${name}-${version}/" -o rpm/SOURCES/"${name}-${version}.${format}"
  44. pushd rpm
  45. sed -e "s/^\(Version: \).*$/\1${version}/" \
  46. -e "s/^\(Source0: \).*$/\1${name}-${version}.${format}/" \
  47. SPECS/"${spec_name}".in > SPECS/"${spec_name}"
  48. rpmbuild -bb SPECS/"${spec_name}" --define "%_topdir `pwd`"