* Refactoring _bsd_pkg @ 2003-01-02 14:04 James Devenish 2003-01-02 14:41 ` Oliver Kiddle 2003-01-03 8:39 ` Proposed changes to _bsd_pkg -- request for comments James Devenish 0 siblings, 2 replies; 7+ messages in thread From: James Devenish @ 2003-01-02 14:04 UTC (permalink / raw) To: zsh-users; +Cc: David Lebel [-- Attachment #1: Type: text/plain, Size: 957 bytes --] Hi, Is anyone using _bsd_pkg with OpenBSD 3.x? The platform for which _bsd_pkg is relevant to me is OpenBSD. Until today, I hadn't realised that _bsd_pkg even existed. Having just tried it, I think the reason I didn't notice is that it behave{s,d} incorrectly and therefore I didn't realised that something intelligent was at work. Also, I notice that the OpenBSD ports tree contains a patch that I can't see in zsh CVS HEAD. I have attached the completion function that I have been using for pkg_delete and pkg_info. Mine is concise, partly because it does not support pkg_add, pkg_create, or other BSDs. However, there are some salient differences. Having downloaded the _bsd_pkg HEAD, it appears that there are some errors in it from the OpenBSD perspective (as in previous versions). I don't know whether this is because other BSDs are different or because no one has noticed. Is anyone aware of these sorts of things or is it only my perception? [-- Attachment #2: _ports_pkg --] [-- Type: text/plain, Size: 1831 bytes --] #compdef pkg_delete pkg_info # Thanks to the OpenBSD man pages for pkg_delete(1) and pkg_info(1) # (whence comes the switch documentation). local _pkg_delete_options _pkg_info_options _package _pkg_delete_options=( '-v[Turn on verbose output]' \ '-D[Do not execute deinstallation script]' \ '-d[Remove left-over empty directories]' \ '-n[Don''t deinstall, just report the steps to be taken]' \ '-f[Force, even if script failed or dependency exists]' \ '-p[Use this installation prefix if none specified by package]:directory:_files -/' \ '*:installed package:_package' ) _pkg_info_options=( '(* -)-a[Show information for all currently installed packages]' \ '-c[Show the one-line comment field for each package]' \ '-D[Show the install-message file (if any) for each package]' \ '-d[Show the long-description field for each package]' \ '-e[Test for the presence of another package]:prerequisite package:_package' \ '-f[Show the packing list instructions for each package]' \ '-I[Show the index entry for each package]' \ '-i[Show the install script (if any) for each package]' \ '-k[Show the de-install script (if any) for each package]' \ '-L[Show the files within each package (installed pathnames)]' \ '-l[Prefix each information category header]:directory:_files -/' \ '-m[Show the mtree file (if any) for each package]' \ '-p[Show the installation prefix for each package]' \ '-q[Be "quiet", just dump raw info]' \ '-R[Show which packages require a given package]' \ '-r[Show the requirements script (if any) for each package]' \ '-v[Turn on verbose output]' \ '*:installed package:_package' ) _package() { _values /var/db/pkg/*(-/:t) } case "$service" in pkg_delete) _arguments -s "$_pkg_delete_options[@]" && return 0 ;; pkg_info) _arguments -s "$_pkg_info_options[@]" && return 0 ;; esac ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Refactoring _bsd_pkg 2003-01-02 14:04 Refactoring _bsd_pkg James Devenish @ 2003-01-02 14:41 ` Oliver Kiddle 2003-01-02 15:37 ` James Devenish 2003-01-03 8:39 ` Proposed changes to _bsd_pkg -- request for comments James Devenish 1 sibling, 1 reply; 7+ messages in thread From: Oliver Kiddle @ 2003-01-02 14:41 UTC (permalink / raw) To: James Devenish; +Cc: zsh-users, David Lebel On 2 Jan, you wrote: > > The platform for which _bsd_pkg is relevant to me is OpenBSD. Until > today, I hadn't realised that _bsd_pkg even existed. Having just tried > it, I think the reason I didn't notice is that it behave{s,d} incorrectly > and therefore I didn't realised that something intelligent was at work. It was written originally for FreeBSD with some NetBSD options being added later. You're the first person I remember mentioning its use with OpenBSD. Though doubtless there are people who have tried it and just ignored the incorrect behaviour. > Also, I notice that the OpenBSD ports tree contains a patch that I can't > see in zsh CVS HEAD. I have attached the completion function that I have > been using for pkg_delete and pkg_info. Mine is concise, partly because > it does not support pkg_add, pkg_create, or other BSDs. However, there > are some salient differences. Having downloaded the _bsd_pkg HEAD, it > appears that there are some errors in it from the OpenBSD perspective > (as in previous versions). I don't know whether this is because other > BSDs are different or because no one has noticed. Is there any chance that you could merge your OpenBSD functions into the _bsd_pkg HEAD and then submit a patch to the zsh-workers list. They can then be committed to cvs without upsetting FreeBSD users. It should just be a matter of sticking an `openbsd*)' section in the various `case "$OSTYPE" in' parts of the function. If not, I can attempt to do it but I'll probably make a mess of it as I don't have access to any BSD systems to check it against. Cheers Oliver This e-mail and any attachment is for authorised use by the intended recipient(s) only. It may contain proprietary material, confidential information and/or be subject to legal privilege. It should not be copied, disclosed to, retained or used by, any other party. If you are not an intended recipient then please promptly delete this e-mail and any attachment and all copies and inform the sender. Thank you. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Refactoring _bsd_pkg 2003-01-02 14:41 ` Oliver Kiddle @ 2003-01-02 15:37 ` James Devenish 0 siblings, 0 replies; 7+ messages in thread From: James Devenish @ 2003-01-02 15:37 UTC (permalink / raw) To: zsh-users; +Cc: David Lebel [-- Attachment #1: Type: text/plain, Size: 1366 bytes --] In message <2419.1041518512@finches.logica.co.uk> on Thu, Jan 02, 2003 at 03:41:52PM +0100, Oliver Kiddle wrote: > Is there any chance that you could merge your OpenBSD functions into > the _bsd_pkg HEAD and then submit a patch to the zsh-workers list. They > can then be committed to cvs without upsetting FreeBSD users. It should > just be a matter of sticking an `openbsd*)' section in the various `case > "$OSTYPE" in' parts of the function. Yes, that's fine, I have attached a diff for the beast, only improving pkd_delete, and pkg_info. I also replaced tabs with spaces since the file seemed to have a mixture, and that's made the patch a bit large. This is just a heads-up and I don't really intent on anyone feeling willing to commit this verbatim -- it's night-time here and I'll have another look at it tomorrow. (And the person with the CC of my post is the OpenBSD port maintainer for zsh, so he may have something useful to add.) pkg_add still doesn't work quite right because it always has some directories (those matching the pattern /*) in the completion list, even if my current directory is not /. PS. I replaced '\'' with '', but maybe that's not portable? Also, I noticed that in my own script, I had an error for the -l option (I suspect it's an option that's never used in an interactive shell, let alone used with a completion mechanism). [-- Attachment #2: patch-Completion_BSD_Command__bsd_pkg --] [-- Type: text/plain, Size: 8687 bytes --] Index: _bsd_pkg OpenBSD compatability for pkg_delete and pkg_info options. OpenBSD compatability for pkg_add packages list. Detabbed. Allow symlinks to directories in addition to directories. =================================================================== RCS file: /cvsroot/zsh/zsh/Completion/BSD/Command/_bsd_pkg,v retrieving revision 1.5 diff -u -r1.5 _bsd_pkg --- _bsd_pkg 26 Sep 2002 10:30:01 -0000 1.5 +++ _bsd_pkg 2 Jan 2003 15:31:42 -0000 @@ -6,15 +6,19 @@ case $OSTYPE in netbsd*) - portsdir=/usr/pkgsrc + portsdir=${PORTSDIR:-/usr/pkgsrc} + pkgsdir=${PACKAGES:-$portsdir/packages}/All + ;; + openbsd*) + portsdir=${PORTSDIR:-/usr/ports} + pkgsdir=${PACKAGES:-$portsdir/packages}/$(arch -s)/All ;; *) portsdir=${PORTSDIR:-/usr/ports} + pkgsdir=${PACKAGES:-$portsdir/packages}/All ;; esac - pkgsdir=${PACKAGES:-$portsdir/packages}/All - paths=( "${(@)${(@s.:.)PKG_PATH}:#}" ) _files "$@" -g '*.t[bg]z' && ret=0 (( $#path )) && _files "$@" -W paths -g '*.t[bg]z' && ret=0 @@ -25,7 +29,7 @@ (( $+functions[_bsd_pkg_pkgs] )) || _bsd_pkg_pkgs() { - compadd "$@" - ${PKG_DBDIR:-/var/db/pkg}/*(/:t) + compadd "$@" - ${PKG_DBDIR:-/var/db/pkg}/*(-/:t) } (( $+functions[_bsd_pkg_pkgs_and_files] )) || @@ -48,11 +52,11 @@ pkg_add) flags=( '-f[force installation]' - '-I[don'\''t execute installation scripts]' + '-I[don''t execute installation scripts]' '-M[run in master mode]' - '-n[don'\''t really install packages]' + '-n[don''t really install packages]' '-p[specify prefix]:prefix directory:_files -/' - '-R[don'\''t record]' + '-R[don''t record]' '-S[run in slave mode]' '-t[specify mktemp template]:mktemp template:_files -/' '-v[be verbose]' @@ -67,9 +71,9 @@ ;; netbsd*) flags=( - $flags[@] - '-u[update]' - '-V[show version and exit]' + $flags[@] + '-u[update]' + '-V[show version and exit]' ) ;; esac @@ -83,37 +87,37 @@ case "$OSTYPE" in freebsd*) flags=( - '-f[specify plist file]:plist file:_files' - '(-b)-c[specify comment file]:comment file:_files' - '(-b)-d[specify descr file]:descr file:_files' - '-Y[assume YES for any questions asked]' - '-N[assume NO for any questions asked]' - '(-b)-O[packing list only mode]' - '-v[be verbose]' - '-h[force tar to follow symlinks]' - '(-b)-i[specify pre-install script]:pre-install script:_files' - '(-b)-I[specify post-install script]:post-install script:_files' - '(-b)-P[specify initial dependencies]:dependencies:_bsd_pkg_pkgs' - '(-b)-p[specify prefix]:prefix directory:_files -/' - '(-b)-k[specify deinstall script]:deinstall script:_files' - '(-b)-K[specify post-deinstall script]:post-deinstall script:_files' - '(-b)-r[specify req script]:req script:_files' - '(-b)-s[specify source directory]:source directory:_files -/' - '(-b)-t[specify mktemp template]:mktemp template:_files' - '(-b)-X[specify exclude file]:exclude file for tar:_files' - '(-b)-D[specify message file]:message file:_files' - '(-b)-m[specify mtree file]:mtree file:_files' - '(-b)-o[specify origin]:origin:_files -W ${PORTSDIR\:-/usr/ports} -/' - '-j[use bzip2]' - '-z[use gzip]' - '(-c -d -O -i -I -P -p -k -K -r -s -t -X -D -m -o)-b[specify pkgname]:pkgname:_bsd_pkg_pkgs' - '*:package file name:_files' + '-f[specify plist file]:plist file:_files' + '(-b)-c[specify comment file]:comment file:_files' + '(-b)-d[specify descr file]:descr file:_files' + '-Y[assume YES for any questions asked]' + '-N[assume NO for any questions asked]' + '(-b)-O[packing list only mode]' + '-v[be verbose]' + '-h[force tar to follow symlinks]' + '(-b)-i[specify pre-install script]:pre-install script:_files' + '(-b)-I[specify post-install script]:post-install script:_files' + '(-b)-P[specify initial dependencies]:dependencies:_bsd_pkg_pkgs' + '(-b)-p[specify prefix]:prefix directory:_files -/' + '(-b)-k[specify deinstall script]:deinstall script:_files' + '(-b)-K[specify post-deinstall script]:post-deinstall script:_files' + '(-b)-r[specify req script]:req script:_files' + '(-b)-s[specify source directory]:source directory:_files -/' + '(-b)-t[specify mktemp template]:mktemp template:_files' + '(-b)-X[specify exclude file]:exclude file for tar:_files' + '(-b)-D[specify message file]:message file:_files' + '(-b)-m[specify mtree file]:mtree file:_files' + '(-b)-o[specify origin]:origin:_files -W ${PORTSDIR\:-/usr/ports} -/' + '-j[use bzip2]' + '-z[use gzip]' + '(-c -d -O -i -I -P -p -k -K -r -s -t -X -D -m -o)-b[specify pkgname]:pkgname:_bsd_pkg_pkgs' + '*:package file name:_files' ) ;; netbsd*) # NetBSD users, improve me! flags=( - '*:package name:_bsd_pkg_pkgs' + '*:package name:_bsd_pkg_pkgs' ) ;; esac @@ -124,10 +128,10 @@ pkg_delete) flags=( - '-D[don'\''t execute deinstallation scripts]' + '-D[don''t execute deinstallation scripts]' '-d[remove empty directories]' '-f[force deinstallation]' - '-n[don'\''t really deinstall packages]' + '-n[don''t really deinstall packages]' '-p[specify prefix]:prefix directory:_files -/' '-v[be verbose]' ) @@ -136,35 +140,43 @@ freebsd*) flags=( $flags[@] - '(:)-a[delete all installed packages]' + '(:)-a[delete all installed packages]' '-G[do not expand glob patterns]' - '-i[be interactive]' + '-i[be interactive]' '-r[delete recursively]' '-x[use regular expression]' ) ;; netbsd*) flags=( - $flags[@] - '(:)-a[delete all installed packages]' - '-F[specify each package by an installed file]' - '-i[be interactive]' - '-O[only delete the package'\''s entries]' + $flags[@] + '(:)-a[delete all installed packages]' + '-F[specify each package by an installed file]' + '-i[be interactive]' + '-O[only delete the package''s entries]' '-R[delete upward recursively]' '-r[delete recursively]' - '-V[show version and exit]' + '-V[show version and exit]' ) ;; esac - _arguments -s \ - $flags[@] \ - '(-a)*:package name:_bsd_pkg_pkgs_and_files' + case "$OSTYPE" in + openbsd*) + _arguments -s \ + $flags[@] \ + '*:installed package name:_bsd_pkg_pkgs' + ;; + *) + _arguments -s \ + $flags[@] \ + '(-a)*:package name:_bsd_pkg_pkgs_and_files' + ;; + esac ;; pkg_info) flags=( - '(:)-a[show all installed packages]' '-c[show comment fields]' '-D[show install-message files]' '-d[show long descriptions]' @@ -188,30 +200,41 @@ flags=( $flags[@] '-G[do not expand glob patterns]' - '-g[show files that'\''s modified]' - '-o[show origin]' - '-s[show total size occupied by each package]' - '-t[specify mktemp template]:mktemp template:_files -/' - '*-W[show which package the file belongs to]:file:_files' - '-x[use regular expression]' + '-g[show files that are modified]' + '-o[show origin]' + '-s[show total size occupied by each package]' + '-t[specify mktemp template]:mktemp template:_files -/' + '*-W[show which package the file belongs to]:file:_files' + '-x[use regular expression]' ) ;; netbsd*) flags=( - $flags[@] - '-B[show build information]' - '-b[show RCS Id strings]' - '-F[specify each package by an installed file]' - '-S[show total size occupied by each package and its dependents]' - '-s[show total size occupied by each package]' - '-V[show version and exit]' + $flags[@] + '-B[show build information]' + '-b[show RCS Id strings]' + '-F[specify each package by an installed file]' + '-S[show total size occupied by each package and its dependents]' + '-s[show total size occupied by each package]' + '-V[show version and exit]' ) ;; esac - _arguments -s \ - $flags[@] \ - '(-a)*:package name:_bsd_pkg_pkgs_and_files' + case "$OSTYPE" in + openbsd*) + _arguments -s \ + '(* -)-a[show all installed packages]' \ + $flags[@] \ + '*:installed package name:_bsd_pkg_pkgs' + ;; + *) + _arguments -s \ + '(:)-a[show all installed packages]' \ + $flags[@] \ + '(-a)*:package name:_bsd_pkg_pkgs_and_files' + ;; + esac ;; esac } ^ permalink raw reply [flat|nested] 7+ messages in thread
* Proposed changes to _bsd_pkg -- request for comments 2003-01-02 14:04 Refactoring _bsd_pkg James Devenish 2003-01-02 14:41 ` Oliver Kiddle @ 2003-01-03 8:39 ` James Devenish 2003-01-03 9:14 ` Roman Neuhauser 2003-01-03 10:19 ` Phil Pennock 1 sibling, 2 replies; 7+ messages in thread From: James Devenish @ 2003-01-03 8:39 UTC (permalink / raw) To: zsh-users [-- Attachment #1: Type: text/plain, Size: 2890 bytes --] Hello users, I am looking for some feedback from *BSD users/admins who find themselves using zsh's _bsd_pkg completion for pkg_add, pkg_create, pkg_delete and pkg_info. I am working with OpenBSD but would really appreciate some feedback from someone using _bsd_pkg under FreeBSD. Arising from some light discussion on -workers, I have attached a revised version of _bsd_pkg which takes into account OpenBSD specifics. However, I have some queries about this file as well as looking for people who can confirm its behaviour under FreeBSD and NetBSD. Part I: _bsd_pkg_pkgfiles(), _bsd_pkg_makepaths(), pkg_add() Includes a patch for _bsd_pkg_pkgfiles(), which was matching paths against an undefined variable $PKG_PATH. Is this defined under FreeBSD, perhaps? I found the completion worked erroneously under OpenBSD. My attached version fixes that, and also allows this sort of completion: % ls /usr/ports/packages/blah/ All databases % ls /usr/ports/packages/blah/All foo.tgz bar.tgz % ls /usr/ports/packages/blah/databases db1.tgz db2.tgz % pwd /my/home/directory % ls -dF * */* dir1/ dir1/file3.tgz dir2/ file1.tgz file2.txt % pkg_add <Tab> file1.tgz foo.tgz bar.tgz % pkg_add dir1/<Tab>file3.tgz % pkg_add databases/<Tab> db1.tgz db2.tgz % pkg_add foo<Tab> pkg_add /usr/ports/packages/blah/All/foo.tgz % pkg_add -v foo.tgz pkg_add -v /usr/ports/packages/blah/All/foo.tgz The previous behaviour (for me) was: % pkg_add <Tab> /usr/ports/packages/blah/All/foo.tgz /usr/ports/packages/blah/All/bar.tgz file1.tgz dir1 dir2 /bin /dev /etc I like the "new" behaviour. Basically, the selection list is much more readable and can understand packages subdirectories (to help jog one's memory). So far, the latter is in a 'case' construct for OpenBSD since I don't know how other BSDs lay out their /usr/ports/packages/*. Now this is getting bloat-like, but the previous behaviour seems to leave plenty of room to squeeze out some day-to-date value. The patch I post to zsh-workers won't include all of this for now, but I am interested in users' opinions. Maybe you would like a function that you could bind to a keystroke to bring up package lists. Part II: Flags for pkg_info Under OpenBSD, the -a option can only be used on its own (no other flags or arguments are appropriate). I have implemented this inside a 'case' for openbsd*. If the other BSDs are the same, then we can reduce some of the 'case' constructs. Part III: Other patches Other differences between HEAD and my attachment are (copied from a patch file that I will pass on to -workers): # Replaced single quotes with double quotes # (for readability/neatness when there are nested quote marks). # Detabbed. # OpenBSD compatability for pkg_delete, pkg_info, pkg_create options. # _bsd_pkg_pkgs allows symlinks to directories, not just directories # (rarely useful, but helped once when I was in a pinch). -- James [-- Attachment #2: _bsd_pkg --] [-- Type: text/plain, Size: 8409 bytes --] #compdef pkg_add pkg_create pkg_delete pkg_info # James Devenish <j-devenish@users.sourceforge.net> # Fri, 3 Jan 2003 16:35:32 +0800 # Posted to <zsh-users@sunsite.de> mailing list for opinions. # Replaced single quotes with double quotes. # (for readability/neatness when there are nested quote marks). # Detabbed. # OpenBSD compatability for pkg_delete, pkg_info, pkg_create options. # OpenBSD compatability for pkg_add packages list (requires $MACHTYPE, allows .tar). # _bsd_pkg_pkgs allow symlinks to directories in addition to directories # (rarely useful, but helped once when I was in a pinch). # - from James Devenish <j-devenish@users.sourceforge.net> # _bsd_pkg_pkgfiles no longer includes matches from a lone empty path element # (fixes directories matching /* from appearing when cwd is not /) # - from Oliver Kiddle <okiddle@yahoo.co.uk>, arising out of a query from JD # includes abbreviated completion for pkg_add plus pkg_list # - some portions taken from Bart Schaefer <schaefer@brasslantern.com> local portsdir pkgsdir paths (( $+functions[_bsd_pkg_makepaths] )) || _bsd_pkg_makepaths() { case $OSTYPE in netbsd*) portsdir=${PORTSDIR:-/usr/pkgsrc} pkgsdir=${PACKAGES:-$portsdir/packages}/All paths=( . $pkgsdir ${(s.:.)PKG_PATH} ) ;; openbsd*) portsdir=${PORTSDIR:-/usr/ports} pkgsdir=${PACKAGES:-$portsdir/packages}/$(arch -s) paths=( . $pkgsdir/All $pkgsdir ${(s.:.)PKG_PATH} ) ;; *) portsdir=${PORTSDIR:-/usr/ports} pkgsdir=${PACKAGES:-$portsdir/packages}/All paths=( . $pkgsdir ${(s.:.)PKG_PATH} ) ;; esac } # files that could be package files: (( $+functions[_bsd_pkg_pkgfiles] )) || _bsd_pkg_pkgfiles() { local ret=1 portsdir pkgsdir paths _bsd_pkg_makepaths case $OSTYPE in openbsd*) _files "$@" -W paths -g '*.(t[bg]z|tar)' ;; *) _files "$@" -W paths -g '*.t[bg]z' ;; esac return ret } # names of packages that are currently installed: (( $+functions[_bsd_pkg_pkgs] )) || _bsd_pkg_pkgs() { compadd "$@" - ${PKG_DBDIR:-/var/db/pkg}/*(-/:t) } (( $+functions[_bsd_pkg_pkgs_and_files] )) || _bsd_pkg_pkgs_and_files() { local ret=1 if (( $words[(I)-*F*] )); then _files "$@" && ret=0 else _bsd_pkg_pkgs "$@" && ret=0 fi return ret } _bsd_pkg() { local flags case "$service" in pkg_add) flags=( "-f[force installation]" "-I[don't execute installation scripts]" "-M[run in master mode]" "-n[don't really install packages]" "-p[specify prefix]:prefix directory:_files -/" "-R[don't record]" "-S[run in slave mode]" "-t[specify mktemp template]:mktemp template:_files -/" "-v[be verbose]" ) case "$OSTYPE" in freebsd*) flags=( $flags[@] "-r[fetch from remote site]" ) ;; netbsd*) flags=( $flags[@] "-u[update]" "-V[show version and exit]" ) ;; esac _arguments -s \ $flags[@] \ "*:package to install:_bsd_pkg_pkgfiles" ;; pkg_create) flags=( "-f[specify plist file]:plist file:_files" "(-b)-c[specify comment file]:comment file:_files" "(-b)-d[specify descr file]:descr file:_files" "-Y[assume YES for any questions asked]" "-N[assume NO for any questions asked]" "(-b)-O[packing list only mode]" "-v[be verbose]" "-h[force tar to follow symlinks]" "(-b)-i[specify pre-install script]:pre-install script:_files" "(-b)-P[specify initial dependencies]:dependencies:_bsd_pkg_pkgs" "(-b)-p[specify prefix]:prefix directory:_files -/" "(-b)-k[specify deinstall script]:deinstall script:_files" "(-b)-r[specify req script]:req script:_files" "(-b)-t[specify mktemp template]:mktemp template:_files" "(-b)-X[specify exclude file]:exclude file for tar:_files" "(-b)-D[specify message file]:message file:_files" "(-b)-m[specify mtree file]:mtree file:_files" ) case "$OSTYPE" in netbsd*) # NetBSD users, improve me! flags=( $flags[@] "*:package name:_bsd_pkg_pkgs" ) ;; openbsd*) # TODO check -b flags=( $flags[@] "-C[specify conflict list]:conflicts:_bsd_pkg_pkgs" "-s[fake prefix]:fake destination directory:_files -/" "*:package file name:_files" ) ;; freebsd*) flags=( $flags[@] "(-b)-I[specify post-install script]:post-install script:_files" "(-b)-s[specify source directory]:source directory:_files -/" "(-b)-K[specify post-deinstall script]:post-deinstall script:_files" "(-b)-o[specify origin]:origin:_files -W ${PORTSDIR\:-/usr/ports} -/" "-j[use bzip2]" "-z[use gzip]" "(-c -d -O -i -I -P -p -k -K -r -s -t -X -D -m -o)-b[specify pkgname]:pkgname:_bsd_pkg_pkgs" "*:package file name:_files" ) ;; esac _arguments -s \ $flags[@] ;; pkg_delete) flags=( "-D[don't execute deinstallation scripts]" "-d[remove empty directories]" "-f[force deinstallation]" "-n[don't really deinstall packages]" "-p[specify prefix]:prefix directory:_files -/" "-v[be verbose]" ) case "$OSTYPE" in freebsd*) flags=( $flags[@] "(:)-a[delete all installed packages]" "-G[do not expand glob patterns]" "-i[be interactive]" "-r[delete recursively]" "-x[use regular expression]" ) ;; netbsd*) flags=( $flags[@] "(:)-a[delete all installed packages]" "-F[specify each package by an installed file]" "-i[be interactive]" "-O[only delete the package""s entries]" "-R[delete upward recursively]" "-r[delete recursively]" "-V[show version and exit]" ) ;; esac case "$OSTYPE" in openbsd*) _arguments -s \ $flags[@] \ "*:installed package name:_bsd_pkg_pkgs" ;; *) _arguments -s \ $flags[@] \ "(-a)*:package name:_bsd_pkg_pkgs_and_files" ;; esac ;; pkg_info) flags=( "-c[show comment fields]" "-D[show install-message files]" "-d[show long descriptions]" "-e[test if package is installed]:package name:_bsd_pkg_pkgs" "-f[show packing list instructions]" "-I[show index lines]" "-i[show install scripts]" "-k[show deinstall scripts]" "-L[show full pathnames of files]" "-l[specify prefix string]:prefix string:" "-m[show mtree files]" "-p[show installation prefixes]" "-q[be quiet]" "-R[show list list of installed requiring packages]" "-r[show requirements scripts]" "-v[be verbose]" ) case "$OSTYPE" in freebsd*) flags=( $flags[@] "-G[do not expand glob patterns]" "-g[show files that are modified]" "-o[show origin]" "-s[show total size occupied by each package]" "-t[specify mktemp template]:mktemp template:_files -/" "*-W[show which package the file belongs to]:file:_files" "-x[use regular expression]" ) ;; netbsd*) flags=( $flags[@] "-B[show build information]" "-b[show RCS Id strings]" "-F[specify each package by an installed file]" "-S[show total size occupied by each package and its dependents]" "-s[show total size occupied by each package]" "-V[show version and exit]" ) ;; esac case "$OSTYPE" in openbsd*) _arguments -s \ "(* -)-a[show all installed packages]" \ $flags[@] \ "*:installed package name:_bsd_pkg_pkgs" ;; *) _arguments -s \ "(:)-a[show all installed packages]" \ $flags[@] \ "(-a)*:package name:_bsd_pkg_pkgs_and_files" ;; esac ;; esac } # convert abbreviated package paths to full package paths pkg_add() { setopt localoptions noksharrays noshwordsplit integer i=$ARGC if ((i)); then _bsd_pkg_makepaths while ((i)) do for candidate in $paths do if [[ -f $candidate/$argv[i] ]]; then argv[i]=$candidate/$argv[i] continue fi done ((i--)) done echo pkg_add $* fi command pkg_add $* } _bsd_pkg "$@" ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Proposed changes to _bsd_pkg -- request for comments 2003-01-03 8:39 ` Proposed changes to _bsd_pkg -- request for comments James Devenish @ 2003-01-03 9:14 ` Roman Neuhauser 2003-01-03 10:19 ` Phil Pennock 1 sibling, 0 replies; 7+ messages in thread From: Roman Neuhauser @ 2003-01-03 9:14 UTC (permalink / raw) To: zsh-users # j-devenish@users.sourceforge.net / 2003-01-03 16:39:27 +0800: > I am looking for some feedback from *BSD users/admins who find > themselves using zsh's _bsd_pkg completion for pkg_add, pkg_create, > pkg_delete and pkg_info. I am working with OpenBSD but would really > appreciate some feedback from someone using _bsd_pkg under FreeBSD. I don't really use pkg_*, but do use FreeBSD. more below. > Includes a patch for _bsd_pkg_pkgfiles(), which was matching paths > against an undefined variable $PKG_PATH. Is this defined under FreeBSD, > perhaps? I found the completion worked erroneously under OpenBSD. pkg_add(1): The value of the PKG_PATH is used if a given package can't be found. The environment variable should be a series of entries separated by colons. Each entry consists of a directory name. The current directory may be indicated implicitly by an empty directory name, or explicitly by a sin gle period. I don't use the pkg_* tools, but looks like it should be ${PKG_PATH:-/usr/ports/packages} or something like that. > My attached version fixes that, and also allows this sort of completion: > % pkg_add <Tab> > file1.tgz foo.tgz bar.tgz > % pkg_add dir1/<Tab>file3.tgz > % pkg_add databases/<Tab> > db1.tgz db2.tgz > % pkg_add foo<Tab> > pkg_add /usr/ports/packages/blah/All/foo.tgz > % pkg_add -v foo.tgz > pkg_add -v /usr/ports/packages/blah/All/foo.tgz nice! > I like the "new" behaviour. so do I. :) > Basically, the selection list is much more readable and can understand > packages subdirectories (to help jog one's memory). So far, the latter > is in a 'case' construct for OpenBSD since I don't know how other BSDs > lay out their /usr/ports/packages/*. should be the same. > Under OpenBSD, the -a option can only be used on its own (no other flags > or arguments are appropriate). I have implemented this inside a 'case' > for openbsd*. If the other BSDs are the same, then we can reduce some > of the 'case' constructs. A quick test shows that -v, -p, -q, -g further modify the -a output, others are noop. I haven't found a switch that would make it break (tried about 1/2 of them) -- If you cc me or remove the list(s) completely I'll most likely ignore your message. see http://www.eyrie.org./~eagle/faqs/questions.html ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Proposed changes to _bsd_pkg -- request for comments 2003-01-03 8:39 ` Proposed changes to _bsd_pkg -- request for comments James Devenish 2003-01-03 9:14 ` Roman Neuhauser @ 2003-01-03 10:19 ` Phil Pennock 2003-01-03 10:30 ` James Devenish 1 sibling, 1 reply; 7+ messages in thread From: Phil Pennock @ 2003-01-03 10:19 UTC (permalink / raw) To: zsh-users On 2003-01-03 at 16:39 +0800, James Devenish wrote: > I am working with OpenBSD but would really > appreciate some feedback from someone using _bsd_pkg under FreeBSD. I can't help with that part, since I've not yet migrated away from compctl bindings ... It's also worth noting that all the *BSDs have online man-pages. > I like the "new" behaviour. Basically, the selection list is much more > readable and can understand packages subdirectories (to help jog one's > memory). So far, the latter is in a 'case' construct for OpenBSD since > I don't know how other BSDs lay out their /usr/ports/packages/*. OpenBSD: /usr/ports/packages/`uname -m`/category/package where "category" is "All" or one of the categories from /usr/ports, in which case the contents are symlinks to the All case. I can't remember how the multi-package situation was resolved, so you might want to look more closely at the layout for something like the teTeX packages. Sorry, the only OpenBSD box which I can currently reach is 2.9 and predates a lot of the rearrangements. Under FreeBSD, packages are strictly optional and are built from the installed files (as opposed to the OpenBSD fake-root install, then package creation, then real install from packages). _If_ /usr/ports/packages has been created, then packages will be created under there; if not, then they'll be created inside the ports directory and you'll have things like /usr/ports/shells/zsh/zsh-4.0.6.tgz. Also, FreeBSD is moving steadily towards bzip2 instead of gzip, so you'll see packages with .tbz2 extensions (or, for a short while, there were .tbz extensions, still for bzip2). Which will be created, .tbz2 or .tgz, depends simply upon how old your ports infrastructure makefiles are. My workstation has both, simply because I keep my ports tree updated, including /usr/ports/Mk/. FreeBSD skips the `uname -m` directory level, but is otherwise the same. If memory serves, FreeBSD doesn't have multi-packages, so that issue doesn't arise. Nor does FreeBSD have flavored packages; the package built will have one name, no matter which $USE_* variables were passed to the make system. > # OpenBSD compatability for pkg_delete, pkg_info, pkg_create options. OpenBSD's pkg_info rocks, simply because it doesn't need the version number of a package if there's one version installed. "pkg_info -L zsh" is so convenient. -Phil (the person to blame if you dislike OpenBSD's not including zftp unless you explicitly pick that flavo(u)r of zsh.) -- "We've got a patent on the conquering of a country through the use of force. We believe in world peace through extortionate license fees." -- Andy Forster ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: Proposed changes to _bsd_pkg -- request for comments 2003-01-03 10:19 ` Phil Pennock @ 2003-01-03 10:30 ` James Devenish 0 siblings, 0 replies; 7+ messages in thread From: James Devenish @ 2003-01-03 10:30 UTC (permalink / raw) To: zsh-users In message <20030103111950.A31382@globnix.org> on Fri, Jan 03, 2003 at 11:19:50AM +0100, Phil Pennock wrote: > It's also worth noting that all the *BSDs have online man-pages. LOL pretty stupid of me to overlook that. I could have looked at the FreeBSD man pages long ago! Oh well. > OpenBSD: No worries, I have machines running OpenBSD (but not {Free,Net}BSD). > Under FreeBSD, packages are strictly optional and are built from the > installed files (as opposed to the OpenBSD fake-root install, then > package creation, then real install from packages). _If_ > /usr/ports/packages has been created, then packages will be created > under there; if not, then they'll be created inside the ports directory > and you'll have things like /usr/ports/shells/zsh/zsh-4.0.6.tgz. Interesting. Though _bsd_pkg was made for FreeBSD originally, I wonder if it is still accurate for FreeBSD. > Also, FreeBSD is moving steadily towards bzip2 instead of gzip, so > you'll see packages with .tbz2 extensions (or, for a short while, there > were .tbz extensions, still for bzip2). Which will be created, .tbz2 or > .tgz, depends simply upon how old your ports infrastructure makefiles > are. My workstation has both, simply because I keep my ports tree > updated, including /usr/ports/Mk/. Okay, I introduced a switch statement for filename extensions because it seemed to be more involved than simply t[gbz]. I should probably dig up archives of the -workers thread on that topic, to see if there is anything about what you just mentioned. > -Phil (the person to blame if you dislike OpenBSD's not including zftp > unless you explicitly pick that flavo(u)r of zsh.) :) ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2003-01-03 10:30 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2003-01-02 14:04 Refactoring _bsd_pkg James Devenish 2003-01-02 14:41 ` Oliver Kiddle 2003-01-02 15:37 ` James Devenish 2003-01-03 8:39 ` Proposed changes to _bsd_pkg -- request for comments James Devenish 2003-01-03 9:14 ` Roman Neuhauser 2003-01-03 10:19 ` Phil Pennock 2003-01-03 10:30 ` James Devenish
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).