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).
63 lines
2.3 KiB
Python
Executable File
63 lines
2.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Usage: -i <path/to/input-header.h> -o <path/to/output-header.h> -m LLDB_MAJOR_VERSION -n LLDB_MINOR_VERSION -p LLDB_PATCH_VERSION
|
|
|
|
This script uncomments and populates the versioning information in lldb-defines.h. Note that the LLDB version numbering looks like MAJOR.MINOR.PATCH
|
|
"""
|
|
|
|
import argparse
|
|
import os
|
|
import re
|
|
|
|
LLDB_VERSION_REGEX = re.compile(r"//\s*#define LLDB_VERSION\s*$", re.M)
|
|
LLDB_REVISION_REGEX = re.compile(r"//\s*#define LLDB_REVISION\s*$", re.M)
|
|
LLDB_VERSION_STRING_REGEX = re.compile(r"//\s*#define LLDB_VERSION_STRING\s*$", re.M)
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(
|
|
description="This script uncomments and populates the versioning information in lldb-defines.h. Note that the LLDB version numbering looks like MAJOR.MINOR.PATCH"
|
|
)
|
|
parser.add_argument("-i", "--input_path", help="The filepath for the input header.")
|
|
parser.add_argument(
|
|
"-o", "--output_path", help="The filepath for the output header."
|
|
)
|
|
parser.add_argument("-m", "--major", help="The LLDB version major.")
|
|
parser.add_argument("-n", "--minor", help="The LLDB version minor.")
|
|
parser.add_argument("-p", "--patch", help="The LLDB version patch number.")
|
|
args = parser.parse_args()
|
|
input_path = str(args.input_path)
|
|
output_path = str(args.output_path)
|
|
|
|
with open(input_path, "r") as input_file:
|
|
lines = input_file.readlines()
|
|
file_buffer = "".join(lines)
|
|
|
|
with open(output_path, "w") as output_file:
|
|
# For the defines in lldb-defines.h that define the major, minor and version string
|
|
# uncomment each define and populate its value using the arguments passed in.
|
|
# e.g. //#define LLDB_VERSION -> #define LLDB_VERSION <LLDB_MAJOR_VERSION>
|
|
file_buffer = re.sub(
|
|
LLDB_VERSION_REGEX,
|
|
r"#define LLDB_VERSION " + args.major,
|
|
file_buffer,
|
|
)
|
|
|
|
file_buffer = re.sub(
|
|
LLDB_REVISION_REGEX,
|
|
r"#define LLDB_REVISION " + args.patch,
|
|
file_buffer,
|
|
)
|
|
file_buffer = re.sub(
|
|
LLDB_VERSION_STRING_REGEX,
|
|
r'#define LLDB_VERSION_STRING "{0}.{1}.{2}"'.format(
|
|
args.major, args.minor, args.patch
|
|
),
|
|
file_buffer,
|
|
)
|
|
output_file.write(file_buffer)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|