From: Clint Adams <schizo@debian.org>
To: zsh-workers@sunsite.dk
Subject: PATCH: _deb_packages caching
Date: Fri, 30 Mar 2001 16:00:36 -0500 [thread overview]
Message-ID: <20010330160036.A3477@dman.com> (raw)
This adds caching layer support to _deb_packages, a la _rpm.
It should probably make use of _call as well.
Index: Completion/Debian/_deb_packages
===================================================================
RCS file: /cvsroot/zsh/zsh/Completion/Debian/_deb_packages,v
retrieving revision 1.2
diff -u -r1.2 _deb_packages
--- Completion/Debian/_deb_packages 2000/04/11 07:57:57 1.2
+++ Completion/Debian/_deb_packages 2001/03/30 20:59:11
@@ -3,19 +3,26 @@
# Usage: _deb_packages expl... avail|installed|uninstalled
_deb_packages_update_avail () {
- if (( ! $+_deb_packages_cache_avail )); then
+ if ( [[ ${+_deb_packages_cache_avail} -eq 0 ]] ||
+ _cache_invalid DEBS_avail ) && ! _retrieve_cache DEBS_avail;
+ then
_deb_packages_cache_avail=(
${(f)"$(apt-cache dumpavail | awk '/^Package:/ { print $2 }')"}
)
+
+ _store_cache DEBS_avail _deb_packages_cache_avail
fi
cachevar=_deb_packages_cache_avail
}
_deb_packages_update_installed () {
- if (( ! $+_deb_packages_cache_installed )); then
+ if ( [[ ${+_deb_packages_cache_installed} -eq 0 ]] ||
+ _cache_invalid DEBS_installed ) && ! _retrieve_cache DEBS_installed;
+ then
_deb_packages_cache_installed=(
${${${(f)"$(dpkg --get-selections)"}:#*deinstall}%% *}
)
+ _store_cache DEBS_installed _deb_packages_cache_installed
fi
cachevar=_deb_packages_cache_installed
}
@@ -32,7 +39,12 @@
}
_deb_packages () {
- local command="$argv[$#]" expl cachevar pkgset
+ local command="$argv[$#]" expl cachevar pkgset update_policy
+
+ zstyle -s ":completion:*:*:$service:*" cache-policy update_policy
+ if [[ -z "$update_policy" ]]; then
+ zstyle ":completion:*:*:$service:*" cache-policy _debs_caching_policy
+ fi
[[ "$command" = (installed|uninstalled|avail) ]] || {
_message "_deb_packages:unknown command: $command"
@@ -53,5 +65,16 @@
_tags packages && compadd "$expl[@]" - "${(@P)cachevar}"
}
+
+ _debs_caching_policy () {
+ # rebuild if cache is more than a week old
+ oldp=( "$1"(mw+1) )
+ (( $#oldp )) && return 0
+
+ [[ /var/cache/apt/pkgcache.bin -nt "$1" ||
+ /var/lib/dpkg/available -nt "$1" ]]
+ }
+
+
_deb_packages "$@"
reply other threads:[~2001-03-30 21:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20010330160036.A3477@dman.com \
--to=schizo@debian.org \
--cc=zsh-workers@sunsite.dk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).