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