Skip to content

Commit

Permalink
chore: initial jammy packaging directory
Browse files Browse the repository at this point in the history
  • Loading branch information
zarkdav authored and fujiapple852 committed Apr 4, 2024
1 parent 14575e3 commit 8ef54fd
Show file tree
Hide file tree
Showing 12 changed files with 156 additions and 0 deletions.
65 changes: 65 additions & 0 deletions debian/README.debian
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
Trippy packaging for Debian and Ubuntu
======================================

TL;DR: to generate your own debian package with your own Rust toolchain,
the vendored dependencies need to be generated first with:
./debian/rules vendor
then you can simply run:
debuild --prepend-path ~/.cargo/bin -sa
as long as the original Trippy source archive
`trippy_<version>.orig.tar.gz` exists in the parent directory.

---

The debian directory contains the necessary files to generate a debian
package. In order for the package to be built without network access
(a requirement for most automatic build systems, such as Debian's
and Canonical's), we cannot rely on the Cargo automatic dependencies
resolution.

Instead, the `vendor` rule uses [`cargo vendor`] [1] to "vendor" all
crates.io dependencies for the project into a `debian/vendor.tar.xz`
tarball. This tarball contains all remote sources from dependencies that
are specified in the Cargo manifest. It is automatically extracted during
the build, which uses the [`--frozen`] [2] option to prevent Cargo from
attempting to access the network. Once this tarball is generated you
only need to use `vendor` rule again if you want to refresh the sources
of the dependencies.

---

The creation and administration of a Personal Package Archive (PPA)
is beyond the scope of this doc, but if you need to host Trippy in your
PPA, you simply need to run:
debuild --prepend-path ~/.cargo/bin -S -sa
followed by:
dput <your ppa> ../<source_package_name>.changes

The provided `debian` directory targets the Ubuntu Jammy 22.04 LTS
distribution. It is possible to target other distributions simply
by editing the `debian/changelog` file and changing the version and
distribution fields:
trippy (0.10.0-1ubuntu0.1~jammy1) jammy; urgency=medium
trippy (0.10.0-1ubuntu0.1~mantis1) mantis; urgency=medium
trippy (0.10.0-1ubuntu0.1~noble1) noble; urgency=medium
It is preferable to use `debchange` for this, eg:
debchange --distribution noble --newversion 0.10.0-1ubuntu0.1~noble1

---

NOTES:
- all `commands` are relative to the Trippy source directory.
- the tarball is compressed with xz as per the [blog post] [3] I used
as a reference.

TODOS:
- remove Windows-specific dependencies from the vendored dependencies, see
[Cargo issue #11929] [4]
- move the vendor tarball outside of the debian directory, but this can
only be done once it's been relieved of the Windows-specific dependencies.

REFERENCES:
[1]: https://doc.rust-lang.org/cargo/commands/cargo-vendor.html
[2]: https://doc.rust-lang.org/cargo/commands/cargo.html?highlight=frozen#manifest-options
[3]: https://blog.zhimingwang.org/packaging-rust-project-for-ubuntu-ppa "Packaging a Rust project for Ubuntu PPA"
[4]: https://github.com/rust-lang/cargo/issues/11929
5 changes: 5 additions & 0 deletions debian/cargo.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[source.crates-io]
replace-with = "vendored-sources"

[source.vendored-sources]
directory = "vendor"
5 changes: 5 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
trippy (0.10.0-1ubuntu0.1~jammy1) jammy; urgency=medium

* Initial release.

-- Fuji Apple <fujiapple852@gmail.com> Thur, 04 Apr 2024 10:30:13 +0800
21 changes: 21 additions & 0 deletions debian/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Source: trippy
Section: contrib/net
Priority: optional
Maintainer: Fuji Apple <fujiapple852@gmail.com>
Rules-Requires-Root: no
Build-Depends: debhelper-compat (= 13),
cargo:native,
rustc:native,
libstd-rust-dev
Standards-Version: 4.6.2
Vcs-Browser: https://github.com/fujiapple852/trippy
Vcs-Git: https://github.com/fujiapple852/trippy.git

Package: trippy
Architecture: any
Depends:
${shlibs:Depends},
${misc:Depends},
Description: network diagnostic tool combining traceroute and ping
Trippy combines the functionality of traceroute and ping and
is designed to assist with the analysis of network issues.
32 changes: 32 additions & 0 deletions debian/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: https://github.com/fujiapple852/trippy
Upstream-Name: trippy
Upstream-Contact: FujiApple <fujiapple852@gmail.com>

Files:
*
Copyright:
2022-2024 Trippy Contributors (https://github.com/fujiapple852/trippy/graphs/contributors)
License: Apache-2.0

Files:
debian/*
Copyright:
2024 Fuji Apple <fujiapple852@gmail.com>
License: Apache-2.0

License: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
.
https://www.apache.org/licenses/LICENSE-2.0
.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comment:
On Debian systems, the complete text of the Apache version 2.0 license
can be found in "/usr/share/common-licenses/Apache-2.0".
24 changes: 24 additions & 0 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/make -f

.PHONY: override_dh_strip vendor

%:
dh $@

vendor:
-[ -d vendor ] && rm -rf vendor
cargo vendor
tar cJf debian/vendor.tar.xz vendor

override_dh_auto_build:
mkdir .cargo
cp debian/cargo.config .cargo/config
tar xJf debian/vendor.tar.xz
cargo build --release --frozen

override_dh_auto_clean:
cargo clean
rm -rf .cargo vendor

override_dh_strip:
dh_strip --no-automatic-dbgsym
1 change: 1 addition & 0 deletions debian/source/format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.0 (quilt)
1 change: 1 addition & 0 deletions debian/source/include-binaries
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
debian/vendor.tar.xz
1 change: 1 addition & 0 deletions debian/trippy.docs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
README.md
1 change: 1 addition & 0 deletions debian/trippy.install
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/release/trip usr/bin
Empty file added launchpad_public_key.pgp
Empty file.
Empty file added launchpad_secret_key.pgp
Empty file.

0 comments on commit 8ef54fd

Please sign in to comment.