fix(library and packaging): patch fpm to use it with debian for Paws (#5108)

This commit is contained in:
sdepassio 2024-07-17 11:32:45 +02:00 committed by GitHub
parent 5f8386c82d
commit bff20e4b8c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 46 additions and 3 deletions

32
.github/patch/fpm-deb.rb.diff vendored Normal file
View File

@ -0,0 +1,32 @@
--- deb-save.rb 2024-07-12 16:04:30.785256976 +0000
+++ deb.rb 2024-07-12 16:21:22.035244607 +0000
@@ -709,10 +709,19 @@
end.flatten
if origin == FPM::Package::CPAN
+
+ # By default, we'd prefer to name Debian-targeted Perl packages using the
+ # same naming scheme that Debian itself uses, which is usually something
+ # like "lib<module-name-hyphenated>-perl", such as libregexp-common-perl
+ #
+ logger.info("Changing package name to match Debian's typical libmodule-name-perl style")
+ self.name = "lib#{self.name.sub(/^perl-/, "")}-perl"
+
# The fpm cpan code presents dependencies and provides fields as perl(ModuleName)
# so we'll need to convert them to something debian supports.
- # Replace perl(ModuleName) > 1.0 with Debian-style perl-ModuleName (> 1.0)
+ # Replace perl(Module::Name) > 1.0 with Debian-style libmodule-name-perl (> 1.0)
+ # per: https://www.debian.org/doc/packaging-manuals/perl-policy/ch-module_packages.html
perldepfix = lambda do |dep|
m = dep.match(/perl\((?<name>[A-Za-z0-9_:]+)\)\s*(?<op>.*$)/)
if m.nil?
@@ -723,7 +732,7 @@
modulename = m["name"].gsub("::", "-")
# Fix any upper-casing or other naming concerns Debian has about packages
- name = "#{attributes[:cpan_package_name_prefix]}-#{modulename}"
+ name = "lib#{modulename}-perl"
if m["op"].empty?
name

View File

@ -327,9 +327,12 @@ jobs:
image: [packaging-plugins-bullseye, packaging-plugins-bookworm, packaging-plugins-jammy, packaging-plugins-bullseye-arm64]
name:
[
"ARGV::Struct",
"Authen::SCRAM::Client",
"Config::AWS",
"Convert::EBCDIC",
"Crypt::Blowfish_PP",
"DataStruct::Flat",
"DateTime::Format::Duration::ISO8601",
"Device::Modbus",
"Digest::SHA1",
@ -371,6 +374,10 @@ jobs:
image: packaging-plugins-bullseye-arm64
arch: arm64
runner_name: ["self-hosted", "collect-arm64"]
- name: "Paws"
use_dh_make_perl: "false"
deb_dependencies: "libmoose-perl libmoosex-classattribute-perl libjson-maybexs-perl liburl-encode-perl libargv-struct-perl libmoo-perl libtype-tiny-perl libdatastruct-flat-perl libmodule-find-perl"
no-auto-depends: true
- name: "Statistics::Regression"
build_distribs: "bullseye"
version: "0.53"
@ -416,8 +423,6 @@ jobs:
run: |
apt-get install -y ruby libcurl4-openssl-dev libssh-dev uuid-dev libczmq-dev
PACKAGE_NAME=`echo ${{ matrix.name }} | sed -e 's/::/-/g' | tr '[A-Z]' '[a-z]' | sed -e 's/^/lib/g' | sed -e 's/$/-perl/g' | sed -e 's/liblib/lib/g'`
if [ -z "${{ matrix.deb_dependencies }}" ]; then
PACKAGE_DEPENDENCIES=""
else
@ -426,11 +431,17 @@ jobs:
done
fi
if [ ! -z "${{ matrix.no-auto-depends }}" ]; then
PACKAGE_DEPENDENCIES="$PACKAGE_DEPENDENCIES --no-auto-depends"
fi
cpanm Module::Build::Tiny
cpanm Module::Install
gem install fpm
fpm -a native -s cpan -t ${{ matrix.package_extension }} --deb-dist ${{ matrix.distrib }} --iteration ${{ matrix.distrib }} --verbose --cpan-verbose --no-cpan-test -n $PACKAGE_NAME$PACKAGE_DEPENDENCIES -v ${{ steps.package-version.outputs.package_version }} ${{ matrix.name }}
# Patch to apply fpm fix for debian package generation while waiting for the official fix to be released.
patch -i .github/patch/fpm-deb.rb.diff $(find / -type f -name "deb.rb")
fpm -a native -s cpan -t ${{ matrix.package_extension }} --deb-dist ${{ matrix.distrib }} --iteration ${{ matrix.distrib }} --verbose --cpan-verbose --no-cpan-test$PACKAGE_DEPENDENCIES -v ${{ steps.package-version.outputs.package_version }} ${{ matrix.name }}
shell: bash
- if: ${{ contains(matrix.build_distribs, matrix.distrib) && matrix.use_dh_make_perl == 'true' }}