-
Notifications
You must be signed in to change notification settings - Fork 0
/
v4l2loopback-dc-build.sh
executable file
·108 lines (105 loc) · 4.47 KB
/
v4l2loopback-dc-build.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
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash
set -eux
# podman pull archlinux:latest
# podman run -v ./:/tmp/out --rm -ti archlinux:latest /tmp/out/v4l2loopback-dc-build.sh
# archlinux image
OUT_DIR="/tmp/out"
TMP_PKG_DIR="/tmp/v4l2loopback-dc"
repo_suffixes=('-staging' '-main' '-beta' '-rel' '-3.6' '-3.5' '-3.3.3' '-3.3.2' '-3.3.1' '-3.3' '-3.2' '-3.1' '-3.0' '')
_rs=("${repo_suffixes[@]:0:${#repo_suffixes[@]}-1}")
for s in "${_rs[@]}"
do
repo_suffixes=("${repo_suffixes[@]:0:${#_rs[@]}+1}" "$s" "${repo_suffixes[@]:${#_rs[@]}+1}")
done
i=0
for s in "${repo_suffixes[@]}"
do
if [[ "$s" == "${1:-}" ]]
then
break
fi
i=$((i+1))
done
if [[ "$i" -ge "${#repo_suffixes[@]}" ]]
then
exit 1
fi
ret_code="$(curl -sSLIo /dev/null -w '%{http_code}' "https://steamdeck-packages.steamos.cloud/archlinux-mirror/jupiter${repo_suffixes[${i}]}/os/x86_64/jupiter${repo_suffixes[${i}]}.db")"
if [[ "$ret_code" != '200' ]]
then
exit 0
fi
# Setup builduser and module directory
useradd -m builduser
mkdir -p /etc/sudoers.d
echo 'builduser ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/builduser
mkdir -p "$TMP_PKG_DIR"
tar -xf "$OUT_DIR/v4l2loopback-dc.tar.zst" -C "$TMP_PKG_DIR"
find "$TMP_PKG_DIR" -type f -name '*.xz' -exec unxz -f '{}' +
find "$TMP_PKG_DIR" -type f -name '*.gz' -exec gunzip -f '{}' +
find "$TMP_PKG_DIR" -type f -name '*.zst' -exec unzstd -f --rm '{}' +
# Add SteamOS server and repos
echo 'Server = https://steamdeck-packages.steamos.cloud/archlinux-mirror/$repo/os/$arch' > /etc/pacman.d/mirrorlist
sed -i -e 's/\s*#\?\s*SigLevel\s*=\s*.*$/SigLevel = Never/g' -e '/^Include\s*=/d' /etc/pacman.conf
sed -i -e 's/^\[/[/;T;s/^\(\[options\]\)/\1/;t;d' /etc/pacman.conf
kernel_pkg_list=()
kernel_pkg_prefix=''
for repo in jupiter holo core extra community
do
for s in "${repo_suffixes[@]:i}"
do
ret_code="$(curl -sSLIo /dev/null -w '%{http_code}' "https://steamdeck-packages.steamos.cloud/archlinux-mirror/${repo}${s}/os/x86_64/${repo}${s}.db")"
if [[ "$ret_code" == '200' ]]
then
echo -e "\n\n[${repo}${s}]\nInclude = /etc/pacman.d/mirrorlist" >> /etc/pacman.conf
if [[ "$repo" == 'jupiter' ]]
then
kernel_pkg_prefix="https://steamdeck-packages.steamos.cloud/archlinux-mirror/${repo}${s}/os/x86_64"
readarray -t kernel_pkg_list < <(curl -sSL "https://steamdeck-packages.steamos.cloud/archlinux-mirror/${repo}${s}/os/x86_64/" | grep -oP 'href="\Klinux-neptune[^"]*' | grep -v -e '\.sig$' -e '-headers-' -e '-debug-' -e '-wip-' | sort -rV)
fi
break
fi
done
done
pacman -Syy --noconfirm
pacman -Rndd --noconfirm libverto || true
pacman -S --overwrite='*' --noconfirm - < <(pacman -Qqn)
pacman -S --noconfirm --needed base-devel git mkinitcpio sudo wget
rm -rf /usr/share/libalpm/hooks/*mkinitcpio*.hook || true
su -l -c '[ ! -d droidcam ] && git clone https://aur.archlinux.org/droidcam.git ; cd droidcam ; sed -i -e "s/^\(pkgname\s*=\).*$/\1v4l2loopback-dc-dkms/" -e "s/^\(makedepends\s*=\)/#\1/" -e "s/^\(build()\)/_\1/" PKGBUILD ; makepkg -cCfsi --noconfirm' builduser
for pkg in "${kernel_pkg_list[@]}"
do
if ! pacman --noconfirm -U "${kernel_pkg_prefix}/${pkg}" "${kernel_pkg_prefix}/$(echo "${pkg}" | sed 's/\(-[0-9]\.\)/-headers\1/')"
then
continue
fi
kernel_targets=()
readarray -t kernel_targets < <(pacman -Qsq linux-neptune | grep -v headers)
my_break=0
for kt in "${kernel_targets[@]}"
do
kf="$(pacman -Qlq "$kt" | grep '/usr/lib/modules/[^/]\+/' | head -n 1)"
dkms_src="$(basename /usr/src/v4l2loopback-dc*)"
if dkms install "${dkms_src%-*}/${dkms_src##*-}" -k "$(basename "$kf")"
then
tar -cf - "${kf}updates/dkms" | tar -xf - -C "$TMP_PKG_DIR"
tar -cf - /etc/modules-load.d /etc/modprobe.d | tar -xf - -C "$TMP_PKG_DIR"
else
cat /var/lib/dkms/v4l2loopback-dc/*/build/make.log || true
if grep -q -e 'incompatible gcc/plugin versions' -e 'cannot load plugin' /var/lib/dkms/v4l2loopback-dc/*/build/make.log
then
my_break=1
break
fi
fi
done
if [[ "${my_break}" -eq 1 ]]
then
break
fi
done
find "$TMP_PKG_DIR" -type f -name '*.xz' -exec unxz -f '{}' +
find "$TMP_PKG_DIR" -type f -name '*.gz' -exec gunzip -f '{}' +
find "$TMP_PKG_DIR" -type f -name '*.zst' -exec unzstd -f --rm '{}' +
# finally package the modules tar
tar -cf - --numeric-owner -C "$TMP_PKG_DIR" . | zstd -19 > "$OUT_DIR/v4l2loopback-dc.tar.zst"