forked from google/android-cuttlefish
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwrite-equivs.sh
executable file
·51 lines (42 loc) · 1.15 KB
/
write-equivs.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
#!/bin/bash
set -o errexit
# set -x
source utils.sh
# $1 = parent
# $2 = parent version
# $3 = name
# $4 = version
# $5 = op
# $6 = filter
# $7 = process
function write_equivs {
local parent="$1"
local parent_version="$2"
local name="$3"
local version="$4"
local op="$5"
local filter="$6"
local process="$7"
if [ -z "$(is_installed ${name} ${version} ${op})" ]; then
return
fi
if ! grep -q -E "^${name}$|^${name} " equivs.txt; then
local package_and_arch=$(add_arch "${name}")
local installed_version=$(dpkg-query -W -f='${Version}' "${package_and_arch}")
if [ "${version}" != '_' ]; then
if ! dpkg --compare-versions ${installed_version} ${op} ${version}; then
echo Installed package ${package_and_arch} version ${installed_version} not ${op} to/than ${version} 2>&1
exit 1
fi
else
# The depencency did not specify a version; we use the installed version
# and the eq operator
op=eq
fi
printf "%-${SHLVL}s" " "
echo "${name}" "${installed_version}" "${op}" | tee -a equivs.txt
./parse-deps.sh "${name}" "${filter}" "${process}"
fi
}
touch equivs.txt
write_equivs $*