aboutsummaryrefslogtreecommitdiff
path: root/tools/XBMCLive/live-initramfs/bin/live-reconfigure
blob: 16cb51dfa4c35880a4364bc1f9f0c55c7b3591f0 (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
#! /bin/sh

set -e

export PATH=/usr/bin:/usr/sbin:/sbin:/bin

frontend=noninteractive

findcommandinroot ()
{
	ROOT="${1}/"
	shift

	while [ "${#}" -ge 1 ]
	do
		P="${PATH}"

		while [ "${P}" ]
		do
			D=${P%%:*}
			P=${P#*:}

			if [ "${D}" = "${P}" ]
			then
				P=
			fi

			if [ -z "${D}" ]
			then
				D=.
			fi

			if [ -x "${ROOT}${D}/${1}" ]
			then
				echo "${D}/${1}"
				return 0
			fi
		done

		shift
	done

	return 1
}

runcommandinroot ()
{
	C=$(findcommandinroot "${1}" "${2}")
	ROOT="${1}"

	shift
	shift

	[ -n "${C}" ] && chroot "${ROOT}" "${C}" "${@}"
}

root="${1}"
package="${2}"

version=$(runcommandinroot "${root}" dpkg-query -W --showformat='${Version}' "${package}" 2>/dev/null) || version=""

if [ -z "${version}" ]
then
	echo >&2 "${0}: package '${package}' is not installed"
	exit 0
fi

runcommandinroot "${root}" dpkg-reconfigure -fnoninteractive --no-reload "${package}"

exit 0