From 956aea50efe0e53b906ba3b26388c918b106235c Mon Sep 17 00:00:00 2001 From: Hardcore Sushi Date: Fri, 3 Dec 2021 15:45:01 +0100 Subject: [PATCH] Packaging --- Cargo.toml | 1 + README.md | 24 +++++++--- packaging/.gitignore | 3 ++ packaging/deb/doby/DEBIAN/control | 7 +++ packaging/package.sh | 71 +++++++++++++++++++++++++++++ packaging/pkg/PKGBUILD | 18 ++++++++ packaging/tarball/doby/completions | 1 + packaging/tarball/doby/install.sh | 28 ++++++++++++ packaging/tarball/doby/uninstall.sh | 11 +++++ 9 files changed, 157 insertions(+), 7 deletions(-) create mode 100644 packaging/.gitignore create mode 100644 packaging/deb/doby/DEBIAN/control create mode 100755 packaging/package.sh create mode 100644 packaging/pkg/PKGBUILD create mode 120000 packaging/tarball/doby/completions create mode 100755 packaging/tarball/doby/install.sh create mode 100755 packaging/tarball/doby/uninstall.sh diff --git a/Cargo.toml b/Cargo.toml index 7413c19..d660409 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,6 +6,7 @@ authors = ["Hardcore Sushi "] license = "GPL-3.0-or-later" description = "Simple, secure and lightweight symmetric encryption from the command line" readme = "README.md" +repository = "https://forge.chapril.org/hardcoresushi/doby" [profile.release] lto = true diff --git a/README.md b/README.md index ae7ff91..2b00ed1 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # doby -Secure symmetric encryption from the command line. +Simple, secure and lightweight symmetric encryption from the command line doby started as a fork of [aef](https://github.com/wyhaya/aef) by [wyhaya](https://github.com/wyhaya) with the goal of becoming a simple, fast and lightweight CLI utility for symmetric encryption. It aims to be an alternative to the old [ccrypt](http://ccrypt.sourceforge.net) tool by using modern cryptography and authenticated encryption. @@ -83,7 +83,7 @@ ARGS: # Installation You can download doby from the "Releases" section in this repo. -All binaries MUST be signed with my PGP key available on keyservers. To import it: +All releases MUST be signed with my PGP key available on keyservers. To import it: ```bash gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 007F84120107191E ``` @@ -96,15 +96,25 @@ gpg --verify ``` __Don't continue if the verification fails!__ -If everything goes fine, you can compute the SHA-256 hash of the binary file you want to verify: +If everything goes fine, you can download the package corresponding to your distribution. To verify it, compute its SHA-256 hash: ```bash -sha256sum +sha256sum ``` -Compare this output and the hash in the PGP-signed message. __Don't execute the file if the hashes don't match!__ +Compare the output and the hash in the PGP-signed message. If the hashes match, the file is authenticated and you can continue the installation. -You can make doby available in your `$PATH` by running: +On debian: ```bash -sudo cp /usr/local/bin/ +sudo dpkg -i doby-*.deb +``` + +On Arch: +```bash +sudo pacman -U doby-*.pkg.tar.zst +``` + +On other distros: +```bash +tar -xzf doby-*.tar.gz && sudo doby/install.sh ``` # Build diff --git a/packaging/.gitignore b/packaging/.gitignore new file mode 100644 index 0000000..0ad7a6e --- /dev/null +++ b/packaging/.gitignore @@ -0,0 +1,3 @@ +*.deb +*.gz +*.pkg.tar.zst diff --git a/packaging/deb/doby/DEBIAN/control b/packaging/deb/doby/DEBIAN/control new file mode 100644 index 0000000..a3d1402 --- /dev/null +++ b/packaging/deb/doby/DEBIAN/control @@ -0,0 +1,7 @@ +Package: doby +Version: VERSION +Depends: libc6 +Homepage: https://forge.chapril.org/hardcoresushi/doby +Maintainer: Hardcore Sushi +Architecture: amd64 +Description: Simple, secure and lightweight symmetric encryption from the command line diff --git a/packaging/package.sh b/packaging/package.sh new file mode 100755 index 0000000..94769ef --- /dev/null +++ b/packaging/package.sh @@ -0,0 +1,71 @@ +#!/bin/bash + +set_version() { + cp $1 /tmp/$(basename $1).original && + sed -i "s/VERSION/$version/g" $1 +} + +restore() { + mv /tmp/$(basename $1).original $1 +} + +package_deb() {( + mkdir -p deb/doby/usr/bin deb/doby/usr/share/man/man1 \ + deb/doby/usr/share/bash-completion/completions \ + deb/doby/usr/share/zsh/vendor-completions && + cp ../target/release/doby deb/doby/usr/bin && + cp ../man/doby.1.gz deb/doby/usr/share/man/man1 && + cp ../completions/bash deb/doby/usr/share/bash-completion/completions/doby && + cp ../completions/zsh deb/doby/usr/share/zsh/vendor-completions/_doby && + cd deb && set_version doby/DEBIAN/control && dpkg -b doby && + restore doby/DEBIAN/control && mv doby.deb ../doby-$version-x86_64.deb && + rm -r doby/usr +)} + +package_pkg() {( + mkdir pkg/src && + cp ../target/release/doby pkg/src && + cp ../man/doby.1.gz pkg/src && + cp -r ../completions pkg/src && + cd pkg && set_version PKGBUILD && + makepkg && restore PKGBUILD && + mv doby-*.pkg.tar.zst ../doby-$version-x86_64.pkg.tar.zst && rm -r src pkg +)} + +package_tarball() {( + cp ../target/x86_64-unknown-linux-musl/release/doby tarball/doby && + cp ../man/doby.1.gz tarball/doby && + cd tarball && tar -chzf ../doby-$version-x86_64.tar.gz doby && + rm doby/doby* +)} + +if [ "$#" -eq 1 ]; then + cargo_toml="../Cargo.toml" + + if [ ! -f $cargo_toml ]; then + echo "Error: $cargo_toml not found." >&2; + exit 1; + fi + + version=$(grep "^version = " ../Cargo.toml | cut -d "\"" -f 2) + echo "Packaging doby v$version..." + case $1 in + "deb") + package_deb + ;; + "pkg") + package_pkg + ;; + "tarball") + package_tarball + ;; + "all") + package_deb + package_pkg + package_tarball + ;; + esac +else + echo "usage: $0 " >&2 + exit 1; +fi \ No newline at end of file diff --git a/packaging/pkg/PKGBUILD b/packaging/pkg/PKGBUILD new file mode 100644 index 0000000..1c63549 --- /dev/null +++ b/packaging/pkg/PKGBUILD @@ -0,0 +1,18 @@ +# Maintainer: Hardcore Sushi +pkgname=doby +pkgver=VERSION +pkgrel=0 +depends=("glibc") +arch=("x86_64") +pkgdesc="Simple, secure and lightweight symmetric encryption from the command line" +url="https://forge.chapril.org/hardcoresushi/doby" +license=("GPL-3.0-or-later") + +package() { + mkdir -p $pkgdir/usr/bin $pkgdir/usr/share/man/man1 \ + $pkgdir/usr/share/bash-completion/completions $pkgdir/usr/share/zsh/vendor-completions + cp $srcdir/doby $pkgdir/usr/bin + cp $srcdir/doby.1.gz $pkgdir/usr/share/man/man1 + cp $srcdir/completions/bash $pkgdir/usr/share/bash-completion/completions/doby + cp $srcdir/completions/zsh $pkgdir/usr/share/zsh/vendor-completions/_doby +} diff --git a/packaging/tarball/doby/completions b/packaging/tarball/doby/completions new file mode 120000 index 0000000..d51e84b --- /dev/null +++ b/packaging/tarball/doby/completions @@ -0,0 +1 @@ +../../../completions \ No newline at end of file diff --git a/packaging/tarball/doby/install.sh b/packaging/tarball/doby/install.sh new file mode 100755 index 0000000..77dc5ec --- /dev/null +++ b/packaging/tarball/doby/install.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +ROOT=$(dirname $0) + +if [ $(id -u) -ne 0 ]; then + echo "Error: root access required" >&2 + exit 1 +elif [ ! -f $ROOT/doby ]; then + echo "Error: doby binary not found in $ROOT" >&2 + exit 1 +fi + +install -v -g 0 -o 0 $ROOT/doby /usr/bin + +MAN_FOLDER=/usr/share/man/man1 +if [ -d $MAN_FOLDER ]; then + install -v -g 0 -o 0 -m 0644 $ROOT/doby.1.gz $MAN_FOLDER +fi + +BASH_COMPLETION_FOLDER=/usr/share/bash-completion/completions +if [ -d $BASH_COMPLETION_FOLDER ]; then + install -v -g 0 -o 0 -m 0644 $ROOT/completions/bash $BASH_COMPLETION_FOLDER/doby +fi + +ZSH_COMPLETION_FOLDER=/usr/share/zsh/vendor-completions +if [ -d $ZSH_COMPLETION_FOLDER ]; then + install -v -g 0 -o 0 -m 0644 $ROOT/completions/zsh $ZSH_COMPLETION_FOLDER/_doby +fi \ No newline at end of file diff --git a/packaging/tarball/doby/uninstall.sh b/packaging/tarball/doby/uninstall.sh new file mode 100755 index 0000000..66f881c --- /dev/null +++ b/packaging/tarball/doby/uninstall.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +if [ $(id -u) -ne 0 ]; then + echo "Error: root access required" >&2 + exit 1 +fi + +rm -v /usr/bin/doby +rm -v /usr/share/man/man1/doby.1.gz 2>/dev/null +rm -v /usr/share/bash-completion/completions/doby 2>/dev/null +rm -v /usr/share/zsh/vendor-completions/_doby 2>/dev/null