1
0
mirror of https://github.com/dynup/kpatch synced 2025-04-11 03:31:20 +00:00

Merge pull request from ryanmiao/master

Add -c|--config option to kpatch-build
This commit is contained in:
Seth Jennings 2014-03-21 11:08:24 -05:00
commit 95b76492e4

View File

@ -93,27 +93,32 @@ find_tools_dir() {
} }
usage() { usage() {
echo "usage: $0 [-s|--sourcedir <dir>] <patch file>" >&2 echo "usage: $0 [options] <patch file>" >&2
echo " -h, --help Show this help message" >&2
echo " -s, --sourcedir Specify kernel source directory" >&2
echo " -c, --config Specify kernel config file" >&2
} }
while [[ "$#" -gt 0 ]]; do PARSED_OPT_ARRAY=($(getopt -u -n "$0" -o hs:c: -l "help,sourcedir:,config:" -- "$@")) || die "getopt failed"
case "$1" in
for index in ${!PARSED_OPT_ARRAY[*]}; do
case "${PARSED_OPT_ARRAY[$index]}" in
-h|--help) -h|--help)
usage usage
exit 0 exit 0
;; ;;
-s|--sourcedir) -s|--sourcedir)
shift USERSRCDIR="$(readlink -f ${PARSED_OPT_ARRAY[$(( $index+1 ))]})"
[[ "$#" -eq 0 ]] && die "no source dir specified" [[ ! -d "$USERSRCDIR" ]] && die "source dir $USERSRCDIR not found"
USERSRCDIR="$(readlink -f $1)"
[[ ! -d "$USERSRCDIR" ]] && die "source dir $1 not found"
shift
;; ;;
*) -c|--config)
[[ -n "$PATCHFILE" ]] && die "bad argument: $1" CONFIGFILE="$(readlink -f ${PARSED_OPT_ARRAY[$(( $index+1 ))]})"
PATCHFILE="$(readlink -f $1)" [[ ! -f "$CONFIGFILE" ]] && die "config file $CONFIGFILE not found"
[[ ! -f "$PATCHFILE" ]] && die "patch file $1 not found" ;;
shift --)
PATCHFILE="$(readlink -f ${PARSED_OPT_ARRAY[$(( $index+1 ))]})"
[[ ! -f "$PATCHFILE" ]] && die "patch file $PATCHFILE not found"
break
;; ;;
esac esac
done done
@ -145,7 +150,11 @@ if [[ -d "$SRCDIR" ]] || [[ -n "$USERSRCDIR" ]]; then
mkdir -p "$CACHEDIR" mkdir -p "$CACHEDIR"
mkdir -p "$OBJDIR" "$OBJDIR2" mkdir -p "$OBJDIR" "$OBJDIR2"
if [[ -n "$CONFIGFILE" ]]; then
cp "$CONFIGFILE" "$OBJDIR/.config" || die "config file is missing"
else
cp "$USERSRCDIR/.config" "$OBJDIR" || die "source dir is missing a .config file" cp "$USERSRCDIR/.config" "$OBJDIR" || die "source dir is missing a .config file"
fi
echo "Copying source to $SRCDIR" echo "Copying source to $SRCDIR"
cp -a "$USERSRCDIR" "$SRCDIR" || die "copy failed" cp -a "$USERSRCDIR" "$SRCDIR" || die "copy failed"