From 5843070fd1edee2e6e65a77eb01c3a70c67630c2 Mon Sep 17 00:00:00 2001 From: Ivan Davidov Date: Sat, 2 Dec 2017 03:24:45 +0200 Subject: [PATCH] Added new script to the build chain which reverts the ownership of all files if the MLL build process has been started as 'root'. Also, the overlay structure is copied in proper way (this was serious bug). --- src/16_cleanup.sh | 26 ++++++++++++++++++++++++++ src/rebuild.sh | 1 + 2 files changed, 27 insertions(+) create mode 100755 src/16_cleanup.sh diff --git a/src/16_cleanup.sh b/src/16_cleanup.sh new file mode 100755 index 000000000..ac697149b --- /dev/null +++ b/src/16_cleanup.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +# This script is useful if you have executed the MLL build process +# with elevated rights. Ths script recursively reverts the ownership +# of all files back to the original user. + +set -e + +SRC_DIR=`pwd` + +echo "*** CLEANUP BEGIN ***" + +if [ "$(id -u)" = "0" ] ; then + echo "Applying original ownership to all affected files. This may take a while." + + # Find the original user. Note that this may not always be correct. + ORIG_USER=`who | awk '{print \$1}'` + echo "Original user is '$ORIG_USER'." + + # Apply ownership back to original owner for all affected files. + chown -R $ORIG_USER:$ORIG_USER * +else + echo "No need to perform cleanup." +fi + +echo "*** CLEANUP END ***" diff --git a/src/rebuild.sh b/src/rebuild.sh index 5c6d3949b..ae84ca0cd 100755 --- a/src/rebuild.sh +++ b/src/rebuild.sh @@ -14,3 +14,4 @@ set -e ./13_prepare_iso.sh ./14_generate_iso.sh ./15_generate_image.sh +./16_cleanup.sh