about summary refs log tree commit diff
path: root/Completion/Mandrake
diff options
context:
space:
mode:
authorAndrey Borzenkov <bor@users.sourceforge.net>2002-05-08 15:55:36 +0000
committerAndrey Borzenkov <bor@users.sourceforge.net>2002-05-08 15:55:36 +0000
commitae5ac5edea6f4c49e89291e4e973283c252fa59c (patch)
tree282be66a06ac6de88c680d641a7c89edd2cb5aed /Completion/Mandrake
parent6d73a3b843ac1961ccce067a0c191c1bcdf20d7f (diff)
downloadzsh-ae5ac5edea6f4c49e89291e4e973283c252fa59c.tar.gz
zsh-ae5ac5edea6f4c49e89291e4e973283c252fa59c.tar.xz
zsh-ae5ac5edea6f4c49e89291e4e973283c252fa59c.zip
Merge 17080,17076,17075,17074,16461,16434,16437,16258,16247,16253
Diffstat (limited to 'Completion/Mandrake')
-rw-r--r--Completion/Mandrake/Command/.distfiles4
-rw-r--r--Completion/Mandrake/Command/_urpmi177
2 files changed, 181 insertions, 0 deletions
diff --git a/Completion/Mandrake/Command/.distfiles b/Completion/Mandrake/Command/.distfiles
new file mode 100644
index 000000000..91e79f8e9
--- /dev/null
+++ b/Completion/Mandrake/Command/.distfiles
@@ -0,0 +1,4 @@
+DISTFILES_SRC='
+.distfiles
+_urpmi
+'
diff --git a/Completion/Mandrake/Command/_urpmi b/Completion/Mandrake/Command/_urpmi
new file mode 100644
index 000000000..0f39f8635
--- /dev/null
+++ b/Completion/Mandrake/Command/_urpmi
@@ -0,0 +1,177 @@
+#compdef urpme urpmi urpmi.addmedia urpmi.removemedia urpmi.update urpmq
+
+_urpmi_cache_policy() {
+  local -a synthesis
+  local i
+  synthesis=(/var/lib/urpmi/synthesis.*)
+  for i in $synthesis; do
+    [[ -e "$1" && -e "$i" && "$1" -nt "$i" ]] && return 1
+  done
+  return 0
+}
+    
+_urpmi_media() {
+  local source media brace expl
+  local -a all_sources
+
+  [[ -f /etc/urpmi/urpmi.cfg ]] || return 1
+
+  while read source media brace; do
+    [[ "$brace" != "{" ]] && continue
+    all_sources=("$all_sources[@]" $source)
+  done < /etc/urpmi/urpmi.cfg
+
+  _values -s , 'urpmi media' "$all_sources[@]"
+}
+
+_urpmi_rpms() {
+  local pkg ret=1 expl
+
+  _tags rpms files
+
+  while _tags; do
+    if _requested rpms expl 'urpmi RPMs'; then
+      local -a synthesis pkgs
+      synthesis=(/var/lib/urpmi/synthesis.*(N))
+      if [[ $#synthesis -gt 0 ]]; then
+	if _cache_invalid _urpmi_rpms || ! _retrieve_cache _urpmi_rpms; then
+	  pkgs=($(zcat $synthesis | \
+	    grep @info@ | cut -d @ -f 3 | sed -e 's/\.[^.]*$//'))
+	  _store_cache _urpmi_rpms pkgs
+	fi
+	compadd "$expl[@]" -a pkgs && ret=0
+      fi
+    fi
+
+    _requested files expl '(S)RPM files' \
+      _files -g '*.(#i)rpm' && ret=0
+  done
+
+  return $ret
+}
+
+_urpmi_media_url() {
+  local expl ret=1
+
+  if compset -P file:// || compset -P removable://; then
+    _files "$@" -W / -/ && ret=0
+  elif [[ -prefix '(ftp|http)://' ]]; then
+    _urls "$@" && ret=0
+  else
+    _wanted mediatype expl 'type of media' \
+      compadd "$@" -- file:// http:// ftp:// removable:// && ret=0
+  fi
+
+  return $ret
+}
+
+_urpme_package() {
+  local -a _rpms
+  _rpms=( $(_call_program packages rpm -qa 2>/dev/null) )
+  compadd "$@" -a -- _rpms
+}
+
+_urpmi() {
+  local state context line ret=1
+  typeset -A opt_args
+
+  case "$service" in
+    urpme )
+      _arguments -A '-*' \
+	"--auto[do not ask any question]" \
+	"-a[find all matches]" \
+	": :_urpme_package"
+    ;;
+    urpmi.addmedia )
+      _arguments -A '-*' \
+	"(--wget)--curl[use curl to retrieve distant files]" \
+	"(:)--distrib[automatically create all media from an installation medium]:media URL:_urpmi_media_url" \
+	"--update[mark as update media]" \
+	"(--curl)--wget[use wget to retrieve distant files]" \
+	"-c[clean headers cache directory]" \
+	"-f[force generation of hdlist files]" \
+	"-h[try to find and use synthesis or hdlist file]" \
+	"(--distrib):name of media: " \
+	"(--distrib):media URL:_urpmi_media_url" \
+	"(--distrib): :(with)" \
+	"(--distrib):relative path to hdlist file: " \
+       && ret=0
+    ;;
+    urpmi.removemedia )
+      _arguments -A '-*' \
+	"(:)-a[select all media]" \
+	"(-a)"{,\*}": :_urpmi_media" \
+       && ret=0
+    ;;
+    urpmi.update )
+      _arguments -A '-*' \
+	"(--wget)--curl[use curl to retrieve distant files]" \
+	"(--curl)--wget[use wget to retrieve distant files]" \
+	"(:)-a[select all non-removable media]" \
+	"-c[clean /var/cache/urpmi/headers on exit]" \
+	"-d[force complete computation of depslist.ordered file]" \
+	"*-f[force generation of hdlist files]" \
+	"(-a)"{,\*}": :_urpmi_media" \
+       && ret=0
+    ;;
+    urpmi )
+      _arguments -A '-*' \
+	"(: -)--help[print usage information]" \
+	"(--help)--allow-medium-change[allow change of removable media]" \
+	"(--help)--auto[do not ask any questions]" \
+	"(--help)--auto-select[select the packages to update]" \
+	"(--help -X)--best-output[automatically select text or X interface]" \
+	"(--help)--complete[use parsehdlist server to complete selection]" \
+	"(--help --wget)--curl[use curl to retrieve distant files]" \
+	"(--help)--force[proceed even when some packages do not exist]" \
+	"(--help --fuzzy -z)"{--fuzzy,-y}"[return all matches even if exact match exists]" \
+	"(--help)--media[use only the media listed by comma]: :_urpmi_media" \
+	"(--help)--noclean[do not clean RPM cache]" \
+	"(--help --src -s)"{--src,-s}"[next package is source package]" \
+	"(--help)--update[use only update media]" \
+	"(--help --curl)--wget[use wget to retrieve distant files]" \
+	"(--help)-a[select all packages matching command line]" \
+	"(--help -m -M)-m[choose minimum closure of requires (default)]" \
+	"(--help -m -M)-M[choose maximum closure of requires]" \
+	"(--help)-P[do not search in provides]" \
+	"(--help -q -v)-q[be quiet]" \
+	"(--help -q -v)-v[verbose mode]" \
+	"(--help --best-output)-X[use X interface]" \
+	"(--help)"{,\*}": :_urpmi_rpms" \
+      && ret=0
+    ;;
+    urpmq )
+      _arguments -A '-*' \
+	"(--help -h)--auto-select[automatically select packages for upgrading the system]" \
+	"(--help -h)--force[ignore non-existent packages]" \
+	"(--help -h --fuzzy -z)"{--fuzzy,-y}"[return all matches even if exact match exists]" \
+	"(--help -h)--headers[extract headers for package listed from urpmi db to stdout]" \
+	"(--help -h)--media[use only the media listed by comma]: :_urpmi_media" \
+	"(--help -h)--sources[show full path to package file]" \
+	"(--help -h --src -s)"{--src,-s}"[next package is source package]" \
+	"(--help -h)--update[use only update media]" \
+	"(--help -h -c -p -P)-c[choose complete method for resolving requires closure]" \
+	"(--help -h)-d[show package depndencies]" \
+	"(--help -h)-f[print version, release and arch with name]" \
+	"(--help -h)-g[print groups too with name]" \
+	"(--help -h -c -p -P)-p[allow search in provides to find package]" \
+	"(--help -h -c -p -P)-P[do not search in provides to find package]" \
+	"(--help -h)-r[print version and release too with name]" \
+	"(--help -h)-u[remove package if a better version is already installed]" \
+	"(--help -h)-v[verbose mode]" \
+	"(--help -h)*:urpmi package name: " \
+     && ret=0
+    ;;
+  esac
+
+  return $ret
+}
+
+local update_policy
+
+zstyle -s ":completion:*:*:urpmi:*" cache-policy update_policy
+if [[ -z "$update_policy" ]]; then
+    zstyle ":completion:*:*:urpmi:*" cache-policy _urpmi_cache_policy
+fi
+
+_urpmi "$@"