fix: new format
This commit is contained in:
@@ -32,7 +32,8 @@ def get_nginx_info() -> tuple[str | None, str | None]:
|
|||||||
return (None, None)
|
return (None, None)
|
||||||
|
|
||||||
|
|
||||||
def download_and_unpack(url: str) -> str:
|
def download_and_unpack(module: dict) -> str:
|
||||||
|
url = module["url"]
|
||||||
print(f"Downloading '{url}'...")
|
print(f"Downloading '{url}'...")
|
||||||
file_name = url.split("/")[-1]
|
file_name = url.split("/")[-1]
|
||||||
if Path(file_name).exists():
|
if Path(file_name).exists():
|
||||||
@@ -46,7 +47,7 @@ def download_and_unpack(url: str) -> str:
|
|||||||
print("Unpacking...")
|
print("Unpacking...")
|
||||||
subprocess.call(["tar", "zxvf", file_name])
|
subprocess.call(["tar", "zxvf", file_name])
|
||||||
print(f"Download and unpack complete: {file_name} to {file_name_without_ext}")
|
print(f"Download and unpack complete: {file_name} to {file_name_without_ext}")
|
||||||
return file_name_without_ext
|
return module["name"]
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@@ -77,9 +78,9 @@ def main():
|
|||||||
source_dir = download_and_unpack(nginx_url)
|
source_dir = download_and_unpack(nginx_url)
|
||||||
module_source_dirs = []
|
module_source_dirs = []
|
||||||
for module in config["modules"]:
|
for module in config["modules"]:
|
||||||
print(f"Downloading module: {module}")
|
print(f"Downloading module: {module['name']}")
|
||||||
module_source_dir = download_and_unpack(module)
|
module_source_dir = download_and_unpack(module)
|
||||||
print(f"Module '{module}' downloaded successfully.")
|
print(f"Module '{module['name']}' downloaded successfully.")
|
||||||
module_source_dirs.append(module_source_dir)
|
module_source_dirs.append(module_source_dir)
|
||||||
# Configure and build modules
|
# Configure and build modules
|
||||||
args = [f"--add-dynamic-module=../{dir}" for dir in module_source_dirs]
|
args = [f"--add-dynamic-module=../{dir}" for dir in module_source_dirs]
|
||||||
@@ -87,12 +88,10 @@ def main():
|
|||||||
subprocess.call(["./configure", "--with-compat", *args], cwd=source_dir)
|
subprocess.call(["./configure", "--with-compat", *args], cwd=source_dir)
|
||||||
subprocess.call(["make", "modules"], cwd=source_dir)
|
subprocess.call(["make", "modules"], cwd=source_dir)
|
||||||
# Copy .so files to module path
|
# Copy .so files to module path
|
||||||
for module in module_source_dirs:
|
for child in Path(f"{source_dir}/objs").iterdir():
|
||||||
so_file = f"{module}.so"
|
if child.suffix == ".so":
|
||||||
source_so_path = f"{source_dir}/objs/{so_file}"
|
print(f"Copying module: {child.name}")
|
||||||
dest_so_path = f"{module_path}/{so_file}"
|
subprocess.call(["cp", child.resolve(), module_path])
|
||||||
print(f"Copying {source_so_path} to {dest_so_path}...")
|
|
||||||
subprocess.call(["cp", source_so_path, dest_so_path])
|
|
||||||
print("All modules installed successfully.")
|
print("All modules installed successfully.")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
{
|
{
|
||||||
"modules": [
|
"modules": [
|
||||||
"https://github.com/leev/ngx_http_geoip2_module/archive/refs/tags/3.4.tar.gz",
|
{
|
||||||
"https://github.com/linsongze/ngx_http_image_filter_module/archive/refs/heads/master.tar.gz"
|
"name": "ngx_http_geoip2_module-3.4",
|
||||||
|
"url": "https://github.com/leev/ngx_http_geoip2_module/archive/refs/tags/3.4.tar.gz"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ngx_http_image_filter_module-master",
|
||||||
|
"url": "https://github.com/linsongze/ngx_http_image_filter_module/archive/refs/heads/master.tar.gz"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user