blob: 7f2b1d53d1fba8695d4814e927680335090c9fd3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
#!/usr/bin/env zsh
PDIR="$HOME/packages"
PKG_ROOT="ssh://derf.homelinux.org/packages"
local info=$'\e[0;36m'
local reset=$'\e[0m'
local HG_OPTIONS='--quiet'
local CL_OPTIONS='-q'
echo_status () {
echo "${info}$*${reset}"
}
if [ ! -d $PDIR ]; then
echo_status "$PDIR not found!!"
exit 100
fi
check_deps () {
[ -r $PDIR/$1/.deps ] || return 0
DEPS=($(cat $PDIR/$1/.deps))
for dep in DEPS; {
if [ ! -d $PDIR/$dep ]; then
echo -n "$1 depends on $dep. Install dependency? [Y/n] "
read
if [ ! "$REPLY" = 'n' ]; then
"$0" add "$dep"
fi
fi
}
}
pkg_add () {
if [ -d $PDIR/$1 ]; then
echo_status "Package already installed!"
return 100
fi
check_deps "$1"
cd $PDIR || return 255
echo_status 'Retrieving package...'
hg $HG_OPTIONS clone $PKG_ROOT/$1 || return 255
if [ -f $1/hooks/post-add ]; then
echo_status 'Executing post-add hook'
. $1/hooks/post-add
fi
echo_status 'Checking symlinks...'
cd $1
checklinks $CL_OPTIONS
return 0
}
pkg_remove () {
if [ ! -d $PDIR/$1 ]; then
echo_status "Package not installed!"
return 100
fi
if [ -f $PDIR/$1/hooks/pre-remove ]; then
echo_status 'Executing pre-remove hook'
. $PDIR/$1/hooks/pre-remove
fi
rm -r $PDIR/$1
echo_status "Package removed."
}
pkg_update () {
cd $PDIR
for i in *(/); {
echo_status "Updating package $i..."
check_deps "$1"
cd $i
hg $HG_OPTIONS fetch
checklinks $CL_OPTIONS
if [ -f hooks/post-update ]; then
echo_status 'Executing post-update hook'
. hooks/post-update
fi
cd ..
}
}
case "$1" in
add) pkg_add "$2" ;;
update) pkg_update ;;
remove) pkg_remove "$2" ;;
esac
|