#!/bin/bash ########################################################################### # # Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. # # THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN # WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. # # @file create_update_usb.sh # # @author (last) Behrouz NematiPour # @date (last) 01-Nov-2021 # @author (original) Behrouz NematiPour # @date (original) 01-Nov-2021 # ############################################################################ # This script is collecting all the scripts and files and copy in a folder # to be later used to update a newly flashed SoM # Run example # └$ /home/denali/Projects/application/scripts/create_update_usb.sh Projects/application/ /media/denali/usb-disk1/ FOLDER_BIN=/home/dnavaei/workspace_UI/build/build/poky_64_release FOLDER_SRC=/home/dnavaei/workspace_UI/build/application FOLDER_SRC_SCRIPTS=/home/dnavaei/workspace_UI/build/ui.scripts FOLDER_DST=$1/"Update_folder" TEMP_DIR="Temp" CLOUD_SYNC="cloudsync" DENALI_BIN=denali FOLDER_SCR=scripts FOLDER_FNT=resources/fonts FOLDER_SET=resources/settings SCRIPT_SLF=create_update_folder.sh SCRIPT_AUT=autostart SCRIPT_RUN=run.sh SCRIPT_SU1=start.sh SCRIPT_SU2=setup.sh SCRIPT_GLBLS=globals.sh listOfHiddenGits=() #if [ ! -z "$1" ]; then # FOLDER_SRC="$1" #fi #if [ ! -z "$2" ]; then # FOLDER_DST="$2" #fi #create the destination folder mkdir -p "$FOLDER_DST" mkdir -p "$TEMP_DIR" #mkdir -p "$FOLDER_DST"/"$CLOUD_SYNC" # Copy the required folders cp -r "$FOLDER_SRC_SCRIPTS"/"$FOLDER_SCR" "$FOLDER_DST" cp -r "$FOLDER_SRC"/"$FOLDER_FNT" "$FOLDER_DST" # The settings folder is a symbolically linked folder so L is used to copy the contents # and not the link cp -rL "$FOLDER_SRC"/"$FOLDER_SET" "$FOLDER_DST" #move the setup scrips to the root folder of the usb mv "$FOLDER_SRC_SCRIPTS"/"$FOLDER_SCR"/"$SCRIPT_SU1" "$FOLDER_DST" mv "$FOLDER_SRC_SCRIPTS"/"$FOLDER_SCR"/"$SCRIPT_SU2" "$FOLDER_DST" mv "$FOLDER_SRC_SCRIPTS"/"$FOLDER_SCR"/"$SCRIPT_RUN" "$FOLDER_DST" mv "$FOLDER_SRC_SCRIPTS"/"$FOLDER_SCR"/"$SCRIPT_AUT" "$FOLDER_DST" mv "$FOLDER_SRC_SCRIPTS"/"$FOLDER_SCR"/"$SCRIPT_GLBLS" "$FOLDER_DST" # Remove the ui.config folder after copying its contents rm -rf "$FOLDER_DST"/settings/ui.config #copy the UI Software device binary to the root folder of the usb cp "$FOLDER_BIN"/"$DENALI_BIN" "$FOLDER_DST" cd "$TEMP_DIR" || return # Clone the cloud sync and checkout the wanted branch git clone ssh://git@devapps.diality.us:7999/ui/cloudsync.git cd cloudsync git checkout staging echo "Here is my branch" git status cd .. echo "Current Directory $(pwd)" cd .. # Move the cloud sync to the destination folder #cp -r "$TEMP_DIR"/* "$FOLDER_DST"/"$CLOUD_SYNC" cp -r "$TEMP_DIR"/* "$FOLDER_DST" # Find all the files that are git related and are hidden and remove them IFS=$'\n' read -r -d '' -a listOfHiddenGits < <(find "$FOLDER_DST" -name ".git*") for hidden in "${listOfHiddenGits[@]}" do rm -rf "$hidden" done #removing this script to clean up the script folder #rm "$FOLDER_DST"/"$FOLDER_SCR"/"$SCRIPT_SLF" TODO this is not needed