Update the Zsh pkgtools.
authorSteve Youngs <steve@sxemacs.org>
Thu, 13 Feb 2014 11:07:29 +0000 (21:07 +1000)
committerSteve Youngs <steve@sxemacs.org>
Thu, 13 Feb 2014 11:07:29 +0000 (21:07 +1000)
Added a function to find reverse dependencies and fixed a couple of minor
niggling things.

* etc/pkgusr/zsh/zsh-pkgtools (pkgwant): New function that lists
packages that depend on a certain pkg.

* etc/pkgusr/zsh/zsh-pkgtools (H-pkg): Mention pkgwant().

* etc/pkgusr/zsh/zsh-pkgtools (xtar,vtar): Fix bug where xz files
weren't being detected.

* etc/pkgusr/zsh/zsh-pkgtools (pkg_ldconfig): Prevent spurious
output.

* etc/pkgusr/zsh/_zsh-pkgtools: Tab-complete users for pkgwant.

Signed-off-by: Steve Youngs <steve@sxemacs.org>
etc/pkgusr/zsh/_zsh-pkgtools
etc/pkgusr/zsh/zsh-pkgtools

index 51ba0c4..ac71782 100644 (file)
@@ -1,9 +1,9 @@
-#compdef ppkg cpkg dpkg upkg vpkg ipkg gpkg wpkg pkgrepo pkgsu xtar vtar
+#compdef ppkg cpkg dpkg upkg vpkg ipkg gpkg wpkg pkgrepo pkgsu pkgwant xtar vtar
 
 case $service in
         (cpkg) _command_names -e ;;
         (?pkg) _wanted file expl 'Pkg User' _users ;;
-        (pkgrepo|pkgsu) _wanted file expl 'Pkg User' _users ;;
+        (pkgrepo|pkgsu|pkgwant) _wanted file expl 'Pkg User' _users ;;
         ([xv]tar) _wanted file expl 'Tarball' _files -g '*.{t{gz,bz{,2},lz,xz},tar.{Z,gz,bz2,lzma,xz}}(-.)' ;;
 esac
 
index 1f11308..3c5164f 100644 (file)
@@ -20,6 +20,7 @@ H-pkg ()
         gpkg [PKG]    -- print general notes of PKG.
         wpkg [PKG]    -- print PKG website URL.
         dpkg [PKG]    -- print PKG dependencies.
+       pkgwant [PKG] -- print a list of packages that depend on PKG
         pkgrepo [PKG] <t> -- print the source repo location of PKG
                              with optional 2nd arg non-nil, also print
                              repo type.
@@ -169,6 +170,19 @@ pkgrepo()
         fi
 }
 
+pkgwant()
+{
+       if [[ $ARGC -lt 1 || $ARGC -gt 1 ]]; then
+               echo Invalid or mission argument >&2
+               echo "Usage: $0 [PKG]" >&2
+               return 1
+       fi
+
+       for p in $(lpkg); do
+               dpkg ${p} | grep -q $argv[1] && print ${p}
+       done
+}
+
 xtar()
 {
         if [[ $ARGC -lt 1 || $ARGC -gt 1 ]]; then
@@ -187,7 +201,7 @@ xtar()
                (tar)   opts=xf ;;
                (gzip)  opts=zxf ;;
                (bzip2) opts=jxf ;;
-               (xz)    opts=Jxf ;;
+               (xz|XZ  opts=Jxf ;;
                (*)
                        # try lzma
                        if lzmainfo ${fname} &>/dev/null; then
@@ -220,7 +234,7 @@ vtar()
                 (tar)   opts=tvvvf ;;
                 (gzip)  opts=ztvvvf ;;
                 (bzip2) opts=jtvvvf ;;
-               (xz)    opts=Jtvvvf ;;
+               (xz|XZ) opts=Jtvvvf ;;
                 (*)
                        # lzma.  Here because lzmainfo is too stupid
                        if lzmainfo ${fname} &>/dev/null; then
@@ -272,7 +286,7 @@ pkg_install()
         fi
 }
 
-alias pkg_ldconfig='ssh -l root localhost -t ldconfig'
+alias pkg_ldconfig='ssh -l root localhost ldconfig'
 
 ### End