dch-generate.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. # note: the following file has CRLF line endings (Windows)
  11. cbuild="../src/CurrentBuild.txt"
  12. # required for debian packaging
  13. package="softether-vpn"
  14. status="UNRELEASED"
  15. # timezone in +hh:mm from GMT
  16. # assuming the orij. author is in Japan: +9 GMT
  17. tzone="+09:00"
  18. # builder name, builder email
  19. builder="John Q. Sample"
  20. email="[email protected]"
  21. # static changelog entry
  22. entry="* See: http://www.softether.org/5-download/history"
  23. # check if ./changelog exists, check if $cbuild exists
  24. if [ ! -e ./changelog ]; then
  25. /bin/echo -ne "Are you in debian/? I can't find: ./changelog\n"
  26. exit 1
  27. fi
  28. if [ ! -e $cbuild ]; then
  29. /bin/echo -ne "This doesn't look like the SoftEtherVPN source tree. I can't find: src/CurrentBuild.txt\n"
  30. exit 1
  31. fi
  32. # parse version and date -- formatted in RFC 2822 format -- from ../src/CurrentBuild.txt
  33. while IFS=$'\ ' read -r line_data; do
  34. cbuildarray[i]=$(echo "${line_data}"| sed -e s/\\r// -e s/.*\ //)
  35. ((++i))
  36. done < $cbuild
  37. #buildnumber="${cbuildarray[0]}"
  38. #majorversion="${cbuildarray[1]}"
  39. #releasetype="${cbuildarray[2]}"
  40. #unparseddate="${cbuildarray[3]}"
  41. # "${cbuildarray[1]}" needs to be converted
  42. # from "406" to "4.06"
  43. # this is really ugly and requires GNU awk (afaik)
  44. version="$(echo "$(echo "${cbuildarray[1]}" | awk '{sub(/[0-9]/,"&.",$0);print $0}' )"".""${cbuildarray[0]}""-""${cbuildarray[2]}")"
  45. # "${cbuildarray[3]}" \needs\ to be converted
  46. # from "20140321_131655" to "20140321 13:16:55+0900"
  47. # this is really really ugly and requires GNU date and GNU awk (afaik)
  48. convertformat="$(echo "$(echo "${cbuildarray[3]}" | sed s/_.*//)"" ""$(echo "${cbuildarray[3]}" | sed s/.*_// | awk '{gsub(/[0-9][0-9]/,"&:",$0);print $0}' | sed s/\:$//)")"
  49. # now we send $convertformat and $tzone to `date` and have it automagically reformat it for us
  50. date="$(date -R --date="$(echo "$convertformat""$tzone")")"
  51. # print the new debian changelog
  52. /bin/echo -ne "$package ($version) $status; urgency=low\n\n $entry\n\n -- $builder <$email> $date\n"
  53. exit 0