blob: c73a202f459153c07f6708aa38ca8fd27dfae6b6 (
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
85
86
87
88
89
90
91
92
93
94
|
#!/bin/sh
extract () {
tar -h --no-overwrite-dir -vvxf $1 -C ${SYSROOT} | grep ^- | tr -s " " | cut -d" " -f6 | cut -c2-
}
install_package () {
local pkg_file="$1"
local name="$2"
local info_file="$pkg_file.info"
local installed_dir="${INSTALLED_DIR}/$name"
local info="$installed_dir/info"
local files="$installed_dir/files"
local checksum="$installed_dir/checksum"
mkdir -p "$installed_dir"
[ -f $files ] && mv $files $files.old
extract $1 > $files
cp $info_file $info
md5sum $pkg_file | cut -d' ' -f1 > $checksum
if [ -f "$files.old" ]; then
for file in $(diff $files $files.old | grep ^\> | cut -d' ' -f2); do
rm -f ${SYSROOT}$file
done
rm $files.old
fi
}
get_package_filecount() {
set -- $(get_package_download_info $1)
echo $4
}
total_filecount() {
local packages=$@
local count=0
for package in $packages; do
local name=$(basename -s .xipkg $package | cut -d. -f2)
local c=$(get_package_filecount $name)
count=$((count+c))
done
echo $count
}
run_postinstall () {
postinstall="${SYSROOT}/var/lib/xipkg/postinstall"
if [ -d $postinstall ]; then
for file in $(ls $postinstall/*.sh); do
f=$(basename $file)
# run the postinstall file
#
chmod 755 $file
[ "${SYSROOT}" = "/" ] &&
sh "/var/lib/xipkg/postinstall/$f" &&
rm $file &&
printf "${GREEN}run postinstall for $f!\n"
done
rmdir $postinstall
fi
}
install () {
local packages=$@
local missing=""
for package in $packages; do
[ ! -f $package ] && missing="$missing $(basename $package)"
done
if [ "${#missing}" != "0" ]; then
# warning: potential recursion loop here
fetch $missing
else
local total=$(total_filecount $packages)
local files_files=""
for package in $packages; do
local name=$(basename -s .xipkg $package | cut -d. -f2)
install_package $package $name &
mkdir -p "${INSTALLED_DIR}/$name/"
filelist="${INSTALLED_DIR}/$name/files"
touch $filelist
files_files="$files_files $filelist"
done
wait_for_extract $total ${files_files}
run_postinstall
fi
}
|