diff --git a/.drone.yml b/.drone.yml index b59e87f..67c6edd 100644 --- a/.drone.yml +++ b/.drone.yml @@ -2,16 +2,25 @@ kind: pipeline type: docker name: default +environment: + RPM_PACKAGER_NAME: 'askiiart' + RPM_PACKAGER_EMAIL: 'rpm@askiiart.net' + steps: - - name: Build polycat + - name: Build polycat fedora package image: fedora commands: - - '/drone/src/compilation.sh' + - '/drone/src/run.sh' volumes: - name: program-archives path: /compiled + - name: fedora-repo + path: /repo volumes: - name: program-archives host: - path: /mnt/user/files/repos/archives + path: /mnt/user/files/repos/archives/ + - name: fedora-repo + host: + path: /mnt/user/files/repos/fedora/x86_64/ diff --git a/README.md b/README.md index 29a2640..d263f91 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,10 @@ -# Polycat build +# Polycat (fedora) -- Builds polycat and places it in `$COMPILED_DIR/polycat/polycat.tar.zst` -- Version file at `$COMPILED_DIR/polycat/version` +TODO: Add proper changelog updates -## Archive details +## Environment variables -``` -. -├── polycat -└── polycat.ttf -``` +**REQUIRED** -Recommended: - -| File | Location | Permissions | -| --------------- | -------------------------------------- | ----------- | -| `./polycat` | `/usr/bin/polycat` | 755 | -| `./polycat.ttf` | `/usr/share/fonts/polycat/polycat.ttf` | 644 | +- RPM packager name - `RPM_PACKAGER_NAME` +- RPM packager email - `RPM_PACKAGER_EMAIL` diff --git a/compilation.sh b/compilation.sh deleted file mode 100755 index 26fabcf..0000000 --- a/compilation.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -# prep -dnf install git -y -workdir=$(mktemp -d) -built_dir=${COMPILED_DIR:-/compiled}/polycat -mkdir -p $built_dir -version_file=$built_dir/version -touch $version_file - -# clone and check whether it's up-to-date -cd $workdir -git clone https://github.com/2IMT/polycat.git -cd ./polycat/ -# check version -version=$(printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short=7 HEAD)") -if grep -q $version $version_file; then - echo "already up to date, exiting" - exit -fi -# get build deps -dnf install cmake g++ -y -# get submodules -git submodule update --init --depth 1 - - -# compilation -cd $workdir/polycat/ -cmake -DCMAKE_BUILD_TYPE=RELEASE . -cmake --build . - -# build .tar.zst archive -cd $workdir -mkdir ./polycat-built -mv ./polycat/polycat ./polycat-built/ -mv ./polycat/res/polycat.ttf ./polycat-built/ -mkdir -p ${COMPILED_DIR:-/compiled}/polycat/ -cd $workdir/polycat-built/ -tar --zstd -cf $built_dir/polycat.tar.zst . -echo $version >$version_file - -echo "polycat updated to $version" diff --git a/polycat.spec b/polycat.spec new file mode 100644 index 0000000..42de7eb --- /dev/null +++ b/polycat.spec @@ -0,0 +1,33 @@ +Name: polycat +Version: r93.0c836d5 +Release: %autorelease +Summary: runcat module for polybar (or waybar) + +License: MIT +URL: https://github.com/2IMT/polycat + +BuildRequires: tar zstd +Requires: glibc + +%description +A runcat module for polybar (or waybar) written in C++ + +%prep +mkdir ./polycat/ +cd ./polycat/ +tar --zstd -xf ${COMPILED_DIR:-/compiled}/polycat/polycat.tar.zst + +%install +cd ./polycat/ +mkdir -p %{buildroot}%{_bindir} +install -Dm755 ./polycat %{buildroot}%{_bindir}/polycat +mkdir -p %{buildroot}%{datadir}/fonts/polycat/ +install -Dm644 ./polycat.ttf %{buildroot}%{_datadir}/fonts/polycat/polycat.ttf + +%files +%{_bindir}/polycat +%{_datadir}/fonts/polycat/polycat.ttf + +%changelog +* DATE_HERE RPM_PACKAGER_NAME <RPM_PACKAGER_EMAIL> +- CHANGELOG_MESSAGE_HERE diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..7ff1047 --- /dev/null +++ b/run.sh @@ -0,0 +1,45 @@ +#!/usr/bin/env bash +set -euo pipefail + +built_dir=${COMPILED_DIR:-/compiled}/polycat +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 polycat-aaaaaa thing below +touch $repo_dir/polycat-tmp +if $(ls $repo_dir/polycat-* | grep -q "$version"); then + rm $repo_dir/polycat-tmp + echo "package is already up to date, exiting" + exit +fi +rm $repo_dir/polycat-tmp + +# prep +dnf install fedora-packager rpmdevtools createrepo_c -y +rpmdev-setuptree + +# update spec file +sed -i "s/Version:.*/Version: $version/g" polycat.spec +sed -i "s/DATE_HERE/$(date '+%a %b %d %Y')/g" polycat.spec +sed -i "s/CHANGELOG_MESSAGE_HERE/Update to $version/g" polycat.spec +sed -i "s/RPM_PACKAGER_NAME/$RPM_PACKAGER_NAME/g" polycat.spec +sed -i "s/RPM_PACKAGER_EMAIL/$RPM_PACKAGER_EMAIL/g" polycat.spec + +# build package and move to the repo +rpmbuild -bb polycat.spec +mv ~/rpmbuild/RPMS/x86_64/polycat-$version-* $repo_dir/ + +# remove old versions +cd $repo_dir +# this is the easiest way to make sure it doesn't just fail because no polycat-* exists +# (which only happens on first run) +touch polycat-r0.rpm +rm $(ls polycat-*.rpm | sort --version-sort | sed '$d') +rm polycat-r0.rpm || true + +# update repo +createrepo_c . + +echo "package is at $repo_dir/$(ls $repo_dir/polycat-*.rpm)"