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 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
|
_reprepro()
{
local cur prev commands options noargoptions i state cmd ignores hiddencommands commands codenames confdir basedir architectures components
confdir=""
basedir=""
function parse_config() {
local conffile distfile
if [[ -n "$confdir" ]] ; then
conffile="$confdir/options"
distfile="$confdir/distributions"
elif [[ -n "$basedir" ]] ; then
conffile="$basedir/conf/options"
distfile="$basedir/conf/distributions"
else
conffile="./conf/options"
distfile="./conf/distributions"
fi
if [[ -e "$conffile" ]] ; then
if grep -q '^confdir ' -- "$conffile" 2>/dev/null ; then
distfile="$(grep '^confdir ' -- "$conffile" 2>/dev/null | sed -e 's/^confdir //')/distributions"
elif [ -z "$confdir" ] && grep -q '^basedir ' -- "$conffile" 2>/dev/null ; then
distfile="$(grep '^basedir ' -- "$conffile" 2>/dev/null | sed -e 's/^basedir //')/conf/distributions"
fi
fi
if [[ -e "$distfile" ]] ; then
codenames="$(awk -- '/^[Cc][Oo][Dd][Ee][Nn][Aa][Mm][Ee]: / {$1="";print}' "$distfile")"
architectures="$(awk -- '/^[Aa][Rr][Cc][Hh][Ii][Tt][Ee][Cc][Tt][Uu][Rr][Ee][Ss]: / {$1="";print}' "$distfile")"
components="$(awk -- '/^[Cc][Oo][Mm][Pp][Oo][Nn][Ee][Nn][Tt][Ss]: / {$1="";print}' "$distfile")"
else
codenames="experimental woody sarge sid etch whatever-you-defined"
architectures="source i386 abacus whatever-you-defined"
components="main contrib non-free whatever-you-defined"
fi
}
COMPREPLY=()
ignores='ignore forbiddenchar 8bit emptyfilenamepart overlongcomments\
spaceonlyline malformedchunk shortkeyid unknownfield\
wrongdistribution missingfield brokenold brokenversioncmp\
extension unusedarch surprisingarch surprisingbinary\
wrongsourceversion wrongversion brokensignatures\
uploaders missingfile'
noargoptions='--delete --nodelete --help -h --verbose -v\
--nothingiserror --nolistsdownload --keepunreferencedfiles\
--keepunneededlists --keepdirectories\
--ask-passphrase --nonothingiserror --listsdownload\
--nokeepunreferencesfiles --nokeepunneededfiles --nokeepdirectories\
--noask-passphrase --skipold --noskipold'
options='-b -i --basedir --ignore --unignore --methoddir --distdir --dbdir\
--listdir --overridedir --confdir --section -S --priority -P --component -C\
--architecture -A --type -T --export'
i=1
prev=""
cmd="XYZnoneyetXYZ"
while [[ $i -lt $COMP_CWORD ]] ; do
cur=${COMP_WORDS[i]}
prev=""
case "$cur" in
--basedir=*)
basedir="${cur#--basedir=}"
i=$((i+1))
;;
--confdir=*)
confdir="${cur#--confdir=}"
i=$((i+1))
;;
--*=*)
i=$((i+1))
;;
-b|--basedir)
prev="$cur"
basedir="${COMP_WORDS[i+1]}"
i=$((i+2))
;;
--confdir)
prev="$cur"
confdir="${COMP_WORDS[i+1]}"
i=$((i+2))
;;
-i|--ignore|--unignore|--methoddir|--distdir|--dbdir|--listdir|--overridedir|--section|-S|--priority|-P|--component|-C|--architecture|-A|--type|-T|--export)
prev="$cur"
i=$((i+2))
;;
--*|-*)
i=$((i+1))
;;
*)
cmd="$cur"
i=$((i+1))
break
;;
esac
done
cur=${COMP_WORDS[COMP_CWORD]}
if [[ $i -gt $COMP_CWORD && -n "$prev" ]]; then
case "$prev" in
-b|--basedir|--methoddir|--distdir|--dbdir|--listdir|--overridedir|--confdir)
COMPREPLY=( $( compgen -d -- $cur ) )
return 0
;;
-T|--type)
COMPREPLY=( $( compgen -W "dsc deb udeb" -- $cur ) )
return 0
;;
-i|--ignore|--unignore)
COMPREPLY=( $( compgen -W "$ignores" -- $cur ) )
return 0
;;
-P|--priority)
COMPREPLY=( $( compgen -W "required important standard optional extra" -- $cur ) )
return 0
;;
-S|--section)
COMPREPLY=( $( compgen -W "admin base comm contrib devel doc editors electronics embedded games gnome graphics hamradio interpreters kde libs libdevel mail math misc net news non-free oldlibs otherosfs perl python science shells sound tex text utils web x11 contrib/admin contrib/base contrib/comm contrib/contrib contrib/devel contrib/doc contrib/editors contrib/electronics contrib/embedded contrib/games contrib/gnome contrib/graphics contrib/hamradio contrib/interpreters contrib/kde contrib/libs contrib/libdevel contrib/mail contrib/math contrib/misc contrib/net contrib/news contrib/non-free contrib/oldlibs contrib/otherosfs contrib/perl contrib/python contrib/science contrib/shells contrib/sound contrib/tex contrib/text contrib/utils contrib/web contrib/x11 non-free/admin non-free/base non-free/comm non-free/contrib non-free/devel non-free/doc non-free/editors non-free/electronics non-free/embedded non-free/games non-free/gnome non-free/graphics non-free/hamradio non-free/interpreters non-free/kde non-free/libs non-free/libdevel non-free/mail non-free/math non-free/misc non-free/net non-free/news non-free/non-free non-free/oldlibs non-free/otherosfs non-free/perl non-free/python non-free/science non-free/shells non-free/sound non-free/tex non-free/text non-free/utils non-free/web non-free/x11" -- $cur ) )
return 0
;;
-A|--architecture)
parse_config
COMPREPLY=( $( compgen -W "$architectures" -- $cur ) )
return 0
;;
-C|--component)
parse_config
COMPREPLY=( $( compgen -W "$components" -- $cur ) )
return 0
;;
--export)
COMPREPLY=( $( compgen -W "never changed normal force" -- $cur ) )
return 0
;;
esac
fi
if [[ "XYZnoneyetXYZ" = "$cmd" ]] ; then
commands='remove list listfilter createsymlinks export\
check reoverride checkpool rereference dumpreferences\
dumpunreferenced deleteunreferenced retrack dumptracks\
cleartracks removetrack update checkupdate pull \
checkpull includedeb includeudeb includedsc include copy'
hiddencommands='__d __extractcontrol _detect _forget\
_listmd5sums _addmd5sum _dumpcontents\
_removereferences _addreference'
if [[ "$cur" == -* ]]; then
case "$cur" in
--ignore=*)
COMPREPLY=( $( compgen -W "$ignores" -- ${cur#--ignore=} ) )
;;
--unignore=*)
COMPREPLY=( $( compgen -W "$ignores" -- ${cur#--unignore=} ) )
;;
--component=*)
parse_config
COMPREPLY=( $( compgen -W "$components" -- {cur#--component=} ) )
;;
--architectures=*)
parse_config
COMPREPLY=( $( compgen -W "$architectures" -- {cur#--architectures=} ) )
;;
*)
COMPREPLY=( $( compgen -W "$options $noargoptions" -- $cur ) )
;;
esac
elif [[ "$cur" == _* ]]; then
COMPREPLY=( $( compgen -W "$hiddencommands" -- $cur ) )
else
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
fi
return 0
fi
case "$cmd" in
remove|list|listfilter|removetrack)
# first argument is the codename
if [[ $i -eq $COMP_CWORD ]] ; then
parse_config
COMPREPLY=( $( compgen -W "$codenames" -- $cur ) )
return 0
fi
# these later could also look for stuff, but
# that might become a bit slow
;;
export|update|checkupdate|pull|checkpull|rereference|retrack|cleartracks|dumptracks|check|reoverride)
# all arguments are codenames
parse_config
COMPREPLY=( $( compgen -W "$codenames" -- $cur ) )
return 0
;;
includedeb)
# first argument is the codename
if [[ $i -eq $COMP_CWORD ]] ; then
parse_config
COMPREPLY=( $( compgen -W "$codenames" -- $cur ) )
return 0
fi
# then one .deb file follows
if [[ $(( $i + 1 )) -eq $COMP_CWORD ]] ; then
_filedir "!*.deb"
fi
return 0
;;
includedsc)
# first argument is the codename
if [[ $i -eq $COMP_CWORD ]] ; then
parse_config
COMPREPLY=( $( compgen -W "$codenames" -- $cur ) )
return 0
fi
# then one .dsc file follows
if [[ $(( $i + 1 )) -eq $COMP_CWORD ]] ; then
_filedir "!*.dsc"
fi
return 0
;;
include)
# first argument is the codename
if [[ $i -eq $COMP_CWORD ]] ; then
parse_config
COMPREPLY=( $( compgen -W "$codenames" -- $cur ) )
return 0
fi
# then one .changes file follows
if [[ $(( $i + 1 )) -eq $COMP_CWORD ]] ; then
_filedir "!*.changes"
fi
return 0
;;
copy)
# first argument is a codename
if [[ $i -eq $COMP_CWORD ]] ; then
parse_config
COMPREPLY=( $( compgen -W "$codenames" -- $cur ) )
return 0
fi
# second argument is a codename
if [[ $(( $i + 1 )) -eq $COMP_CWORD ]] ; then
parse_config
COMPREPLY=( $( compgen -W "$codenames" -- $cur ) )
return 0
fi
# here we could look for package names existing in
# that distribution, but that would be slow...
;;
esac
COMPREPLY=( $( compgen -f -- $cur ) )
return 0
}
complete -F _reprepro reprepro
|