mirror of
https://gitlab.alpinelinux.org/alpine/abuild.git
synced 2025-01-03 05:02:18 +00:00
abuild-sign: refactor
This commit is contained in:
parent
42b0e019b9
commit
144ee3f113
@ -18,6 +18,30 @@ die() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
do_sign() {
|
||||||
|
# we are actually only interested in the name, not the file itself
|
||||||
|
keyname=${pubkey##*/}
|
||||||
|
|
||||||
|
for f; do
|
||||||
|
i=$(readlink -f $f)
|
||||||
|
[ -d "$i" ] && i="$i/APKINDEX.tar.gz"
|
||||||
|
repo="${i%/*}"
|
||||||
|
cd "$repo" || die "Failed to sign $i"
|
||||||
|
sig=".SIGN.RSA.$keyname"
|
||||||
|
openssl dgst -sha1 -sign "$privkey" -out "$sig" "$i" || die "Failed to sign $i"
|
||||||
|
tmptargz=$(mktemp)
|
||||||
|
tar -c "$sig" | abuild-tar --cut | gzip -9 > "$tmptargz"
|
||||||
|
tmpsigned=$(mktemp)
|
||||||
|
cat "$tmptargz" "$i" > "$tmpsigned"
|
||||||
|
rm -f "$tmptargz" "$sig"
|
||||||
|
mv "$tmpsigned" "$i"
|
||||||
|
chmod 644 "$i"
|
||||||
|
if [ -z "$quiet" ]; then
|
||||||
|
echo "Signed $i"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
echo "abuild-sign $abuild_ver"
|
echo "abuild-sign $abuild_ver"
|
||||||
echo "usage: abuild-sign [-hq] [-k PRIVKEY] [-p PUBKEY] INDEXFILE..."
|
echo "usage: abuild-sign [-hq] [-k PRIVKEY] [-p PUBKEY] INDEXFILE..."
|
||||||
@ -61,26 +85,5 @@ if [ -z "$pubkey" ]; then
|
|||||||
pubkey=${PACKAGER_PUBKEY:-"${privkey}.pub"}
|
pubkey=${PACKAGER_PUBKEY:-"${privkey}.pub"}
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# we are actually only interested in the name, not the file itself
|
do_sign "$@"
|
||||||
keyname=${pubkey##*/}
|
|
||||||
|
|
||||||
for f in "$@"; do
|
|
||||||
i=$(readlink -f $f)
|
|
||||||
[ -d "$i" ] && i="$i/APKINDEX.tar.gz"
|
|
||||||
repo="${i%/*}"
|
|
||||||
cd "$repo" || die "Failed to sign $i"
|
|
||||||
sig=".SIGN.RSA.$keyname"
|
|
||||||
openssl dgst -sha1 -sign "$privkey" -out "$sig" "$i" || die "Failed to sign $i"
|
|
||||||
tmptargz=$(mktemp)
|
|
||||||
tar -c "$sig" | abuild-tar --cut | gzip -9 > "$tmptargz"
|
|
||||||
tmpsigned=$(mktemp)
|
|
||||||
cat "$tmptargz" "$i" > "$tmpsigned"
|
|
||||||
rm -f "$tmptargz" "$sig"
|
|
||||||
mv "$tmpsigned" "$i"
|
|
||||||
chmod 644 "$i"
|
|
||||||
if [ -z "$quiet" ]; then
|
|
||||||
echo "Signed $i"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
Loading…
Reference in New Issue
Block a user