update.sh 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #!/bin/bash
  2. # Script to prepare update for new kernel release
  3. set -e
  4. set -o pipefail
  5. LINUX_REPOSITORY=linux
  6. while getopts "R:t:b:v:r:h" OPTION; do
  7. case $OPTION in
  8. R)
  9. LINUX_REPOSITORY=$OPTARG
  10. ;;
  11. t)
  12. LINUX_TAG=$OPTARG
  13. ;;
  14. b)
  15. LINUX_BASE=$OPTARG
  16. ;;
  17. v)
  18. LINUX_VERSION=$OPTARG
  19. ;;
  20. r)
  21. LINUX_PACKAGE_RELEASE=$OPTARG
  22. ;;
  23. h)
  24. echo "update.sh -rtbh"
  25. echo " -R path to Linux Git repository"
  26. echo " -t tag in Linux Git repository to pick"
  27. echo " -b manual basis for this kernel"
  28. echo " -v manual version for this kernel"
  29. echo " -r manual release version for this kernel"
  30. echo " -h this help message"
  31. exit 1
  32. ;;
  33. *)
  34. echo "Incorrect options provided"
  35. exit 1
  36. ;;
  37. esac
  38. done
  39. # Fetch from Git repository
  40. echo "Fetching $LINUX_TAG from Linux Git repository..."
  41. git --git-dir $LINUX_REPOSITORY/.git fetch origin --depth 1 $LINUX_TAG
  42. git --git-dir $LINUX_REPOSITORY/.git checkout FETCH_HEAD
  43. if [[ -z "$LINUX_BASE" ]]; then
  44. # Parse the Ubuntu base from which our build is derived
  45. UBUNTU_BASE=$(git --git-dir $LINUX_REPOSITORY/.git log -1 --pretty=%B | sed -n "s/^.*Ubuntu-\([0-9.-]*\).*$/\1/p")
  46. LINUX_BASE="Ubuntu $UBUNTU_BASE"
  47. fi
  48. if [[ -z "$LINUX_VERSION" ]]; then
  49. # Parse the Linux version from the Linux repository if it not provided by the user
  50. LINUX_VERSION=$(dpkg-parsechangelog -l $LINUX_REPOSITORY/debian.master/changelog --show-field Version | sed -n "s/^\([0-9.]*\).*$/\1/p")
  51. fi
  52. echo "Using Linux $LINUX_VERSION based on $LINUX_BASE."
  53. # Prepare Debian changelog
  54. sed -e "s/@KVNAME@/$LINUX_VERSION/g" -e "s/@KVMAJMIN@/$LINUX_VERSION_MAJOR.$LINUX_VERSION_MINOR/g" < debian/control.in > debian/control
  55. LINUX_VERSION_MAJOR=$(echo $LINUX_VERSION | cut -d. -f1)
  56. LINUX_VERSION_MINOR=$(echo $LINUX_VERSION | cut -d. -f2)
  57. LINUX_VERSION_PATCH=$(echo $LINUX_VERSION | cut -d. -f3)
  58. LINUX_VERSION_PATCH=${LINUX_VERSION_PATCH:-0} # Default to 0
  59. LINUX_PACKAGE_RELEASE_PREVIOUS=$(scripts/version.sh -r)
  60. # Check whether we need to increment the package release
  61. if [[ -n $LINUX_PACKAGE_RELEASE ]]; then
  62. echo "Using custom package release $LINUX_PACKAGE_RELEASE"
  63. elif [[ $LINUX_VERSION == "$(scripts/version.sh -L)" ]]; then
  64. LINUX_PACKAGE_RELEASE=$((LINUX_PACKAGE_RELEASE_PREVIOUS + 1))
  65. echo "Incrementing package release to $LINUX_PACKAGE_RELEASE"
  66. else
  67. LINUX_PACKAGE_RELEASE=1
  68. echo "New package release"
  69. fi
  70. echo "Updating Makefile..."
  71. # Update the Makefile with the proper version numbers
  72. sed -i Makefile \
  73. -e "s/^KERNEL_MAJ=[0-9]*$/KERNEL_MAJ=$LINUX_VERSION_MAJOR/" \
  74. -e "s/^KERNEL_MIN=[0-9]*$/KERNEL_MIN=$LINUX_VERSION_MINOR/" \
  75. -e "s/^KERNEL_PATCHLEVEL=[0-9]*$/KERNEL_PATCHLEVEL=$LINUX_VERSION_PATCH/" \
  76. -e "s/^KREL=[0-9]*$/KREL=1/" \
  77. -e "s/^PKGREL=[0-9]*$/PKGREL=$LINUX_PACKAGE_RELEASE/"
  78. echo "Generating entry for change log..."
  79. # Generate a changelog entry
  80. debchange -v $LINUX_VERSION-$LINUX_PACKAGE_RELEASE -D edge --force-distribution -U -M "Update to Linux $LINUX_VERSION based on $LINUX_BASE."
  81. echo "Cleaning up"
  82. rm -f debian/control