[go: up one dir, main page]

Menu

[r30]: / trunk / libindex.sh  Maximize  Restore  History

Download this file

98 lines (88 with data), 2.0 kB

 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
#!/bin/sh
# Init the cached index.
# fetch from repository to $APK_CACHE if not existing.
# sets the global variable INDEX_CACHE
index_init() {
mkdir -p $APK_CACHE
if [ ! -f "$CACHED_INDEX" ] ; then
mkdir -p `dirname $CACHED_INDEX`
fetch $INDEX_URI $APK_CACHE
fi
}
# update the cached index. If the fetch fails, rollback to the current index.
index_update() {
mv $CACHED_INDEX $CACHED_INDEX.backup
if fetch $INDEX_URI $APK_CACHE ; then
rm $CACHED_INDEX.backup
else
mv $CACHED_INDEX.backup $CACHED_INDEX
return 1
fi
}
# functions that queries the cached index
# parameter: DEPEND | REQURIED_BY | SHASUMS
index_cat() {
index_init
tar -O -zxf $CACHED_INDEX $1
}
#index_get_deps() {
# local pkg
# pkg=`rm_ver $1`
# index_cat DEPEND | grep "^${pkg}:" | cut -d : -f 2
#}
#
# reqursively find all dependencies
#index_recurse_deps() {
# local i
# for i in `index_get_deps $1` ; do
# index_recurse_deps $i
# done
# echo $1
#}
#
#index_all_deps() {
# index_recurse_deps $1 | sort | uniq
#}
#
#index_get_reqs() {
# local pkg
# pkg=`rm_ver $1`
# index_cat REQUIRED_BY | grep "^${pkg}:" | cut -d : -f 2
#}
# get the package filename (without path)
# parameter can either be a:
# pkgf - just return the parameter
# pkgv - just append .apk
# pkg - append version number and .apk
#
index_get_pkgf() {
local regexp p=$1
if is_apk $p ; then
echo $p
return
elif has_version $p ; then
regexp=" $p.apk"
else
regexp=" $p-[0-9].*"
fi
index_cat SHASUMS | awk "/$regexp/ {print \$2}" | tail -n 1
}
# get the package name-version from index
index_get_pkgv() {
basename `index_get_pkgf $1` .apk
}
# Append APK_PATH if parameter is not an uri (contains "^[a-z]*:/")
# if parameter is not an apk, find the version number also
index_get_uri() {
local pkgf p=$1
if is_uri $p ; then
echo $p
elif is_apk $p ; then
echo "$APK_PATH/$p"
else
pkgf=`index_get_pkgf $p`
# return error in case the package is not in index
[ -z "$pkgf" ] && return 1
echo "$APK_PATH/$pkgf"
fi
}