aboutsummaryrefslogtreecommitdiffstats
path: root/community/apt-dater-host/apk-improve-Machine-Type-reporting.patch
blob: 021436aeb5de3d61a4451a40dedff91fcf28a145 (plain) (blame)
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
From f90d99ca8c4a04396d94ef42abe794d6ce75173b Mon Sep 17 00:00:00 2001
From: Henrik Riomar <henrik.riomar@gmail.com>
Date: Sat, 27 Jan 2018 19:50:38 +0100
Subject: [PATCH] apk: improve Machine Type reporting

Report Xen-PV, xen-dom0 or xen-domU to apt-dater (instead of just xen).
---
 apk/apt-dater-host | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/apk/apt-dater-host b/apk/apt-dater-host
index 25c9fb8..3bd8829 100755
--- a/apk/apt-dater-host
+++ b/apk/apt-dater-host
@@ -4,13 +4,13 @@
 #
 # Implementation of the protocol described in
 #   https://github.com/DE-IBH/apt-dater-host/blob/master/doc/ADP-0.6
-# using Busybox ash, awk and sed for use with Alpine Linux
+# using Busybox ash, awk, sed, and tr for use with Alpine Linux
 #
 # Author:
 #   Henrik Riomar <henrik.riomar@gmail.com>
 #
 # Copyright Holder:
-#   2016, 2017 (C) Henrik Riomar
+#   2016-2018 (C) Henrik Riomar
 #
 # License:
 #   This program is free software; you can redistribute it and/or modify
@@ -32,6 +32,7 @@ ADP_VERSION="0.6"
 ROOT_CMD="sudo"
 APK_CMD="/sbin/apk"
 VIRT_WHAT_CMD="/usr/sbin/virt-what --test-root=/"
+DMESG_CMD="dmesg"
 
 err=255 # exit code returned by Perl from die()
 
@@ -94,16 +95,16 @@ get_pkg_stat()
 # VIRT: ${Name}
 get_virt()
 {
-	virt=$(dmesg | awk '/Hypervisor detected:/ {print $NF}')
+	virt=$($DMESG_CMD | awk -F': ' '/Hypervisor detected:/ {print $NF}')
 	if [ -n "$virt" ]; then
-		echo "VIRT: $virt"
+		echo "VIRT: $(echo "$virt" | tr -s ' ' '-')"
 	else
-		virt=$($VIRT_WHAT_CMD 2> /dev/null)
+		virt=$($VIRT_WHAT_CMD 2> /dev/null | tail -1)
 		ret=$?
 		if [ -z "$virt" ]; then
 			[ $ret -eq 0 ] && echo "VIRT: Physical" || echo "VIRT: Unknown"
 		else
-			echo "VIRT: $(echo $virt | awk '{print $1}')"
+			echo "VIRT: $(echo "$virt" | tr -s ' ' '-')"
 		fi
 	fi
 }
-- 
2.11.0