summaryrefslogtreecommitdiff
path: root/tests/bin/apk
blob: df1711cef2d235baebc5bd5e03c5871354d46d66 (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
#!/bin/sh

arch=aarch64

if [ "$1" = "--print-arch" ]; then
	echo $arch
	exit
fi

rootfs=.
kver=5.15.78-0
audit_prefix="U "
while [ $# -gt 0 ]; do
	case "$1" in
		add|del)
			echo "DEBUG: fake apk" "$@"
			cmd="$1"
			;;
		audit)
			cmd="$1"
			;;
		-p|--root)
			shift
			rootfs="$1"
			;;
		--quiet)
			audit_prefix=""
			shift ;;
		--arch) shift ;;
		--repositories-file) shift ;;
		--keys-dir) shift ;;
		[a-z]*)
			pkgs="$pkgs $1"
			;;
	esac
	shift
done

if [ "$cmd" = audit ]; then
		mkdir -p etc
		touch etc/hosts etc/localtime
		echo "${audit_prefix}etc/hosts"
		echo "${audit_prefix}etc/localtime"
		exit 0
fi

for pkg in $pkgs; do
	case "$pkg" in
		linux-firmware*)
			# simulate install firmware
			mkdir -p "$rootfs"/lib/firmware/brcm
			touch "$rootfs"/lib/firmware/brcm/brcmfmac43456-sdio.raspberrypi,400.bin \
				"$rootfs"/lib/firmware/brcm/brcmfmac43456-sdio.raspberrypi,400.clm_blob \
				"$rootfs"/lib/firmware/brcm/brcmfmac43456-sdio.raspberrypi,400.txt \
				"$rootfs"/lib/firmware/brcm/brcmfmac43752-sdio.bin \
				"$rootfs"/lib/firmware/brcm/brcmfmac43752-sdio.txt \
				"$rootfs"/lib/firmware/brcm/"brcmfmac43455-sdio.Raspberry Pi Foundation-Raspberry Pi Compute Module 4.txt" \
				"$rootfs"/lib/firmware/brcm/brcmfmac43455-sdio.bin \
				"$rootfs"/lib/firmware/brcm/brcmfmac43455-sdio.clm_blob
			;;
		linux-*)
			# simulate installing kernel
			flavor=${pkg#linux-}
			mkdir -p "$rootfs"/lib/modules/$kver-$flavor/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac \
				"$rootfs"/boot
			touch "$rootfs"/boot/System.map-$flavor \
				"$rootfs"/boot/config-$flavor \
				"$rootfs"/boot/vmlinuz-$flavor
			cat >"$rootfs/lib/modules/$kver-$flavor"/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko <<-EOF
				vermagic:       $kver-$flavor SMP preempt mod_unload modversions $arch
				firmware:       brcm/brcmfmac*-sdio.*.bin
				firmware:       brcm/brcmfmac*-sdio.*.txt
				firmware:       brcm/brcmfmac43752-sdio.clm_blob
				firmware:       brcm/brcmfmac43752-sdio.bin
			EOF
			gzip "$rootfs/lib/modules/$kver-$flavor"/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko
			;;
	esac
done