#!/bin/sh # Compile the target rootfs's GSettings XML schemas. # Apk installs packages with --no-scripts, so gschemas.compiled is not created # by package triggers. WebKitGTK's network process aborts when the compiled # schema database is missing, producing an "Unexpected WebKit error". set -eu BASE_DIR="$(cd "$(dirname "$0")/.." && pwd)" TARGET_ROOTFS="${1:-${ROOTFS_DIR:-$BASE_DIR/rootfs}}" SCHEMA_DIR="$TARGET_ROOTFS/usr/share/glib-2.0/schemas" if [ ! -d "$SCHEMA_DIR" ]; then echo "Error: GSettings schema directory is missing: $SCHEMA_DIR" >&2 exit 1 fi schema_found=0 for schema_file in "$SCHEMA_DIR"/*.gschema.xml "$SCHEMA_DIR"/*.enums.xml; do if [ -f "$schema_file" ]; then schema_found=1 break fi done if [ "$schema_found" -ne 1 ]; then echo "Error: no GSettings schema XML files found in $SCHEMA_DIR" >&2 exit 1 fi if ! command -v glib-compile-schemas >/dev/null 2>&1; then echo "Error: glib-compile-schemas is required to compile $SCHEMA_DIR" >&2 exit 1 fi glib-compile-schemas --strict --targetdir="$SCHEMA_DIR" "$SCHEMA_DIR" >/dev/null if [ ! -s "$SCHEMA_DIR/gschemas.compiled" ]; then echo "Error: glib-compile-schemas did not create gschemas.compiled" >&2 exit 1 fi chmod 0644 "$SCHEMA_DIR/gschemas.compiled" echo "[ok] compiled GSettings schemas in $SCHEMA_DIR"