initial commit

This commit is contained in:
askiiart 2025-03-06 13:09:47 -06:00
commit 4e162d1949
Signed by untrusted user who does not match committer: askiiart
GPG key ID: 6A32977DAF31746A
3 changed files with 72 additions and 0 deletions

17
.drone.yml Normal file
View file

@ -0,0 +1,17 @@
kind: pipeline
type: docker
name: default
steps:
- name: Build cavif
image: debian
commands:
- '/drone/src/compilation.sh'
volumes:
- name: program-archives
path: /compiled
volumes:
- name: program-archives
host:
path: /mnt/user/files/repos/archives

17
README.md Normal file
View file

@ -0,0 +1,17 @@
# Cavif build
- Builds [cavif](https://github.com/kornelski/cavif-rs) and places it in `$COMPILED_DIR/cavif/cavif.tar.zst`
- Version file at `$COMPILED_DIR/cavif/version`
## Archive details
```
.
├── cavif
```
Recommended:
| File | Location | Permissions |
| --------------- | -------------------------------------- | ----------- |
| `./cavif` | `/usr/bin/cavif` | 755 |

38
compilation.sh Executable file
View file

@ -0,0 +1,38 @@
#!/usr/bin/env bash
set -euo pipefail
workdir=$(mktemp -d)
built_dir=${COMPILED_DIR:-/compiled}/cavif
mkdir -p $built_dir
version_file=$built_dir/version
touch $version_file
apt update
apt install curl jq -y
# clone and check whether it's up-to-date
mkdir -p $workdir/cavif/
cd $workdir/cavif/
# check version
version=$(curl -L 'https://crates.io/api/v1/crates/cavif' | jq '.crate.default_version' -r)
if grep -q $version $version_file; then
echo "already up to date, exiting"
exit
fi
# get build deps
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. ~/.cargo/env
apt install gcc nasm -y
# build cavif
cargo install cavif
cp ~/.cargo/bin/cavif $workdir/cavif/
# crate .tar.zst archive
cd $workdir/cavif/
mkdir -p ${COMPILED_DIR:-/compiled}/cavif/
apt install zstd -y
tar --zstd -cf $built_dir/cavif.tar.zst .
echo $version >$version_file
echo "cavif updated to $version"