File: binpath-test.sh

package info (click to toggle)
runit-services 0.10.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 404 kB
  • sloc: sh: 477; makefile: 2
file content (47 lines) | stat: -rwxr-xr-x 1,281 bytes parent folder | download | duplicates (2)
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
#!/bin/sh
set -e

# test that path in bin file remains consistent with the one
# used by packages; packages rarely changes path of executable
# but when they do, it breaks our services. see #1069075

rc=0

echo "importing dh-runit control file.."
cp debian/runit-services.runit "$AUTOPKGTEST_TMP"
echo "done"

apt-file update

cd "$AUTOPKGTEST_TMP"

while read line ; do
	# skip empty lines
	[ -z "$line" ] && continue
	firstchar="$(echo $line | head -c 1)"
	if [ "$firstchar" = '#' ]; then
		echo "skipping, line commented"
		continue
	fi
#	echo "$line"
	binpath=$(echo "$line" | sed 's/^.*bin=/bin=/')
#	echo "bin path is  ${binpath}"
	binpath=${binpath%%,*}  #just to be sure
	binpath=${binpath#*=} #strip bin=
	bin=${binpath##*/}
#	echo "bin path is  ${binpath}"
	if apt-file search "$binpath" >/dev/null ; then
		echo "OK: $binpath found"
	elif apt-file search "$bin" | grep  '/bin/\|/sbin/\|/libexec/' ; then
		echo "ERROR: $bin found, but path is not $binpath"
		#this is really bad, like #1069075
		rc=$((rc+1))
	else
		echo "WARNING: $binpath not found in any package!"
		# package is not in archive or is arch specific, like amd64/i386 only
		# not really an issue but warning may help catching scripts with removed packages
	fi
done <  runit-services.runit

exit "$rc"