cb424d7448
verify-patch-sanity.py validates every active recipe .patch has internally- consistent hunk line counts — catching the 'malformed patch at line N' failure at commit/CI/preflight time instead of hours into a cook. This cycle hit that class three times (qtwaylandscanner, sddm, xwayland), each only discovered when cookbook tried to apply the patch. Running it across the repo found 29 latent malformed patches (validated against GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22'). They were harmless only because they sit in vendored recipes (baked, not re- applied) — but would fail on any version-bump re-derivation. --fix recounts the hunk headers (body untouched) and repaired all 29. Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test (test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats (empty placeholders, bare-@@ git hunks).
58 lines
1.9 KiB
Bash
Executable File
58 lines
1.9 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
CERT="lldb_codesign"
|
|
|
|
function error() {
|
|
echo error: "$@"
|
|
exit 1
|
|
}
|
|
|
|
function cleanup {
|
|
# Remove generated files
|
|
rm -f "$TMPDIR/$CERT.tmpl" "$TMPDIR/$CERT.cer" "$TMPDIR/$CERT.key" > /dev/null 2>&1
|
|
}
|
|
|
|
trap cleanup EXIT
|
|
|
|
# Check if the certificate is already present in the system keychain
|
|
security find-certificate -Z -p -c "$CERT" /Library/Keychains/System.keychain > /dev/null 2>&1
|
|
if [ $? -eq 0 ]; then
|
|
echo Certificate has already been generated and installed
|
|
exit 0
|
|
fi
|
|
|
|
# Create the certificate template
|
|
cat <<EOF >$TMPDIR/$CERT.tmpl
|
|
[ req ]
|
|
default_bits = 2048 # RSA key size
|
|
encrypt_key = no # Protect private key
|
|
default_md = sha512 # MD to use
|
|
prompt = no # Prompt for DN
|
|
distinguished_name = codesign_dn # DN template
|
|
[ codesign_dn ]
|
|
commonName = "$CERT"
|
|
[ codesign_reqext ]
|
|
keyUsage = critical,digitalSignature
|
|
extendedKeyUsage = critical,codeSigning
|
|
EOF
|
|
|
|
echo Generating and installing lldb_codesign certificate
|
|
|
|
# Generate a new certificate
|
|
openssl req -new -newkey rsa:2048 -x509 -days 3650 -nodes -config "$TMPDIR/$CERT.tmpl" -extensions codesign_reqext -batch -out "$TMPDIR/$CERT.cer" -keyout "$TMPDIR/$CERT.key" > /dev/null 2>&1
|
|
[ $? -eq 0 ] || error Something went wrong when generating the certificate
|
|
|
|
# Install the certificate in the system keychain
|
|
sudo security add-trusted-cert -d -r trustRoot -p codeSign -k /Library/Keychains/System.keychain "$TMPDIR/$CERT.cer" > /dev/null 2>&1
|
|
[ $? -eq 0 ] || error Something went wrong when installing the certificate
|
|
|
|
# Install the key for the certificate in the system keychain
|
|
sudo security import "$TMPDIR/$CERT.key" -A -k /Library/Keychains/System.keychain > /dev/null 2>&1
|
|
[ $? -eq 0 ] || error Something went wrong when installing the key
|
|
|
|
# Kill task_for_pid access control daemon
|
|
sudo pkill -f /usr/libexec/taskgated > /dev/null 2>&1
|
|
|
|
# Exit indicating the certificate is now generated and installed
|
|
exit 0
|