Skip to content

Commit 15fc367

Browse files
committed
of added upgrade command.
scripts/dev/upgrade.sh added upgrade dev commands to find and replace strings from old versions automatically with sed.
1 parent eefa659 commit 15fc367

File tree

2 files changed

+89
-1
lines changed

2 files changed

+89
-1
lines changed

scripts/dev/upgrade.sh

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/bin/bash
2+
UP_VERSION=0.0.1
3+
4+
local BASE_DIR=$1
5+
6+
OF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
7+
OF_DIR="$(realpath "$OF_DIR/../../")"
8+
OF_CORE_SCRIPT_DIR="$(realpath "$OF_DIR/scripts")"
9+
OF_CORE_CI_SCRIPT_DIR="$(realpath "$OF_DIR/scripts/ci")"
10+
OF_PG_INSTALLED_DIR="$(realpath "$OF_DIR/projectGenerator")"
11+
12+
read -p "Enter the base directory to search for addon_config.mk files: " BASE_DIR
13+
if [[ ! -d "${OF_DIR}/$BASE_DIR" ]]; then
14+
echo "Error: Directory $BASE_DIR does not exist."
15+
exit 1
16+
fi
17+
18+
echo "Warning: This script will modify addon_config.mk files in the specified path."
19+
echo "Please backup your projects before proceeding."
20+
read -p "Do you want to continue? (Y/n): " CONFIRM
21+
22+
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
23+
echo "Upgrade cancelled. No changes were made."
24+
exit 0
25+
fi
26+
27+
echo "Searching for addon_config.mk files in $BASE_DIR..."
28+
ADDON_CONFIG_FILES=$(find "$BASE_DIR" -type f -name "addon_config.mk")
29+
if [[ -z "$ADDON_CONFIG_FILES" ]]; then
30+
echo "No addon_config.mk files found in the specified directory."
31+
exit 0
32+
fi
33+
echo "Processing addons_config.mk files..."
34+
for FILE in $ADDON_CONFIG_FILES; do
35+
echo "Updating [$FILE]..."
36+
sed -i.bak \
37+
-e 's/linux64:/linux\/64:/g' \
38+
-e 's/linuxarmv7l:/linux\/armv7l:/g' \
39+
-e 's/linuxaarch64:/linux\/aarch64:/g' \
40+
-e 's/linuxarmv6l:/linux\/armv6l:/g' \
41+
-e 's|/lib/linuxarmv6l/|/lib/linux/armv6l/|g' \
42+
-e 's|/lib/linuxarmv7l/|/lib/linux/armv7l/|g' \
43+
-e 's|/lib/linuxaarch64/|/lib/linux/aarch64/|g' \
44+
-e 's|/lib/linux64/|/lib/linux/64/|g' \
45+
"$FILE"
46+
47+
echo "Backup created: [${FILE}.bak]"
48+
done
49+
50+
echo "Upgrade complete. Backup files have been created with a .bak extension."
51+
52+
echo "Remove *.bak backup files?"
53+
read -p "Do you want to continue? (Y/n): " CONFIRM
54+
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
55+
echo "Upgrade cancelled. No changes were made."
56+
exit 0
57+
fi
58+
for FILE in $ADDON_CONFIG_FILES; do
59+
rm ${FILE}.bak
60+
echo "Removed created: ${FILE}.bak"
61+
done
62+
63+

scripts/of.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22
# pipe commands to core openFrameworks scripts
3-
OF_SCRIPT_VERSION=0.1.0
3+
OF_SCRIPT_VERSION=0.1.1
44
# Dan Rosser 2025
55
OF_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
66
OF_DIR="$(realpath "$OF_DIR/../")"
@@ -64,6 +64,7 @@ echo " coreScriptPath: $OF_SCRIPT_PATH"
6464

6565
runCommand() {
6666
local CMD=$1
67+
local SUBCMD=$2
6768
local SCRIPT
6869
case "$CMD" in
6970
setup)
@@ -74,6 +75,30 @@ runCommand() {
7475
echo "openFrameworks update"
7576
SCRIPT="${OF_SCRIPT_PATH}/download_libs.sh"
7677
;;
78+
upgrade)
79+
echo "openFrameworks upgrade"
80+
case "$SUBCMD" in
81+
addons)
82+
echo "Upgrading addons"
83+
SCRIPT="${OF_SCRIPT_PATH}/dev/upgrade.sh addons"
84+
;;
85+
apps)
86+
echo "Upgrading apps"
87+
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"
88+
echo "Please confirm backup your projects before proceeding."
89+
read -p "Do you want to continue? (Y/n): " CONFIRM
90+
if [[ ! "$CONFIRM" =~ ^[Yy]$ ]]; then
91+
echo "Upgrade cancelled. No changes were made."
92+
exit 0
93+
fi
94+
SCRIPT="${OF_SCRIPT_PATH}/dev/upgrade.sh addons"
95+
;;
96+
*)
97+
echo "Unknown upgrade action: $SUBCMD"
98+
echo "Valid upgrade actions: addons"
99+
exit 1
100+
;;
101+
esac
77102
*)
78103
echo "Unknown command: $command"
79104
echo "Valid commands: setup, update"

0 commit comments

Comments
 (0)