[FE training-materials-updates] gen-lab-archive: only chown when needed

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Fri May 22 17:57:24 CEST 2015


Repository : git://git.free-electrons.com/training-materials.git

On branch  : master
Link       : http://git.free-electrons.com/training-materials/commit/?id=1204f640cd79470c9d00bc3314426fff2efef77a

>---------------------------------------------------------------

commit 1204f640cd79470c9d00bc3314426fff2efef77a
Author: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
Date:   Fri May 22 17:56:07 2015 +0200

    gen-lab-archive: only chown when needed
    
    Only chown the lab-data directory when some tarballs have been
    extracted as root.
    
    I don't like to run stuff that need sudo password.
    
    Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>


>---------------------------------------------------------------

1204f640cd79470c9d00bc3314426fff2efef77a
 gen-lab-archive | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/gen-lab-archive b/gen-lab-archive
index f7214c5..ad7d067 100755
--- a/gen-lab-archive
+++ b/gen-lab-archive
@@ -46,12 +46,16 @@ $RSYNC --exclude=.git -a --delete lab-data/$1/ $FELABS
 
 $ECHO "Extracting tar.xz archives (root permissions needed for device files)"
 
+tarball_extracted=no
 for f in `$FIND $FELABS -name "*.tar.xz"`; do
 	$SUDO $TAR -C `dirname $f` -Jxf $f
 	$RM $f
+	tarball_extracted=yes
 done
 
-$SUDO $CHOWN -R $USER.$USER $FELABS
+if test "${tarball_extracted}" = "yes"; then
+    $SUDO $CHOWN -R $USER.$USER $FELABS
+fi
 
 $ECHO "Uncompressing other .xz files"
 $FIND $FELABS -name "*.xz" -exec $UNXZ {} ';'



More information about the training-materials-updates mailing list