Message ID | 20240419213216.518041-2-angelo.compagnucci@gmail.com |
---|---|
State | Accepted |
Headers | show |
Series | Fix fail2ban | expand |
Am 19.04.24 um 23:32 schrieb Angelo Compagnucci: > When packaging data_files in a wheel, those files shall have the destination > path expressed as relative to the wheel installation. > The reason for that is the wheel installation shall be contained inside a > specific folder and/or in site-packages. > When building the wheel file by the bdist_wheel command, python will package > files with absolute pats as python files ending up installing them in > site-packages. > > Fixes: > http://autobuild.buildroot.net/results/36ac5278d19195a21c3d02d087965e08f49228ef > > Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com> Tested-by: Fiona Klute <fiona.klute+wiwa@gmx.de> Testing included: Build for aarch64, configuring fail2ban for sshd, testing that a host indeed gets banned after repeated failed login attempts (password auth), with syslog-ng (the default fail2ban patterns don't work with Busybox syslogd) and nftables. Thanks for fixing the build, Angelo! Best regards, Fiona > --- > ...001-setup.py-fix-data-relative-paths.patch | 73 +++++++++++++++++++ > 1 file changed, 73 insertions(+) > create mode 100644 package/fail2ban/0001-setup.py-fix-data-relative-paths.patch > > diff --git a/package/fail2ban/0001-setup.py-fix-data-relative-paths.patch b/package/fail2ban/0001-setup.py-fix-data-relative-paths.patch > new file mode 100644 > index 0000000000..e1b5bc490b > --- /dev/null > +++ b/package/fail2ban/0001-setup.py-fix-data-relative-paths.patch > @@ -0,0 +1,73 @@ > +From 7b7fa3c02d4575c09362336bc310835c37859f1a Mon Sep 17 00:00:00 2001 > +From: Angelo Compagnucci <angelo.compagnucci@gmail.com> > +Date: Fri, 19 Apr 2024 22:47:20 +0200 > +Subject: [PATCH] setup.py: fix data relative paths > +MIME-Version: 1.0 > +Content-Type: text/plain; charset=UTF-8 > +Content-Transfer-Encoding: 8bit > + > +As per distutils documentation: > + > +The directory should be a relative path. It is interpreted relative to the > +installation prefix (Python’s sys.prefix for system installations; > +site.USER_BASE for user installations). Distutils allows directory to be an > +absolute installation path, but this is discouraged since it is incompatible > +with the wheel packaging format [1]. > + > +When packaging to a bdist_wheel indeed, the files in the "data_files" dictionary > +are not picked at all as data files if they have an absolute path, > +but they are instead added to the wheel as python files. > +This has the effect of installing them as part of python files in the > +site-packages folder when the wheel is installed. > + > +This patch cannot be sent upstream because it breaks the legacy way of > +installing the package with *python setup.py install* and it is needed only to > +comply with the pep517 buildroot compatibility layer. > + > +[1] https://docs.python.org/3.10/distutils/setupscript.html#installing-additional-files > +Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com> > +--- > + setup.py | 14 +++++++------- > + 1 file changed, 7 insertions(+), 7 deletions(-) > + > +diff --git a/setup.py b/setup.py > +index 91f71cf2..99ba2e32 100755 > +--- a/setup.py > ++++ b/setup.py > +@@ -238,26 +238,26 @@ setup( > + for f in w[2]] > + } if with_tests else {}, > + data_files = [ > +- ('/etc/fail2ban', > ++ ('etc/fail2ban', > + glob("config/*.conf") > + ), > +- ('/etc/fail2ban/filter.d', > ++ ('etc/fail2ban/filter.d', > + glob("config/filter.d/*.conf") > + ), > +- ('/etc/fail2ban/filter.d/ignorecommands', > ++ ('etc/fail2ban/filter.d/ignorecommands', > + [p for p in glob("config/filter.d/ignorecommands/*") if isfile(p)] > + ), > +- ('/etc/fail2ban/action.d', > ++ ('etc/fail2ban/action.d', > + glob("config/action.d/*.conf") + > + glob("config/action.d/*.py") > + ), > +- ('/etc/fail2ban/fail2ban.d', > ++ ('etc/fail2ban/fail2ban.d', > + '' > + ), > +- ('/etc/fail2ban/jail.d', > ++ ('etc/fail2ban/jail.d', > + '' > + ), > +- ('/var/lib/fail2ban', > ++ ('var/lib/fail2ban', > + '' > + ), > + ] + data_files_extra, > +-- > +2.34.1 > +
Hello Angelo, On Fri, 19 Apr 2024 23:32:15 +0200 Angelo Compagnucci <angelo.compagnucci@gmail.com> wrote: > diff --git a/package/fail2ban/0001-setup.py-fix-data-relative-paths.patch b/package/fail2ban/0001-setup.py-fix-data-relative-paths.patch > new file mode 100644 > index 0000000000..e1b5bc490b > --- /dev/null > +++ b/package/fail2ban/0001-setup.py-fix-data-relative-paths.patch > @@ -0,0 +1,73 @@ > +From 7b7fa3c02d4575c09362336bc310835c37859f1a Mon Sep 17 00:00:00 2001 > +From: Angelo Compagnucci <angelo.compagnucci@gmail.com> > +Date: Fri, 19 Apr 2024 22:47:20 +0200 > +Subject: [PATCH] setup.py: fix data relative paths > +MIME-Version: 1.0 > +Content-Type: text/plain; charset=UTF-8 > +Content-Transfer-Encoding: 8bit > + > +As per distutils documentation: > + > +The directory should be a relative path. It is interpreted relative to the > +installation prefix (Python’s sys.prefix for system installations; > +site.USER_BASE for user installations). Distutils allows directory to be an > +absolute installation path, but this is discouraged since it is incompatible > +with the wheel packaging format [1]. > + > +When packaging to a bdist_wheel indeed, the files in the "data_files" dictionary > +are not picked at all as data files if they have an absolute path, > +but they are instead added to the wheel as python files. > +This has the effect of installing them as part of python files in the > +site-packages folder when the wheel is installed. > + > +This patch cannot be sent upstream because it breaks the legacy way of > +installing the package with *python setup.py install* and it is needed only to > +comply with the pep517 buildroot compatibility layer. > + > +[1] https://docs.python.org/3.10/distutils/setupscript.html#installing-additional-files > +Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com> Thanks for the patch! However, this patch has no Upstream: tag, causing a check-package warning when being applied: WARNING: package/fail2ban/0001-setup.py-fix-data-relative-paths.patch:0: missing Upstream in the header (https://nightly.buildroot.org/#_additional_patch_documentation) What is the upstream status of this patch? Thanks! Thomas
Am 09.07.24 um 22:28 schrieb Thomas Petazzoni via buildroot: > Hello Angelo, > > On Fri, 19 Apr 2024 23:32:15 +0200 > Angelo Compagnucci <angelo.compagnucci@gmail.com> wrote: > > >> diff --git a/package/fail2ban/0001-setup.py-fix-data-relative-paths.patch b/package/fail2ban/0001-setup.py-fix-data-relative-paths.patch >> new file mode 100644 >> index 0000000000..e1b5bc490b >> --- /dev/null >> +++ b/package/fail2ban/0001-setup.py-fix-data-relative-paths.patch >> @@ -0,0 +1,73 @@ >> +From 7b7fa3c02d4575c09362336bc310835c37859f1a Mon Sep 17 00:00:00 2001 >> +From: Angelo Compagnucci <angelo.compagnucci@gmail.com> >> +Date: Fri, 19 Apr 2024 22:47:20 +0200 >> +Subject: [PATCH] setup.py: fix data relative paths >> +MIME-Version: 1.0 >> +Content-Type: text/plain; charset=UTF-8 >> +Content-Transfer-Encoding: 8bit >> + >> +As per distutils documentation: >> + >> +The directory should be a relative path. It is interpreted relative to the >> +installation prefix (Python’s sys.prefix for system installations; >> +site.USER_BASE for user installations). Distutils allows directory to be an >> +absolute installation path, but this is discouraged since it is incompatible >> +with the wheel packaging format [1]. >> + >> +When packaging to a bdist_wheel indeed, the files in the "data_files" dictionary >> +are not picked at all as data files if they have an absolute path, >> +but they are instead added to the wheel as python files. >> +This has the effect of installing them as part of python files in the >> +site-packages folder when the wheel is installed. >> + >> +This patch cannot be sent upstream because it breaks the legacy way of >> +installing the package with *python setup.py install* and it is needed only to >> +comply with the pep517 buildroot compatibility layer. >> + >> +[1] https://docs.python.org/3.10/distutils/setupscript.html#installing-additional-files >> +Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com> > > Thanks for the patch! > > However, this patch has no Upstream: tag, causing a check-package > warning when being applied: > > WARNING: package/fail2ban/0001-setup.py-fix-data-relative-paths.patch:0: missing Upstream in the header (https://nightly.buildroot.org/#_additional_patch_documentation) > > What is the upstream status of this patch? I believe the last paragraph of the patch description answers the question, maybe you could add a shortened version as the Upstream tag? E.g.: Upstream: N/A (breaks upstream install, only for Buildroot compatibility) Best regards, Fiona
diff --git a/package/fail2ban/0001-setup.py-fix-data-relative-paths.patch b/package/fail2ban/0001-setup.py-fix-data-relative-paths.patch new file mode 100644 index 0000000000..e1b5bc490b --- /dev/null +++ b/package/fail2ban/0001-setup.py-fix-data-relative-paths.patch @@ -0,0 +1,73 @@ +From 7b7fa3c02d4575c09362336bc310835c37859f1a Mon Sep 17 00:00:00 2001 +From: Angelo Compagnucci <angelo.compagnucci@gmail.com> +Date: Fri, 19 Apr 2024 22:47:20 +0200 +Subject: [PATCH] setup.py: fix data relative paths +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +As per distutils documentation: + +The directory should be a relative path. It is interpreted relative to the +installation prefix (Python’s sys.prefix for system installations; +site.USER_BASE for user installations). Distutils allows directory to be an +absolute installation path, but this is discouraged since it is incompatible +with the wheel packaging format [1]. + +When packaging to a bdist_wheel indeed, the files in the "data_files" dictionary +are not picked at all as data files if they have an absolute path, +but they are instead added to the wheel as python files. +This has the effect of installing them as part of python files in the +site-packages folder when the wheel is installed. + +This patch cannot be sent upstream because it breaks the legacy way of +installing the package with *python setup.py install* and it is needed only to +comply with the pep517 buildroot compatibility layer. + +[1] https://docs.python.org/3.10/distutils/setupscript.html#installing-additional-files +Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com> +--- + setup.py | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/setup.py b/setup.py +index 91f71cf2..99ba2e32 100755 +--- a/setup.py ++++ b/setup.py +@@ -238,26 +238,26 @@ setup( + for f in w[2]] + } if with_tests else {}, + data_files = [ +- ('/etc/fail2ban', ++ ('etc/fail2ban', + glob("config/*.conf") + ), +- ('/etc/fail2ban/filter.d', ++ ('etc/fail2ban/filter.d', + glob("config/filter.d/*.conf") + ), +- ('/etc/fail2ban/filter.d/ignorecommands', ++ ('etc/fail2ban/filter.d/ignorecommands', + [p for p in glob("config/filter.d/ignorecommands/*") if isfile(p)] + ), +- ('/etc/fail2ban/action.d', ++ ('etc/fail2ban/action.d', + glob("config/action.d/*.conf") + + glob("config/action.d/*.py") + ), +- ('/etc/fail2ban/fail2ban.d', ++ ('etc/fail2ban/fail2ban.d', + '' + ), +- ('/etc/fail2ban/jail.d', ++ ('etc/fail2ban/jail.d', + '' + ), +- ('/var/lib/fail2ban', ++ ('var/lib/fail2ban', + '' + ), + ] + data_files_extra, +-- +2.34.1 +
When packaging data_files in a wheel, those files shall have the destination path expressed as relative to the wheel installation. The reason for that is the wheel installation shall be contained inside a specific folder and/or in site-packages. When building the wheel file by the bdist_wheel command, python will package files with absolute pats as python files ending up installing them in site-packages. Fixes: http://autobuild.buildroot.net/results/36ac5278d19195a21c3d02d087965e08f49228ef Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com> --- ...001-setup.py-fix-data-relative-paths.patch | 73 +++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 package/fail2ban/0001-setup.py-fix-data-relative-paths.patch