summaryrefslogtreecommitdiffstats
path: root/test/integration/create-test-data
blob: eff2ba53029e9e754bc62dc0f66e3fd138b02b5a (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
#!/bin/sh
set +e # its okay to fail in these script, most of the time the apt* stuff will generate errors

if [ -z "$1" -o -z "$2" ]; then
	echo "Usage: $0 file codename pkg…"
	exit 1
fi

CHECK_ARGS='no'
TESTDIR="$(readlink -f "$(dirname "$0")")"
. "$TESTDIR/framework"
find_project_binary_dir
BUILDDIRECTORY="${APT_INTEGRATION_TESTS_BUILD_DIR:-"${PROJECT_BINARY_DIR}/cmdline"}"

GENERATE="$1"
CODENAME="$2"
shift 2

WORKDIR="$(mktemp -d)"
cleanupworkdir() {
	if [ -z "$WORKDIR" ]; then return; fi
	rm -rf "$WORKDIR"
}
trap "cleanupworkdir;" 0 HUP INT QUIT ILL ABRT FPE SEGV PIPE TERM
touch "$WORKDIR/status"
TMPGEN="$WORKDIR/Packages"
export LANG=C.UTF-8

aptgetinstall() {
	aptget install "$@" --no-install-recommends -t "$CODENAME" -s \
		-o Dir::state::status="$WORKDIR/status" \
		-o Dir::Cache="$WORKDIR" \
		-o pkgCacheGen::Essential=none \
		-o APT::Immediate-Configure=0
}
LISTOFPKGS="$(aptgetinstall "$@" 2> /dev/null | awk '/^Inst/ {print $2}' | sed -e "s#\$#/$CODENAME#")"
if [ -z "$LISTOFPKGS" ]; then
	echo "List of packages is empty: run apt-get install command again for you now"
	aptgetinstall
	exit 1
fi
aptcache show $LISTOFPKGS --no-all-versions 2> "$WORKDIR/error.lst" | sed -e '/^ / d' \
	-e '/^SHA1: / d' -e '/^SHA256: / d' \
	-e '/^Homepage: / d' -e '/^Tag: / d' \
	-e '/^Xul-Appid: / d' \
	-e '/^Status: / d' \
	-e 's/^Description-en:/Description:/' \
	> "$TMPGEN"

if [ "$CODENAME" = "experimental" ]; then
	aptcache show $(cut -d"'" -f 4 "$WORKDIR/error.lst" | sed -e 's#$#/sid#') --no-all-versions 2> /dev/null >> "$TMPGEN"
fi

if echo "$GENERATE" | grep '^status-' > /dev/null; then
	sed -i "$TMPGEN" -e '/^Package: / a\
Status: install ok installed' \
		-e '/^Filename: / d' -e '/^Size: / d' -e '/^MD5sum: / d'
fi

apt-sortpkgs "$TMPGEN" > "$GENERATE"