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.

132 lines
3.0 KiB

  1. #!/bin/bash
  2. # SPDX-License-Identifier: GPL-3.0+
  3. # Copyright (C) 2018, Martin Kepplinger <martink@posteo.de>
  4. #
  5. # Script to build release-archives with. This requires a checkout from git.
  6. # WARNING: This script is very dangerous! It may delete any untracked files.
  7. set -e
  8. have_version=0
  9. have_image=0
  10. usage()
  11. {
  12. echo "Usage: $0 -v version -i release_image"
  13. }
  14. args=$(getopt -o v:i: -- "$@")
  15. if [ $? -ne 0 ] ; then
  16. usage
  17. exit 1
  18. fi
  19. eval set -- "$args"
  20. while [ $# -gt 0 ]
  21. do
  22. case "$1" in
  23. -i)
  24. RELEASE_IMAGE=$2
  25. have_image=1
  26. shift
  27. ;;
  28. -v)
  29. version=$2
  30. have_version=1
  31. shift
  32. ;;
  33. --)
  34. shift
  35. break
  36. ;;
  37. *)
  38. echo "Invalid option: $1"
  39. usage
  40. exit 1
  41. ;;
  42. esac
  43. shift
  44. done
  45. if [ ! "$have_image" -gt 0 ] ; then
  46. echo "please provide a release image"
  47. usage
  48. exit 1
  49. fi
  50. # Do we have a desired version number?
  51. if [ "$have_version" -gt 0 ] ; then
  52. echo "trying to build version $version"
  53. else
  54. echo "please specify a version"
  55. usage
  56. exit 1
  57. fi
  58. # Version number sanity check
  59. if grep "${version}" NEWS
  60. then
  61. echo "configurations seems ok"
  62. else
  63. echo "please check the NEWS file"
  64. exit 1
  65. fi
  66. # Check that we are on master
  67. branch=$(git rev-parse --abbrev-ref HEAD)
  68. echo "we are on branch $branch"
  69. if [ ! "${branch}" = "master" ] ; then
  70. echo "you don't seem to be on the master branch"
  71. exit 1
  72. fi
  73. if git diff-index --quiet HEAD --; then
  74. # no changes
  75. echo "there are no uncommitted changes (version bump)"
  76. exit 1
  77. fi
  78. echo "======================================================"
  79. echo " are you fine with the following version bump?"
  80. echo "======================================================"
  81. git diff
  82. echo "======================================================"
  83. read -r -p " Press enter to continue"
  84. echo "======================================================"
  85. filesize=$(wc -c <"${RELEASE_IMAGE}")
  86. reference_filesize=4194304
  87. if [ ! "$filesize" -eq "$reference_filesize" ] ; then
  88. echo "filesize of release image is wrong"
  89. exit 1
  90. fi
  91. # copy-in the ROM
  92. cp "${RELEASE_IMAGE}" .
  93. RELEASE_IMAGE_FILE=$(basename "${RELEASE_IMAGE}")
  94. sha256sum ${RELEASE_IMAGE_FILE} > "${RELEASE_IMAGE_FILE}.sha256"
  95. # copy-in device independent stuff
  96. cp ../SOURCE.md sources/
  97. tar -cJf skulls-x230-"${version}".tar.xz \
  98. README.md \
  99. NEWS \
  100. util \
  101. LICENSE* \
  102. x230_before_first_install.sh \
  103. x230_skulls.sh \
  104. x230_heads.sh \
  105. external_install_bottom.sh \
  106. external_install_top.sh \
  107. sources \
  108. "${RELEASE_IMAGE_FILE}" \
  109. "${RELEASE_IMAGE_FILE}.sha256"
  110. rm "${RELEASE_IMAGE_FILE}"
  111. rm "${RELEASE_IMAGE_FILE}.sha256"
  112. rm sources/SOURCE.md
  113. git commit -a -m "update to ${version}"
  114. git tag -s "${version}" -m "skulls-x230 ${version}"
  115. sha256sum skulls-x230-"${version}".tar.xz > skulls-x230-"${version}".tar.xz.sha256
  116. sha512sum skulls-x230-"${version}".tar.xz > skulls-x230-"${version}".tar.xz.sha512
  117. gpg -b -a skulls-x230-"${version}".tar.xz