#!/bin/sh # post_build.sh - Common post-build script for Raspberry Pi # # Called by Buildroot after assembling the target rootfs. # Arguments: # $1 = path to the target rootfs directory (e.g., output/target) # # Environment: # BR2_EXTERNAL_RPI_COMMON_PATH = path to this external tree # # Use this script for: # - Fixing file permissions # - Creating symlinks # - Generating config files that depend on build-time variables # - Stripping unnecessary files from the rootfs # # Do NOT use this for: # - Installing packages (use rootfs overlay or a package .mk instead) # - Modifying files outside $1 set -e TARGET_DIR="$1" # Example: ensure /etc/hostname exists with a default value if [ ! -f "${TARGET_DIR}/etc/hostname" ]; then echo "rpi-common" > "${TARGET_DIR}/etc/hostname" fi # Example: remove unnecessary documentation to save space rm -rf "${TARGET_DIR}/usr/share/man" rm -rf "${TARGET_DIR}/usr/share/doc" echo ">>> Common post-build script completed"