69 lines
2.5 KiB
Bash
Executable File
69 lines
2.5 KiB
Bash
Executable File
#!/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
|
|
|
|
# Add usb_modeswitch mdev rule
|
|
grep -q "usb_modeswitch" "$TARGET_DIR/etc/mdev.conf" || \
|
|
echo '$PRODUCT=bda/1a2b.* root:root 0660 */lib/mdev/rtl8821cu_usb_modeswitch.sh' >> "$TARGET_DIR/etc/mdev.conf"
|
|
|
|
# Add wlan_setup mdev rule
|
|
grep -q "wlan_setup" "$TARGET_DIR/etc/mdev.conf" || \
|
|
echo '$PRODUCT=bda/c820.* root:root 0660 */lib/mdev/wlan_setup.sh' >> "$TARGET_DIR/etc/mdev.conf"
|
|
|
|
# Add wlan0 configuration
|
|
grep -q "iface wlan0" "$TARGET_DIR/etc/network/interfaces" || \
|
|
cat >> "$TARGET_DIR/etc/network/interfaces" << 'EOF'
|
|
|
|
auto wlan0
|
|
iface wlan0 inet dhcp
|
|
pre-up ip link set wlan0 up
|
|
pre-up wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
|
|
EOF
|
|
|
|
# Generate /etc/build-info with details about this build
|
|
build_user="$(id -un)"
|
|
build_host="$(hostname)"
|
|
build_date="$(date '+%Y-%m-%d %H:%M:%S %z')"
|
|
|
|
# Determine the git revision the same way the Linux kernel does:
|
|
# prefer a tag (git describe), fall back to the short hash, and append
|
|
# "-dirty" if tracked files are modified or there are untracked files.
|
|
build_rev="unknown"
|
|
if [ -n "$BR2_EXTERNAL_RPI_COMMON_PATH" ] && \
|
|
git -C "$BR2_EXTERNAL_RPI_COMMON_PATH" rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
|
git_dir="$BR2_EXTERNAL_RPI_COMMON_PATH"
|
|
build_rev="$(git -C "$git_dir" describe --always --tags 2>/dev/null || \
|
|
git -C "$git_dir" rev-parse --short HEAD 2>/dev/null || \
|
|
echo unknown)"
|
|
# Refresh the index so diff-index doesn't report stale stat info
|
|
git -C "$git_dir" update-index --refresh >/dev/null 2>&1 || :
|
|
dirty=""
|
|
if ! git -C "$git_dir" diff-index --quiet HEAD -- 2>/dev/null; then
|
|
dirty="-dirty"
|
|
elif [ -n "$(git -C "$git_dir" ls-files --others --exclude-standard 2>/dev/null)" ]; then
|
|
dirty="-dirty"
|
|
fi
|
|
build_rev="${build_rev}${dirty}"
|
|
fi
|
|
|
|
cat > "$TARGET_DIR/etc/build-info" << EOF
|
|
Built by: ${build_user}@${build_host}
|
|
Build date: ${build_date}
|
|
Revision: ${build_rev}
|
|
EOF |