Skip to content

Commit

Permalink
Tizen Studio version upgrade (#20)
Browse files Browse the repository at this point in the history
* changed default tizen version to 4.0
* backup and purge features introduced
* minor changes
* readme updated
  • Loading branch information
kamildzi authored Nov 2, 2020
1 parent 8d8dd0c commit 67d7402
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 13 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ TIZEN_USER=someuser
TIZEN_UID=1000
TIZEN_GID=1000

# root password
# root password (docker container)
ROOT_PASS=12345

# --- AUDIO CONFIG ---
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.env
_backups
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
114 changes: 103 additions & 11 deletions runTizen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 67d7402

Please sign in to comment.