From 3dfe38a9e5d48ec5093c5e8a0d9d41eb47ca79c2 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sun, 5 Jan 2020 23:26:10 +0100 Subject: [PATCH] Prepare migration to zstd archives Signed-off-by: Knut Ahlers --- .gitignore | 2 ++ Makefile | 9 +++++++-- scripts/check_aur_updates.sh | 4 ++-- scripts/has_archive_mix.sh | 16 ++++++++++++++++ scripts/repoctl.sh | 2 +- 5 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 scripts/has_archive_mix.sh diff --git a/.gitignore b/.gitignore index 1f972f7..4633672 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ *.files.sig *.tar.xz *.tar.xz.sig +*.tar.zstd +*.tar.zstd.sig diff --git a/Makefile b/Makefile index 1d8589f..36d8ad5 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -export DATABASE:=$(shell find . -maxdepth 1 -mindepth 1 -name '*.db.tar.xz') +export DATABASE:=$(shell find . -maxdepth 1 -mindepth 1 -name '*.db.tar.xz' -or -name '*.db.tar.zstd') export REPOKEY:=D0391BF9 @@ -19,7 +19,7 @@ download: --acl=public-read \ s3://arch-luzifer-io/repo/x86_64/ $(CURDIR)/ -upload: cleanup_files +upload: cleanup_files check_archive_mix vault2env --key=secret/aws/private -- aws s3 sync \ --delete \ --exclude '*.old*' \ @@ -65,3 +65,8 @@ scripts/repoctl.toml: sign_database: repo-add -s --key $(REPOKEY) $(DATABASE) + +# Helpers + +check_archive_mix: + bash ./scripts/has_archive_mix.sh diff --git a/scripts/check_aur_updates.sh b/scripts/check_aur_updates.sh index da6fbe6..28b6816 100755 --- a/scripts/check_aur_updates.sh +++ b/scripts/check_aur_updates.sh @@ -14,12 +14,12 @@ join_by() { declare -A local_versions declare -A aur_versions -database=$(find . -maxdepth 1 -mindepth 1 -name '*.db.tar.xz') +database=$(find . -maxdepth 1 -mindepth 1 -name '*.db.tar.xz' -or '*.db.tar.zstd') aur_query=("https://aur.archlinux.org/rpc/?v=5&type=info") step "Collecting local package versions..." -known_packages=$(tar -tf luzifer.db.tar.xz | grep -v /desc | sed -E 's@^(.*)-([^-]+-[0-9]+)/$@\1 \2@') +known_packages=$(tar -tf ${database} | grep -v /desc | sed -E 's@^(.*)-([^-]+-[0-9]+)/$@\1 \2@') IFS=$'\n' diff --git a/scripts/has_archive_mix.sh b/scripts/has_archive_mix.sh new file mode 100644 index 0000000..0a90e30 --- /dev/null +++ b/scripts/has_archive_mix.sh @@ -0,0 +1,16 @@ +#!/bin/bash +set -euo pipefail + +[[ $(find . -name '*.tar.zstd' | wc -l) -gt 0 ]] || { + echo "No ZStd archives found, nothing to worry" + exit 0 +} + +[[ $(find . -name '*.tar.xz' | wc -l) -gt 0 ]] && { + echo "Both XZ and ZStd archives found, pay attention!" +} + +[[ $(find . -name '*.db.tar.xz' | wc -l) -gt 0 ]] && [[ $(find . -name '*.db.tar.zstd' | wc -l) -gt 0 ]] && { + echo "Found XZ and ZStd databases! Check this!" + exit 1 +} diff --git a/scripts/repoctl.sh b/scripts/repoctl.sh index c8261cf..582ebc9 100755 --- a/scripts/repoctl.sh +++ b/scripts/repoctl.sh @@ -2,7 +2,7 @@ set -euo pipefail cat -s <scripts/repoctl.toml -repo = "$(find $(pwd) -mindepth 1 -maxdepth 1 -name '*.db.tar.xz')" +repo = "$(find $(pwd) -mindepth 1 -maxdepth 1 -name '*.db.tar.xz' -or '*.db.tar.xstd')" backup = false interactive = false columnate = false