-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpkg_info
46 lines (40 loc) · 871 Bytes
/
pkg_info
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
#!/bin/sh
sqlite=`which sqlite3`
db_path=/var/db/pkgdb/local.sqlite
pkg_path=/var/db/pkg
if [ ! -f "$sqlite" ]
then
echo "Please install sqlite3 (/usr/ports/databases/sqlite3)"
exit
fi
if [ ! -f "$db_path" ]
then
echo "DB file not found"
exit
fi
if [ "$(ls -A $pkg_path)" ]; then
rm -r $pkg_path/*
fi
pkg_list=`$sqlite $db_path "SELECT name || '-' || version FROM packages;"`
for row in $pkg_list
do
mkdir $pkg_path/$row
done
if [ $# -eq 0 ]
then
$sqlite $db_path "SELECT name || '-' || version FROM packages ORDER BY name;"
exit
fi
case "$1" in
-La)
$sqlite $db_path "SELECT path FROM files;"
;;
-L)
$sqlite $db_path "SELECT f.path FROM files f JOIN packages p ON f.package_id = p.id WHERE (p.name || '-' || p.version) = '$2';"
;;
update)
;;
*)
echo "Parameter \"$1\" is not developed"
;;
esac