Use a bash script for creating the tarball instead

This commit is contained in:
Jacob 2023-09-16 17:24:52 +02:00
parent 7393a99ccd
commit 8248f235ef
4 changed files with 21 additions and 17 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
*packages/*.PKGBUILD
*packages/*.patch
*packages/.need_mktar
*zst*
*db*
*tar.gz*

18
aurmake
View File

@ -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

View File

@ -133,6 +133,14 @@ function main() {
}
print "\t\t\t</table>\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<p>See <a href=\"lister.php\">this page</a> for more information.</p>\n";
print "\t\t<h2>Download</h2>\n";
print "\t\t\t<p>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.</p>\n";
print "\t\t\t<p>A tar.gz archive can be found <a href=\"packages/packages.tar.gz\">here</a>.</p>\n";
print "\t\t\t<p>A tar.gz archive can be found <a href=\"$self?action=archive\">here</a>.</p>\n";
} else if ($request == "view" && $query != '') {
$packageCount = 0;
$packageVersions = array();

View File

@ -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