Add --skip-signing option
This commit is contained in:
1 parent
c57c9620de
commit
c7b4bdd3a1
2 files changed
+71
-53
No files matched your search
@@ -33,8 +33,16 @@ print_header "Omarchy AUR Package Builder"
|
|||||||
# Parse command line arguments
|
# Parse command line arguments
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case $1 in
|
case $1 in
|
||||||
|
--skip-signing)
|
||||||
|
SKIP_SIGNING=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
-h | --help)
|
-h | --help)
|
||||||
echo "Usage: $0"
|
echo "Usage: $0 [OPTIONS]"
|
||||||
|
echo ""
|
||||||
|
echo "Options:"
|
||||||
|
echo " --skip-signing Build packages without GPG signing"
|
||||||
|
echo " -h, --help Show this help message"
|
||||||
echo ""
|
echo ""
|
||||||
echo "This script builds AUR packages from:"
|
echo "This script builds AUR packages from:"
|
||||||
echo " build/packages/omarchy-aur.packages"
|
echo " build/packages/omarchy-aur.packages"
|
||||||
@@ -54,30 +62,35 @@ if [[ ! -f "$BUILD_DIR/packages/omarchy-aur.packages" ]]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Get GPG key from 1Password or environment for signing
|
# Handle GPG signing setup
|
||||||
if [[ -z "$GPG_PRIVATE_KEY" ]]; then
|
if [[ "$SKIP_SIGNING" == true ]]; then
|
||||||
print_info "Fetching GPG signing key from 1Password..."
|
print_warning "Skipping GPG signing (--skip-signing flag set)"
|
||||||
GPG_PRIVATE_KEY=$(op document get "Omarchy GPG Private Key" --account=omarchy.1password.com) || {
|
|
||||||
print_error "Failed to fetch GPG key from 1Password or environment"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
print_info "Using existing GPG signing key from environment"
|
# Get GPG key from 1Password or environment for signing
|
||||||
fi
|
if [[ -z "$GPG_PRIVATE_KEY" ]]; then
|
||||||
export GPG_PRIVATE_KEY="$GPG_PRIVATE_KEY"
|
print_info "Fetching GPG signing key from 1Password..."
|
||||||
|
GPG_PRIVATE_KEY=$(op document get "Omarchy GPG Private Key" --account=omarchy.1password.com) || {
|
||||||
|
print_error "Failed to fetch GPG key from 1Password or environment"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
print_info "Using existing GPG signing key from environment"
|
||||||
|
fi
|
||||||
|
export GPG_PRIVATE_KEY="$GPG_PRIVATE_KEY"
|
||||||
|
|
||||||
# Get passphrase from 1Password or environment
|
# Get passphrase from 1Password or environment
|
||||||
if [[ -z "$GPG_PASSPHRASE" ]]; then
|
if [[ -z "$GPG_PASSPHRASE" ]]; then
|
||||||
print_info "Fetching GPG key passphrase from 1Password..."
|
print_info "Fetching GPG key passphrase from 1Password..."
|
||||||
GPG_PASSPHRASE=$(op item get "Omarchy GPG Private Key" --account=omarchy.1password.com --fields password --reveal) || {
|
GPG_PASSPHRASE=$(op item get "Omarchy GPG Private Key" --account=omarchy.1password.com --fields password --reveal) || {
|
||||||
print_error "Failed to fetch GPG passphrase from 1Password or environment"
|
print_error "Failed to fetch GPG passphrase from 1Password or environment"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
print_info "Using existing GPG passphrase from environment"
|
print_info "Using existing GPG passphrase from environment"
|
||||||
|
fi
|
||||||
|
export GPG_PASSPHRASE
|
||||||
|
print_success "GPG signing key and passphrase loaded"
|
||||||
fi
|
fi
|
||||||
export GPG_PASSPHRASE
|
|
||||||
print_success "GPG signing key and passphrase loaded"
|
|
||||||
|
|
||||||
# Build/update the Docker image
|
# Build/update the Docker image
|
||||||
print_info "Building Docker image..."
|
print_info "Building Docker image..."
|
||||||
@@ -87,6 +100,7 @@ print_info "Running AUR package build..."
|
|||||||
# Build Docker arguments
|
# Build Docker arguments
|
||||||
DOCKER_ARGS=(
|
DOCKER_ARGS=(
|
||||||
--rm
|
--rm
|
||||||
|
-e SKIP_SIGNING
|
||||||
-e GPG_PRIVATE_KEY
|
-e GPG_PRIVATE_KEY
|
||||||
-e GPG_PASSPHRASE
|
-e GPG_PASSPHRASE
|
||||||
-v "$ARCH_DIR:/output"
|
-v "$ARCH_DIR:/output"
|
||||||
|
|||||||
+35
-31
@@ -3,41 +3,46 @@
|
|||||||
|
|
||||||
echo "==> Importing GPG keys..."
|
echo "==> Importing GPG keys..."
|
||||||
|
|
||||||
# Import signing key (required)
|
# Check if signing is enabled
|
||||||
echo " -> Importing signing key..."
|
if [[ "$SKIP_SIGNING" == true ]]; then
|
||||||
# Import with batch mode and no tty for automated signing
|
echo " -> Skipping signing key import (--skip-signing enabled)"
|
||||||
echo "$GPG_PRIVATE_KEY" | gpg --batch --import || {
|
else
|
||||||
echo " -> ERROR: Failed to import signing key"
|
# Import signing key (required for signing)
|
||||||
exit 1
|
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
|
# Configure GPG for automated signing with passphrase
|
||||||
echo "allow-loopback-pinentry" >>~/.gnupg/gpg-agent.conf
|
echo "allow-loopback-pinentry" >>~/.gnupg/gpg-agent.conf
|
||||||
echo "pinentry-mode loopback" >>~/.gnupg/gpg.conf
|
echo "pinentry-mode loopback" >>~/.gnupg/gpg.conf
|
||||||
gpg-connect-agent reloadagent /bye 2>/dev/null || true
|
gpg-connect-agent reloadagent /bye 2>/dev/null || true
|
||||||
|
|
||||||
# Extract key ID and configure
|
# Extract key ID and configure
|
||||||
KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep "sec" | head -1 | awk '{print $2}' | cut -d'/' -f2)
|
KEY_ID=$(gpg --list-secret-keys --keyid-format LONG | grep "sec" | head -1 | awk '{print $2}' | cut -d'/' -f2)
|
||||||
if [[ -n "$KEY_ID" ]]; then
|
if [[ -n "$KEY_ID" ]]; then
|
||||||
# Trust the key using fingerprint
|
# Trust the key using fingerprint
|
||||||
FINGERPRINT=$(gpg --list-secret-keys --with-colons | grep "^fpr" | head -1 | cut -d':' -f10)
|
FINGERPRINT=$(gpg --list-secret-keys --with-colons | grep "^fpr" | head -1 | cut -d':' -f10)
|
||||||
echo "$FINGERPRINT:6:" | gpg --import-ownertrust
|
echo "$FINGERPRINT:6:" | gpg --import-ownertrust
|
||||||
# Set as default key in makepkg.conf
|
# Set as default key in makepkg.conf
|
||||||
echo "GPGKEY=\"$KEY_ID\"" >>~/.makepkg.conf
|
echo "GPGKEY=\"$KEY_ID\"" >>~/.makepkg.conf
|
||||||
echo " -> Signing key configured: $KEY_ID"
|
echo " -> Signing key configured: $KEY_ID"
|
||||||
|
|
||||||
# Test signing with the key and passphrase
|
# Test signing with the key and passphrase
|
||||||
echo " -> Testing GPG signing capability..."
|
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
|
echo "test" | gpg --batch --yes --pinentry-mode loopback --passphrase "$GPG_PASSPHRASE" --sign --local-user "$KEY_ID" >/dev/null 2>&1
|
||||||
if [[ $? -ne 0 ]]; then
|
if [[ $? -ne 0 ]]; then
|
||||||
echo " -> ERROR: Failed to sign with the provided passphrase"
|
echo " -> ERROR: Failed to sign with the provided passphrase"
|
||||||
echo " -> Please check your passphrase and try again"
|
echo " -> Please check your passphrase and try again"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo " -> GPG signing test successful"
|
||||||
|
else
|
||||||
|
echo " -> ERROR: Could not extract key ID"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo " -> GPG signing test successful"
|
|
||||||
else
|
|
||||||
echo " -> ERROR: Could not extract key ID"
|
|
||||||
exit 1
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Read the gpg-keys.txt file for verification keys
|
# Read the gpg-keys.txt file for verification keys
|
||||||
@@ -68,4 +73,3 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo " -> GPG setup complete"
|
echo " -> GPG setup complete"
|
||||||
|
|
||||||
Reference in new issue
Block a user