aboutsummaryrefslogtreecommitdiffstats
path: root/community/xe-guest-utilities/detect_distribution.patch
blob: 39b9df859a3a26556e2aadd3f902dfba1313cf30 (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
diff --git a/./mk/xe-linux-distribution b/./mk/xe-linux-distribution.new
index dc35b2bcbd..a8b1d5899f 100755
--- a/./mk/xe-linux-distribution
+++ b/./mk/xe-linux-distribution
@@ -462,6 +462,24 @@ identify_boot2docker()
 
 }
 
+identify_alpine()
+{
+    # only tested with Alpine 3.7+
+    alpine_release="$1"
+    local major
+    local minor
+
+    if [ ! -f "${alpine_release}" ]; then
+        return 1
+    fi
+
+    major=$(awk -F. '{printf("%s", $1)}' ${alpine_release})
+    minor=$(awk -F. '{printf("%s.%s", $2, $3)}' ${alpine_release})
+
+    write_to_output "alpine" "${major}" "${minor}" "Alpine Linux $(head -n 1 ${alpine_release})"
+}
+
+
 if [ $# -eq 1 ] ; then
     exec 1>"$1"
 fi
@@ -484,6 +502,7 @@ if [ -z "${TEST}" ] ; then
     identify_lsb lsb_release         && exit 0
     identify_debian /etc/debian_version && exit 0
     identify_boot2docker /etc/boot2docker && exit 0
+    identify_alpine /etc/alpine-release && exit 0
 
 
     if [ $# -eq 1 ] ; then