From 6ae88d881b5ef1206918c33c1a98ae39a8dbb370 Mon Sep 17 00:00:00 2001 From: Mikolaj Izdebski Date: Mon, 2 Sep 2024 08:13:08 +0200 Subject: [PATCH] Extract archive as separate function --- downstream.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/downstream.sh b/downstream.sh index d330a21..af52f3c 100755 --- a/downstream.sh +++ b/downstream.sh @@ -111,6 +111,17 @@ function prep() fi } +function archive() +{ + mkdir -p archive + rm -f archive/$p.tar archive/$p.tar.zst + commit=$($git -C "downstream/$p" rev-parse upstream-base) + date=$($git -C "downstream/$p" cat-file commit $commit | sed -n '/^author /s/.* \([0-9][0-9]* [+-][0-9][0-9]*$\)/\1/;T;p;q') + tree=$($git -C "downstream/$p" cat-file commit $commit | sed -n 's/^tree //;T;p;q') + $git -C "downstream/$p" archive --prefix downstream/$p/ --mtime "$date" "$tree" >archive/$p.tar + zstd --rm -T8 -12 archive/$p.tar +} + for p; do if [[ ! -f project/$p.properties ]]; then echo "$0: $p: upstream descriptor not found" >&2 @@ -135,13 +146,7 @@ for p; do elif [[ "$cmd" = prep ]]; then prep elif [[ "$cmd" = archive ]]; then - mkdir -p archive - rm -f archive/$p.tar archive/$p.tar.zst - commit=$($git -C "downstream/$p" rev-parse upstream-base) - date=$($git -C "downstream/$p" cat-file commit $commit | sed -n '/^author /s/.* \([0-9][0-9]* [+-][0-9][0-9]*$\)/\1/;T;p;q') - tree=$($git -C "downstream/$p" cat-file commit $commit | sed -n 's/^tree //;T;p;q') - $git -C "downstream/$p" archive --prefix downstream/$p/ --mtime "$date" "$tree" >archive/$p.tar - zstd --rm -T8 -12 archive/$p.tar + archive else echo "$0: unknown command: $cmd" >&2 exit 1