summaryrefslogtreecommitdiff
path: root/sys-boot/os-prober/files/os-prober-linux-distro-parse-os-release.patch
blob: 2aa2b316a45ee3d60fef11fcd1ca424c8290eae8 (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
Index: os-prober/os-probes/mounted/common/90linux-distro
===================================================================
--- os-prober.orig/os-probes/mounted/common/90linux-distro
+++ os-prober/os-probes/mounted/common/90linux-distro
@@ -10,7 +10,18 @@ type="$3"
 uuid="$4"
 subvol="$5"
 
-if [ -e "$dir/etc/os-release" ]; then
+if [ -L "$dir/etc/os-release" ]; then
+	RELPATH=$(readlink -f "$dir/etc/os-release")
+	if readlink "$dir/etc/os-release" | grep -q '^/'; then
+		RELPATH="$dir$RELPATH"
+	fi
+	if [ -f "$RELPATH" ]; then
+		short="$(grep ^NAME= "$RELPATH" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g; s/[[:space:]].*//')"
+		long="$(grep ^PRETTY_NAME= "$RELPATH" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g')"
+	else
+		exit 1
+	fi
+elif [ -e "$dir/etc/os-release" ]; then
 	short="$(grep ^NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g; s/[[:space:]].*//')"
 	long="$(grep ^PRETTY_NAME= "$dir/etc/os-release" | sed 's/^[^=]*=//; s/^['\''"]\(.*\)['\''"]$/\1/; s/\\\(.\)/\1/g')"
 elif [ -e "$dir/etc/debian_version" ]; then