|
| 1 | +#!/bin/sh |
| 2 | +# Build the EGO-compliant extension zip into dist/. |
| 3 | +# Does NOT require gnome-shell; uses zip + gettext + glib tools only. |
| 4 | +# Layout matches extensions.gnome.org rules: metadata.json at the root, schema |
| 5 | +# XML only (no gschemas.compiled), compiled translations, no build files. |
| 6 | +set -eu |
| 7 | + |
| 8 | +UUID="audio-output-switcher@mehmetnuri.github.io" |
| 9 | +DOMAIN="audio-output-switcher" |
| 10 | +ZIP="dist/$UUID.shell-extension.zip" |
| 11 | + |
| 12 | +for t in zip msgfmt glib-compile-schemas; do |
| 13 | + command -v "$t" >/dev/null 2>&1 || { echo "ERROR: '$t' not found"; exit 1; } |
| 14 | +done |
| 15 | + |
| 16 | +# 1. Validate metadata.json |
| 17 | +if command -v python3 >/dev/null 2>&1; then |
| 18 | + python3 -c "import json,sys; json.load(open('metadata.json'))" \ |
| 19 | + || { echo "ERROR: metadata.json is not valid JSON"; exit 1; } |
| 20 | +fi |
| 21 | + |
| 22 | +# 2. Validate the GSettings schema (strict). The compiled output is NOT shipped. |
| 23 | +glib-compile-schemas --strict schemas/ >/dev/null |
| 24 | +rm -f schemas/gschemas.compiled |
| 25 | + |
| 26 | +# 3. Compile translations po/*.po -> locale/<lang>/LC_MESSAGES/<domain>.mo |
| 27 | +for po in po/*.po; do |
| 28 | + [ -e "$po" ] || continue |
| 29 | + lang=$(basename "$po" .po) |
| 30 | + mkdir -p "locale/$lang/LC_MESSAGES" |
| 31 | + msgfmt --check "$po" -o "locale/$lang/LC_MESSAGES/$DOMAIN.mo" |
| 32 | +done |
| 33 | + |
| 34 | +# 4. Assemble the zip |
| 35 | +mkdir -p dist |
| 36 | +rm -f "$ZIP" |
| 37 | +zip -qX "$ZIP" metadata.json extension.js prefs.js LICENSE |
| 38 | +zip -qX "$ZIP" schemas/*.gschema.xml |
| 39 | +zip -qX "$ZIP" locale/*/LC_MESSAGES/*.mo |
| 40 | + |
| 41 | +echo "Built $ZIP" |
| 42 | +unzip -l "$ZIP" |
0 commit comments