#!/bin/sh
# Patch a linux image which has support for Qt-5.3.0 or Qt-5.4.0 and should have Qt-5.6.3 instead.
# CrossControl AB 2018
# Daniel Nisses-Gagnér

VERSION=1.0.0
UUID_FILE=/opt/etc/machine-id
UUID_LINK=/etc/machine-id
SUCCESS=0

echo "Patching uuid for Qt-5.6.3 runtime"

#Unclock the filesystem
mount -o remount,rw /

# Run dbus-uuidgen to generate a new uuid and pass it to /opt/etc/machine-id
UUID=$(dbus-uuidgen)
echo $UUID > $UUID_FILE

#Create a symbolic link from /etc/
if [ ! -f $UUID_LINK ]; then
	ln -s $UUID_FILE $UUID_LINK
fi

#Lock the filesystem
mount -o remount,ro /

# Create a stamp to indicate installed package
if [ ! -d /opt/packages ]; then
	mkdir /opt/packages
fi
touch /opt/packages/Qt5.6.3_uuid-patch_ARM_${VERSION}

exit $SUCCESS