Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reproducible archives #152

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions downstream.sh
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ function prep()
if [[ "$type" = git ]]; then
$git clone -n "upstream/$p.git" "downstream/$p"
$git -C "downstream/$p" checkout -b upstream-base "$ref"
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')
elif [[ "$type" = zip ]]; then
date="100000000 +0000"
$git init "downstream/$p"
unzip "upstream/$p-$version.zip" -d "downstream/$p"
dir="downstream/$p"/$(ls "downstream/$p")
Expand All @@ -79,7 +82,7 @@ function prep()
rmdir "$dir"
fi
$git -C "downstream/$p" add .
$git -C "downstream/$p" commit -m "Import version $version"
$git -C "downstream/$p" commit --date "$date" -m "Import version $version"
$git -C "downstream/$p" checkout -b upstream-base
else
echo "$0: $p: unsupported upstream type: $type" >&2
Expand All @@ -99,7 +102,7 @@ function prep()
elif [[ "$p" == jflex ]]; then
rm -r downstream/jflex/jflex/examples/
fi
$git -C "downstream/$p" commit --allow-empty -a -m 'Remove binary files'
$git -C "downstream/$p" commit --date "$date" --allow-empty -a -m 'Remove binary files'
$git -C "downstream/$p" checkout -b downstream upstream-base
if [[ -d patches/$p ]]; then
set patches/$p/*.patch
Expand All @@ -108,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 @@ -132,15 +146,9 @@ for p; do
elif [[ "$cmd" = prep ]]; then
prep
elif [[ "$cmd" = archive ]]; then
mkdir -p archive
rm -f archive/$p.tar archive/$p.tar.xz
$git -C "downstream/$p" archive --prefix downstream/$p/ upstream-base >archive/$p.tar
archive
else
echo "$0: unknown command: $cmd" >&2
exit 1
fi
done

if [[ $cmd = archive ]]; then
echo archive/*.tar | xargs -n1 -P20 xz -9evT8
fi
Loading