Merge ensure-vmtools-in-vmdk-header into ubuntu/master [a=jchittum] [r=rcj]

vmtools version in vmdk header (LP: #1893898)

LP: #1893898 describes missing vmtools version from the vmdk headers.
The version should be added as ddb.toolsVersion = "2147483647" however
the sed was no longer replacing a ddb.comment field with the tools
version. Rather than subbing ddb.comment with toolsVersion, this commit
deletes ddb.comment (which the comment mentions could cause errors),
and adds the correct value. There was no visibility into the descriptor
during hook creation, so debug statements were added. This allows us to
quickly verify in the logs that bad statements are removed (the possibly
offending commetns), as well as ensuring that the toolsVersion is added

MP: https://code.launchpad.net/~jchittum/livecd-rootfs/+git/livecd-rootfs/+merge/392401
sil2100/proposed-components
Robert C Jennings 4 years ago
commit df38b9ba75
No known key found for this signature in database
GPG Key ID: 740C3D9EEDF2ED73

6
debian/changelog vendored

@ -1,3 +1,9 @@
livecd-rootfs (2.697) UNRELEASED; urgency=medium
* Ensure vmtools version entered into vmdk header (LP: #1893898)
-- John Chittum <john.chittum@canonical.com> Mon, 19 Oct 2020 10:52:54 -0500
livecd-rootfs (2.696) hirsute; urgency=medium livecd-rootfs (2.696) hirsute; urgency=medium
* auto/config: seed ubuntu-desktop when building hyperv image LP: #1901846 * auto/config: seed ubuntu-desktop when building hyperv image LP: #1901846

@ -236,28 +236,34 @@ modify_vmdk_header() {
# Extract the vmdk header for manipulation # Extract the vmdk header for manipulation
dd if="${vmdk_name}" of="${descriptor}" bs=1 skip=512 count=1024 dd if="${vmdk_name}" of="${descriptor}" bs=1 skip=512 count=1024
echo "Cat'ing original descriptor to console for debugging."
# cat header so we are aware of the original descriptor for debugging
cat $descriptor
# The sed lines below is where the magic is. Specifically: # trim null bytes to treat as standard text file
# ddb.toolsVersion: sets the open-vm-tools so that VMware shows tr -d '\000' < $descriptor > $newdescriptor
# the tooling as current
# ddb.virtualHWVersion: set the version to 7, which covers most # add newline to newdescriptor
# current versions of VMware echo "" >> $newdescriptor
# createType: make sure its set to stream Optimized
# remove the vmdk-stream-converter comment and replace with # add required tools version
# # Disk DescriptorFile. This is needed for Virtualbox echo -n 'ddb.toolsVersion = "2147483647"' >> $newdescriptor
# remove the comments from vmdk-stream-converter which causes
# VirtualBox and others to fail VMDK validation # diff original descriptor and new descriptor for debugging
# diff exits 1 if difference. pipefail not set so piping diff
sed -e 's|# Description file.*|# Disk DescriptorFile|' \ # to cat prints diff and swallows exit 1
-e '/# Believe this is random*/d' \ echo "Printing diff of original and new descriptors."
-e '/# Indicates no parent/d' \ diff --text $descriptor $newdescriptor | cat
-e '/# The Disk Data Base/d' \
-e 's|ddb.comment.*|ddb.toolsVersion = "2147483647"|' \
"${descriptor}" > "${newdescriptor}" # The header must be 1024 or less before padding
if ! expr $(stat --format=%s ${newdescriptor}) \< 1025 > /dev/null 2>&1; then
# The header is cannot be bigger than 1024 echo "descriptor is too large, VMDK will be invalid!";
expr $(stat --format=%s ${newdescriptor}) \< 1024 > /dev/null 2>&1 || { exit 1
echo "descriptor is too large, VMDK will be invalid!"; exit 1; } fi
# reset newdescriptor to be 1024
truncate --no-create --size=1K $newdescriptor
# Overwrite the vmdk header with our new, modified one # Overwrite the vmdk header with our new, modified one
dd conv=notrunc,nocreat \ dd conv=notrunc,nocreat \

Loading…
Cancel
Save