Skip to content

Commit

Permalink
Extract archive as separate function
Browse files Browse the repository at this point in the history
  • Loading branch information
mizdebsk committed Sep 2, 2024
1 parent 2fed3a6 commit 6ae88d8
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions downstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 6ae88d8

Please sign in to comment.