blob: 871fe2ac78da954d26772caee1d866e20f32b68f (
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
#!/bin/sh
# Download a file and find out the http code
#
download_file() {
curl ${CURL_OPTS} -o $1 -w "%{http_code}" $2 2>> ${LOG_FILE}
}
# Check if the user can write to the selected systemroot
#
checkroot () {
[ -w "${SYSROOT}" ] || {
printf "${RED}Please run as root!${RESET}\n"
exit 1
}
}
# this function is broken
wait_for_jobs () {
local text=$1
local end=$2
shift 2
joblist="-e $(echo $@ | sed "s/ / -e /g")"
echo "$joblist"
if ! $QUIET; then
local total=$#
local completed=0
while [ "$completed" != "$total" ]; do
running=$(ps aux | grep $joblist | wc -l)
completed=$(( $total - $running + 1))
hbar -T "$text" $completed $total
done
hbar -t ${HBAR_COMPLETE} -T "$end" $completed $total
fi
wait
}
wait_for_download () {
if ! $QUIET; then
local total_download=$1
shift
local downloaded=0
while [ "$downloaded" -lt "$total_download" ]; do
downloaded=0
for output in $@; do
[ -f $output ] && {
size=$(stat -t $output | cut -d" " -f2)
} || {
size=0
}
downloaded=$((downloaded+size))
done
hbar -h -T " downloading packages" $downloaded $total_download
done
hbar -th ${HBAR_COMPLETE} -T "${CHECKMARK} downloaded packages" $downloaded $total_download
fi
wait
}
wait_for_extract () {
if ! $QUIET; then
local total_filecount=$1
local extracted=0
shift
while [ "$extracted" -lt "$total_filecount" ]; do
extracted=0
for output in $@; do
if [ -f $output ]; then
size=$(cat $output | wc -l)
extracted=$((extracted+size))
fi
done
hbar -T " extracting files" $extracted $total_filecount
done
hbar -t ${HBAR_COMPLETE} -T "${CHECKMARK} extracted packages" $extracted $total_filecount
fi
wait
}
prompt_question () {
$NOCONFIRM && return 0
printf "$1 [Y/n] "
read response
[ "${var%${var#?}}"x != 'nx' ]
}
# return if a package is present on the system or not
#
is_installed() {
[ -f "${SYSROOT}${INSTALLED_DIR}/$1/checksum" ]
}
# get the installed checksum of a package ($1)
#
get_installed_version () {
local name=$1
local file="${SYSROOT}${INSTALLED_DIR}/$name/checksum"
[ -f $file ] &&
cat $file
}
#
#
package_exists () {
[ -f "${PACKAGES_DIR}/$1" ]
}
|