From 8248f235eff81960c8c2ede2961555fa568a1dbd Mon Sep 17 00:00:00 2001 From: speedie Date: Sat, 16 Sep 2023 17:24:52 +0200 Subject: [PATCH] Use a bash script for creating the tarball instead --- .gitignore | 1 + aurmake | 18 ++---------------- packages/index.php | 10 +++++++++- packages/viewer/archive.sh | 9 +++++++++ 4 files changed, 21 insertions(+), 17 deletions(-) create mode 100644 packages/viewer/archive.sh diff --git a/.gitignore b/.gitignore index 551d60b..3f42b77 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *packages/*.PKGBUILD *packages/*.patch +*packages/.need_mktar *zst* *db* *tar.gz* diff --git a/aurmake b/aurmake index fc64b0b..773d9e8 100755 --- a/aurmake +++ b/aurmake @@ -3,17 +3,6 @@ source .OPT || exit 1 -get_checksum() { - summary() { - printf "%s\n" "$(stat -c '%y' "$1") $(md5sum "$1")" - } - - export -f summary - find packages/ -name "*.tar*" -type f -exec bash -c 'summary "$0"' {} \; | LC_ALL=C sort | md5sum -} - -[ -d "packages/" ] && sum1="$(get_checksum)" - if [ -x "$(command -v repo-add)" ]; then [ ! -d "packages/" ] && printf "No packages, exiting..\n" >> /dev/stderr && exit 1 @@ -23,6 +12,7 @@ if [ -x "$(command -v repo-add)" ]; then rm -f ./*"${SERVER_NAME}"* repo-add -s -R "${SERVER_NAME}.db.tar.gz" *.pkg.tar.zst > /tmp/repo-add.log find . -maxdepth 1 -type l -delete + [ -f "${SERVER_NAME}.db.tar.gz" ] && diff -up "${SERVER_NAME}.db.tar.gz" "${SERVER_NAME}.db" > /dev/null && mktar=true cp "${SERVER_NAME}.db.tar.gz" "${SERVER_NAME}.db" cd .. || exit 1 @@ -31,11 +21,7 @@ else printf "Warning: repo-add not found, will only copy viewer.\n" >> /dev/stderr fi -if [ -d "packages/" ] && [ "$sum1" != "$(get_checksum)" ]; then - tar -cf packages.tar packages - gzip -c packages.tar > packages/packages.tar.gz - rm -f packages.tar -fi +[ "$mktar" = "true" ] && touch packages/.need_mktar if [ "$1" = "publish" ]; then [ ! -x "$(command -v rsync)" ] && printf "rsync not found.\n" > /dev/stderr && exit 1 diff --git a/packages/index.php b/packages/index.php index c8b460a..90235aa 100644 --- a/packages/index.php +++ b/packages/index.php @@ -133,6 +133,14 @@ function main() { } print "\t\t\t\n"; + } else if ($request == "archive") { + exec("./viewer/archive.sh", $output); + + if (file_exists("packages.tar.gz")) { + header("Location: packages.tar.gz"); + } + + exit(); } else if ($request == "view" && $query == '') { printHead($self, "speedie-aur", "speedie-aur", "My unofficial Arch Linux repository containing many useful packages"); @@ -152,7 +160,7 @@ function main() { print "\t\t\t

See this page for more information.

\n"; print "\t\t

Download

\n"; print "\t\t\t

If you wish, you can download the full packages/ directory containing all packages, the database and the PHP itself. This may be useful if you want to have a local repository that won't get updated, or you want to contribute back.

\n"; - print "\t\t\t

A tar.gz archive can be found here.

\n"; + print "\t\t\t

A tar.gz archive can be found here.

\n"; } else if ($request == "view" && $query != '') { $packageCount = 0; $packageVersions = array(); diff --git a/packages/viewer/archive.sh b/packages/viewer/archive.sh new file mode 100644 index 0000000..a7ee48d --- /dev/null +++ b/packages/viewer/archive.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +dir="$(dirname "$0")" + +if [ -f "$dir/../.need_mktar" ]; then + rm -f "$dir/../.need_mktar" + mkdir -p packages/ ; cp "$dir/../"* packages/ ; cp -r viewer lister packages/ + tar -cf packages.tar packages/ && gzip packages.tar +fi