update.sh 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/bash
  2. # Script to prepare update for new kernel release
  3. set -e
  4. set -o pipefail
  5. LINUX_REPOSITORY=linux
  6. LINUX_VERSION_PREVIOUS=$(scripts/version.sh -L)
  7. while getopts "R:t:v:r:h" OPTION; do
  8. case $OPTION in
  9. R)
  10. LINUX_REPOSITORY=$OPTARG
  11. ;;
  12. t)
  13. LINUX_TAG=$OPTARG
  14. ;;
  15. v)
  16. LINUX_VERSION=$OPTARG
  17. ;;
  18. r)
  19. LINUX_PACKAGE_RELEASE=$OPTARG
  20. ;;
  21. h)
  22. echo "update.sh -Rrtvh"
  23. echo " -R path to Linux Git repository"
  24. echo " -t tag in Linux Git repository to pick"
  25. echo " -v manual version for this kernel"
  26. echo " -r manual release version for this kernel"
  27. echo " -h this help message"
  28. exit 1
  29. ;;
  30. *)
  31. echo "Incorrect options provided"
  32. exit 1
  33. ;;
  34. esac
  35. done
  36. # Fetch from Git repository
  37. echo "Fetching $LINUX_TAG from Linux Git repository..."
  38. git --git-dir $LINUX_REPOSITORY/.git fetch origin --depth 1 $LINUX_TAG
  39. git --git-dir $LINUX_REPOSITORY/.git checkout FETCH_HEAD
  40. if [[ -z "$LINUX_VERSION" ]]; then
  41. # Parse the Linux version from the Linux repository if it not provided by the user
  42. LINUX_VERSION=$(scripts/version.sh -L)
  43. fi
  44. echo "Using Linux $LINUX_VERSION."
  45. # Prepare Debian changelog
  46. sed -e "s/@KVNAME@/$LINUX_VERSION/g" -e "s/@KVMAJMIN@/$LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR/g" < debian/templates/control.in > debian/control
  47. LINUX_VERSION_MAJOR=$(echo $LINUX_VERSION | cut -d. -f1)
  48. LINUX_VERSION_MINOR=$(echo $LINUX_VERSION | cut -d. -f2)
  49. LINUX_VERSION_PATCH=$(echo $LINUX_VERSION | cut -d. -f3)
  50. LINUX_VERSION_PATCH=${LINUX_VERSION_PATCH:-0} # Default to 0
  51. LINUX_PACKAGE_RELEASE_PREVIOUS=$(scripts/version.sh -r)
  52. # Check whether we need to increment the package release
  53. if [[ -n $LINUX_PACKAGE_RELEASE ]]; then
  54. echo "Using custom package release $LINUX_PACKAGE_RELEASE"
  55. elif [[ $LINUX_VERSION == "$LINUX_VERSION_PREVIOUS" ]]; then
  56. LINUX_PACKAGE_RELEASE=$((LINUX_PACKAGE_RELEASE_PREVIOUS + 1))
  57. echo "Incrementing package release to $LINUX_PACKAGE_RELEASE"
  58. else
  59. LINUX_PACKAGE_RELEASE=1
  60. echo "New package release"
  61. fi
  62. echo "Updating crack.bundle..."
  63. wget https://kernel.ubuntu.com/~kernel-ppa/mainline/v$LINUX_VERSION/crack.bundle -O crack.bundle
  64. echo "Generating entry for change log..."
  65. # Generate a changelog entry
  66. debchange -v $LINUX_VERSION-$LINUX_PACKAGE_RELEASE -D edge --force-distribution -U -M "Update to Linux $LINUX_VERSION."
  67. echo "Cleaning up"
  68. rm -f debian/control