From 67d74024196f7a68ff35b51f81305187ebf7c8f4 Mon Sep 17 00:00:00 2001 From: Kamil D Date: Mon, 2 Nov 2020 19:24:00 +0100 Subject: [PATCH] Tizen Studio version upgrade (#20) * changed default tizen version to 4.0 * backup and purge features introduced * minor changes * readme updated --- .env.example | 4 +- .gitignore | 1 + README.md | 52 +++++++++++++++++++++++ runTizen.sh | 114 ++++++++++++++++++++++++++++++++++++++++++++++----- 4 files changed, 158 insertions(+), 13 deletions(-) diff --git a/.env.example b/.env.example index c10589d..faa3e11 100644 --- a/.env.example +++ b/.env.example @@ -5,7 +5,7 @@ TIZEN_USER=someuser TIZEN_UID=1000 TIZEN_GID=1000 -# root password +# root password (docker container) ROOT_PASS=12345 # --- AUDIO CONFIG --- @@ -44,7 +44,7 @@ TIZEN_TARGET=WEARABLE-4.0 # -- VERSION CONFIG -- # select Tizen Studio version -TIZEN_VERSION=3.7 +TIZEN_VERSION=4.0 # -- XSERVER SETTINGS -- # defaults should be fine in most cases diff --git a/.gitignore b/.gitignore index 4c49bd7..b7d8e1c 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .env +_backups diff --git a/README.md b/README.md index 108e937..81c7e99 100644 --- a/README.md +++ b/README.md @@ -56,3 +56,55 @@ Once the IDE is installed and started up, please be sure to enable Hardware Supp 3. go to the `HW Support` and enable settings: * `CPU VT` * `GPU` + +# IDE Upgrade / Reinstall process +This paragraph describes how to deal with upgrade and reinstall process. + +Please note: +- Refer to `.env.example` for details and detailed volume descriptions. +- First step (data backup) is completely optional. You can skip this if you don't have any data to worry about. +- Failed or incomplete installations can be fixed by following this procedure. + +Please follow below steps: + +1. (Optional) Backup the data from docker volumes: +- `LOCAL_TIZEN_STUDIO_DIRECTORY` +- `LOCAL_TIZEN_STUDIO_DATA_DIRECTORY` +- `LOCAL_WORKSPACE` + +You might copy the data manually, or use a built-in backup script: + +```bash +./runTizen.sh backup +``` + +2. Delete the contents of the volumes (to force a clean install): +- `LOCAL_TIZEN_STUDIO_DIRECTORY` +- `LOCAL_TIZEN_STUDIO_DATA_DIRECTORY` +- `LOCAL_WORKSPACE` (optional, don't wipe the workspace if you want your project data to stay intact) + +You might wipe the directories manually or use built-in script. +The script will ask you which volumes would you like to wipe out. + +```bash +./runTizen.sh purge +``` + +3. Edit .env file with your favourite editor (and change the `TIZEN_VERSION`) +```bash +nano .env +``` + +4. Rebuild the docker image + +First, please remove current Tizen4Docker image. +Please note that image name (`tizen4docker_tizen`) might differ on your machine. +```bash +sudo docker image rm tizen4docker_tizen +``` + +After the image is deleted, please start the runner script. +A new docker image will be built automatically and then the IDE will be installed. +```bash +./runTizen.sh +``` \ No newline at end of file diff --git a/runTizen.sh b/runTizen.sh index 198be51..9a97804 100755 --- a/runTizen.sh +++ b/runTizen.sh @@ -30,6 +30,14 @@ authWithPkexec='yes' SCRIPT_ROOT=$( readlink -f $( dirname "${BASH_SOURCE[0]}" ) ) COMPOSE_FILE="$SCRIPT_ROOT/docker-compose.yml" ENV_FILE="$SCRIPT_ROOT/.env" +BACKUP_DIR="$SCRIPT_ROOT/_backups" + +# ============== +# Dates config +# ============== + +DATE_FORMAT='%Y-%m-%d__%H-%M' +DATE=(`date +$DATE_FORMAT`) # ============== # Set CMD @@ -39,10 +47,17 @@ case $1 in "xterm" | "debug" | "d" ) # xterm is useful for debugging CMD='xterm' + ACTION="false" + ;; + "backup" | "purge" ) + # general actions + CMD="false" + ACTION=$1 ;; * ) # Default: Tizen Studio CMD="/opt/scripts/runTizenIDE.sh" + ACTION="false" ;; esac @@ -97,29 +112,106 @@ init() { # traps trap terminate SIGINT SIGTERM ERR - # allow root (and the docker) connection to X-Server - xhost +local:root - TERMINATED=0 + if [[ $CMD != "false" ]]; then + # allow root (and the docker) connection to X-Server + xhost +local:root + fi } terminate() { - if [[ $TERMINATED == 0 ]]; then - printText "Terminating ..." + printText "Terminating ..." + if [[ $CMD != "false" ]]; then # disallow root connection to X-Server xhost -local:root - TERMINATED=1 fi + + exit +} + +askContinue() { + read -p $'\n Continue? [Y/n] ' ans + echo "" + if [[ $ans != 'Y' ]]; then + printText "Aborted by user" + terminate + fi +} + +# docker volumes purge process +interactivePurge() { + cd "$SCRIPT_ROOT" + source "$ENV_FILE" + + printText "Interactive volumes purge started..." + + printText "About to clear LOCAL_TIZEN_STUDIO_DIRECTORY: \n$LOCAL_TIZEN_STUDIO_DIRECTORY" + read -p "Clear it? [Y/n] " ans + if [[ $ans == 'Y' ]]; then + rm -rf "$LOCAL_TIZEN_STUDIO_DIRECTORY" + mkdir "$LOCAL_TIZEN_STUDIO_DIRECTORY" + echo "... OK" + fi + + printText "About to clear LOCAL_TIZEN_STUDIO_DATA_DIRECTORY: \n$LOCAL_TIZEN_STUDIO_DATA_DIRECTORY" + read -p "Clear it? [Y/n] " ans + if [[ $ans == 'Y' ]]; then + rm -rf "$LOCAL_TIZEN_STUDIO_DATA_DIRECTORY" + mkdir "$LOCAL_TIZEN_STUDIO_DATA_DIRECTORY" + echo "... OK" + fi + + printText "About to clear LOCAL_WORKSPACE: \n$LOCAL_WORKSPACE" + echo -e "\033[33mNOTE: \033[33;5mTHIS WILL CLEAR YOUR PROJECT WORKSPACE\033[0m" + echo -e "\033[33m (you can say 'no' if all you want is to restart the IDE installation process)\033[0m" + read -p "Clear it? [Y/n] " ans + if [[ $ans == 'Y' ]]; then + rm -rf "$LOCAL_WORKSPACE" + mkdir "$LOCAL_WORKSPACE" + echo "... OK" + fi + + printText "Interactive volumes purge stopped..." +} + +# volume data backup process +volumesBackup() { + CURRENT_BACKUP_DIR="$BACKUP_DIR"/"$DATE" + + cd "$SCRIPT_ROOT" + source "$ENV_FILE" + + # user confirmation + printText "Notice:\nDocker volumes backups will be saved at: \n$CURRENT_BACKUP_DIR" + askContinue + + # actual backup + mkdir -p "$CURRENT_BACKUP_DIR" + cp -ap "$LOCAL_TIZEN_STUDIO_DIRECTORY" "$CURRENT_BACKUP_DIR" + cp -ap "$LOCAL_TIZEN_STUDIO_DATA_DIRECTORY" "$CURRENT_BACKUP_DIR" + cp -ap "$LOCAL_WORKSPACE" "$CURRENT_BACKUP_DIR" + + printText "Backup is done. To restore the backup data, please manually copy it into the defined volume paths." } main() { init - # run the container - $authPrefix docker-compose \ - --file "$COMPOSE_FILE" \ - --env-file "$ENV_FILE" \ - run --rm tizen "$CMD" + if [[ $CMD != "false" ]]; then + # default - run the container + $authPrefix docker-compose \ + --file "$COMPOSE_FILE" \ + --env-file "$ENV_FILE" \ + run --rm tizen "$CMD" + + elif [[ $ACTION == "backup" ]]; then + # backup docker volumes + volumesBackup + + elif [[ $ACTION == "purge" ]]; then + # clear docker volumes + interactivePurge + fi terminate }