feat(design-demo): debian packaging

This commit is contained in:
Michael Aaron Murphy 2023-09-13 15:19:58 +02:00 committed by Michael Murphy
parent 37d5dd8b65
commit 5cd9d74189
12 changed files with 164 additions and 4 deletions

14
.gitignore vendored
View file

@ -1,3 +1,13 @@
/target
debian/*
!debian/changelog
!debian/control
!debian/copyright
!debian/install
!debian/rules
!debian/source
.cargo
.idea
Cargo.lock
/.idea
target
vendor
vendor.tar

5
debian/changelog vendored Normal file
View file

@ -0,0 +1,5 @@
libcosmic (0.1.0) jammy; urgency=medium
* Initial release.
-- Michael Aaron Murphy <michael@mmurphy.dev> Tue, 12 Sep 2023 08:53:33 +0200

25
debian/control vendored Normal file
View file

@ -0,0 +1,25 @@
Source: libcosmic
Section: utils
Priority: optional
Maintainer: Michael Aaron Murphy <michael@mmurphy.dev>
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

7
debian/copyright vendored Normal file
View file

@ -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 <michael@mmurphy.dev>
Source: https://github.com/pop-os/libcosmic
Files: *
Copyright: System76 <info@system76.com>
License: MPL-2.0

2
debian/install vendored Normal file
View file

@ -0,0 +1,2 @@
/usr/bin/cosmic-design-demo
/usr/share/applications/com.system76.CosmicDesignDemo.desktop

23
debian/rules vendored Executable file
View file

@ -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

1
debian/source/format vendored Normal file
View file

@ -0,0 +1 @@
3.0 (native)

5
debian/source/options vendored Normal file
View file

@ -0,0 +1,5 @@
tar-ignore=.github
tar-ignore=.vscode
tar-ignore=result
tar-ignore=target
tar-ignore=vendor

26
examples/design-demo/justfile Executable file
View file

@ -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)

9
just/packaging.just Normal file
View file

@ -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)

39
just/rust.just Normal file
View file

@ -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

View file

@ -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}}
run name:
cargo run --release -p {{name}}