From d57d47a19b5119247b9488b145020c113f12c07d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= Date: Fri, 16 Dec 2022 08:29:30 +0100 Subject: [PATCH 1/3] Provides/Depends nginx-abi-${nginx:abi} --- debian/control | 13 +++++-------- debian/debhelper/nginx_mod.pm | 11 +++++++++-- debian/libnginx-mod.substvars | 1 + debian/nginx-dev.install | 1 + debian/rules | 3 +++ 5 files changed, 19 insertions(+), 10 deletions(-) create mode 100644 debian/libnginx-mod.substvars diff --git a/debian/control b/debian/control index 07bfa5c..c61529e 100644 --- a/debian/control +++ b/debian/control @@ -22,8 +22,7 @@ Rules-Requires-Root: no Package: nginx Architecture: all -Depends: nginx-core (<< ${source:Version}.1~) | nginx-full (<< ${source:Version}.1~) | nginx-light (<< ${source:Version}.1~) | nginx-extras (<< ${source:Version}.1~), - nginx-core (>= ${source:Version}) | nginx-full (>= ${source:Version}) | nginx-light (>= ${source:Version}) | nginx-extras (>= ${source:Version}), +Depends: nginx-abi-${nginx:abi}, ${misc:Depends} Description: small, powerful, scalable web/proxy server Nginx ("engine X") is a high-performance web and reverse proxy server @@ -62,8 +61,6 @@ Package: nginx-dev Architecture: all Multi-Arch: foreign Depends: ${misc:Depends}, ${S:Build-Depends}, - nginx-core (<< ${source:Version}.1~) | nginx-light (<< ${source:Version}.1~) | nginx-extras (<< ${source:Version}.1~), - nginx-core (>= ${source:Version}) | nginx-light (>= ${source:Version}) | nginx-extras (>= ${source:Version}) Provides: dh-sequence-nginx Description: nginx web/proxy server - development headers Nginx ("engine X") is a high-performance web and reverse proxy server @@ -88,7 +85,7 @@ Depends: libnginx-mod-http-geoip (= ${binary:Version}), ${shlibs:Depends} Breaks: nginx-full (<< 1.18.0-1), Replaces: nginx-full (<< 1.18.0-1), -Provides: httpd, httpd-cgi, nginx +Provides: httpd, httpd-cgi, nginx, nginx-abi-${nginx:abi} Conflicts: nginx-extras, nginx-light Suggests: nginx-doc (= ${source:Version}) Description: nginx web/proxy server (standard version) @@ -126,7 +123,7 @@ Depends: libnginx-mod-http-auth-pam, nginx-core (<< ${source:Version}.1~), ${misc:Depends}, ${shlibs:Depends} -Provides: httpd, httpd-cgi, nginx +Provides: httpd, httpd-cgi, nginx, nginx-abi-${nginx:abi} Suggests: nginx-doc (= ${source:Version}) Description: nginx web/proxy server (standard version with 3rd parties) Nginx ("engine X") is a high-performance web and reverse proxy server @@ -160,7 +157,7 @@ Depends: libnginx-mod-http-echo (>= 1:0.63-3~), iproute2, ${misc:Depends}, ${shlibs:Depends} -Provides: httpd, httpd-cgi, nginx +Provides: httpd, httpd-cgi, nginx, nginx-abi-${nginx:abi} Conflicts: nginx-extras, nginx-core Suggests: nginx-doc (= ${source:Version}) Description: nginx web/proxy server (basic version) @@ -206,7 +203,7 @@ Depends: libnginx-mod-http-auth-pam (>= 1:1.5.3-2~), iproute2, ${misc:Depends}, ${shlibs:Depends} -Provides: httpd, httpd-cgi, nginx +Provides: httpd, httpd-cgi, nginx, nginx-abi-${nginx:abi} Conflicts: nginx-core, nginx-light Suggests: nginx-doc (= ${source:Version}) Description: nginx web/proxy server (extended version) diff --git a/debian/debhelper/nginx_mod.pm b/debian/debhelper/nginx_mod.pm index 4b19403..1d9f2fb 100644 --- a/debian/debhelper/nginx_mod.pm +++ b/debian/debhelper/nginx_mod.pm @@ -9,6 +9,7 @@ use strict; use warnings; use Dpkg::Deps qw(deps_parse); use Dpkg::Control::Info; +use Dpkg::Substvars; use Debian::Debhelper::Dh_Lib qw(error doit getpackages addsubstvar); use File::Spec; use parent qw(Debian::Debhelper::Buildsystem::makefile); @@ -37,10 +38,16 @@ sub new { my $this= $class->SUPER::new(@_); $this->prefer_out_of_source_building(@_); $this->{has_ndk} = $this->has_build_dep("libnginx-mod-http-ndk-dev"); - if ($this->{has_ndk} == 1){ - foreach my $cur (getpackages('arch')) { + my $sv = Dpkg::Substvars->new(); + $sv->load($this->_NGINX_SRC_DIR . "/debian/libnginx-mod.substvars"); + my $abi = $sv->get("nginx:abi"); + foreach my $cur (getpackages('arch')) { + if ($this->{has_ndk} == 1) { addsubstvar($cur, "misc:Depends", "libnginx-mod-http-ndk"); } + if ($abi) { + addsubstvar($cur, "misc:Depends", "nginx-abi-" . $abi); + } } return $this; } diff --git a/debian/libnginx-mod.substvars b/debian/libnginx-mod.substvars new file mode 100644 index 0000000..e3a2408 --- /dev/null +++ b/debian/libnginx-mod.substvars @@ -0,0 +1 @@ +nginx:abi=1 diff --git a/debian/nginx-dev.install b/debian/nginx-dev.install index efc1578..a667e85 100644 --- a/debian/nginx-dev.install +++ b/debian/nginx-dev.install @@ -6,3 +6,4 @@ debian/debhelper/nginx.pm usr/share/perl5/Debian/Debhelper/Sequence/ debian/debhelper/dh_nginx usr/bin/ debian/debhelper/nginx_mod.pm usr/share/perl5/Debian/Debhelper/Buildsystem/ debian/autoscripts/* usr/share/debhelper/autoscripts/ +debian/libnginx-mod.substvars usr/share/nginx/src/debian/ diff --git a/debian/rules b/debian/rules index c852729..53204f3 100755 --- a/debian/rules +++ b/debian/rules @@ -123,6 +123,9 @@ override_dh_installsystemd: override_dh_installlogrotate: dh_installlogrotate --package nginx-common --name=nginx +override_dh_gencontrol: + dh_gencontrol -- -Tdebian/substvars -Tdebian/libnginx-mod.substvars + build.arch.%: $(MAKE) -C $(BUILDDIR_$*) build From e91cf826057e346997c780a92b17364e6218c23d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= Date: Mon, 19 Dec 2022 23:26:52 +0100 Subject: [PATCH 2/3] Fix tabs --- debian/debhelper/dh_nginx | 42 +++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/debian/debhelper/dh_nginx b/debian/debhelper/dh_nginx index f2b9bb5..9acea24 100755 --- a/debian/debhelper/dh_nginx +++ b/debian/debhelper/dh_nginx @@ -268,30 +268,30 @@ foreach my $package ((@{$dh{DOPACKAGES}})) } } - my @postinst_autoscripts; + my @postinst_autoscripts; - if ($#{$PACKAGE_TYPE{'has_a_module'}} >= 0) - { - if ($package !~ m/libnginx-mod-\w+?/) - { - warning("Package $package appears to be an Nginx module. It should comply to the package naming scheme libnginx-mod-\n"); - } - if ($nginx_in_tree){ - addsubstvar($package, "misc:Depends", nginx_depends()); - } else { - my $ngx_ver = `grep 'define NGINX_VERSION' /usr/share/nginx/src/src/core/nginx.h | sed -e 's/^.*"\\(.*\\)".*/\\1/'`; - chomp($ngx_ver); - addsubstvar($package, "misc:Depends", "nginx-common (>= $ngx_ver), nginx-common (<< $ngx_ver.1~)"); - } + if ($#{$PACKAGE_TYPE{'has_a_module'}} >= 0) + { + if ($package !~ m/libnginx-mod-\w+?/) + { + warning("Package $package appears to be an Nginx module. It should comply to the package naming scheme libnginx-mod-\n"); + } + if ($nginx_in_tree){ + addsubstvar($package, "misc:Depends", nginx_depends()); + } else { + my $ngx_ver = `grep 'define NGINX_VERSION' /usr/share/nginx/src/src/core/nginx.h | sed -e 's/^.*"\\(.*\\)".*/\\1/'`; + chomp($ngx_ver); + addsubstvar($package, "misc:Depends", "nginx-common (>= $ngx_ver), nginx-common (<< $ngx_ver.1~)"); + } - my $modules = ""; - foreach my $module (@{$PACKAGE_TYPE{'has_a_module'}}) - { - $modules .= "$module "; - } + my $modules = ""; + foreach my $module (@{$PACKAGE_TYPE{'has_a_module'}}) + { + $modules .= "$module "; + } - push @postinst_autoscripts, ["module", $modules]; - } + push @postinst_autoscripts, ["module", $modules]; + } if (! $dh{NOSCRIPTS}) { From d7418a6a87a28819076d3f1c9575947a31948130 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lal?= Date: Mon, 19 Dec 2022 23:52:25 +0100 Subject: [PATCH 3/3] Include nginx version in abi from debian/rules --- debian/debhelper/dh_nginx | 19 +++++++++---------- debian/debhelper/nginx_mod.pm | 7 ------- debian/libnginx-mod.substvars | 1 - debian/nginx-dev.install | 2 +- debian/rules | 13 ++++++++++++- 5 files changed, 22 insertions(+), 20 deletions(-) delete mode 100644 debian/libnginx-mod.substvars diff --git a/debian/debhelper/dh_nginx b/debian/debhelper/dh_nginx index 9acea24..c303731 100755 --- a/debian/debhelper/dh_nginx +++ b/debian/debhelper/dh_nginx @@ -23,17 +23,22 @@ use strict; use File::Find; use Debian::Debhelper::Dh_Lib; - +use Dpkg::Substvars; =head1 NAME dh_nginx - register configuration snippets to the nginx web server =cut - +my $abi; sub nginx_depends { - return 'nginx-common (= ${source:Version})' + if (!$abi) { + my $sv = Dpkg::Substvars->new(); + $sv->load("/usr/share/nginx/src/debian/libnginx-mod.substvars"); + $abi = $sv->get("nginx:abi"); + } + return "nginx-abi-$abi"; } sub nginx_api_installdir @@ -276,13 +281,7 @@ foreach my $package ((@{$dh{DOPACKAGES}})) { warning("Package $package appears to be an Nginx module. It should comply to the package naming scheme libnginx-mod-\n"); } - if ($nginx_in_tree){ - addsubstvar($package, "misc:Depends", nginx_depends()); - } else { - my $ngx_ver = `grep 'define NGINX_VERSION' /usr/share/nginx/src/src/core/nginx.h | sed -e 's/^.*"\\(.*\\)".*/\\1/'`; - chomp($ngx_ver); - addsubstvar($package, "misc:Depends", "nginx-common (>= $ngx_ver), nginx-common (<< $ngx_ver.1~)"); - } + addsubstvar($package, "misc:Depends", nginx_depends()); my $modules = ""; foreach my $module (@{$PACKAGE_TYPE{'has_a_module'}}) diff --git a/debian/debhelper/nginx_mod.pm b/debian/debhelper/nginx_mod.pm index 1d9f2fb..7df00d4 100644 --- a/debian/debhelper/nginx_mod.pm +++ b/debian/debhelper/nginx_mod.pm @@ -9,7 +9,6 @@ use strict; use warnings; use Dpkg::Deps qw(deps_parse); use Dpkg::Control::Info; -use Dpkg::Substvars; use Debian::Debhelper::Dh_Lib qw(error doit getpackages addsubstvar); use File::Spec; use parent qw(Debian::Debhelper::Buildsystem::makefile); @@ -38,16 +37,10 @@ sub new { my $this= $class->SUPER::new(@_); $this->prefer_out_of_source_building(@_); $this->{has_ndk} = $this->has_build_dep("libnginx-mod-http-ndk-dev"); - my $sv = Dpkg::Substvars->new(); - $sv->load($this->_NGINX_SRC_DIR . "/debian/libnginx-mod.substvars"); - my $abi = $sv->get("nginx:abi"); foreach my $cur (getpackages('arch')) { if ($this->{has_ndk} == 1) { addsubstvar($cur, "misc:Depends", "libnginx-mod-http-ndk"); } - if ($abi) { - addsubstvar($cur, "misc:Depends", "nginx-abi-" . $abi); - } } return $this; } diff --git a/debian/libnginx-mod.substvars b/debian/libnginx-mod.substvars deleted file mode 100644 index e3a2408..0000000 --- a/debian/libnginx-mod.substvars +++ /dev/null @@ -1 +0,0 @@ -nginx:abi=1 diff --git a/debian/nginx-dev.install b/debian/nginx-dev.install index a667e85..250b101 100644 --- a/debian/nginx-dev.install +++ b/debian/nginx-dev.install @@ -2,8 +2,8 @@ debian/build-src/auto usr/share/nginx/src/ debian/build-src/src usr/share/nginx/src/ debian/build-src/conf_flags usr/share/nginx/src/ debian/build-src/configure usr/share/nginx/src/ +debian/build-src/debian/libnginx-mod.substvars usr/share/nginx/src/debian/ debian/debhelper/nginx.pm usr/share/perl5/Debian/Debhelper/Sequence/ debian/debhelper/dh_nginx usr/bin/ debian/debhelper/nginx_mod.pm usr/share/perl5/Debian/Debhelper/Buildsystem/ debian/autoscripts/* usr/share/debhelper/autoscripts/ -debian/libnginx-mod.substvars usr/share/nginx/src/debian/ diff --git a/debian/rules b/debian/rules index 53204f3..2f09854 100755 --- a/debian/rules +++ b/debian/rules @@ -1,7 +1,16 @@ #!/usr/bin/make -f export DH_VERBOSE=1 +include /usr/share/dpkg/pkg-info.mk + export DEB_BUILD_MAINT_OPTIONS=hardening=+all + +# increase this value when DEB_VERSION_UPSTREAM is the same and ABI breaks because: +# - a patch might change it +# - a build-dependency has changed +# note that debian revision can increase without breaking ABI +nginx_abi = $(DEB_VERSION_UPSTREAM)-1 + debian_cflags:=$(shell dpkg-buildflags --get CFLAGS) -fPIC $(shell dpkg-buildflags --get CPPFLAGS) debian_ldflags:=$(shell dpkg-buildflags --get LDFLAGS) -fPIC @@ -124,7 +133,7 @@ override_dh_installlogrotate: dh_installlogrotate --package nginx-common --name=nginx override_dh_gencontrol: - dh_gencontrol -- -Tdebian/substvars -Tdebian/libnginx-mod.substvars + dh_gencontrol -- -Tdebian/substvars -T$(BUILDDIR_src)/debian/libnginx-mod.substvars build.arch.%: $(MAKE) -C $(BUILDDIR_$*) build @@ -136,6 +145,8 @@ build.src: if [ -e $(CURDIR)/configure ]; then cp $(CURDIR)/configure $(BUILDDIR_src)/; fi echo "NGX_CONF_FLAGS=(" $(basic_configure_flags) ")" > $(BUILDDIR_src)/conf_flags pod2man debian/debhelper/dh_nginx > $(BUILDDIR_src)/dh_nginx.1 + mkdir -p $(BUILDDIR_src)/debian + echo "nginx:abi=$(nginx_abi)" > $(BUILDDIR_src)/debian/libnginx-mod.substvars strip.arch.%: dh_strip --package=nginx-$(*) -O--dbgsym-migration='nginx-$(*)-dbg (<< 1.10.1-3~)'