dch-generate.sh 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. #!/bin/bash
  2. # use: ./debian/dch-generate.sh > ./debian/changelog
  3. # desc: quick and dirty (emphasis on dirty) debian changelog generator for SoftEtherVPN
  4. #
  5. # Copyright (c) 2014 Sahal Ansari ([email protected])
  6. #
  7. # This program is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU General Public License
  9. # version 2 as published by the Free Software Foundation.
  10. # warning: the following file has CRLF line endings (Windows)
  11. # the location of the following file is relative to this script
  12. cbuild="../src/CurrentBuild.txt"
  13. # required for debian packaging
  14. package="softether-vpn"
  15. status="UNRELEASED"
  16. # timezone in +hh:mm from UTC (+9 UTC)
  17. tzone="+09:00"
  18. # static changelog entry
  19. entry="* See: http://www.softether.org/5-download/history"
  20. # are you a debian maintainer?
  21. if [ -z "$DEBFULLNAME" ]; then
  22. DEBFULLNAME="John Q. Sample"
  23. fi
  24. if [ -z "$DEBEMAIL" ]; then
  25. DEBEMAIL="[email protected]"
  26. fi
  27. # where am i located? in $DIR, of course!
  28. DIR="$( cd "$( dirname "$0" )" && pwd )"
  29. cd "$DIR"
  30. # check if debian/changelog exists, check if $cbuild exists
  31. if [ ! -e ./changelog ]; then
  32. echo "Am I in debian/? I can't find changelog"
  33. exit 1
  34. fi
  35. if [ ! -e "$cbuild" ]; then
  36. echo "This doesn't look like the SoftEtherVPN source tree. I can't find ""$cbuild"
  37. exit 1
  38. fi
  39. # version and date info from $cbuild are put into array ${cbuildarray[@]}
  40. # build "${cbuildarray[0]}", major version "${cbuildarray[1]}",
  41. # release type "${cbuildarray[2]}", and date "${cbuildarray[3]}"
  42. while IFS=$'\r\n' read -r line_data; do
  43. cbuildarray[i]="${line_data##*[A-Z]\ }"
  44. ((++i))
  45. done < "$cbuild"
  46. # "${cbuildarray[1]}" is converted from "406" to "4.06" using GNU awk
  47. majorversion="$(echo "${cbuildarray[1]}" | awk '{sub(/[0-9]/,"&.",$0);print $0}')"
  48. # "${cbuildarray[3]}" is split and the second half is converted from
  49. # from "131655" to "13:16:55" using GNU awk then it's put back together
  50. # (like humpty dumpty) and sent to GNU date for conversion to UTC
  51. time="$(echo "${cbuildarray[3]#*_}" | awk '{gsub(/[0-9][0-9]/,"&:",$0);print $0}')"
  52. date="$(date -R --date="$(echo "${cbuildarray[3]%_*}"" ""${time%?}""$tzone")")"
  53. # print the new debian changelog
  54. echo "$package"" (""$majorversion"".""${cbuildarray[0]}""-""${cbuildarray[2]}"") ""$status""; urgency=low"
  55. echo
  56. echo " ""$entry"
  57. echo
  58. echo " --"" ""$DEBFULLNAME"" <""$DEBEMAIL""> ""$date"
  59. exit 0