Added ability build for custom nginx version for distributive build

This commit is contained in:
Alexey Berezhok
2026-06-21 01:15:00 +03:00
parent 6bebc87323
commit ffc5c20fee
7 changed files with 147 additions and 5 deletions

33
packages/deb/control.sh Normal file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
# This script generates the debian/control file with correct nginx version dependency
# Usage: control.sh [NGINX_VERSION]
# If NGINX_VERSION is not specified, it uses DETECTED_NGINX_VERSION from environment or default "1.24.0"
NGINX_VER="${1:-${DETECTED_NGINX_VERSION:-1.24.0}}"
cat > debian/control << EOF
Source: nginx-mod-rewrite
Section: web
Priority: optional
Maintainer: Alexey Berezhok <a@bayrepo.ru>
Build-Depends: debhelper-compat (=13),
dh-autoreconf,
libssl-dev,
libpcre2-dev,
zlib1g-dev,
nginx (=${NGINX_VER})
Standards-Version: 4.7.0
Homepage: https://docs.brepo.ru/nginx-mod_rewrite
Package: nginx-mod-rewrite
Architecture: any
Depends: \${shlibs:Depends}, nginx (=${NGINX_VER})
Provides: nginx-http-module, nginx-apache-rewrite
Description: Nginx rewrite module dynamic module adding mod_rewrite functionality
Dynamic Nginx module implementing Apache mod_rewrite functionality.
The package is built from Nginx sources and the module's own files, and then
installs only the compiled shared object into /etc/nginx/modules directory.
EOF
echo "Generated debian/control for nginx version: $NGINX_VER"

View File

@@ -0,0 +1,14 @@
Source: nginx-mod-rewrite
Section: web
Priority: optional
Maintainer: Alexey Berezhok <a@bayrepo.ru>
Build-Depends: debhelper (>= 13), bash, openssl-dev, libssl-dev
Standards-Version: 4.7.0
Homepage: https://docs.brepo.ru/nginx-mod_rewrite
Package: nginx-mod-rewrite
Architecture: any
Depends: ${shlibs:Depends}, nginx (>= 1.4.0)
Provides: nginx-http-module, nginx-apache-rewrite
Description: Nginx rewrite module dynamic module adding mod_rewrite functionality
Dynamic Nginx module implementing Apache mod_rewrite functionality.

View File

@@ -7,21 +7,26 @@ export DH_COMPAT=$(DEBHELPER_COMPAT)
export BUILD_DIR = debian/build
export INSTALDIR = debian/nginx-mod-rewrite/usr/share/nginx/modules
export CONFFDIR = debian/nginx-mod-rewrite/etc/nginx/modules
export DOCSDIR = debian/nginx-mod-rewrite/usr/share/info
# Package metadata (matches debian/control)
PACKAGE_NAME = nginx-mod-rewrite
# Set build options
override_dh_auto_build:
bash package_preparer.sh download . system
bash package_preparer.sh build
override_dh_auto_install:
mkdir -p $(INSTALDIR) $(CONFFDIR)
mkdir -p $(INSTALDIR) $(CONFFDIR) $(DOCSDIR)
cp *.so $(INSTALDIR)/
echo 'load_module "$(INSTALDIR)/ngx_http_apache_rewrite_module.so";' > \
$(CONFFDIR)/ngx_http_apache_rewrite_module.conf
cp BUILDINFO.txt $(DOCSDIR)/${PACKAGE_NAME}-BUILDINFO.txt
override_dh_auto_clean:
rm -rf debian/build
rm -f *.so
rm -f BUILDINFO.txt
rm -rf nginx-*
%:

View File

@@ -1,6 +1,8 @@
%define name nginx-mod-rewrite
%define version 0.1
%define release 1%{?dist}
%global nginx_version ${NGINX_CUSTOM_VER:-$(rpm -q nginx --queryformat '%{VERSION}' | cut -d'-' -f1)}
%define summary "Nginx rewrite module dynamic module adding mod_rewrite functionality"
%define license Apache-2.0
%define url https://docs.brepo.ru/nginx-mod-rewrite
@@ -21,7 +23,7 @@ BuildRequires: pcre-devel
BuildRequires: zlib-devel
BuildRequires: bash
BuildRequires: wget
Requires: nginx
Requires: nginx=%{nginx_version}
%description
Dynamic Nginx module implementing Apache mod_rewrite functionality.
@@ -37,7 +39,8 @@ bash package_preparer.sh build
%install
# Install only the dynamic module
mkdir -p %{buildroot}%{nginx_moduledir} %{buildroot}%{nginx_moduleconfdir}
mkdir -p %{buildroot}%{nginx_moduledir} %{buildroot}%{nginx_moduleconfdir} \
%{buildroot}%{_datarootdir}/info/
cp *.so %{buildroot}%{nginx_moduledir}
echo 'load_module "%{nginx_moduledir}/ngx_http_apache_rewrite_module.so";' \
> %{buildroot}%{nginx_moduleconfdir}/ngx_http_apache_rewrite_module.conf
@@ -49,7 +52,7 @@ fi
%files
%license LICENSE
%license LICENSE BUILDINFO.txt
%attr(0640,root,root) %{nginx_moduleconfdir}/ngx_http_apache_rewrite_module.conf
%attr(0755,root,root) %{nginx_moduledir}/ngx_http_apache_rewrite_module.so