| #!/bin/bash |
| |
| function check_program { |
| prog=$1 |
| |
| if ! type $prog >& /dev/null ; then |
| echo "Can't find the $prog script in the search path." |
| echo "Please copy it from the xfstests-bld directory" |
| echo "to a local bin directory." |
| exit 1 |
| fi |
| } |
| |
| check_program kbuild |
| check_program install-kconfig |
| |
| function add_config() { |
| set -vx |
| BLD_DIR=$($KBUILD --get-build-dir) |
| if test -z "$BLD_DIR" ; then |
| echo "Can't find kernel build directory" |
| exit 1 |
| fi |
| if ! test -d "$BLD_DIR" ; then |
| echo "Build directory $BLD_DIR does not exist" |
| exit 1 |
| fi |
| |
| if test -f "$BLD_DIR/.config" ; then |
| cp "$BLD_DIR/.config" /tmp/config-save.$$ |
| fi |
| |
| DEFCONFIG=$(install-kconfig $INSTALL_KCONFIG_OPTS $INSTALL_KCONFIG_OPTS \ |
| --get-config-fn) |
| if test -z "$DEFCONFIG" ; then |
| echo "Can't find defconfig file" |
| exit 1 |
| fi |
| if ! test -f "$DEFCONFIG" ; then |
| echo "Defocnfig file $DEFCONFIG does not exist" |
| exit 1 |
| fi |
| |
| cp "$DEFCONFIG" "$BLD_DIR/.config" |
| cat "$ADD_FILE" >> "$BLD_DIR/.config" |
| $KBUILD olddefconfig >& /dev/null |
| $KBUILD savedefconfig >& /dev/null |
| cp "$BLD_DIR/defconfig" "$DEFCONFIG" |
| } |
| |
| KBUILD=kbuild |
| INSTALL_KCONFIG_OPTS= |
| |
| while [ "$1" != "" ]; |
| do |
| case "$1" in |
| --use-generic) |
| INSTALL_KCONFIG_OPTS=--generic |
| ;; |
| --perf) |
| INSTALL_KCONFIG_OPTS=--perf |
| ;; |
| -*) |
| echo "unknown option: $1" |
| exit 1 |
| ;; |
| *) |
| break |
| ;; |
| esac |
| shift |
| done |
| |
| ADD_FILE=$1 |
| |
| if test -z "$ADD_FILE" ; then |
| echo "Usage: $0 <add-file>" |
| exit 1 |
| fi |
| |
| add_config |
| |
| exit 0 |