Linux phones have no banking apps, and a command line is no answer on a phone. The app does everything the nostro command does and, like it, only talks to nostrod: it holds no key and no token. - Nostro.Ui, a toolkit whose screens are functions that fill a frame, ported from imsd-messages ca5cd72d; Nostro.App, the app's state, forms and screens; Nostro.Ui.Shell, which puts them on a Wayland window with Crafter.Graphics; nostro-app; and Nostro.DebugCommands for the --debug-api build. - Client: every method also in an asynchronous form for an sd-event loop, with DaemonMissing and OutcomeUnknown. - nostrod's Flatpak is net.catcrafts.Nostrod now and the app takes net.catcrafts.Nostro; install.sh moves the state. The app's Flatpak, both Flatpaks cross-built for aarch64, and the licence texts they carry. - nostro-fake-system, a made-up bus and bank with a real nostrod on them, to look at the app against. The README's screenshots are taken on it. - The nostro command: an API key's environment is the key's own to say, so --sandbox is for bunq-oauth alone, and a virtual card is listed as VIRTUAL. The published contract changes in three places, before any release (design rule 10): - Transactions' query takes `stored`: answered from what nostrod has stored, without asking the bank. The app searches with it; before, every search was a call to bunq. - AddBunq's `environment` no longer chooses over what the key says of itself: a key of the other environment is refused. - SetCardStatus refuses to freeze or unfreeze a virtual card. bunq reports one as DEACTIVATED however well it pays, and leaves it as it is when asked, without an error. The app is GPL-3.0-only, the library stays LGPL-3.0-only, and no code moved from one to the other (design rule 13). Transaction's schema is unchanged. Verified: the 17 tests pass with every line, function and region of what they link run, and the five lint runs are clean. Every screen was looked at on the made-up system, at a phone's and a desktop's sizes in the light and the dark look, on Plasma under Wayland. What is said of bunq's cards comes from its sandbox, with throwaway users, and from one real virtual card. Known to have been used against production: connecting, and reading accounts, payments and cards. Not known to have been tried: a payment from the app against bunq, OAuth against bunq, and anything on a phone. Building the app takes --graphics=, a Crafter.Graphics checkout on its branch claude/nostro-app, until that branch is merged and pinned here. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
139 lines
7.4 KiB
Shell
Executable file
139 lines
7.4 KiB
Shell
Executable file
#!/bin/sh
|
|
# SPDX-License-Identifier: LGPL-3.0-only
|
|
# SPDX-FileCopyrightText: Copyright (C) 2026 Catcrafts®
|
|
|
|
# build-aarch64.sh: Nostro's two Flatpaks for aarch64, a phone's architecture, into an OSTree repository: the app
|
|
# (net.catcrafts.Nostro) and the service with the nostro command (net.catcrafts.Nostrod). crafter-build cross-compiles
|
|
# the executables against the sysroot of make-aarch64-sysroot.sh (run that first), and flatpak's build commands
|
|
# assemble them on org.freedesktop.Platform 26.08, with the libc++ they were linked against in /app/lib.
|
|
#
|
|
# packaging/flatpak/build-aarch64.sh <repo> [branch] # branch: stable by default
|
|
#
|
|
# The repository is created when it does not exist. On the phone, as root, with the repository copied over:
|
|
# packaging/system/install.sh --repo <repo> --app. The cache and $CRAFTER_REF are make-aarch64-sysroot.sh's.
|
|
# $NOSTRO_GRAPHICS names a Crafter.Graphics checkout's project.cpp for the app, for as long as project.cpp asks for one
|
|
# (--graphics=). Needs flatpak, flock, readelf and appstreamcli.
|
|
set -eu
|
|
|
|
REPO=${1:?usage: build-aarch64.sh <repo> [branch]}
|
|
BRANCH=${2:-stable}
|
|
APP_ID=net.catcrafts.Nostro
|
|
SERVICE_ID=net.catcrafts.Nostrod
|
|
ARCH=aarch64
|
|
TRIPLE=aarch64-unknown-linux-gnu
|
|
MULTIARCH=aarch64-linux-gnu
|
|
RUNTIME_VERSION=26.08
|
|
CRAFTER_REF=${CRAFTER_REF:-net.catcrafts.CrafterBuild//stable}
|
|
CACHE=${NOSTRO_FLATPAK_CACHE:-${XDG_CACHE_HOME:-$HOME/.cache}/nostro-flatpak}
|
|
INSTALLATION="$CACHE/installation"
|
|
SYSROOT="$CACHE/sysroot-$ARCH"
|
|
LIBCXX="$CACHE/libcxx-$ARCH"
|
|
SRC=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
|
|
# flatpak commands that need the aarch64 Sdk and Platform see their installation; crafter-build runs from wherever it
|
|
# is installed.
|
|
withsdk() { FLATPAK_USER_DIR="$INSTALLATION" "$@"; }
|
|
|
|
command -v readelf >/dev/null 2>&1 || { echo "readelf (binutils) is needed: the NEEDED checks below run on it" >&2; exit 1; }
|
|
# One build at a time on this cache: the build directories are removed and made again by every run.
|
|
mkdir -p "$CACHE"
|
|
exec 9>"$CACHE/lock"; flock 9
|
|
[ -f "$SYSROOT/.made-from" ] || { echo "no sysroot at $SYSROOT: run packaging/flatpak/make-aarch64-sysroot.sh first" >&2; exit 1; } # under the lock: a sysroot being made is not missing
|
|
|
|
# Generic armv8-a: a Flatpak is for any aarch64 machine, not one SoC. An output directory's name ends in a hash of the
|
|
# configuration, and an older variant left in bin/ would be a second match below: this run's are the only ones.
|
|
rm -rf "$SRC/bin/"*"-$TRIPLE-armv8-a-generic-"*
|
|
crafter() { (cd "$SRC" && flatpak run "$CRAFTER_REF" --march=armv8-a --mtune=generic --banks=bunq "$@" -- --target="$TRIPLE" --sysroot="$SYSROOT"); }
|
|
# The one executable of that name this run built. The library and the command are both called nostro, so a directory
|
|
# is told by what it holds.
|
|
built() {
|
|
name=$1
|
|
set -- "$SRC/bin/$name-$TRIPLE-armv8-a-generic-"*/"$name"
|
|
[ $# = 1 ] && [ -x "$1" ] || { echo "expected one $name for $TRIPLE under $SRC/bin, found: $*" >&2; exit 1; }
|
|
echo "$1"
|
|
}
|
|
|
|
echo ">> the executables for $TRIPLE"
|
|
crafter
|
|
crafter --product=daemon
|
|
crafter --product=app ${NOSTRO_GRAPHICS:+"--graphics=$NOSTRO_GRAPHICS"}
|
|
cli=$(built nostro)
|
|
daemon=$(built nostrod)
|
|
app=$(built nostro-app)
|
|
|
|
platform=$(withsdk flatpak --user info --show-location --arch="$ARCH" "org.freedesktop.Platform//$RUNTIME_VERSION")/files
|
|
# Every library an executable and the libraries it carries need is in the Platform or in /app/lib, or the first start
|
|
# would fail on the phone. And one unwinder: LLVM's libunwind, which the carried libc++abi uses, never the Platform's
|
|
# libunwind 8 beside it.
|
|
checked() {
|
|
files=$1
|
|
shift
|
|
missing=0
|
|
for elf in "$@" "$files/lib/"lib*.so.1; do
|
|
for lib in $(readelf -d "$elf" | sed -n 's/.*(NEEDED).*\[\(.*\)\]/\1/p'); do
|
|
if [ ! -e "$platform/lib/$MULTIARCH/$lib" ] && [ ! -e "$platform/lib/$lib" ] && [ ! -e "$files/lib/$lib" ]; then
|
|
echo "$(basename "$elf") needs $lib, which neither the Platform nor /app/lib has" >&2
|
|
missing=1
|
|
fi
|
|
done
|
|
if readelf -d "$elf" | grep -q 'NEEDED.*\[libunwind\.so\.8\]'; then
|
|
echo "$(basename "$elf") links libunwind 8, not LLVM's libunwind" >&2
|
|
missing=1
|
|
fi
|
|
done
|
|
[ "$missing" = 0 ] || exit 1
|
|
}
|
|
# What both carry: the C++ runtime they were linked against, and the licences of what is in them, which
|
|
# packaging/licenses/NOTICE names.
|
|
carried() {
|
|
files=$1
|
|
id=$2
|
|
mkdir -p "$files/lib"
|
|
cp -a "$LIBCXX/usr/lib/"libc++.so.1* "$LIBCXX/usr/lib/"libc++abi.so.1* "$LIBCXX/usr/lib/"libunwind.so.1* "$files/lib/"
|
|
install -Dm644 "$SRC/packaging/flatpak/$id.metainfo.xml" "$files/share/metainfo/$id.metainfo.xml"
|
|
install -Dm644 -t "$files/share/licenses/$id" "$SRC/LICENSE" "$SRC/LICENSE.GPL" "$SRC/packaging/licenses/NOTICE" \
|
|
"$SRC/packaging/licenses/nlohmann-json-MIT.txt" "$SRC/packaging/licenses/LLVM-LICENSE.TXT"
|
|
}
|
|
# The AppStream catalogue entry software centres list an app by, with PNG icons: appstreamcli's default, JPEG XL, is
|
|
# not read by older clients.
|
|
catalogued() {
|
|
appstreamcli compose --prefix=/ --origin="$2" --image-format=png \
|
|
--result-root="$1" --data-dir="$1/share/app-info/xmls" --icons-dir="$1/share/app-info/icons/flatpak" "$1"
|
|
}
|
|
mkdir -p "$(dirname "$REPO")"
|
|
|
|
echo ">> $SERVICE_ID from $cli and $daemon"
|
|
build="$CACHE/build-service-$ARCH"
|
|
rm -rf "$build"
|
|
withsdk flatpak build-init --arch="$ARCH" "$build" "$SERVICE_ID" org.freedesktop.Sdk org.freedesktop.Platform "$RUNTIME_VERSION"
|
|
files="$build/files"
|
|
install -Dm755 "$cli" "$files/bin/nostro"
|
|
install -Dm755 "$daemon" "$files/bin/nostrod"
|
|
carried "$files" "$SERVICE_ID"
|
|
checked "$files" "$files/bin/nostro" "$files/bin/nostrod"
|
|
catalogued "$files" "$SERVICE_ID"
|
|
# nostrod talks to the bank, and to the bus, logind and polkit on the system bus; the command talks to nostrod there.
|
|
# As packaging/flatpak/net.catcrafts.Nostrod.yaml has it for x86_64.
|
|
withsdk flatpak build-finish "$build" --command=nostro --share=network --socket=system-bus
|
|
withsdk flatpak build-export --arch="$ARCH" "$REPO" "$build" "$BRANCH"
|
|
|
|
echo ">> $APP_ID from $app"
|
|
build="$CACHE/build-app-$ARCH"
|
|
rm -rf "$build"
|
|
withsdk flatpak build-init --arch="$ARCH" "$build" "$APP_ID" org.freedesktop.Sdk org.freedesktop.Platform "$RUNTIME_VERSION"
|
|
files="$build/files"
|
|
# The app finds its fonts and the window library's shaders beside itself.
|
|
mkdir -p "$files/bin"
|
|
cp -a "$(dirname "$app")/." "$files/bin/"
|
|
carried "$files" "$APP_ID"
|
|
install -Dm644 "$SRC/packaging/flatpak/$APP_ID.desktop" "$files/share/applications/$APP_ID.desktop"
|
|
install -Dm644 "$SRC/packaging/flatpak/$APP_ID.svg" "$files/share/icons/hicolor/scalable/apps/$APP_ID.svg"
|
|
install -Dm644 -t "$files/share/licenses/$APP_ID" "$SRC/assets/OFL.txt" "$SRC/packaging/licenses/stb-LICENSE.txt" \
|
|
"$SRC/packaging/licenses/wayland-protocols-NOTICE.txt" "$SRC/packaging/licenses/Vulkan-Utility-Libraries-Apache-2.0.txt" \
|
|
"$SRC/packaging/licenses/libevdev-COPYING.txt"
|
|
checked "$files" "$files/bin/nostro-app"
|
|
catalogued "$files" "$APP_ID"
|
|
# The compositor, the graphics device, and nostrod on the system bus; the desktop's portals need no permission. As
|
|
# project.cpp has it for the x86_64 Flatpak crafter-build makes.
|
|
withsdk flatpak build-finish "$build" --command=nostro-app --socket=wayland --device=dri --system-talk-name=net.catcrafts.Nostro1
|
|
withsdk flatpak build-export --arch="$ARCH" "$REPO" "$build" "$BRANCH"
|
|
echo ">> done: app/$SERVICE_ID/$ARCH/$BRANCH and app/$APP_ID/$ARCH/$BRANCH in $REPO"
|