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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135 | diff --git a/tools/ds-identify b/tools/ds-identify
index ee5e05a4..44c449ce 100755
--- a/tools/ds-identify
+++ b/tools/ds-identify
@@ -91,6 +91,8 @@ DI_DMI_SYS_VENDOR=""
DI_DMI_PRODUCT_SERIAL=""
DI_DMI_PRODUCT_UUID=""
DI_FS_LABELS=""
+DI_FS_TYPES=""
+DI_ISO9660_DEVS=""
DI_KERNEL_CMDLINE=""
DI_VIRT=""
DI_PID_1_PRODUCT_NAME=""
@@ -181,32 +183,47 @@ block_dev_with_label() {
return 0
}
-read_fs_labels() {
- cached "${DI_FS_LABELS}" && return 0
+read_fs_info() {
+ cached "${DI_BLKID_OUTPUT}" && return 0
# do not rely on links in /dev/disk which might not be present yet.
# note that older blkid versions do not report DEVNAME in 'export' output.
- local out="" ret=0 oifs="$IFS" line="" delim=","
- local labels=""
if is_container; then
# blkid will in a container, or at least currently in lxd
# not provide useful information.
DI_FS_LABELS="$UNAVAILABLE:container"
- else
- out=$(blkid -c /dev/null -o export) || {
- ret=$?
- error "failed running [$ret]: blkid -c /dev/null -o export"
- return $ret
- }
- IFS="$CR"
- set -- $out
- IFS="$oifs"
- for line in "$@"; do
- case "${line}" in
- LABEL=*) labels="${labels}${line#LABEL=}${delim}";;
- esac
- done
- DI_FS_LABELS="${labels%${delim}}"
+ DI_FS_TYPES="$UNAVAILABLE:container"
+ DI_ISO9660_DEVS="$UNAVAILBLE:container"
+ return
fi
+ local oifs="$IFS" line="" delim=","
+ local ret=0 out="" labels="" fstypes="" dev="" ftype="" isodevs=""
+ out=$(blkid -c /dev/null -o export) || {
+ ret=$?
+ error "failed running [$ret]: blkid -c /dev/null -o export"
+ DI_FS_LABELS="$UNAVAILABLE:error"
+ DI_FS_TYPES="$UNAVAILABLE:error"
+ DI_ISO9660_DEVS="$UNAVAILBLE:error"
+ return $ret
+ }
+ IFS="$CR"
+ set -- $out
+ IFS="$oifs"
+ for line in "$@"; do
+ case "${line}" in
+ DEVNAME=*) dev=${line#DEVNAME=};;
+ LABEL=*) labels="${labels}${line#LABEL=}${delim}";;
+ TYPE=*)
+ ftype=${line#TYPE=}
+ fstypes="${fstypes}$ftype${delim}"
+ if [ "$ftype" = "iso9660" ]; then
+ isodevs="${isodevs} ${dev}";
+ fi
+ ;;
+ esac
+ done
+ DI_FS_LABELS="${labels%${delim}}"
+ DI_FS_TYPES="${fstypes%${delim}}"
+ DI_ISO9660_DEVS="${isodevs% }}"
}
cached() {
@@ -214,10 +231,6 @@ cached() {
}
-has_cdrom() {
- [ -e "${PATH_ROOT}/dev/cdrom" ]
-}
-
detect_virt() {
local virt="${UNAVAILABLE}" r="" out=""
if [ -d /run/systemd ]; then
@@ -645,19 +658,28 @@ ovf_vmware_guest_customization() {
}
dscheck_OVF() {
- local p=""
check_seed_dir ovf ovf-env.xml && return "${DS_FOUND}"
+ [ "${DI_VIRT}" = "none" ] && return ${DS_NOT_FOUND}
+
+ local isodevs="${DI_ISO9660_DEVS}"
+ case "$isodevs" in
+ ""|$UNAVAILABLE:*) return ${DS_NOT_FOUND};;
+ esac
+
if ovf_vmware_guest_customization; then
return ${DS_FOUND}
fi
- has_cdrom || return ${DS_NOT_FOUND}
+ # here we could grep or look for ovf-environment.xml somehow
+ # check, but we're down a pretty specific path at this point.
+ local d=""
+ for d in $isodevs; do
+ grep --quiet --ignore-case ovf-environment.xml &&
+ return $DS_FOUND
+ done
- # FIXME: currently just return maybe if there is a cdrom
- # ovf iso9660 transport does not specify an fs label.
- # better would be to check if
- return ${DS_MAYBE}
+ return ${DS_NOT_FOUND}
}
dscheck_Azure() {
@@ -930,7 +952,7 @@ collect_info() {
read_dmi_product_name
read_dmi_product_serial
read_dmi_product_uuid
- read_fs_labels
+ read_fs_info
}
print_info() {
|