Hi,
Is it possible to build several openwrt firmware images for the same device but with different configuration?
i build firmware image for an organization so i put related configuration files in build_root/files/
now i have to remove the files of Org1 and put config files for Org2 and then run make -jxx world to build an image for the second one.
is there a way to put configuration files in build_root/files/org1/, org2/, org3/ .....
and when run build command i get generated images in build_root/bin/targets/......./org1/, org2/, org3/
As filesystems on OpenWrt images are pretty much always compressed, there is not much alternative to compiling. You need to include the correct files and then compress the lot.
If you has a limited number of devices and they can see each other's settings, (so that all settings can be stored on all devices), the approach from lleachii might work, where you use run-at-first-boot script to set some settings e.g. according to the lan MAC of the device.
Other approach might be to create scripts for copying the next files to files/ and running the compilation again.
That might be speeded up by using the imagebuilder instead of the whole toolchain. I crafted a script for imagebuilder where my files/ are separate from the actual imagebuilder, so that you can just pass the files/ as an argument to the image-cooking command:
That script
copies build keys (not important),
brands the exact build date/time/version to a file,
does the compilation with "../files" as path to "files/": FILES="../files"
finally renames/copies the created images and build script itself
if the compile have to be done over and over for each org.
then i could use sh script to copy files from baths and do builds one after the other
#!/bin/bash
# Configuration
OPENWRT_BUILD_DIR="/openwrt"
OPENWRT_TARGET_DIR="$OPENWRT_BUILD_DIR/bin/targets/ramips/mt7621"
CONFIG_DIR="/org-config"
OPENWRT_FILES_DIR="$OPENWRT_BUILD_DIR/files"
TARGET_DEVICE="HYC-G920" # Default target device KM08-708H OR HYC-G920 OR DW02-412
# Organization list
ORG_LIST=(
"org-1"
"org-2"
"org-3"
"org-4"
"org-5"
)
# Function to build firmware for an organization
build_organization() {
local org="$1"
local snapshot_dir="$CONFIG_DIR/$org/snapshot/$TARGET_DEVICE"
echo "Copying files from $snapshot_dir to $OPENWRT_FILES_DIR..."
cp -r "$snapshot_dir"/* "$OPENWRT_FILES_DIR/"
echo "Building firmware for $org..."
# Build firmware
cd "$OPENWRT_BUILD_DIR" || exit
make -j23 |& tee build_output.log
# Check if build succeeded
if grep -q "checksum" build_output.log; then
echo "Build succeeded"
else
echo "Build failed"
exit 1
fi
# Move generated *.bin files to organization's bin folder
mv "$OPENWRT_TARGET_DIR"/*.bin "$CONFIG_DIR/$org/snapshot/bin/"
# Clean OpenWRT files directory
echo "Cleaning up OpenWRT files directory..."
rm -rf "$OPENWRT_FILES_DIR"/*
echo "Build for $org completed successfully"
}
# Main script
for org in "${ORG_LIST[@]}"; do
build_organization "$org"
done
echo "All organizations built successfully"
Default target device KM08-708H OR HYC-G920 OR DW02-412
for each org. i have either one of these folders that contain config files for a target device.
thank you once again.
@RuralRoots
i think it will need a script too to switch between env(s)
but thank you for the idea i didn't knew about it before.
i would use it in the feature thank you.
@lleachii
the thing is that there are custom files that are not part of UCI system.
so i have to use /files
Thank you