Skip to content

Commit

Permalink
of added upgrade command.
Browse files Browse the repository at this point in the history
scripts/dev/upgrade.sh added upgrade dev commands to find and replace strings from old versions automatically with sed.
  • Loading branch information
danoli3 committed Jan 18, 2025
1 parent eefa659 commit 15fc367
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 1 deletion.
63 changes: 63 additions & 0 deletions scripts/dev/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash
UP_VERSION=0.0.1

local BASE_DIR=$1

OF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
OF_DIR="$(realpath "$OF_DIR/../../")"
OF_CORE_SCRIPT_DIR="$(realpath "$OF_DIR/scripts")"
OF_CORE_CI_SCRIPT_DIR="$(realpath "$OF_DIR/scripts/ci")"
OF_PG_INSTALLED_DIR="$(realpath "$OF_DIR/projectGenerator")"

read -p "Enter the base directory to search for addon_config.mk files: " BASE_DIR
if [[ ! -d "${OF_DIR}/$BASE_DIR" ]]; then
echo "Error: Directory $BASE_DIR does not exist."
exit 1
fi

echo "Warning: This script will modify addon_config.mk files in the specified path."
echo "Please backup your projects before proceeding."
read -p "Do you want to continue? (Y/n): " CONFIRM

if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
echo "Upgrade cancelled. No changes were made."
exit 0
fi

echo "Searching for addon_config.mk files in $BASE_DIR..."
ADDON_CONFIG_FILES=$(find "$BASE_DIR" -type f -name "addon_config.mk")
if [[ -z "$ADDON_CONFIG_FILES" ]]; then
echo "No addon_config.mk files found in the specified directory."
exit 0
fi
echo "Processing addons_config.mk files..."
for FILE in $ADDON_CONFIG_FILES; do
echo "Updating [$FILE]..."
sed -i.bak \
-e 's/linux64:/linux\/64:/g' \
-e 's/linuxarmv7l:/linux\/armv7l:/g' \
-e 's/linuxaarch64:/linux\/aarch64:/g' \
-e 's/linuxarmv6l:/linux\/armv6l:/g' \
-e 's|/lib/linuxarmv6l/|/lib/linux/armv6l/|g' \
-e 's|/lib/linuxarmv7l/|/lib/linux/armv7l/|g' \
-e 's|/lib/linuxaarch64/|/lib/linux/aarch64/|g' \
-e 's|/lib/linux64/|/lib/linux/64/|g' \
"$FILE"

echo "Backup created: [${FILE}.bak]"
done

echo "Upgrade complete. Backup files have been created with a .bak extension."

echo "Remove *.bak backup files?"
read -p "Do you want to continue? (Y/n): " CONFIRM
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
echo "Upgrade cancelled. No changes were made."
exit 0
fi
for FILE in $ADDON_CONFIG_FILES; do
rm ${FILE}.bak
echo "Removed created: ${FILE}.bak"
done


27 changes: 26 additions & 1 deletion scripts/of.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# pipe commands to core openFrameworks scripts
OF_SCRIPT_VERSION=0.1.0
OF_SCRIPT_VERSION=0.1.1
# Dan Rosser 2025
OF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
OF_DIR="$(realpath "$OF_DIR/../")"
Expand Down Expand Up @@ -64,6 +64,7 @@ echo " coreScriptPath: $OF_SCRIPT_PATH"

runCommand() {
local CMD=$1
local SUBCMD=$2
local SCRIPT
case "$CMD" in
setup)
Expand All @@ -74,6 +75,30 @@ runCommand() {
echo "openFrameworks update"
SCRIPT="${OF_SCRIPT_PATH}/download_libs.sh"
;;
upgrade)
echo "openFrameworks upgrade"
case "$SUBCMD" in
addons)
echo "Upgrading addons"
SCRIPT="${OF_SCRIPT_PATH}/dev/upgrade.sh addons"
;;
apps)
echo "Upgrading apps"
echo "Warning: This script will modify files in the Apps folder. Stop and Back up the folder. Commit all to all local repos. Then Continue"
echo "Please confirm backup your projects before proceeding."
read -p "Do you want to continue? (Y/n): " CONFIRM
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
echo "Upgrade cancelled. No changes were made."
exit 0
fi
SCRIPT="${OF_SCRIPT_PATH}/dev/upgrade.sh addons"
;;
*)
echo "Unknown upgrade action: $SUBCMD"
echo "Valid upgrade actions: addons"
exit 1
;;
esac
*)
echo "Unknown command: $command"
echo "Valid commands: setup, update"
Expand Down

0 comments on commit 15fc367

Please sign in to comment.