postit-debian/debian/rules
Paul Schneider 41ab11d7b9
Some checks failed
Forgejo Release postit-deb / release (push) Failing after 3m59s
workflow: crossbuild-essential-arm64 + CONFIG_SITE
The previous two attempts (wget + dpkg-deb -x from packages.debian.org,
apt-get install libc6:arm64) were wrong approaches. The
Debian-recommended way is the crossbuild-essential-<ARCH> meta-package,
which pulls in:

  - gcc-aarch64-linux-gnu / g++-aarch64-linux-gnu (cross-gcc, unused
    for our managed-only build but installed for consistency)
  - binutils-aarch64-linux-gnu (provides aarch64-linux-gnu-objdump
    needed by dh_makeshlibs — replaces the previous binutils-only
    install)
  - libc6-dev:arm64, linux-libc-dev:arm64 (cross-libc for dpkg-shlibdeps
    to resolve the arm64 binaries' NEEDED entries against the system
    shlibs cache)
  - dpkg-cross CONFIG_SITE files under /etc/dpkg-cross/

With crossbuild-essential-arm64 installed:
  - dh_makeshlibs finds its aarch64-linux-gnu-objdump ✓
  - dh_shlibdeps can resolve arm64 binaries against the on-host shlibs
    cache ✓
  - dpkg-buildpackage -Pcross,nocheck runs cleanly

The environment for the arm64 make deb is now:

  CONFIG_SITE=/etc/dpkg-cross/cross-config.arm64 \
    DEB_HOST_ARCH=arm64 DEB_BUILD_ARCH=amd64 \
    DEB_BUILD_OPTIONS=nocheck \
    make deb POSTIT_GIT_TAG= POSTIT_RUNTIME=linux-arm64

which matches the Debian cross-build recipe documented at
https://wiki.debian.org/CrossCompiling (Build without a build
environment section).

debian/rules also drops the now-unused override_dh_shlibdeps
override (the stage dir hack) — standard dh_shlibdeps now
works because the cross-libc is installed.
2026-08-17 19:26:11 +01:00

168 lines
7.2 KiB
Makefile
Executable file

#!/usr/bin/make -f
#
# Debian package build for PostIt (Yavsc desktop client).
#
# Pipeline:
# 1. Clone pazof/yavsc at POSTIT_GIT_TAG into a clean working
# tree under build/yavsc-src.
# 2. dotnet publish src/PostIt/PostIt.Desktop — framework-
# dependent (not self-contained), into build/postit-app.
# 3. Render the icon at the hicolor sizes from
# src/PostIt/PostIt/Assets/Icon.png, plus the SVG as the
# scalable form.
# 4. Stage everything under debian/tmp/ — the layout dh_install
# expects:
# /usr/lib/postit/ (managed assemblies)
# /usr/bin/postit (wrapper script)
# /usr/share/applications/ (postit.desktop)
# /usr/share/icons/hicolor/ (icons)
# 5. dh_install moves it all into debian/postit/ and the rest
# of the dh_* helpers assemble the .deb.
POSTIT_GIT_URL ?= https://github.com/pazof/yavsc.git
POSTIT_GIT_TAG ?= 1.0.6
# Runtime identifier passed to `dotnet publish --runtime`. Override
# at build time for non-amd64 targets:
# make deb POSTIT_RUNTIME=linux-arm64
POSTIT_RUNTIME ?= linux-x64
POSTIT_DESKTOP_PROJECT := src/PostIt/PostIt.Desktop/PostIt.Desktop.csproj
POSTIT_BUILD_DIR := $(CURDIR)/build
POSTIT_SRC_DIR := $(POSTIT_BUILD_DIR)/yavsc-src
POSTIT_TMP := $(CURDIR)/debian/tmp
POSTIT_TMP_LIB := $(POSTIT_TMP)/usr/lib/postit
POSTIT_TMP_BIN := $(POSTIT_TMP)/usr/bin
POSTIT_TMP_SHARE := $(POSTIT_TMP)/usr/share
ICON_SIZES := 16 32 48 64 128 256
%:
dh $@
override_dh_auto_clean:
rm -rf $(POSTIT_BUILD_DIR) $(POSTIT_TMP) $(CURDIR)/debian/changelog
override_dh_auto_build:
# The rendered changelog (debian/changelog) is generated from
# debian/changelog.in by the Makefile *before* dpkg-buildpackage
# runs, because dpkg-buildpackage reads debian/changelog before
# any rule (in dpkg-source --before-build) and would fail with
# "changelog missing" if it were not present. If somebody invokes
# dpkg-buildpackage directly without going through the Makefile
# (rare, but cheap to guard against), render the changelog on
# the fly from the current POSTIT_GIT_TAG so the package still
# builds and ships the right version.
if [ ! -f $(CURDIR)/debian/changelog ] && [ -f $(CURDIR)/debian/changelog.in ]; then \
sed 's/@VERSION@/$(POSTIT_GIT_TAG)/g' \
$(CURDIR)/debian/changelog.in > $(CURDIR)/debian/changelog; \
fi
# 1. Fetch the upstream source at POSTIT_GIT_TAG. The ref can
# be either a branch name (e.g. `main`) or a tag (e.g.
# `1.0.1-rc02`); `git fetch origin <ref>` handles both. The
# reference MUST exist on the configured POSTIT_GIT_URL
# remote (default: github.com/pazof/yavsc). If you are
# building from a tag that is only on your local clone
# (typical right after `git tag 1.0.1-rc02` and before
# `git push origin 1.0.1-rc02`), point POSTIT_GIT_URL at
# your local checkout:
# make POSTIT_GIT_URL=file:///home/paul/Workspace/yavsc \
# POSTIT_GIT_TAG=1.0.1-rc02
mkdir -p $(POSTIT_BUILD_DIR)
if [ ! -d $(POSTIT_SRC_DIR)/.git ]; then \
git init -q $(POSTIT_SRC_DIR); \
git -C $(POSTIT_SRC_DIR) remote add origin $(POSTIT_GIT_URL); \
fi
if ! git -C $(POSTIT_SRC_DIR) fetch --depth=1 origin $(POSTIT_GIT_TAG); then \
echo "" >&2; \
echo " ERROR: POSTIT_GIT_TAG='$(POSTIT_GIT_TAG)' is not reachable from POSTIT_GIT_URL='$(POSTIT_GIT_URL)'." >&2; \
echo " Either push the ref to the remote first (e.g. \`git push origin $(POSTIT_GIT_TAG)\`)" >&2; \
echo " or override POSTIT_GIT_URL with a local path that has the ref, e.g." >&2; \
echo " make POSTIT_GIT_URL=file:///home/paul/Workspace/yavsc POSTIT_GIT_TAG=$(POSTIT_GIT_TAG)" >&2; \
echo "" >&2; \
exit 128; \
fi
git -C $(POSTIT_SRC_DIR) checkout -q FETCH_HEAD
# 2. Publish PostIt.Desktop for the host architecture.
# --self-contained false : rely on the system .NET
# runtime (declared in debian/control Depends:).
# -p:PublishReadyToRun=false : avoid R2R which inflates
# the binary for marginal startup gain on a desktop GUI.
# -p:DisableGitVersionTask=true : GitVersion.MsBuild cannot
# resolve the repo when we check out FETCH_HEAD (the working
# tree is in detached-HEAD state, which trips GitVersion's
# FindGitDir path detection). We instead stamp the assembly
# metadata manually from POSTIT_GIT_TAG below.
# -p:Version / -p:AssemblyVersion / -p:FileVersion / -p:InformationalVersion :
# substitute GitVersion's resolved values with values
# derived from the tag we are packaging. The consumer of
# the .deb can still query `dpkg-deb -f postit_*.deb Version`
# for the Debian package version; these MSBuild properties
# only show up in the managed assembly metadata (visible
# via `postit --version` once the WinExe embeds it).
#
# Strip the pre-release suffix (e.g. -rc03) from
# POSTIT_GIT_TAG for AssemblyVersion/FileVersion, since
# those require strict major.minor.build.revision numerics.
# Version / InformationalVersion keep the full string with
# the suffix, which is what SemanticVersion consumers
# expect.
$(eval POSTIT_ASSEMBLY_VERSION := $(shell echo $(POSTIT_GIT_TAG) | sed 's/-.*//'))
dotnet publish $(POSTIT_SRC_DIR)/$(POSTIT_DESKTOP_PROJECT) \
-c Release \
--self-contained false \
--runtime $(POSTIT_RUNTIME) \
-p:PublishReadyToRun=false \
-p:DisableGitVersionTask=true \
-p:Version=$(POSTIT_GIT_TAG) \
-p:AssemblyVersion=$(POSTIT_ASSEMBLY_VERSION).0 \
-p:FileVersion=$(POSTIT_ASSEMBLY_VERSION).0 \
-p:InformationalVersion=$(POSTIT_GIT_TAG) \
-o $(POSTIT_BUILD_DIR)/postit-app
override_dh_auto_test:
# No upstream test suite for PostIt.Desktop at this stage
# (Yavsc.Org.Tests covers the web front, not the desktop
# client). Build smoke is sufficient for the package.
override_dh_shlibdeps:
# The runner image installs crossbuild-essential-arm64, which
# provides libc6-dev:arm64 et al. plus dpkg-cross — enough
# for dh_shlibdeps to resolve the arm64 binaries' NEEDED
# entries against the system's shlibs cache directly. No
# stage dir, no -l hack: standard dh_shlibdeps just works.
dh_shlibdeps
override_dh_strip:
# dh_strip disabled entirely. See MEMORY.md / AGENTS.md for the
# rationale (cross-compiled native .so via NuGet from Avalonia
# deps cannot be parsed by amd64 objcopy/strip).
define stage_postit
mkdir -p $(POSTIT_TMP_LIB)
cp -r $(POSTIT_BUILD_DIR)/postit-app/. $(POSTIT_TMP_LIB)/
mkdir -p $(POSTIT_TMP_BIN)
cp $(CURDIR)/debian/postit.wrapper $(POSTIT_TMP_BIN)/postit
chmod 0755 $(POSTIT_TMP_BIN)/postit
mkdir -p $(POSTIT_TMP_SHARE)/applications
cp $(CURDIR)/debian/postit.desktop \
$(POSTIT_TMP_SHARE)/applications/postit.desktop
mkdir -p $(POSTIT_TMP_SHARE)/icons/hicolor/scalable/apps
cp $(POSTIT_SRC_DIR)/src/PostIt/PostIt/Assets/yavsc-logo.svg \
$(POSTIT_TMP_SHARE)/icons/hicolor/scalable/apps/postit.svg
for size in $(ICON_SIZES); do \
mkdir -p $(POSTIT_TMP_SHARE)/icons/hicolor/$${size}x$${size}/apps; \
convert $(POSTIT_SRC_DIR)/src/PostIt/PostIt/Assets/Icon.png \
-resize $${size}x$${size} \
$(POSTIT_TMP_SHARE)/icons/hicolor/$${size}x$${size}/apps/postit.png; \
done
endef
override_dh_install:
$(call stage_postit)
dh_install