1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
|
#-*- mode: shell-script;-*-
# Debian GNU/Linux make-kpkg(1) completion.
# Copyright 2002 "Dr. Rafael Sepulveda" <drs@gnulinux.org.mx>
#
have make-kpkg &&
_make_kpkg()
{
local cur prev options paroptions special i
#check if we are in a kernel directory.
[[ -d "drivers" && -d "kernel" && -d "fs" && -d "include/linux" ]] || \
return 0
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
options='--added_modules --added-modules --added_patches --added-patches \
--append_to_version --append-to-version --arch --arch_in_name \
--arch-in-name binary build buildpackage --bzimage clean \
--config configure --cross_compile --cross-compile debian \
--flavour --help --initrd kernel_doc kernel_headers kernel_image \
kernel_source libc-kheaders modules modules_clean modules_config \
modules_image --noexec --pgpsign --revision --rootcmd --subarch \
--targets --uc --us --zimage'
paroptions="$options"
[[ $prev == '--config' ]] && \
paroptions='config old oldconfig menu menuconfig x xconfig'
#exclude some options
[[ "$DEBIAN_REVISION_MANDATORY" ]] ||\
{ [[ -a "stamp-configure" ]] && paroptions=${paroptions/--revision}; }
[[ "$ARCH_IN_NAME" ]] && paroptions=${paroptions//--arch[-_]in[-_]name}
[[ "$CROSS_COMPILE" ]] && paroptions=${paroptions//--cross[-_]compile}
[[ "$KPKG_ARCH" ]] && paroptions=${paroptions/--arch}
[[ "$KPKG_SUBARCH" ]] && paroptions=${paroptions/--subarch}
[[ $( grep CONFIG_BLK_DEV_INITRD .config | cut -d= -f2) == "y" ]] && \
[[ "$INITRD" == "YES" ]] && paroptions=${paroptions/--initrd}
for (( i=0; i < ${#COMP_WORDS}-1; i++ )); do
#we need to start and end every line with '|' so it can be recognized.
if [[ ${COMP_WORDS[i]} == @(binary|build|buildpackage|clean|\
|configure|debian|kernel_doc|kernel_headers|kernel_image|\
|kernel_source|libc-kheaders|modules|modules_clean|\
|modules_config|modules_image) ]]; then
paroptions=$( echo $options | sed s/--[^\ ]*//g )
COMPREPLY=( $( compgen -W "$paroptions" | grep ^$cur ) )
return 0;
fi
done
COMPREPLY=( $( compgen -W "$paroptions" | grep ^$cur ) )
return 0
}
[ "$have" ] && complete -F _make_kpkg -o filenames make-kpkg
|