mirror of
https://github.com/kernelkit/infix.git
synced 2026-07-22 01:13:00 +02:00
Infix defines its own Kconfig options with unprefixed names (IMAGE_*, QEMU_*, TRUSTED_KEYS*) and an INFIX_ prefix. Unprefixed names risk clashing with Buildroot and with other br2-externals/spins that source our tree. Rename all 86 options to a common IX_ prefix, collapsing the existing INFIX_ ones, e.g. INFIX_IMAGE_ID becomes IX_IMAGE_ID. The os-release INFIX_DESC field is a runtime interface, not a Kconfig option, and is kept; the qemu Config.in generator's @ARCH@ symbol is updated to match. Closes #1305 Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
149 lines
4.9 KiB
Bash
Executable File
149 lines
4.9 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# shellcheck disable=SC1090,SC1091,SC3053
|
|
|
|
common=$(dirname "$(readlink -f "$0")")
|
|
. "$common/lib.sh"
|
|
. "$BR2_CONFIG" 2>/dev/null
|
|
. "$TARGET_DIR/usr/lib/os-release"
|
|
|
|
# Extract list of loaded YANG modules and their features for yangdoc.html
|
|
mkyangdoc()
|
|
{
|
|
cmd="yangdoc -o $1 -p $TARGET_DIR/usr/share/yang"
|
|
|
|
# shellcheck disable=SC2155
|
|
export SYSREPO_SHM_PREFIX="yangdoc"
|
|
while IFS= read -r line; do
|
|
if echo "$line" | grep -q '^[a-z]'; then
|
|
module=$(echo "$line" | awk '{print $1}')
|
|
cmd="$cmd -m $module"
|
|
feature=$(echo "$line" | awk -F'|' '{print $8}' | sed 's/^ *//;s/ *$//')
|
|
if [ -n "$feature" ]; then
|
|
feature_list=$(echo "$feature" | tr ' ' '\n')
|
|
for feat in $feature_list; do
|
|
cmd="$cmd -e $feat"
|
|
done
|
|
fi
|
|
fi
|
|
done <<EOF
|
|
$(sysrepoctl -l; rm -f /dev/shm/${SYSREPO_SHM_PREFIX}*)
|
|
EOF
|
|
|
|
# Ignore a few top-level oddballs not used by core Infix
|
|
cmd="$cmd -x supported-algorithms"
|
|
|
|
ixmsg "Calling $cmd"
|
|
$cmd
|
|
}
|
|
|
|
if [ -f "$TARGET_DIR/etc/rauc/system.conf" ]; then
|
|
sed -i "s/compatible=.*/compatible=$IX_COMPATIBLE/" "$TARGET_DIR/etc/rauc/system.conf"
|
|
fi
|
|
|
|
if [ -n "${ID_LIKE}" ]; then
|
|
ID="${ID} ${ID_LIKE}"
|
|
fi
|
|
|
|
# Initialize default hostname for hostname.d pattern
|
|
mkdir -p "$TARGET_DIR/etc/hostname.d"
|
|
cp "$TARGET_DIR/etc/hostname" "$TARGET_DIR/etc/hostname.d/10-default"
|
|
|
|
# This is a symlink to /usr/lib/os-release, so we remove this to keep
|
|
# original Buildroot information.
|
|
ixmsg "Creating /etc/os-release"
|
|
rm -f "$TARGET_DIR/etc/os-release"
|
|
{
|
|
echo "NAME=\"$IX_NAME\""
|
|
echo "ID=$IX_ID"
|
|
echo "PRETTY_NAME=\"$IX_TAGLINE $INFIX_VERSION\""
|
|
echo "ID_LIKE=\"${ID}\""
|
|
echo "DEFAULT_HOSTNAME=$BR2_TARGET_GENERIC_HOSTNAME"
|
|
echo "VERSION=\"${INFIX_VERSION}\""
|
|
echo "VERSION_ID=${INFIX_VERSION}"
|
|
echo "BUILD_ID=\"${INFIX_BUILD_ID}\""
|
|
if [ -n "$IX_IMAGE_ID" ]; then
|
|
echo "IMAGE_ID=\"$IX_IMAGE_ID\""
|
|
fi
|
|
if [ -n "$INFIX_RELEASE" ]; then
|
|
echo "IMAGE_VERSION=\"$INFIX_RELEASE\""
|
|
fi
|
|
echo "ARCHITECTURE=\"${IX_ARCH}\""
|
|
echo "HOME_URL=$IX_HOME"
|
|
if [ -n "$IX_VENDOR" ]; then
|
|
echo "VENDOR_NAME=\"$IX_VENDOR\""
|
|
fi
|
|
if [ -n "$IX_VENDOR_HOME" ]; then
|
|
echo "VENDOR_HOME=\"$IX_VENDOR_HOME\""
|
|
fi
|
|
if [ -n "$IX_DOC" ]; then
|
|
echo "DOCUMENTATION_URL=\"$IX_DOC\""
|
|
fi
|
|
if [ -n "$IX_SUPPORT" ]; then
|
|
echo "SUPPORT_URL=\"$IX_SUPPORT\""
|
|
fi
|
|
if [ -n "$IX_DESC" ]; then
|
|
echo "INFIX_DESC=\"$IX_DESC\""
|
|
fi
|
|
} > "$TARGET_DIR/etc/os-release"
|
|
|
|
echo "$IX_TAGLINE $INFIX_VERSION -- $(date +"%b %e %H:%M %Z %Y")" > "$TARGET_DIR/etc/version"
|
|
ixmsg "Creating /etc/version: $(cat "$TARGET_DIR/etc/version")"
|
|
|
|
# In case of ambguities, this is what the image was built from
|
|
cp "$BR2_CONFIG" "$TARGET_DIR/usr/share/infix/config"
|
|
gzip -f "$TARGET_DIR/usr/share/infix/config"
|
|
|
|
# Drop Buildroot default symlink to /tmp
|
|
if [ -L "$TARGET_DIR/var/lib/avahi-autoipd" ]; then
|
|
rm "$TARGET_DIR/var/lib/avahi-autoipd"
|
|
mkdir "$TARGET_DIR/var/lib/avahi-autoipd"
|
|
fi
|
|
|
|
# Drop Buildroot default pam_lastlog.so from login chain
|
|
sed -i '/^[^#]*pam_lastlog.so/s/^/# /' "$TARGET_DIR/etc/pam.d/login"
|
|
|
|
# Allow bash to be login shells, it is added automatically when selected
|
|
# in menuyconfig, but not when BusyBox provides a symlink (for ash).
|
|
# The /bin/{true,false} are old UNIX beart means of disabling a user.
|
|
grep -qsE '^/bin/bash$$' "$TARGET_DIR/etc/shells" \
|
|
|| echo "/bin/bash" >> "$TARGET_DIR/etc/shells"
|
|
grep -qsE '^/bin/true$$' "$TARGET_DIR/etc/shells" \
|
|
|| echo "/bin/true" >> "$TARGET_DIR/etc/shells"
|
|
grep -qsE '^/bin/false$$' "$TARGET_DIR/etc/shells" \
|
|
|| echo "/bin/false" >> "$TARGET_DIR/etc/shells"
|
|
|
|
# Allow clish (symlink to /usr/bin/klish) to be a login shell
|
|
grep -qsE '^/bin/clish$$' "$TARGET_DIR/etc/shells" \
|
|
|| echo "/bin/clish" >> "$TARGET_DIR/etc/shells"
|
|
|
|
# Create YANG documentation
|
|
if [ "$BR2_PACKAGE_HOST_PYTHON_YANGDOC" = "y" ]; then
|
|
mkyangdoc "$BINARIES_DIR/yangdoc.html"
|
|
fi
|
|
|
|
# Bundle the mkdocs User's Guide into the rootfs, served by the WebUI's
|
|
# nginx at /guide/. Only when the WebUI is present (nothing serves it
|
|
# otherwise, and it keeps minimal images small) and mkdocs is on the build
|
|
# host. Best-effort: a failed build warns but does not abort the image
|
|
# build, and the WebUI hides its User Guide entry when the docs are absent.
|
|
mkuserguide()
|
|
{
|
|
local cfg dst
|
|
cfg="$(readlink -f "$common/../..")/mkdocs.yml"
|
|
dst="$TARGET_DIR/var/www/guide"
|
|
|
|
if ! command -v mkdocs >/dev/null 2>&1; then
|
|
ixmsg "mkdocs not found, skipping User's Guide bundling"
|
|
return
|
|
fi
|
|
ixmsg "Building User's Guide into $dst"
|
|
if ! mkdocs build -f "$cfg" -d "$dst" --clean --quiet; then
|
|
ixmsg "WARNING: mkdocs build failed, shipping without on-device User's Guide"
|
|
rm -rf "$dst"
|
|
fi
|
|
}
|
|
|
|
if [ "$BR2_PACKAGE_WEBUI" = "y" ]; then
|
|
mkuserguide
|
|
fi
|