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.

65 lines
1.4 KiB

9 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.4.1 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. get_att_val()
  39. {
  40. att=$1
  41. val=$2
  42. if [ -z $(eval echo \$$att) ]; then
  43. eval $att=$val
  44. fi
  45. }
  46. get_att_val version "2.4.1"
  47. get_att_val format "tar.xz"
  48. name="shadowsocks-libev"
  49. spec_name="shadowsocks-libev.spec"
  50. pushd `git rev-parse --show-toplevel`
  51. git archive v${version} --format=${format} --prefix=${name}-${version}/ -o rpm/SOURCES/${name}-${version}.${format}
  52. pushd rpm
  53. sed -i -e "s/^\(Version: \).*$/\1${version}/" \
  54. -e "s/^\(Source0: \).*$/\1${name}-${version}.${format}/" \
  55. SPECS/${spec_name}
  56. rpmbuild -bb SPECS/${spec_name} --define "%_topdir `pwd`"