Files

79 lines
3.1 KiB
Makefile
Executable File

#!/usr/bin/make -f
export DH_VERBOSE = 1
# Get git commit date for version
GIT_DATE := $(shell date +%Y%m%d)
GIT_COMMIT := HEAD
# Go needs writable directories for its caches
export HOME := $(CURDIR)/debian/tmp-home
export GOCACHE := $(CURDIR)/debian/tmp-home/go-cache
export GOMODCACHE := $(CURDIR)/debian/tmp-home/go-mod
# Launchpad has no network access; build with the bundled toolchain only
export GOTOOLCHAIN := local
%:
dh $@
override_dh_installsystemd:
dh_installsystemd --name=dms
override_dh_auto_build:
# Create Go cache directories (sbuild sets HOME to non-existent path)
mkdir -p $(HOME) $(GOCACHE) $(GOMODCACHE)
# Git source is already included in source package (cloned by ppa-build.sh)
# Launchpad build environment has no internet access
test -d dms-git-repo || (echo "ERROR: dms-git-repo directory not found!" && exit 1)
# Bundled Go (dms-git-repo/go$$VER.linux-{amd64,arm64}.tar.gz), staged by ppa-build.sh
$(eval DEB_HOST_ARCH := $(shell dpkg-architecture -qDEB_HOST_ARCH))
GO_TARBALL=$$(ls "$(CURDIR)"/dms-git-repo/go[0-9]*.linux-$(DEB_HOST_ARCH).tar.gz 2>/dev/null | head -n1); \
test -f "$$GO_TARBALL" || (echo "ERROR: Missing bundled Go toolchain for $(DEB_HOST_ARCH)" && exit 1); \
rm -rf "$(CURDIR)/go-bootstrap" "$(CURDIR)/.go-toolchain"; \
mkdir -p "$(CURDIR)/go-bootstrap"; \
tar -xzf "$$GO_TARBALL" -C "$(CURDIR)/go-bootstrap"; \
mv "$(CURDIR)/go-bootstrap/go" "$(CURDIR)/.go-toolchain"; \
export PATH="$(CURDIR)/.go-toolchain/bin:$$PATH"; \
export GOROOT="$(CURDIR)/.go-toolchain"; \
go version; \
if [ -f dms-git-repo/.dms-version ]; then \
. dms-git-repo/.dms-version; \
echo "Building with VERSION=$$VERSION COMMIT=$$COMMIT ARCH=$(DEB_HOST_ARCH)"; \
cd dms-git-repo/core && $(MAKE) GOFLAGS="-mod=vendor" dist ARCH=$(DEB_HOST_ARCH) VERSION="$$VERSION" COMMIT="$$COMMIT"; \
else \
echo "Warning: .dms-version not found, building without version info"; \
cd dms-git-repo/core && $(MAKE) GOFLAGS="-mod=vendor" dist ARCH=$(DEB_HOST_ARCH); \
fi
cp dms-git-repo/core/bin/dms-linux-$(DEB_HOST_ARCH) dms
chmod +x dms
override_dh_auto_install:
# Install binary
install -Dm755 dms debian/dms-git/usr/bin/dms
# Install systemd user service
install -Dm644 dms-git-repo/assets/systemd/dms.service \
debian/dms-git/usr/lib/systemd/user/dms.service
# Install desktop file and icon
install -Dm644 dms-git-repo/assets/dms-open.desktop \
debian/dms-git/usr/share/applications/dms-open.desktop
install -Dm644 dms-git-repo/assets/com.danklinux.dms.desktop \
debian/dms-git/usr/share/applications/com.danklinux.dms.desktop
install -Dm644 dms-git-repo/assets/com.danklinux.dms.notepad.desktop \
debian/dms-git/usr/share/applications/com.danklinux.dms.notepad.desktop
install -Dm644 dms-git-repo/assets/com.danklinux.dms.svg \
debian/dms-git/usr/share/icons/hicolor/scalable/apps/com.danklinux.dms.svg
override_dh_auto_clean:
# Don't delete dms-git-repo directory - it's part of the source package (native format)
# Clean up build artifacts
rm -f dms
rm -rf dms-git-repo/core/bin
rm -rf debian/tmp-home
rm -rf go-bootstrap .go-toolchain
dh_auto_clean