commit 4e162d19494bf0839001ce6313a0bf456deb7ffd
Author: askiiart <dev@askiiart.net>
Date:   Thu Mar 6 13:09:47 2025 -0600

    initial commit

diff --git a/.drone.yml b/.drone.yml
new file mode 100644
index 0000000..22cc171
--- /dev/null
+++ b/.drone.yml
@@ -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
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..8029025
--- /dev/null
+++ b/README.md
@@ -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         |
diff --git a/compilation.sh b/compilation.sh
new file mode 100755
index 0000000..5e53112
--- /dev/null
+++ b/compilation.sh
@@ -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"