Move signing out
This commit is contained in:
3 files changed
+137
-123
No files matched your search
@@ -1,57 +1,7 @@
|
||||
#!/bin/bash
|
||||
# Import GPG keys for package verification and signing
|
||||
# Import GPG keys for package verification
|
||||
|
||||
echo "==> Importing GPG keys..."
|
||||
|
||||
# Check if signing is enabled
|
||||
if [[ "$SKIP_SIGNING" == true ]]; then
|
||||
echo " -> Skipping signing key import (--skip-signing enabled)"
|
||||
else
|
||||
# Import signing key (required for signing)
|
||||
echo " -> Importing signing key..."
|
||||
# Import with batch mode and no tty for automated signing
|
||||
echo "$GPG_PRIVATE_KEY" | gpg --batch --import || {
|
||||
echo " -> ERROR: Failed to import signing key"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Configure GPG for automated signing with passphrase
|
||||
echo "allow-loopback-pinentry" >>~/.gnupg/gpg-agent.conf
|
||||
echo "pinentry-mode loopback" >>~/.gnupg/gpg.conf
|
||||
gpg-connect-agent reloadagent /bye 2>/dev/null || true
|
||||
|
||||
# Extract key ID and configure
|
||||
KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep "sec" | head -1 | awk '{print $2}' | cut -d'/' -f2)
|
||||
if [[ -n "$KEY_ID" ]]; then
|
||||
# Trust the key using fingerprint
|
||||
FINGERPRINT=$(gpg --list-secret-keys --with-colons | grep "^fpr" | head -1 | cut -d':' -f10)
|
||||
echo "$FINGERPRINT:6:" | gpg --import-ownertrust
|
||||
# Set as default key in makepkg.conf
|
||||
echo "GPGKEY=\"$KEY_ID\"" >>~/.makepkg.conf
|
||||
echo " -> Signing key configured: $KEY_ID"
|
||||
|
||||
# Test signing with the key and passphrase
|
||||
echo " -> Testing GPG signing capability..."
|
||||
echo "test" | gpg --batch --yes --pinentry-mode loopback --passphrase "$GPG_PASSPHRASE" --sign --local-user "$KEY_ID" >/dev/null 2>&1
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo " -> ERROR: Failed to sign with the provided passphrase"
|
||||
echo " -> Please check your passphrase and try again"
|
||||
exit 1
|
||||
fi
|
||||
echo " -> GPG signing test successful"
|
||||
|
||||
# Import public signing key into pacman's keyring for local package verification
|
||||
echo " -> Adding signing key to pacman keyring..."
|
||||
sudo pacman-key --init || exit 1
|
||||
gpg --armor --export "$KEY_ID" > /tmp/signing-key.asc || exit 1
|
||||
sudo pacman-key --add /tmp/signing-key.asc || exit 1
|
||||
rm -f /tmp/signing-key.asc
|
||||
sudo pacman-key --lsign-key "$KEY_ID" || exit 1
|
||||
else
|
||||
echo " -> ERROR: Could not extract key ID"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
echo "==> Importing GPG verification keys..."
|
||||
|
||||
# Read the gpg-keys.txt file for verification keys
|
||||
if [[ -f /build/gpg-keys.txt ]]; then
|
||||
@@ -75,9 +25,7 @@ if [[ -f /build/gpg-keys.txt ]]; then
|
||||
}
|
||||
fi
|
||||
done </build/gpg-keys.txt
|
||||
echo " -> Verification key import complete"
|
||||
echo " ✓ Verification key import complete"
|
||||
else
|
||||
echo " -> No gpg-keys.txt file found, skipping verification key import"
|
||||
echo " -> No gpg-keys.txt file found, skipping"
|
||||
fi
|
||||
|
||||
echo " -> GPG setup complete"
|
||||
Reference in new issue
Block a user