test_kernel_git 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/sh
  2. set -e
  3. GIT_URL=git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
  4. CONF_FILE=build_tools/git_test.conf
  5. usage() {
  6. me=`basename $0`
  7. echo "$me: test building DAHDI vs. kernel from git"
  8. echo "Usage:"
  9. echo " $me checkout <kerneldir> Pull a kernel version into <kerneldir>"
  10. echo " $me update Update (pull) the kernel tree."
  11. echo " $me setver <kernel_ver> Set the kernel version"
  12. echo " $me versions Print available versions"
  13. echo " $me version Print current (kernel) version"
  14. echo " $me version_driver Print the version of DAHDI"
  15. echo " $me build Test-build"
  16. echo " $me git <git command> Run <git command>"
  17. echo ""
  18. echo " $me versions [pattern] List available versions."
  19. }
  20. # Set a variable in $CONF_FILE
  21. # The format of CONF_FILE is assumed to be:
  22. # VAR=value
  23. # in shell syntax. "value" may be quoted.
  24. # "value should not contain a '|' character.
  25. set_var() {
  26. var="$1"
  27. val="$2"
  28. if grep -q "^$var=" $CONF_FILE 2>/dev/null; then
  29. sed -i -e "s|^$var=.*|$var=\"$val\"|" $CONF_FILE
  30. else
  31. echo "$var=\"$val\"" >>$CONF_FILE
  32. fi
  33. }
  34. if [ -r "$CONF_FILE" ]; then . "$CONF_FILE"; fi
  35. if echo "$CONF_FILE" | grep -qv '^/'; then
  36. # make CONF_FILE an absolute path:
  37. CONF_FILE="$PWD/$CONF_FILE"
  38. fi
  39. command="$1"
  40. case "$command" in
  41. checkout)
  42. kernel_dir="$2"
  43. cd "$kernel_dir"
  44. git clone $GIT_URL
  45. set_var kernel_dir "$kernel_dir/linux-2.6"
  46. ;;
  47. update)
  48. cd "$kernel_dir"
  49. git pull
  50. ;;
  51. git)
  52. cd "$kernel_dir"
  53. shift
  54. git "$@"
  55. ;;
  56. versions)
  57. cd "$kernel_dir"
  58. git tag -l $2 | cut -c2-
  59. ;;
  60. version)
  61. cd "$kernel_dir"
  62. echo "Configured: $kernel_ver"
  63. echo -n "Actual: "
  64. git describe | cut -c2-
  65. ;;
  66. version_driver)
  67. version_h=include/dahdi/version.h
  68. make $version_h >/dev/null
  69. awk -F'"' '/DAHDI_VERSION/{print $2}' $version_h
  70. ;;
  71. setver)
  72. kernel_ver="$2"
  73. tag="v$kernel_ver"
  74. cd "$kernel_dir"
  75. git-reset --hard "$tag"
  76. make distclean
  77. make defconfig modules_prepare
  78. set_var kernel_ver "$kernel_ver"
  79. ;;
  80. test|build)
  81. # you can pass extra parameters to the make command in
  82. # two ways:
  83. # 1. Set the value of MAKE_PARAMS in git_test.conf .
  84. # 2. Any extra command-line parameter.
  85. shift
  86. make KSRC="$kernel_dir" KVERS=$kernel_ver $MAKE_PARAMS "$@"
  87. ;;
  88. *)
  89. echo "$0: no such command $command. Aborting."
  90. usage
  91. exit 1
  92. ;;
  93. esac