diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rwxr-xr-xtools/release-build.sh12
-rwxr-xr-xtools/serve.py21
2 files changed, 10 insertions, 23 deletions
diff --git a/tools/release-build.sh b/tools/release-build.sh
index 0d9008f..babf008 100755
--- a/tools/release-build.sh
+++ b/tools/release-build.sh
@@ -38,10 +38,7 @@ supports() {
probe=$(mktemp "${TMPDIR:-/tmp}/cgit-probe.XXXXXX")
trap 'rm -f "$probe" "$probe.c" "$probe.out"' EXIT
-CFLAGS="-O2 -g -Wall \
- -fstack-protector-strong \
- -fPIE \
- -fno-plt"
+CFLAGS="-O2 -g -Wall -fstack-protector-strong -fPIE -fno-plt"
# Level 3 adds the bounds checks level 2 could not prove, and needs GCC 12 or
# Clang 15. Fall back rather than lose fortification altogether.
@@ -57,9 +54,7 @@ if supports "-fstack-clash-protection"; then
CFLAGS="$CFLAGS -fstack-clash-protection"
fi
-LDFLAGS="-pie \
- -Wl,-z,relro,-z,now \
- -Wl,-z,noexecstack"
+LDFLAGS="-pie -Wl,-z,relro,-z,now -Wl,-z,noexecstack"
# These reach only the cgit objects, so git's own sources are not held to them.
# -Wformat-security is an error because a non-literal format with no arguments
@@ -76,5 +71,4 @@ CGIT_EXTRA_CFLAGS="-Wformat -Wformat-security -Werror=format-security"
# flags, and cleanall rather than clean because only cleanall descends into
# vendor/git.
make cleanall
-exec make "$@" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" \
- CGIT_EXTRA_CFLAGS="$CGIT_EXTRA_CFLAGS"
+exec make "$@" CFLAGS="$CFLAGS" LDFLAGS="$LDFLAGS" CGIT_EXTRA_CFLAGS="$CGIT_EXTRA_CFLAGS"
diff --git a/tools/serve.py b/tools/serve.py
index a39d03f..8924e53 100755
--- a/tools/serve.py
+++ b/tools/serve.py
@@ -72,8 +72,7 @@ def split_cgi_output(output: bytes) -> CgiResponse:
than on a non-empty body keeps a legitimately empty body, such as the one
a redirect leaves behind, from being read as headers.
"""
- ends = [(at, len(sep)) for sep in (b"\r\n\r\n", b"\n\n")
- if (at := output.find(sep)) >= 0]
+ ends = [(at, len(sep)) for sep in (b"\r\n\r\n", b"\n\n") if (at := output.find(sep)) >= 0]
if ends:
at, seplen = min(ends)
header_block, body = output[:at], output[at + seplen:]
@@ -150,8 +149,7 @@ class CgitHandler(BaseHTTPRequestHandler):
def send_asset(self, path: Path) -> None:
data = path.read_bytes()
- content_type = (mimetypes.guess_type(path.name)[0]
- or "application/octet-stream")
+ content_type = (mimetypes.guess_type(path.name)[0] or "application/octet-stream")
self.send_response(200)
self.send_header("Content-Type", content_type)
self.send_header("Content-Length", str(len(data)))
@@ -228,8 +226,7 @@ class CgitHandler(BaseHTTPRequestHandler):
self.send_response(response.status, response.reason)
for name, value in response.headers:
self.send_header(name, value)
- if not any(name.lower() == "content-length"
- for name, _ in response.headers):
+ if not any(name.lower() == "content-length" for name, _ in response.headers):
self.send_header("Content-Length", str(len(response.body)))
self.end_headers()
if self.command != "HEAD":
@@ -244,8 +241,7 @@ class CgitHandler(BaseHTTPRequestHandler):
class CgitServer(ThreadingHTTPServer):
"""Holds the paths the handler needs, so none are attached later on."""
- def __init__(self, address: tuple[str, int], config: Path, cgit: Path,
- data_dir: Path) -> None:
+ def __init__(self, address: tuple[str, int], config: Path, cgit: Path, data_dir: Path) -> None:
self.config: Path = config
self.cgit: Path = cgit
self.data_dir: Path = data_dir
@@ -268,14 +264,11 @@ class Options(argparse.Namespace):
def parse_args(argv: list[str] | None = None) -> Options:
parser = argparse.ArgumentParser(description="Preview cgit locally.")
- _ = parser.add_argument("--config", default=Options.config,
- help="path to cgitrc (default: ./cgitrc)")
+ _ = parser.add_argument("--config", default=Options.config, help="path to cgitrc (default: ./cgitrc)")
_ = parser.add_argument("--port", type=int, default=Options.port)
_ = parser.add_argument("--host", default=Options.host)
- _ = parser.add_argument("--cgit", default=Options.cgit,
- help="path to the cgit binary")
- _ = parser.add_argument("--data", default=Options.data,
- help="directory holding cgit.css, cgit.js, images")
+ _ = parser.add_argument("--cgit", default=Options.cgit, help="path to the cgit binary")
+ _ = parser.add_argument("--data", default=Options.data, help="directory holding cgit.css, cgit.js, images")
return parser.parse_args(argv, namespace=Options())