69 lines
1.9 KiB
Bash
Executable File
69 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
[ "$1" ] \
|
|
&& pkg="$1" \
|
|
|| pkg="$(head -n1 ../todo)"
|
|
echo "converting $pkg"
|
|
cd $pkg
|
|
|
|
type="$(cut -d' ' -f1 checksums)"
|
|
version="$(cut -d' ' -f2 checksums)"
|
|
checksum="$(cut -d' ' -f3 checksums)"
|
|
url="$(eval "echo \"$(head -n1 $type-urls)\"")"
|
|
echo "$type"
|
|
echo "$version"
|
|
echo "$checksum"
|
|
echo "$url"
|
|
|
|
if [ -f "$type-sigurls" ]; then
|
|
sigurl="$(eval "echo \"$(head -n1 $type-sigurls)\"")"
|
|
fi
|
|
|
|
echo "pulling archive"
|
|
if [ "$type" = "git" ]; then
|
|
git clone --bare "$url" "git-bare"
|
|
cd "git-bare"
|
|
git worktree add -f "../git-worktree" $version
|
|
|
|
cd ../git-worktree
|
|
version="$(git log | head -n1 | cut -d' ' -f2)" # force use of commit hash
|
|
cd ..
|
|
size="$(expr $(du -sk git-worktree | cut -f1) \* 1024)"
|
|
rm -fr git-worktree git-bare
|
|
printf %s\\t%s\\t%s\\t%s\\n '$version' "$type" "arc" "$(head -n1 $type-urls)">urls
|
|
|
|
else
|
|
curl -o src.$type -L "$url"
|
|
[ "$checksum" ] || checksum="$(sha512sum src.$type | cut -d' ' -f1)"
|
|
[ "$(sha512sum src.$type | cut -d' ' -f1)" = "$checksum" ] || { echo "checksum mismatch" && exit 1; }
|
|
size="$(wc -c src.$type | cut -d' ' -f1)"
|
|
rm src.$type
|
|
printf %s\\t%s\\t%s\\t%s\\n '$version' '$type' "arc" "$(head -n1 $type-urls)">urls
|
|
fi
|
|
printf %s\\t%s\\t%s\\t%s\\t%s\\n "$version" "$type" "arc" "$size" "$checksum">checks
|
|
printf "version=\"$version\"\\ntype=\"$type\"\\n">defaults.sh
|
|
|
|
|
|
if [ "$sigurl" ]; then
|
|
echo "pulling signature"
|
|
curl -o sig -L "$sigurl"
|
|
size="$(wc -c sig | cut -d' ' -f1)"
|
|
checksum="$(sha512sum sig | cut -d' ' -f1)"
|
|
[ "$(sha512sum sig | cut -d' ' -f1)" = "$checksum" ] || { echo "signature checksum mismatch" && exit 1; }
|
|
printf %s\\t%s\\t%s\\t%s\\n '$version' '$type' "sig" "$(head -n1 $type-sigurls)">>urls
|
|
printf %s\\t%s\\t%s\\t%s\\t%s\\n "$version" "$type" "sig" "$size" "$checksum">>checks
|
|
rm sig
|
|
fi
|
|
|
|
rm -fr checksums defaults *-sigurls *-urls
|
|
|
|
echo
|
|
|
|
cat urls
|
|
echo
|
|
cat checks
|
|
echo
|
|
cat defaults.sh
|