aboutsummaryrefslogtreecommitdiffstats
path: root/community/xe-guest-utilities/identify_alpine.patch
blob: d645c139aba8f6bd4ce62ec03a320da183482b1b (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
--- xe-guest-utilities-5.5.0.orig/xe-linux-distribution
+++ xe-guest-utilities-5.5.0/xe-linux-distribution
@@ -248,6 +248,32 @@
     write_to_output "${distro}" "${major}" "${minor}" "${description}"
 }
 
+identify_alpine()
+{
+    alpine_release="$1"
+    local major
+    local minor
+
+    if [ ! -f "${alpine_release}" ] ; then
+        return 1
+    fi
+
+    eval $(sed -n \
+               -e 's/^.*-\([0-9]*\)\.\([0-9]*\)\.[0-9]* .*$/major=\1;minor=\2/gp;' \
+               -e 's/^.*-\([0-9]*\) .*$/major=\1;minor=/gp;' \
+                         "${alpine_release}")
+    
+    if [ -z "${major}" ] ; then
+        return 1
+    fi
+
+    if [ -z "${minor}" ] ; then
+        minor=0
+    fi
+
+    write_to_output "alpine" "${major}" "${minor}" "Alpinelinux $(head -n 1 $alpine_release)"
+}
+
 if [ $# -eq 1 ] ; then
     exec 1>"$1"
 fi
@@ -257,6 +283,7 @@
     identify_sles   /etc/SuSE-release   && exit 0
     identify_lsb    lsb_release         && exit 0
     identify_debian /etc/debian_version && exit 0
+    identify_alpine /etc/alpine-release && exit 0
 
     if [ $# -eq 1 ] ; then
 	rm -f "$1"