unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] Add rubygems updater.
@ 2016-01-01  8:27 Ben Woodcroft
  2016-01-01  9:28 ` Pjotr Prins
  0 siblings, 1 reply; 13+ messages in thread
From: Ben Woodcroft @ 2016-01-01  8:27 UTC (permalink / raw)
  To: guix-devel@gnu.org

[-- Attachment #1: Type: text/plain, Size: 2965 bytes --]

Phew, you almost beat me to the first patch of the year there Pjotr..

It seems there's 30 packages to be updated, out of the 107 in ruby.scm. 
Going through each of these individually seems a little tedious, can we 
do them in bulk somehow or do they have to be committed individually? 
Building and testing all packages that require these packages would be a 
start - is there any way to list all dependent packages?

gnu/packages/ruby.scm:2807:13: ruby-cutest would be upgraded from 1.2.2 
to 1.2.3
gnu/packages/ruby.scm:333:13: ruby-rspec-mocks would be upgraded from 
3.2.1 to 3.4.0
gnu/packages/ruby.scm:1527:13: ruby-daemons would be upgraded from 1.2.2 
to 1.2.3
gnu/packages/ruby.scm:1581:13: ruby-slop would be upgraded from 4.1.0 to 
4.2.1
gnu/packages/ruby.scm:2707:13: ruby-cucumber-core would be upgraded from 
1.3.0 to 1.3.1
gnu/packages/ruby.scm:1486:13: ruby-minitest-sprint would be upgraded 
from 1.1.0 to 1.1.1
gnu/packages/ruby.scm:2221:13: ruby-rb-fsevent would be upgraded from 
0.9.6 to 0.9.7
gnu/packages/ruby.scm:1339:13: ruby-redcarpet would be upgraded from 
3.3.3 to 3.3.4
gnu/packages/ruby.scm:1427:13: ruby-net-ssh would be upgraded from 3.0.1 
to 3.0.2
gnu/packages/ruby.scm:2241:13: ruby-listen would be upgraded from 3.0.3 
to 3.0.5
gnu/packages/ruby.scm:1124:13: ruby-gettext would be upgraded from 3.1.7 
to 3.2.0
gnu/packages/ruby.scm:1765:13: ruby-pry would be upgraded from 0.10.1 to 
0.10.3
gnu/packages/ruby.scm:2467:13: ruby-pg would be upgraded from 0.18.2 to 
0.18.4
gnu/packages/ruby.scm:967:13: ruby-useragent would be upgraded from 
0.13.3 to 0.16.3
gnu/packages/ruby.scm:299:13: ruby-rspec-expectations would be upgraded 
from 3.2.1 to 3.4.0
gnu/packages/ruby.scm:1629:13: ruby-arel would be upgraded from 6.0.3 to 
7.0.0
gnu/packages/ruby.scm:797:13: ruby-notiffany would be upgraded from 
0.0.7 to 0.0.8
gnu/packages/ruby.scm:2684:13: ruby-gherkin3 would be upgraded from 
3.1.1 to 3.1.2
gnu/packages/ruby.scm:162:13: ruby-hoe would be upgraded from 3.13.1 to 
3.14.2
gnu/packages/ruby.scm:452:13: ruby-rjb would be upgraded from 1.5.3 to 1.5.4
gnu/packages/ruby.scm:367:13: ruby-rspec would be upgraded from 3.2.0 to 
3.4.0
gnu/packages/ruby.scm:940:13: ruby-simplecov would be upgraded from 
0.10.0 to 0.11.1
gnu/packages/ruby.scm:1448:13: ruby-minitest would be upgraded from 
5.7.0 to 5.8.3
gnu/packages/ruby.scm:1964:13: ruby-tins would be upgraded from 1.7.0 to 
1.8.1
gnu/packages/ruby.scm:2263:13: ruby-activesupport would be upgraded from 
4.2.4 to 4.2.5
gnu/packages/ruby.scm:1689:13: ruby-nokogiri would be upgraded from 
1.6.6.2 to 1.6.7.1
gnu/packages/ruby.scm:407:13: bundler would be upgraded from 1.10.6 to 
1.11.2
gnu/packages/ruby.scm:2405:13: ruby-ox would be upgraded from 2.2.1 to 2.2.3
gnu/packages/ruby.scm:246:13: ruby-rspec-core would be upgraded from 
3.2.3 to 3.4.1
gnu/packages/ruby.scm:2493:13: ruby-byebug would be upgraded from 6.0.2 
to 8.2.1


Thanks in advance for the review.
ben

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-import-gem-Add-updater.patch --]
[-- Type: text/x-patch; name="0001-import-gem-Add-updater.patch", Size: 6188 bytes --]

From 4f53236278eb75b3e7f89562ae675becf3033679 Mon Sep 17 00:00:00 2001
From: Ben Woodcroft <donttrustben@gmail.com>
Date: Fri, 1 Jan 2016 16:56:07 +1000
Subject: [PATCH] import: gem: Add updater.

* guix/import/gem.scm (guix-package->gem-name,
  gem-package?, latest-release): New procedures.
  (%gem-updater): New variable.
  (rubygems-fetch): Wrap body in
  'call-with-output-file' and 'with-error-to-port'.
* guix/scripts/refresh.scm (%updaters): Add %GEM-UPDATER.
* doc/guix.texi (Invoking guix refresh): Mention RubyGems.
---
 doc/guix.texi            |  2 ++
 guix/import/gem.scm      | 63 +++++++++++++++++++++++++++++++++++++++++++++---
 guix/scripts/refresh.scm |  5 +++-
 3 files changed, 66 insertions(+), 4 deletions(-)

diff --git a/doc/guix.texi b/doc/guix.texi
index a70fbe8..008fcf1 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -4416,6 +4416,8 @@ the updater for @uref{http://elpa.gnu.org/, ELPA} packages;
 the updater for @uref{http://cran.r-project.org/, CRAN} packages;
 @item pypi
 the updater for @uref{https://pypi.python.org, PyPI} packages.
+@item gem
+the updater for @uref{https://rubygems.org, RubyGems} packages.
 @end table
 
 For instance, the following commands only checks for updates of Emacs
diff --git a/guix/import/gem.scm b/guix/import/gem.scm
index c64c4e9..bb25dc8 100644
--- a/guix/import/gem.scm
+++ b/guix/import/gem.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2015 David Thompson <davet@gnu.org>
+;;; Copryight © 2016 Ben Woodcroft <donttrustben@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,21 +20,33 @@
 (define-module (guix import gem)
   #:use-module (ice-9 match)
   #:use-module (ice-9 pretty-print)
+  #:use-module (srfi srfi-1)
   #:use-module (rnrs bytevectors)
   #:use-module (json)
   #:use-module (web uri)
+  #:use-module ((guix download) #:prefix download:)
   #:use-module (guix import utils)
   #:use-module (guix import json)
   #:use-module (guix packages)
+  #:use-module (guix upstream)
   #:use-module (guix licenses)
   #:use-module (guix base32)
-  #:export (gem->guix-package))
+  #:use-module (guix build-system ruby)
+  #:use-module (gnu packages)
+  #:export (gem->guix-package
+            %gem-updater))
 
 (define (rubygems-fetch name)
   "Return an alist representation of the RubyGems metadata for the package NAME,
 or #f on failure."
-  (json-fetch
-   (string-append "https://rubygems.org/api/v1/gems/" name ".json")))
+  ;; XXX: We want to silence the download progress report, which is especially
+  ;; annoying for 'guix refresh', but we have to use a file port.
+  (call-with-output-file "/dev/null"
+    (lambda (null)
+      (with-error-to-port null
+        (lambda ()
+          (json-fetch
+           (string-append "https://rubygems.org/api/v1/gems/" name ".json")))))))
 
 (define (ruby-package-name name)
   "Given the NAME of a package on RubyGems, return a Guix-compliant name for
@@ -130,3 +143,47 @@ VERSION, HASH, HOME-PAGE, DESCRIPTION, DEPENDENCIES, and LICENSES."
                                   (assoc-ref package "licenses"))))
            (make-gem-sexp name version hash home-page
                           description dependencies licenses)))))
+
+(define (guix-package->gem-name package)
+  "Given a PACKAGE built from rubygems.org, return the name of the
+package on RubyGems."
+  (let ((source-url (and=> (package-source package) origin-uri)))
+    ;; The URL has the form:
+    ;; 'https://rubygems.org/downloads/' +
+    ;; package name + '-' + version + '.gem'
+    ;; e.g. "https://rubygems.org/downloads/hashery-2.1.1.gem"
+    (substring source-url 31 (string-rindex source-url #\-))))
+
+(define (gem-package? package)
+  "Return true if PACKAGE is a gem package from RubyGems."
+
+  (define (rubygems-url? url)
+    (string-prefix? "https://rubygems.org/downloads/" url))
+
+  (let ((source-url (and=> (package-source package) origin-uri))
+        (fetch-method (and=> (package-source package) origin-method)))
+    (and (eq? fetch-method download:url-fetch)
+         (match source-url
+           ((? string?)
+            (rubygems-url? source-url))
+           ((source-url ...)
+            (any rubygems-url? source-url))))))
+
+(define (latest-release guix-package)
+  "Return an <upstream-source> for the latest release of GUIX-PACKAGE."
+  (let* ((gem-name (guix-package->gem-name
+                    (specification->package guix-package)))
+         (metadata (rubygems-fetch gem-name))
+         (version (assoc-ref metadata "version"))
+         (url (rubygems-uri gem-name version)))
+    (upstream-source
+     (package guix-package)
+     (version version)
+     (urls (list url)))))
+
+(define %gem-updater
+  (upstream-updater
+   (name 'gem)
+   (description "Updater for RubyGem packages")
+   (pred gem-package?)
+   (latest latest-release)))
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index a5834d1..b2274ff 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org>
 ;;; Copyright © 2014 Eric Bavier <bavier@member.fsf.org>
 ;;; Copyright © 2015 Alex Kost <alezost@gmail.com>
+;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -34,6 +35,7 @@
                 #:select (%gnu-updater %gnome-updater))
   #:use-module (guix import elpa)
   #:use-module (guix import cran)
+  #:use-module (guix import gem)
   #:use-module (guix gnupg)
   #:use-module (gnu packages)
   #:use-module ((gnu packages commencement) #:select (%final-inputs))
@@ -195,7 +197,8 @@ unavailable optional dependencies such as Guile-JSON."
                  %gnome-updater
                  %elpa-updater
                  %cran-updater
-                 ((guix import pypi) => %pypi-updater)))
+                 ((guix import pypi) => %pypi-updater)
+                 %gem-updater))
 
 (define (lookup-updater name)
   "Return the updater called NAME."
-- 
2.6.3


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-01-08 18:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-01  8:27 [PATCH] Add rubygems updater Ben Woodcroft
2016-01-01  9:28 ` Pjotr Prins
2016-01-01 11:18   ` Ben Woodcroft
2016-01-01 11:42     ` Pjotr Prins
2016-01-01 18:17     ` Ludovic Courtès
2016-01-02  0:11       ` Ben Woodcroft
2016-01-02 20:54         ` Ludovic Courtès
2016-01-03  0:50           ` Ben Woodcroft
2016-01-03 14:06             ` Ludovic Courtès
2016-01-05 13:57               ` Ben Woodcroft
2016-01-05 14:56                 ` Ricardo Wurmus
2016-01-08 18:18                 ` Ludovic Courtès
2016-01-02  3:43       ` Pjotr Prins

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).