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.

130 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. RELEASE_DIR="skulls-x230-${version}"
  92. rm -rf "$RELEASE_DIR"
  93. mkdir -p "$RELEASE_DIR"
  94. # copy-in the ROM
  95. cp "${RELEASE_IMAGE}" "$RELEASE_DIR"
  96. RELEASE_IMAGE_FILE=$(basename "${RELEASE_IMAGE}")
  97. sha256sum ${RELEASE_DIR}/${RELEASE_IMAGE_FILE} > "${RELEASE_DIR}/${RELEASE_IMAGE_FILE}.sha256"
  98. # copy in device independent stuff
  99. cp ../SOURCE.md "$RELEASE_DIR"
  100. # copy in x230 stuff
  101. cp -a README.md NEWS util LICENSE* skulls_common.sh \
  102. x230_before_first_install.sh x230_skulls.sh x230_heads.sh \
  103. external_install_bottom.sh external_install_top.sh \
  104. upgrade.sh \
  105. "$RELEASE_DIR"
  106. tar -cJf "$RELEASE_DIR".tar.xz "$RELEASE_DIR"
  107. rm -rf "$RELEASE_DIR"
  108. git commit -a -m "update to ${version}"
  109. git tag -s "${version}" -m "skulls-x230 ${version}"
  110. sha256sum "$RELEASE_DIR".tar.xz > "$RELEASE_DIR".tar.xz.sha256
  111. sha512sum "$RELEASE_DIR".tar.xz > "$RELEASE_DIR".tar.xz.sha512
  112. gpg -b -a "$RELEASE_DIR".tar.xz