sector-f-linux

Sector F Linux
git clone https://git.sectorflabs.com/sector-f-linux.git
Log | Files | Refs | README | LICENSE

build.sh (2245B)


      1 #!/usr/bin/env bash
      2 # Builds the Patina desktop for the image: patina-desktop's own
      3 # packaging/deb/build.py (ADR-0099) in --stage mode, run in a Fedora 45
      4 # container. That is what `make install-full` runs there, so the image gets
      5 # every binary, the apps packaging/bundle.toml pins, the default apps list, the
      6 # session entry, portal and PAM config, laid out under /usr. It lands in
      7 # build/desktop/ as it goes under /, and the Containerfile copies it in; the
      8 # libraries and programs it needs come from dnf there.
      9 #
     10 # PATINA_DESKTOP is the checkout (default: beside patina-os). It builds the
     11 # checkout's last commit, not its working tree, so stray changes don't ship.
     12 # PATINA_DESKTOP_WORKTREE=1 builds the working tree instead, uncommitted
     13 # changes and all, to try them in the VM.
     14 #
     15 # Needs the network: the apps from other repositories are fetched from GitHub
     16 # at the commits bundle.toml pins, and cargo downloads crates. Cargo's
     17 # downloads and the build's work folder are kept in Docker volumes, so
     18 # rebuilds are incremental. The tree is staged in target/full of the checkout,
     19 # as `make install-full` there does.
     20 set -euo pipefail
     21 
     22 ROOT=$(cd "$(dirname "$0")/.." && pwd)
     23 SRC=$(cd "${PATINA_DESKTOP:-$ROOT/../../patina-desktop}" && pwd)
     24 BUILD="$ROOT/build"
     25 STAGE="$BUILD/desktop"
     26 BUILDER=patina-os-desktop-builder
     27 
     28 say() { printf '==> %s\n' "$*"; }
     29 
     30 [[ -d "$SRC/.git" ]] || { echo "error: no checkout at $SRC" >&2; exit 1; }
     31 
     32 say "the build environment"
     33 docker build -q -f "$ROOT/desktop/builder.Containerfile" -t "$BUILDER" "$ROOT/desktop" >/dev/null
     34 
     35 commit=$(git -C "$SRC" rev-parse --short HEAD)
     36 say "building patina-desktop $commit"
     37 rm -rf "$SRC/target/full"
     38 docker run --rm --user "$(id -u):$(id -g)" \
     39   -e CARGO_HOME=/cargo -e HOME=/tmp -e XDG_CACHE_HOME=/cache \
     40   -v patina-os-cargo:/cargo -v patina-os-cache:/cache \
     41   -v "$SRC:/src" -w /src "$BUILDER" \
     42   python3 packaging/deb/build.py --stage target/full --prefix /usr ${PATINA_DESKTOP_WORKTREE:+--worktree}
     43 
     44 rm -rf "$STAGE" && mkdir -p "$STAGE"
     45 cp -a "$SRC/target/full/." "$STAGE/"
     46 mkdir -p "$STAGE/usr/lib/patina-os"
     47 echo "$commit" > "$STAGE/usr/lib/patina-os/desktop"
     48 say "build/desktop/ ($(find "$STAGE/usr/bin" -type f | wc -l) programs in /usr/bin, from $commit)"