Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to rel2fw.sh to allow post-processing #832

Merged
merged 1 commit into from
Jan 9, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion scripts/rel2fw.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ usage() {
echo " -f <firmware output file> Default is $PROJECT_DIR.fw"
echo " -o <image output file> Default is $PROJECT_DIR.img"
echo " -p <file priorities> The ordering of files in the rootfs (may be specified more than once)"
echo " -s <script path> Post-processing script for rootfs (optional)"
echo
echo "Barring errors, the firmware file is always created. The raw image is only"
echo "created if specified."
Expand All @@ -48,7 +49,7 @@ sbin/init 32764
etc/erlinit.config 32763
END

while getopts "a:c:f:o:p:" opt; do
while getopts "a:c:f:o:p:s:" opt; do
case $opt in
a)
ROOTFS_OVERLAYS="$ROOTFS_OVERLAYS $OPTARG"
Expand All @@ -66,6 +67,9 @@ while getopts "a:c:f:o:p:" opt; do
# Append priorities to the master list
cat "$OPTARG" >> "$SQUASHFS_PRIORITIES"
;;
s)
POST_PROCESSING_SCRIPT="$OPTARG"
;;
\?)
echo "$SCRIPT_NAME: ERROR: Invalid option: -$OPTARG"
usage
Expand Down Expand Up @@ -157,6 +161,12 @@ fi
# Merge the Erlang/OTP release onto the base image
"$NERVES_SYSTEM/scripts/merge-squashfs" "$NERVES_SDK_IMAGES/rootfs.squashfs" "$TMP_DIR/combined.squashfs" "$TMP_DIR/rootfs_overlay" "$SQUASHFS_PRIORITIES"

# If a post processing script for the final rootfs was specified, run it
if [ ! -z "${POST_PROCESSING_SCRIPT}" ]; then
echo "Running post-processing script: ${POST_PROCESSING_SCRIPT}"
${POST_PROCESSING_SCRIPT} "$TMP_DIR/combined.squashfs";
fi

# Build the firmware image
echo "Building $FW_FILENAME..."
ROOTFS="$TMP_DIR/combined.squashfs" $FWUP -c -f "$FWUP_CONFIG" \
Expand Down