extract-sandbox.py (594B)
1 #!/usr/bin/env python 2 # This Source Code Form is subject to the terms of the Mozilla Public 3 # License, v. 2.0. If a copy of the MPL was not distributed with this 4 # file, You can obtain one at https://mozilla.org/MPL/2.0/. 5 6 import re 7 8 with open("sandbox/linux/services/namespace_sandbox.cc") as fd: 9 content = fd.read() 10 11 match = re.search( 12 r"#if defined\(LIBC_GLIBC\).*?#endif // defined\(LIBC_GLIBC\)", content, re.DOTALL 13 ) 14 if not match: 15 raise ValueError("Invalid patch extraction pattern") 16 17 patch = match.group() 18 19 with open("namespace_sandbox.inc", "w") as fd: 20 fd.write(patch)