summary refs log tree commit diff
path: root/gnu
diff options
context:
space:
mode:
authorMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-03-13 22:28:36 -0400
committerMaxim Cournoyer <maxim.cournoyer@gmail.com>2023-03-28 22:22:41 -0400
commit7e5c0dc8746c673a31266394987ec026cd99bb24 (patch)
treeb4fde2e62a7815a14f088cba8ebabab3655efba0 /gnu
parent5a693a3235a01e8ce6258ec57d31a36856858a45 (diff)
downloadguix-7e5c0dc8746c673a31266394987ec026cd99bb24.tar.gz
gnu: Add fpm.
* gnu/packages/package-management.scm (fpm): New variable.
* gnu/packages/patches/fpm-newer-clamp-fix.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
Diffstat (limited to 'gnu')
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/package-management.scm86
-rw-r--r--gnu/packages/patches/fpm-newer-clamp-fix.patch33
3 files changed, 120 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index 52be2b1bab..74114a2ba4 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1136,6 +1136,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/fp16-implicit-double.patch		\
   %D%/packages/patches/fp16-system-libraries.patch		\
   %D%/packages/patches/fpc-reproducibility.patch		\
+  %D%/packages/patches/fpm-newer-clamp-fix.patch		\
   %D%/packages/patches/freedink-engine-fix-sdl-hints.patch	\
   %D%/packages/patches/freeimage-unbundle.patch		\
   %D%/packages/patches/fuse-glibc-2.34.patch			\
diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index b439f9326c..537d01e164 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -59,6 +59,7 @@
   #:use-module (gnu packages crypto)
   #:use-module (gnu packages curl)
   #:use-module (gnu packages databases)
+  #:use-module (gnu packages debian)
   #:use-module (gnu packages dejagnu)
   #:use-module (gnu packages dbm)
   #:use-module (gnu packages docbook)
@@ -87,6 +88,7 @@
   #:use-module (gnu packages nettle)
   #:use-module (gnu packages networking)
   #:use-module (gnu packages ninja)
+  #:use-module (gnu packages node)
   #:use-module (gnu packages nss)
   #:use-module (gnu packages patchutils)
   #:use-module (gnu packages perl)
@@ -98,6 +100,7 @@
   #:use-module (gnu packages python-check)
   #:use-module (gnu packages python-web)
   #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages ruby)
   #:use-module (gnu packages serialization)
   #:use-module (gnu packages sqlite)
   #:use-module (gnu packages ssh)
@@ -117,6 +120,7 @@
   #:use-module (guix build-system guile)
   #:use-module (guix build-system meson)
   #:use-module (guix build-system python)
+  #:use-module (guix build-system ruby)
   #:use-module (guix build-system trivial)
   #:use-module (guix download)
   #:use-module (guix gexp)
@@ -2005,6 +2009,88 @@ applications")
 sandboxed desktop applications on GNU/Linux.")
     (license license:lgpl2.1+)))
 
+(define-public fpm
+  (package
+    (name "fpm")
+    (version "1.15.1")
+    (source (origin
+              (method git-fetch)        ;for tests
+              (uri (git-reference
+                    (url "https://github.com/jordansissel/fpm")
+                    (commit (string-append "v" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "1m2zxf7wyk7psvm611yxs68hnwm0pyqilsmcq3x791hz7rvbg68w"))
+              (patches (search-patches "fpm-newer-clamp-fix.patch"))))
+    (build-system ruby-build-system)
+    (arguments
+     (list #:phases
+           #~(modify-phases %standard-phases
+               (add-after 'extract-gemspec 'patch-paths
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   (substitute* '("lib/fpm/util.rb"
+                                  "spec/fpm/util_spec.rb"
+                                  "spec/fpm/package/rpm_spec.rb")
+                     (("\"/bin/sh\"")
+                      (string-append "\"" (search-input-file inputs "bin/sh")
+                                     "\"")))))
+               (add-after 'extract-gemspec 'relax-requirements
+                 (lambda _
+                   (substitute* "fpm.gemspec"
+                     (("\"clamp\", \"~> 1.0.0\"")
+                      "\"clamp\", \">= 1.0.0\""))))
+               (add-after 'extract-gemspec 'disable-problematic-tests
+                 ;; Disable some tests which are failing (see:
+                 ;; https://github.com/jordansissel/fpm/issues/2000).
+                 (lambda _
+                   ;; There are 4 'NoMethodError' test failures in the
+                   ;; command_spec suite, for unknown reasons.
+                   (delete-file "spec/fpm/command_spec.rb")
+                   (substitute* "spec/fpm/package_spec.rb"
+                     (("@oldtmp = ENV\\[\"TMP\"]" all)
+                      "skip('fails with guix')"))
+                   (substitute* "spec/fpm/package/cpan_spec.rb"
+                     ;; This test is marked as expected to fail (pending) when
+                     ;; TRAVIS_OS_NAME is set, but passes with Guix; skip it.
+                     (("it \"should unpack tarball containing" all)
+                      (string-append "x" all)))
+                   (substitute* "spec/fpm/package/gem_spec.rb"
+                     ;; This test fails for unknown reason; perhaps a patched
+                     ;; shebang.
+                     (("it 'should not change the shebang'" all)
+                      (string-append "x" all)))))
+               (replace 'check
+                 (lambda* (#:key tests? #:allow-other-keys)
+                   (when tests?
+                     ;; Set TRAVIS_OS_NAME to skip tests known to cause
+                     ;; problems in minimal environments.
+                     (setenv "TRAVIS_OS_NAME" "GNU Guix")
+                     (invoke "rspec")))))))
+    (native-inputs
+     (list dpkg
+           libarchive
+           node
+           perl-app-cpanminus
+           python
+           ruby-rspec
+           squashfs-tools
+           zstd))
+    (inputs
+     (list bash-minimal
+           ruby-arr-pm
+           ruby-backports
+           ruby-cabin
+           ruby-clamp
+           ruby-pleaserun
+           ruby-rexml
+           ruby-stud))
+    (home-page "https://github.com/jordansissel/fpm/")
+    (synopsis "Package building and mangling tool")
+    (description "@command{fpm} is a command to convert directories, RPMs,
+Python eggs, Ruby gems, and more to RPMs, debs, Solaris packages and more.")
+    (license license:expat)))
+
 (define-public akku
   (package
     (name "akku")
diff --git a/gnu/packages/patches/fpm-newer-clamp-fix.patch b/gnu/packages/patches/fpm-newer-clamp-fix.patch
new file mode 100644
index 0000000000..9fbb15ee29
--- /dev/null
+++ b/gnu/packages/patches/fpm-newer-clamp-fix.patch
@@ -0,0 +1,33 @@
+Retrieved from: https://github.com/jordansissel/fpm/pull/1561.patch
+
+From 956a218a7b35de08ea35da3b702ffdc716656b68 Mon Sep 17 00:00:00 2001
+From: Jordan Sissel <jls@semicomplete.com>
+Date: Mon, 15 Oct 2018 21:05:47 -0700
+Subject: [PATCH] Check if an option has a default value before we try to look
+ it up.
+
+This fixes fpm when used with clamp 1.3.0 or above.
+
+Fixes #1543
+---
+ lib/fpm/command.rb | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/lib/fpm/command.rb b/lib/fpm/command.rb
+index a204001e1..a99ddb627 100644
+--- a/lib/fpm/command.rb
++++ b/lib/fpm/command.rb
+@@ -394,7 +394,12 @@ def execute
+     set = proc do |object, attribute|
+       # if the package's attribute is currently nil *or* the flag setting for this
+       # attribute is non-default, use the value.
+-      if object.send(attribute).nil? || send(attribute) != send("default_#{attribute}")
++
++      # Not all options have a default value, so we assume `nil` if there's no default. (#1543)
++      # In clamp >= 1.3.0, options without `:default => ..` will not have any # `default_xyz` 
++      # methods generated, so we need to check for the presence of this method first.
++      default = respond_to?("default_#{attribute}") ? send("default_#{attribute}") : nil
++      if object.send(attribute).nil? || send(attribute) != default
+         logger.info("Setting from flags: #{attribute}=#{send(attribute)}")
+         object.send("#{attribute}=", send(attribute))
+       end