make-specfile 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #! /bin/bash
  2. #
  3. # bin/make-specfile
  4. # Part of ComixCursors, a desktop cursor theme.
  5. #
  6. # Copyright © 2010–2013 Ben Finney <ben+opendesktop@benfinney.id.au>
  7. # Copyright © 2010–2013 Jens Luetkens <j.luetkens@limitland.de>
  8. #
  9. # This work is free software: you can redistribute it and/or modify it
  10. # under the terms of the GNU General Public License as published by
  11. # the Free Software Foundation, either version 3 of the License, or
  12. # (at your option) any later version.
  13. #
  14. # This work is distributed in the hope that it will be useful, but
  15. # WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. # General Public License for more details.
  18. #
  19. # You should have received a copy of the GNU General Public License
  20. # along with this work. If not, see <http://www.gnu.org/licenses/>.
  21. # Generate the RPM spec file.
  22. bindir="$(dirname $0)"
  23. # argument processing and usage
  24. function show_usage_message {
  25. cat <<_EOT_
  26. Usage: $0 [option]
  27. Generate the ComixCursors RPM spec file.
  28. Uses the environment variables PACKAGENAME and SUMMARY to determine
  29. the parameters of the spec file.
  30. Options:
  31. -h: Display this help text, then exit.
  32. _EOT_
  33. }
  34. while getopts ":uh" opt ; do
  35. case $opt in
  36. h)
  37. show_usage_message
  38. exit
  39. ;;
  40. *)
  41. printf "Unexpected option: -%s\n" "$OPTARG" >&2
  42. show_usage_message
  43. exit 2
  44. ;;
  45. esac
  46. done
  47. # start here
  48. packagename="$PACKAGENAME"
  49. version=$("${bindir}"/current-package-version)
  50. summary="$SUMMARY"
  51. specfile_template="ComixCursors.spec.in"
  52. specfile_changelog="specfile-changelog"
  53. specfile="${packagename}.spec"
  54. sed \
  55. -e "s/PACKAGENAME/${packagename}/g" \
  56. -e "s/VERSION/${version}/g" \
  57. -e "s/SUMMARY/${summary}/g" \
  58. < "$specfile_template" > "${specfile}"
  59. cat "${specfile_changelog}" >> "${specfile}"