summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2008-06-15 11:45:07 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2008-06-15 11:45:07 +0200
commit8e5926c4559aa98a4d5a1d36d44ae20004407b6b (patch)
tree9853446742f0aea5c1248fe447e9ae8b2d86143f /bin
parent4b66df2aba15a127b384c2d40ef3a00bd791a830 (diff)
bin/pkg: Use error functions for some messages
Diffstat (limited to 'bin')
-rwxr-xr-xbin/pkg20
1 files changed, 14 insertions, 6 deletions
diff --git a/bin/pkg b/bin/pkg
index 0cc2498..11ba47d 100755
--- a/bin/pkg
+++ b/bin/pkg
@@ -32,6 +32,14 @@ die () {
exit 100
}
+e_notinstalled () {
+ die "Not installed: $1\n"
+}
+
+e_invalid () {
+ die "Not a valid package name: '$1'\n"
+}
+
clear_line () {
echo -ne "\r \r"
}
@@ -270,8 +278,8 @@ pkg_add () {
}
pkg_remove () {
- [ -d $PDIR/$1 ] || die "Package '$1' is not installed!\n"
- [ -d $PDIR/$1/.hg ] || die "Not a valid package: '$1'\n"
+ [ -d $PDIR/$1 ] || e_notinstalled "$1"
+ [ -d $PDIR/$1/.hg ] || e_invalid "$1"
cd $PDIR/$1
if ([ -r priority ]) {
if ([ $(cat priority) -gt 3 ]) {
@@ -289,7 +297,7 @@ pkg_remove () {
}
pkg_update () {
- cd $PDIR/$1
+ cd $PDIR/$1 || e_notinstalled "$1"
info "Looking for updates: $1"
NEW=$($VCS_CMD $VCS_OPTIONS $VCS_INCOMING)
if ([ $? = 0 ]) {
@@ -351,7 +359,7 @@ pkg_list_available () {
# Local modifications should not be overseen...
pkg_status () {
- cd $PDIR/$1
+ cd $PDIR/$1 || e_notinstalled "$1"
info "looking for local modifications: $1"
# check_deps $1
# checklinks $CL_OPTIONS
@@ -377,7 +385,7 @@ pkg_status_wrapper () {
# Various information related to a package
pkg_info () {
- cd $PDIR/$1 || return
+ cd $PDIR/$1 || e_notinstalled "$1"
[ -z "$1" ] && die "Not enough arguments\n"
# Fetch the infos
NAME="$1"
@@ -423,7 +431,7 @@ pkg_info () {
}
pkg_log () {
- cd $PDIR/$1 || return
+ cd $PDIR/$1 || e_notinstalled "$1"
hg glog | less
}