diff --git a/.drone.yml b/.drone.yml index e3944ce..22cc171 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,25 +2,16 @@ kind: pipeline type: docker name: default -environment: - RPM_PACKAGER_NAME: 'askiiart' - RPM_PACKAGER_EMAIL: 'rpm@askiiart.net' - steps: - - name: Build cavif fedora package - image: fedora + - name: Build cavif + image: debian commands: - - '/drone/src/run.sh' + - '/drone/src/compilation.sh' volumes: - name: program-archives path: /compiled - - name: fedora-repo - path: /repo volumes: - name: program-archives host: - path: /mnt/user/files/repos/archives/ - - name: fedora-repo - host: - path: /mnt/user/files/repos/fedora/x86_64/ + path: /mnt/user/files/repos/archives \ No newline at end of file diff --git a/README.md b/README.md index b430908..8029025 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,17 @@ -# Cavif (fedora) +# Cavif build -TODO: Add proper changelog updates +- 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` -## Environment variables +## Archive details -**REQUIRED** +``` +. +├── cavif +``` -- RPM packager name - `RPM_PACKAGER_NAME` -- RPM packager email - `RPM_PACKAGER_EMAIL` +Recommended: + +| File | Location | Permissions | +| --------------- | -------------------------------------- | ----------- | +| `./cavif` | `/usr/bin/cavif` | 755 | diff --git a/cavif.spec b/cavif.spec deleted file mode 100644 index 41e6a9a..0000000 --- a/cavif.spec +++ /dev/null @@ -1,29 +0,0 @@ -Name: cavif -Version: 6.6.6 -Release: %autorelease -Summary: AVIF image creator in pure Rust - -License: BSD-3-Clause -URL: https://github.com/kornelski/cavif-rs - -BuildRequires: tar zstd - -%description -An AVIF image creator in pure Rust - -%prep -mkdir ./cavif/ -cd ./cavif/ -tar --zstd -xf ${COMPILED_DIR:-/compiled}/cavif/cavif.tar.zst - -%install -cd ./cavif/ -mkdir -p %{buildroot}%{_bindir} -install -Dm755 ./cavif %{buildroot}%{_bindir}/cavif - -%files -%{_bindir}/cavif - -%changelog -* DATE_HERE RPM_PACKAGER_NAME <RPM_PACKAGER_EMAIL> -- CHANGELOG_MESSAGE_HERE \ No newline at end of file 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" diff --git a/run.sh b/run.sh deleted file mode 100755 index eab01a4..0000000 --- a/run.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -built_dir=${COMPILED_DIR:-/compiled}/cavif -version=$(cat $built_dir/version) -repo_dir=${REPO_DIR:-/repo} - -# skip if already up-to-date -# TODO: use the repo instead and check the version with dnf -# yeah this is bad; see also the cavif-aaaaaa thing below -touch $repo_dir/cavif-tmp -if $(ls $repo_dir/cavif-* | grep -q "$version"); then - rm $repo_dir/cavif-tmp - echo "package is already up to date, exiting" - exit -fi -rm $repo_dir/cavif-tmp - -# prep -dnf install fedora-packager rpmdevtools createrepo_c -y -rpmdev-setuptree - -# update spec file -sed -i "s/Version:.*/Version: $version/g" cavif.spec -sed -i "s/DATE_HERE/$(date '+%a %b %d %Y')/g" cavif.spec -sed -i "s/CHANGELOG_MESSAGE_HERE/Update to $version/g" cavif.spec -sed -i "s/RPM_PACKAGER_NAME/$RPM_PACKAGER_NAME/g" cavif.spec -sed -i "s/RPM_PACKAGER_EMAIL/$RPM_PACKAGER_EMAIL/g" cavif.spec - -# build package and move to the repo -rpmbuild -bb cavif.spec -mv ~/rpmbuild/RPMS/x86_64/cavif-$version-* $repo_dir/ - -# remove old versions -cd $repo_dir -# this is the easiest way to make sure it doesn't just fail because no cavif-* exists -# (which only happens on first run) -touch cavif-0.rpm -rm $(ls cavif-*.rpm | sort --version-sort | sed '$d') -rm cavif-0.rpm || true - -# update repo -createrepo_c . - -echo "package is at $repo_dir/$(ls $repo_dir/cavif-*.rpm)"