# -*- shell-script -*-
-# Copyright (C) 2007 Steve Youngs <steve@sxemacs.org>
+# Copyright (C) 2007 - 2013 Steve Youngs <steve@sxemacs.org>
# What lies here is a collection of handy bash shell functions that
# make life a little easier for pkgusr.
showinst()
{
- local top=$(pinky -l $(whoami)|grep -n "^Install Notes:$"|cut -d: -f1)
- local bot=$(pinky -l $(whoami)|grep -n "^General Notes:$"|cut -d: -f1)
+ local top=$(grep -n "^Install Notes:$" ${HOME}/.project|cut -d: -f1)
+ local bot=$(grep -n "^General Notes:$" ${HOME}/.project|cut -d: -f1)
- pinky -l $(whoami)|sed -n ${top},${bot}p
+ sed -n ${top},${bot}p ${HOME}/.project
}
showgen()
{
- local top=$(pinky -l $(whoami)|grep -n "^General Notes:$"|cut -d: -f1)
- local bot=$(pinky -l $(whoami)|grep -n "^CONTENTS:$"|cut -d: -f1)
+ local top=$(grep -n "^General Notes:$" ${HOME}/.project|cut -d: -f1)
+ local bot=$(grep -n "^CONTENTS:$" ${HOME}/.project|cut -d: -f1)
- pinky -l $(whoami)|sed -n ${top},${bot}p
+ sed -n ${top},${bot}p ${HOME}/.project
+}
+
+deps()
+{
+ grep --colour 'Deps: ' ${HOME}/.project
}
listp()
srepo()
{
- pinky -l $(whoami)|grep --colour Repo_Location:.*$
+ grep --colour Repo_Location:.*$ ${HOME}/.project
}
rawrepo()
{
- srepo|awk '{print $2;}'|tr -d '<>'
+ srepo|awk '{print $2;}'|tr -d '<>'
}
trepo()
{
- pinky -l $(whoami)|grep --colour Repo_Type:.*$
+ grep --colour Repo_Type:.*$ ${HOME}/.project
}
web()
{
- pinky -l $(whoami)|grep --colour Web_Site:.*$
+ grep --colour Web_Site:.*$ ${HOME}/.project
}
rawweb()
trepo Display the type of repo (tla, git, svn, mercurial etc)
web Display the package's homepage URL.
rawweb Output just the web URL (to use with lynx etc)
+ deps Display the package's dependencies
xtar [TARBALL] Extract TARBALL, automatically choosing the appropriate
tar(1) options.
vtar [TARBALL] List the contents of TARBALL, automatically choosing
Repo_Location: <URI>
Web_Site: <URL>
+ Deps: <package dependencies>
+
Install Notes:
-------------
Use the build script.
## Version info.
ourname=${0##*/}
-VERSION=1.2
-COPYRIGHT="Copyright (C) 2007 - 2011 Steve Youngs <steve@steveyoungs.com>"
+VERSION=1.3
+COPYRIGHT="Copyright (C) 2007 - 2013 Steve Youngs <steve@steveyoungs.com>"
version_str="${ourname}: ${VERSION}\n${COPYRIGHT}"
show_version()
update_commands()
{ :
- sed -i s/"Last_Updated.*"/"Last_Updated: $(date +%c)"/g ${HOME}/.project
+ sed -i s/"\(Last_Updated: \).*$"/"\1$(date +%c)"/g ${HOME}/.project
+ sed -i s/"\(Deps: \).*$"/"\1$(forall_direntries_from $(whoami) -executable -exec ldd {} 2>/dev/null \;|grep '=>' 2>/dev/null|awk '{print $3;}'|xargs stat --format \"%U:%G\"|sort|uniq|xargs echo -n)"/ ${HOME}/.project
awk '/^CONTENTS:/ { print; exit; } {print}' ${HOME}/.project > ${HOME}/.projtmp
echo "--------" >> ${HOME}/.projtmp
list_package $(whoami) >> ${HOME}/.projtmp
-#compdef ppkg cpkg upkg vpkg ipkg gpkg wpkg pkgrepo pkgsu xtar vtar
+#compdef ppkg cpkg dpkg upkg vpkg ipkg gpkg wpkg pkgrepo pkgsu xtar vtar
case $service in
(cpkg) _command_names -e ;;
# -*- Shell-script -*-
-# Copyright (C) 2007 - 2010 Steve Youngs <steve@steveyoungs.com>
+# Copyright (C) 2007 - 2013 Steve Youngs <steve@steveyoungs.com>
#
# A collection of Zsh functions that I use day to day for maintaining
# and administering my machines. These come in very handy if you set up
ipkg [PKG] -- print install notes of PKG.
gpkg [PKG] -- print general notes of PKG.
wpkg [PKG] -- print PKG website URL.
+ dpkg [PKG] -- print PKG dependencies.
pkgrepo [PKG] <t> -- print the source repo location of PKG
with optional 2nd arg non-nil, also print
repo type.
echo "Usage: $0 [PKG]" >&2
return 1
else
- echo -n "$argv[1]... "
- pinky -l $argv[1]|grep 'Last_Updated:.*'| \
- sed 's/^ //'|grep --colour '.*'
+ grep --colour 'Last_Updated:.*' ~$argv[1]/.project
fi
}
Lpkg ()
{
for pkg in $(sed -n '/^install/p' /etc/group|cut -d: -f4|tr ',' '\n'); do
- printf "${pkg}\t\t\t$(pinky -l ${pkg}|grep Last_Updated|cut -d' ' -f3-)\n"
+ printf "${pkg}\t\t\t$(upkg ${pkg}|cut -d' ' -f3-)\n"
done|less
}
echo "Usage: $0 [PKG]" >&2
return 1
else
- echo -n "$argv[1]... "
- pinky -l $argv[1]|grep 'Version:.*'| \
- sed 's/^ //'|grep --colour '.*'
+ grep --colour 'Version: ' ~$argv[1]/.project
fi
}
echo "Usage: $0 [PKG]" >&2
return 1
else
- local top=$(pinky -l $argv[1]|grep -n "Install Notes"|cut -d: -f1)
- local bot=$(pinky -l $argv[1]|grep -n "General Notes"|cut -d: -f1)
- pinky -l $argv[1]|sed -n ${top},${bot}p
+ local top=$(grep -n "Install Notes" ~$argv[1]/.project|cut -d: -f1)
+ local bot=$(grep -n "General Notes" ~$argv[1]/.project|cut -d: -f1)
+ sed -n ${top},${bot}p ~$argv[1]/.project
fi
}
echo "Usage: $0 [PKG]" >&2
return 1
else
- local top=$(pinky -l $argv[1]|grep -n "General Notes"|cut -d: -f1)
- local bot=$(pinky -l $argv[1]|grep -n "CONTENTS"|cut -d: -f1)
- pinky -l $argv[1]|sed -n ${top},${bot}p
+ local top=$(grep -n "General Notes" ~$argv[1]/.project|cut -d: -f1)
+ local bot=$(grep -n "CONTENTS" ~$argv[1]/.project|cut -d: -f1)
+ sed -n ${top},${bot}p ~$argv[1]/.project
fi
}
+dpkg()
+{
+ if [[ $ARGC -lt 1 || $ARGC -gt 1 ]]; then
+ echo Invalid or missing argument >&2
+ echo "Usage: $0 [PKG]" >&2
+ return 1
+ else
+ grep --colour 'Deps: ' ~$argv[1]/.project
+ fi
+}
+
wpkg()
{
if [[ $ARGC -lt 1 || $ARGC -gt 1 ]]; then
echo "Usage: $0 [PKG]" >&2
return 1
else
- pinky -l $argv[1]|grep --colour 'Web_Site:.*$'
+ grep --colour 'Web_Site: ' ~$argv[1]/.project
fi
}
echo "Usage: $0 [PKG] <t>" >&2
return 1
else
- pinky -l $argv[1]|grep --colour 'Repo_Location:.*$'
- [[ -n "$argv[2]" ]] && pinky -l $argv[1]|grep --colour 'Repo_Type:.*$'
+ grep --colour 'Repo_Location: ' ~$argv[1]/.project
+ [[ -n "$argv[2]" ]] && grep --colour 'Repo_Type: ' ~$argv[1]/.project
fi
}
;; Author: Steve Youngs <steve@sxemacs.org>
;; Maintainer: Steve Youngs <steve@sxemacs.org>
;; Created: <2007-07-13>
-;; Time-stamp: <Saturday Jun 23, 2012 13:56:29 steve>
+;; Time-stamp: <Sunday Feb 3, 2013 12:17:39 steve>
;; Homepage: N/A
;; Keywords: utils package-management
(let* ((allpkgs (pkgusr-all-pkgs))
(pkg (or pkg (completing-read "Package: "
(mapcar #'list allpkgs)
- nil t nil pkgusr-pkg-history))))
+ nil t nil pkgusr-pkg-history)))
+ (pkgfile (format "/usr/src/%s/.project" pkg)))
(when (member pkg allpkgs)
(with-temp-buffer
(erase-buffer)
- (insert (shell-command-to-string (format "pinky -l %s" pkg)))
+ (insert-file-contents pkgfile)
(goto-char (point-min))
(re-search-forward "Web_Site: <\\(.*\\)>$" nil t)
(if (interactive-p)
(pkg (or pkg (completing-read "Package: "
(mapcar #'list allpkgs)
nil t nil pkgusr-pkg-history)))
+ (pkgfile (format "/usr/src/%s/.project" pkg))
repo type)
(when (member pkg allpkgs)
(with-temp-buffer
(erase-buffer)
- (insert (shell-command-to-string (format "pinky -l %s" pkg)))
+ (insert-file-contents pkgfile)
(goto-char (point-min))
(re-search-forward "Repo_Type: <?\\(.*\\)>?$" nil t)
(setq type (match-string 1))
(let* ((allpkgs (pkgusr-all-pkgs))
(pkg (or pkg (completing-read "Package: "
(mapcar #'list allpkgs)
- nil t nil pkgusr-pkg-history))))
+ nil t nil pkgusr-pkg-history)))
+ (pkgfile (format "/usr/src/%s/.project" pkg)))
(if (member pkg allpkgs)
(with-temp-buffer
(erase-buffer)
- (insert (shell-command-to-string (format "pinky -l %s" pkg)))
+ (insert-file-contents pkgfile)
(goto-char (point-min))
(re-search-forward "Version: \\(.*$\\)" nil t)
(if (interactive-p)
(let* ((allpkgs (pkgusr-all-pkgs))
(pkg (or pkg (completing-read "Package: "
(mapcar #'list allpkgs)
- nil t nil pkgusr-pkg-history))))
+ nil t nil pkgusr-pkg-history)))
+ (pkgfile (format "/usr/src/%s/.project" pkg)))
(if (member pkg allpkgs)
(with-temp-buffer
(erase-buffer)
- (insert (shell-command-to-string (format "pinky -l %s" pkg)))
+ (insert-file-contents pkgfile)
(goto-char (point-min))
(re-search-forward "Description: \\(.*$\\)" nil t)
(if (interactive-p)
(match-string 1)))
(error 'pkgusr-unknown-pkg pkg))))
+(defun pkgusr-pkg-deps (&optional pkg)
+ "Return the dependencies of PKG as a string."
+ (interactive)
+ (let* ((allpkgs (pkgusr-all-pkgs))
+ (pkg (or pkg (completing-read "Package: "
+ (mapcar #'list allpkgs)
+ nil t nil pkgusr-pkg-history)))
+ (pkgfile (format "/usr/src/%s/.project" pkg)))
+ (if (member pkg allpkgs)
+ (with-temp-buffer
+ (erase-buffer)
+ (insert-file-contents pkgfile)
+ (goto-char (point-min))
+ (re-search-forward "Deps: \\(.*$\\)" nil t)
+ (if (interactive-p)
+ (message "[%s Deps] %s" pkg (match-string 1))
+ (match-string 1)))
+ (error 'pkgusr-unknown-pkg pkg))))
+
;; A little bogus perhaps, but it works. `pkgusr-find-file' is
;; something that only I can use because it ssh's through root to
;; get to the pkgusr. And nobody but me would have a need for
(global-set-key [(hyper c) f] #'pkgusr-file-pkg)
(global-set-key [(hyper c) (hyper r)] #'pkgusr-list-pkgs-regexp)
(global-set-key [(hyper c) d] #'pkgusr-pkg-description)
+(global-set-key [(hyper c) D] #'pkgusr-pkg-deps)
(global-set-key [(hyper c) g] #'pkgusr-pkg-general-notes)
(global-set-key [(hyper c) i] #'pkgusr-pkg-install-notes)
(global-set-key [(hyper c) r] #'pkgusr-pkg-repo)