-
Notifications
You must be signed in to change notification settings - Fork 3
/
iglu.sh
executable file
·119 lines (111 loc) · 1.67 KB
/
iglu.sh
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/bin/sh -e
# usage: iglu [ add | del | has ] <pkg>
#
# options:
# -a <arch> target arch
# -r <dir> root dir
fatal() {
printf "ERROR: %s\n" "$@"
exit 1
}
warn() {
printf "WARNING: %s\n" "$@"
}
usage() {
if [ ! -z "$1" ]; then
fatal "$@"
fi
printf "usage: %s [add | del | has] <pkg>\n" $(basename "$0")
printf "version: 0.3.0\n"
exit 1
}
if [ -z "$1" ]
then
usage
fi
case "$1" in
add)
shift
root_dir=
yes=
name=
xbps_arch=
while :
do
case "$1" in
-a)
shift
if [ ! -z "$1" ]
then
xbps_arch="$1"
else
fatal '-a requires an argument'
fi
shift
;;
-r)
shift
if [ ! -z "$1" ]
then
root_dir="$1"
else
fatal '-r requires an argument'
fi
shift
;;
-y)
yes=1
shift
;;
*)
if [ ! -z "$1" ]
then
name="$1"
shift
else
break
fi
esac
done
xbps_extra_args=
if [ ! -z "$root_dir" ]
then
xbps_extra_args="-r $root_dir $xbps_extra_args"
fi
if [ ! -z "$yes" ]
then
xbps_extra_args="-y $xbps_extra_args"
fi
if [ ! -z "$xbps_arch" ]
then
export XBPS_ARCH="$xbps_arch"
export XBPS_TARGET_ARCH="$xbps_arch"
fi
case "$name" in
*.xbps)
REPO=/run/iglu
mkdir -p $REPO
cp "$name" "$REPO"
cd "$REPO"
rm -f *-repodata
xbps-rindex -a *.xbps
cd -
b_name=$(basename "$name" | cut -d'.' -f1 | rev | cut -d'-' -f2- | rev)
xbps-install $xbps_extra_args --repository="$REPO" "$b_name" -f
rm -rf $REPO
;;
*)
xbps-install "$name"
;;
esac
;;
del)
xbps-remove -R "$2"
;;
has)
xbps-query "$2"
;;
*)
usage "unknown sub command: $1"
;;
esac