From 5cd9d7418949fc00d0f55ec985c4136e5a41d5cd Mon Sep 17 00:00:00 2001 From: Michael Aaron Murphy Date: Wed, 13 Sep 2023 15:19:58 +0200 Subject: [PATCH] feat(design-demo): debian packaging --- .gitignore | 14 +++++++++++-- debian/changelog | 5 +++++ debian/control | 25 ++++++++++++++++++++++ debian/copyright | 7 +++++++ debian/install | 2 ++ debian/rules | 23 +++++++++++++++++++++ debian/source/format | 1 + debian/source/options | 5 +++++ examples/design-demo/justfile | 26 +++++++++++++++++++++++ just/packaging.just | 9 ++++++++ just/rust.just | 39 +++++++++++++++++++++++++++++++++++ justfile | 12 +++++++++-- 12 files changed, 164 insertions(+), 4 deletions(-) create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/install create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 debian/source/options create mode 100755 examples/design-demo/justfile create mode 100644 just/packaging.just create mode 100644 just/rust.just diff --git a/.gitignore b/.gitignore index 6a59f558..b24970f0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,13 @@ -/target +debian/* +!debian/changelog +!debian/control +!debian/copyright +!debian/install +!debian/rules +!debian/source +.cargo +.idea Cargo.lock -/.idea \ No newline at end of file +target +vendor +vendor.tar diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 00000000..308c9a68 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +libcosmic (0.1.0) jammy; urgency=medium + + * Initial release. + + -- Michael Aaron Murphy Tue, 12 Sep 2023 08:53:33 +0200 diff --git a/debian/control b/debian/control new file mode 100644 index 00000000..8cc57fc3 --- /dev/null +++ b/debian/control @@ -0,0 +1,25 @@ +Source: libcosmic +Section: utils +Priority: optional +Maintainer: Michael Aaron Murphy +Build-Depends: + cargo, + clang, + cmake, + debhelper-compat (=13), + just (>= 1.13.0), + libexpat1-dev, + libfontconfig-dev, + libfreetype-dev, + libxkbcommon-dev, + mold, + pkg-config, + rustc, +Standards-Version: 4.6.2 +Homepage: https://github.com/pop-os/libcosmic + +Package: cosmic-design-demo +Architecture: amd64 arm64 +Depends: ${misc:Depends}, ${shlibs:Depends} +Description: libcosmic demo displaying its design elements and capabilities + libcosmic demo displaying its design elements and capabilities diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 00000000..e85c3869 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,7 @@ +Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: cosmic-design-demo +Upstream-Contact: Michael Murphy +Source: https://github.com/pop-os/libcosmic +Files: * +Copyright: System76 +License: MPL-2.0 \ No newline at end of file diff --git a/debian/install b/debian/install new file mode 100644 index 00000000..3207a550 --- /dev/null +++ b/debian/install @@ -0,0 +1,2 @@ +/usr/bin/cosmic-design-demo +/usr/share/applications/com.system76.CosmicDesignDemo.desktop \ No newline at end of file diff --git a/debian/rules b/debian/rules new file mode 100755 index 00000000..656e006b --- /dev/null +++ b/debian/rules @@ -0,0 +1,23 @@ +#!/usr/bin/make -f + +export DESTDIR = debian/tmp +export VENDOR ?= 1 + +%: + dh $@ + +override_dh_auto_clean: + if ! ischroot && test "${VENDOR}" = "1"; then \ + rm -rf .cargo vendor vendor.tar; \ + mkdir -p .cargo; \ + cargo vendor --sync design-demo/Cargo.toml | head -n -1 > .cargo/config; \ + echo 'directory = "vendor"' >> .cargo/config; \ + tar pcf vendor.tar vendor; \ + rm -rf vendor; \ + fi + +override_dh_auto_build: + just --unstable --working-directory . --justfile design-demo/justfile build-vendored + +override_dh_auto_install: + just --unstable --working-directory . --justfile design-demo/justfile rootdir=$(DESTDIR) install diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 00000000..9f674278 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (native) \ No newline at end of file diff --git a/debian/source/options b/debian/source/options new file mode 100644 index 00000000..7aebc3f1 --- /dev/null +++ b/debian/source/options @@ -0,0 +1,5 @@ +tar-ignore=.github +tar-ignore=.vscode +tar-ignore=result +tar-ignore=target +tar-ignore=vendor \ No newline at end of file diff --git a/examples/design-demo/justfile b/examples/design-demo/justfile new file mode 100755 index 00000000..97bb091e --- /dev/null +++ b/examples/design-demo/justfile @@ -0,0 +1,26 @@ +!include ../just/rust.just +!include ../just/packaging.just + +rootdir := '' +prefix := '/usr' + +# Name of the application's binary +bin-name := 'cosmic-design-demo' + +# The AppID of the application +app-id := 'com.system76.CosmicDesignDemo' + +# Application binary executable source and install destination +bin-src := 'target' / 'release' / bin-name +bin-dst := clean(rootdir / prefix) / 'bin' / bin-name + +# Desktop file source and install destination +desktop-file := app-id + '.desktop' +desktop-src := 'examples' / 'design-demo' / 'resources' / desktop-file +desktop-dst := clean(rootdir / prefix) / 'share' / 'applications' / desktop-file + +# Recipe for compiling the application +build *args: + cargo build -p cosmic-design-demo {{args}} + +install: (install-bin bin-src bin-dst) (install-file desktop-src desktop-dst) \ No newline at end of file diff --git a/just/packaging.just b/just/packaging.just new file mode 100644 index 00000000..3c911e6b --- /dev/null +++ b/just/packaging.just @@ -0,0 +1,9 @@ +[private] +install-cmd options src dest: + install {{options}} {{src}} {{dest}} + +[private] +install-bin src dest: (install-cmd '-Dm0755' src dest) + +[private] +install-file src dest: (install-cmd '-Dm0644' src dest) diff --git a/just/rust.just b/just/rust.just new file mode 100644 index 00000000..b80031a0 --- /dev/null +++ b/just/rust.just @@ -0,0 +1,39 @@ +# Use mold linker if clang and mold exists. +clang-path := `which clang || true` +mold-path := `which mold || true` + +linker-arg := if clang-path != '' { + if mold-path != '' { + '-C linker=' + clang-path + ' -C link-arg=--ld-path=' + mold-path + ' ' + } else { + '' + } +} else { + '' +} + +export RUSTFLAGS := linker-arg + env_var_or_default('RUSTFLAGS', '') + +[private] +default: build-release + +# Compile with release profile +build-release *args: (build '--release' args) + +# Compile with a vendored tarball +build-vendored *args: vendor-extract (build-release '--offline --locked' args) + +# Vendor Cargo dependencies locally +vendor *args: + rm -rf .cargo vendor vendor.tar + mkdir -p .cargo + cargo vendor {{args}} | head -n -1 > .cargo/config + echo 'directory = "vendor"' >> .cargo/config + tar pcf vendor.tar vendor + rm -rf vendor + +# Extracts vendored dependencies +[private] +vendor-extract: + rm -rf vendor + tar pxf vendor.tar diff --git a/justfile b/justfile index aaaf3942..218eef96 100644 --- a/justfile +++ b/justfile @@ -18,6 +18,14 @@ check-winit *args: # Runs a check with JSON message format for IDE integration check-json: (check '--message-format=json') +# Remove Cargo build artifacts +clean: + cargo clean + +# Also remove .cargo and vendored dependencies +clean-dist: clean + rm -rf .cargo vendor vendor.tar target + # Runs an example of the given {{name}} -example name: - cargo run --release -p {{name}} \ No newline at end of file +run name: + cargo run --release -p {{name}}