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.

149 lines
3.6 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. have_image_2=0
  11. usage()
  12. {
  13. echo "Usage: $0 -v version -i release_image -f second_release_image"
  14. }
  15. args=$(getopt -o v:i:f: -- "$@")
  16. if [ $? -ne 0 ] ; then
  17. usage
  18. exit 1
  19. fi
  20. eval set -- "$args"
  21. while [ $# -gt 0 ]
  22. do
  23. case "$1" in
  24. -i)
  25. RELEASE_IMAGE=$2
  26. have_image=1
  27. shift
  28. ;;
  29. -f)
  30. RELEASE_IMAGE_2=$2
  31. have_image_2=1
  32. shift
  33. ;;
  34. -v)
  35. version=$2
  36. have_version=1
  37. shift
  38. ;;
  39. --)
  40. shift
  41. break
  42. ;;
  43. *)
  44. echo "Invalid option: $1"
  45. usage
  46. exit 1
  47. ;;
  48. esac
  49. shift
  50. done
  51. if [ ! "$have_image" -gt 0 ] ; then
  52. echo "we currently need 2 release images"
  53. usage
  54. exit 1
  55. fi
  56. if [ ! "$have_image_2" -gt 0 ] ; then
  57. echo "we currently need 2 release images"
  58. usage
  59. exit 1
  60. fi
  61. # Do we have a desired version number?
  62. if [ "$have_version" -gt 0 ] ; then
  63. echo "trying to build version $version"
  64. else
  65. echo "please specify a version"
  66. usage
  67. exit 1
  68. fi
  69. # Version number sanity check
  70. if grep "${version}" NEWS
  71. then
  72. echo "configurations seems ok"
  73. else
  74. echo "please check the NEWS file"
  75. exit 1
  76. fi
  77. # Check that we are on master
  78. branch=$(git rev-parse --abbrev-ref HEAD)
  79. echo "we are on branch $branch"
  80. if [ ! "${branch}" = "master" ] ; then
  81. echo "you don't seem to be on the master branch"
  82. exit 1
  83. fi
  84. if git diff-index --quiet HEAD --; then
  85. # no changes
  86. echo "there are no uncommitted changes (version bump)"
  87. exit 1
  88. fi
  89. echo "======================================================"
  90. echo " are you fine with the following version bump?"
  91. echo "======================================================"
  92. git diff
  93. echo "======================================================"
  94. read -r -p " Press enter to continue"
  95. echo "======================================================"
  96. filesize=$(wc -c <"${RELEASE_IMAGE}")
  97. reference_filesize=4194304
  98. if [ ! "$filesize" -eq "$reference_filesize" ] ; then
  99. echo "filesize of release image is wrong"
  100. exit 1
  101. fi
  102. filesize=$(wc -c <"${RELEASE_IMAGE_2}")
  103. reference_filesize=4194304
  104. if [ ! "$filesize" -eq "$reference_filesize" ] ; then
  105. echo "filesize of release image is wrong"
  106. exit 1
  107. fi
  108. RELEASE_DIR="skulls-x230-${version}"
  109. rm -rf "$RELEASE_DIR"
  110. mkdir -p "$RELEASE_DIR"
  111. # copy-in the ROMs
  112. cp "${RELEASE_IMAGE}" "$RELEASE_DIR"
  113. cp "${RELEASE_IMAGE_2}" "$RELEASE_DIR"
  114. RELEASE_IMAGE_FILE=$(basename "${RELEASE_IMAGE}")
  115. sha256sum ${RELEASE_DIR}/${RELEASE_IMAGE_FILE} > "${RELEASE_DIR}/${RELEASE_IMAGE_FILE}.sha256"
  116. RELEASE_IMAGE_FILE_2=$(basename "${RELEASE_IMAGE_2}")
  117. sha256sum ${RELEASE_DIR}/${RELEASE_IMAGE_FILE_2} > "${RELEASE_DIR}/${RELEASE_IMAGE_FILE_2}.sha256"
  118. # copy in device independent stuff
  119. cp ../SOURCE.md "$RELEASE_DIR"
  120. # copy in x230 stuff
  121. cp -a README.md NEWS util LICENSE* functions.sh \
  122. x230_skulls.sh x230_heads.sh \
  123. external_install_bottom.sh external_install_top.sh \
  124. "$RELEASE_DIR"
  125. tar -cJf "$RELEASE_DIR".tar.xz "$RELEASE_DIR"
  126. rm -rf "$RELEASE_DIR"
  127. git commit -a -m "update to ${version}"
  128. git tag -s "${version}" -m "skulls-x230 ${version}"
  129. sha256sum "$RELEASE_DIR".tar.xz > "$RELEASE_DIR".tar.xz.sha256
  130. sha512sum "$RELEASE_DIR".tar.xz > "$RELEASE_DIR".tar.xz.sha512
  131. gpg -b -a "$RELEASE_DIR".tar.xz