-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-workspace.sh
More file actions
executable file
·153 lines (133 loc) · 4.77 KB
/
Copy pathsetup-workspace.sh
File metadata and controls
executable file
·153 lines (133 loc) · 4.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#!/usr/bin/env bash
#
# This script sets up the development workspace by cloning project repositories
# into the 'workspace' directory based on a selected profile.
#
# Usage: ./setup-workspace.sh --profile <acrionphoto|nexuslua> [--protocol <https|ssh>]
set -euo pipefail
usage() {
cat << EOF
Usage: $0 --profile <acrionphoto|nexuslua> [--protocol <https|ssh>]
Profiles:
acrionphoto: Clones the full application stack, including the GUI and imaging plugins.
nexuslua: Clones only the core repositories for the nexuslua engine.
Options:
--protocol: Specifies the Git clone protocol. Defaults to https.
'https' is recommended for CI or users without SSH keys.
'ssh' is for developers with push access.
EOF
exit 1
}
# --- Default values ---
profile=""
protocol="https"
# --- Argument Parsing ---
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
--profile)
profile="$2"
shift; shift
;;
--protocol)
protocol="$2"
shift; shift
;;
*)
echo "Error: Unknown option '$key'"
usage
;;
esac
done
if [[ -z "$profile" || ("$protocol" != "https" && "$protocol" != "ssh") ]]; then
usage
fi
# --- Environment Detection ---
is_interactive=false
if [[ -t 0 ]]; then
is_interactive=true
fi
# --- Pre-flight Checks and Warnings for 'acrionphoto' profile ---
kernel_name=$(uname -s)
if [[ "$profile" == "acrionphoto" ]]; then
echo "Info: 'acrionphoto' profile selected. Checking platform compatibility..."
if [[ "$kernel_name" == "Darwin" ]]; then
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
echo "! WARNING: The 'acrionphoto' profile is currently UNSTABLE on macOS. !"
echo "! The 'acrion-image-tools' plugin build is broken due to refactoring. !"
echo "! The script will proceed, but the build is expected to fail. !"
echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
if [[ "$is_interactive" == "true" ]]; then
read -p "Do you want to continue? (y/N) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo "Aborted by user."
exit 1
fi
else
echo "Info: Non-interactive session detected. Continuing automatically in 1 second..."
sleep 1
fi
elif [[ "$kernel_name" == "Linux" && ! -x "$(command -v pacman)" ]]; then
echo "--------------------------------------------------------------------------"
echo "| WARNING: The 'acrionphoto' profile on Linux requires 'pacman'. |"
echo "| It is recommended to use an Arch-based distribution. |"
echo "| The script will proceed, but the 'install-deps' step might fail. |"
echo "--------------------------------------------------------------------------"
fi
fi
# --- Repository Definitions ---
# Format: "repo_path_without_host,local_directory_name,branch_or_tag"
core_repos=(
"acrion/cmake.git,acrion_cmake,main"
"acrion/Cbeam.git,cbeam,main"
"acrion/nexuslua-library.git,nexuslua_library,main"
"acrion/nexuslua.git,nexuslua_executable,main"
"acrion/nexuslua-plugins.git,nexuslua_plugins,main"
)
photo_repos=(
"acrion/photo.git,acrionphoto,main"
"acrion/image.git,acrion_image,main"
"acrion/image-tools.git,acrion_image_tools,main"
)
# --- Select Repositories based on Profile ---
repos_to_clone=()
case "$profile" in
acrionphoto)
repos_to_clone=("${core_repos[@]}" "${photo_repos[@]}")
;;
nexuslua)
repos_to_clone=("${core_repos[@]}")
;;
*)
echo "Error: Invalid profile '$profile'."
usage
;;
esac
# --- Workspace Setup ---
WORKSPACE_DIR="workspace"
mkdir -p "$WORKSPACE_DIR"
# --- Clone Repositories ---
for repo_info in "${repos_to_clone[@]}"; do
IFS=',' read -r repo_path target_dir branch <<< "$repo_info"
full_target_path="$WORKSPACE_DIR/$target_dir"
if [[ -d "$full_target_path" ]]; then
echo "Repository '$target_dir' already exists. Skipping."
continue
fi
repo_url=""
clone_args=("--branch" "$branch")
if [[ "$protocol" == "ssh" ]]; then
repo_url="git@github.com:$repo_path"
else
repo_url="https://github.com/$repo_path"
fi
# Perform a shallow clone in non-interactive environments (e.g., CI) for speed.
# Developers get a full clone by default.
if [[ "$is_interactive" == "false" ]]; then
clone_args+=("--depth" "1")
fi
echo "Cloning '$repo_url' (branch/tag: $branch) into '$full_target_path'..."
git clone "${clone_args[@]}" "$repo_url" "$full_target_path"
done
echo "Workspace setup complete for profile '$profile' using '$protocol' protocol."