@@ -54,6 +54,8 @@ motion:
54
54
- RPi.GPIO
55
55
unix:
56
56
- wiringpi
57
+ additional:
58
+ - "https://www.example.com/motion_install.md"
57
59
` ` `
58
60
59
61
# ## Modified `install.sh` Script
@@ -62,6 +64,7 @@ The install script below:
62
64
1. Parses `python` and `unix` dependencies from each module's YAML file.
63
65
2. Installs Unix dependencies with `apt-get install` and Python dependencies with `pip install`.
64
66
3. Uses a **Python helper** embedded within the script to read YAML files (using `pyyaml`).
67
+ 4. Outputs a summary of installed modules and dependencies. This includes any additional URLs for manual configuration.
65
68
66
69
Here’s the modified `install.sh` script :
67
70
@@ -72,9 +75,10 @@ Here’s the modified `install.sh` script:
72
75
python3 -m venv --system-site-packages myenv
73
76
source myenv/bin/activate
74
77
75
- # Initialize arrays for dependencies and active module names
78
+ # Initialize arrays for dependencies and additional setup URLs
76
79
PYTHON_DEPENDENCIES=()
77
80
UNIX_DEPENDENCIES=()
81
+ ADDITIONAL_URLS=()
78
82
ACTIVE_MODULES=()
79
83
80
84
# Helper function to parse dependencies from YAML files using Python
@@ -87,20 +91,21 @@ module_name = os.path.basename(config_file).replace('.yml', '') # Get the modul
87
91
try:
88
92
with open(config_file) as f:
89
93
config = yaml.safe_load(f)
90
- # Check if the top level of the config is a dictionary to avoid AttributeError
91
94
if isinstance(config, dict):
92
95
for section in config.values():
93
- # Check if module is active before parsing dependencies
94
- if isinstance(section, dict) and section.get('enabled') is True :
96
+ # Ensure each section has 'enabled' set to true and ' dependencies' exists
97
+ if isinstance(section, dict) and section.get('enabled', False) and 'dependencies' in section :
95
98
print(f"MODULE:{module_name}")
96
- if 'dependencies' in section:
97
- for dep_type, deps in section['dependencies'].items():
98
- if dep_type == 'python':
99
- for dep in deps:
100
- print(f"PYTHON:{dep}")
101
- elif dep_type == 'unix':
102
- for dep in deps:
103
- print(f"UNIX:{dep}")
99
+ for dep_type, deps in section['dependencies'].items():
100
+ if dep_type == 'python':
101
+ for dep in deps:
102
+ print(f"PYTHON:{dep}")
103
+ elif dep_type == 'unix':
104
+ for dep in deps:
105
+ print(f"UNIX:{dep}")
106
+ elif dep_type == 'additional':
107
+ for url in deps:
108
+ print(f"ADDITIONAL:{module_name}:{url}")
104
109
except yaml.YAMLError as e:
105
110
print(f"Error reading {config_file}: {e}", file=sys.stderr)
106
111
EOF
@@ -116,6 +121,8 @@ for config_file in config/*.yml; do
116
121
PYTHON_DEPENDENCIES+=("${dependency#PYTHON:}")
117
122
elif [[ $dependency == UNIX:* ]]; then
118
123
UNIX_DEPENDENCIES+=("${dependency#UNIX:}")
124
+ elif [[ $dependency == ADDITIONAL:* ]]; then
125
+ ADDITIONAL_URLS+=("${dependency#ADDITIONAL:}")
119
126
fi
120
127
done < <(parse_dependencies "$config_file")
121
128
done
@@ -124,19 +131,20 @@ done
124
131
UNIQUE_PYTHON_DEPENDENCIES=($(echo "${PYTHON_DEPENDENCIES[@]}" | tr ' ' '\n ' | sort -u | tr '\n ' ' '))
125
132
UNIQUE_UNIX_DEPENDENCIES=($(echo "${UNIX_DEPENDENCIES[@]}" | tr ' ' '\n ' | sort -u | tr '\n ' ' '))
126
133
UNIQUE_ACTIVE_MODULES=($(echo "${ACTIVE_MODULES[@]}" | tr ' ' '\n ' | sort -u | tr '\n ' ' '))
134
+ UNIQUE_ADDITIONAL_URLS=($(echo "${ADDITIONAL_URLS[@]}" | tr ' ' '\n ' | sort -u | tr '\n ' ' '))
127
135
128
- # Update apt-get and install Unix dependencies
129
- if [ ${#UNIQUE_UNIX_DEPENDENCIES[@]} -ne 0 ]; then
130
- sudo apt-get update
131
- for dep in "${UNIQUE_UNIX_DEPENDENCIES[@]}"; do
132
- sudo apt-get install -y "$dep"
133
- done
134
- fi
136
+ # # Update apt-get and install Unix dependencies
137
+ # if [ ${#UNIQUE_UNIX_DEPENDENCIES[@]} -ne 0 ]; then
138
+ # sudo apt-get update
139
+ # for dep in "${UNIQUE_UNIX_DEPENDENCIES[@]}"; do
140
+ # sudo apt-get install -y "$dep"
141
+ # done
142
+ # fi
135
143
136
- # Install Python dependencies explicitly using the virtual environment's pip
137
- for dep in "${UNIQUE_PYTHON_DEPENDENCIES[@]}"; do
138
- myenv/bin/python3 -m pip install "$dep"
139
- done
144
+ # # Install Python dependencies explicitly using the virtual environment's pip
145
+ # for dep in "${UNIQUE_PYTHON_DEPENDENCIES[@]}"; do
146
+ # myenv/bin/python3 -m pip install "$dep"
147
+ # done
140
148
141
149
# Set execute permissions for additional scripts
142
150
chmod 777 startup.sh stop.sh
@@ -157,8 +165,14 @@ echo -e "\nUnix dependencies installed:"
157
165
for dep in "${UNIQUE_UNIX_DEPENDENCIES[@]}"; do
158
166
echo " - $dep"
159
167
done
160
- echo "============================="
161
168
169
+ if [ ${#UNIQUE_ADDITIONAL_URLS[@]} -ne 0 ]; then
170
+ echo -e "\n ACTION REQUIRED: Additional manual configuration required for the following modules:"
171
+ for dep in "${UNIQUE_ADDITIONAL_URLS[@]}"; do
172
+ echo " - $dep"
173
+ done
174
+ fi
175
+ echo "============================="
162
176
` ` `
163
177
164
178
# ## Explanation of Changes
@@ -194,7 +208,7 @@ Remember, only **active modules** will have their dependencies installed.
194
208
195
209
` ` ` plaintext
196
210
==== Installation Summary ====
197
- Active modules installed: 12
211
+ Active modules installed: 13
198
212
- animate
199
213
- braillespeak
200
214
- buzzer
@@ -206,21 +220,26 @@ Active modules installed: 12
206
220
- servos
207
221
- tracking
208
222
- translator
223
+ - universalremote
209
224
- vision
210
225
211
226
Python dependencies installed:
212
227
- adafruit-circuitpython-seesaw
213
228
- googletrans==3.1.0a0
214
229
- gpiozero
230
+ - lirc
215
231
- pigpio
232
+ - pubsub
216
233
- pypubsub
217
234
- python3-munkres
218
235
- python3-opencv
219
236
220
237
Unix dependencies installed:
221
238
- imx500-all
222
- =============================
223
- ` ` `
239
+ - lirc
240
+
241
+ ACTION REQUIRED: Additional manual configuration required for the following modules:
242
+ - motion:https://www.example.com/motion_install.md
224
243
225
244
## Read More
226
245
0 commit comments