aboutsummaryrefslogtreecommitdiff
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2016 Alex Sassmannshausen <alex@pompo.co>
;;; Copyright © 2020, 2023 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
;;; GNU Guix is free software; you can redistribute it and/or modify it
;;; under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 3 of the License, or (at
;;; your option) any later version.
;;;
;;; GNU Guix is distributed in the hope that it will be useful, but
;;; WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.

(define-module (test-cpan)
  #:use-module (guix import cpan)
  #:use-module (guix base32)
  #:use-module (guix upstream)
  #:use-module ((guix download) #:select (url-fetch))
  #:use-module (gcrypt hash)
  #:use-module (guix tests)
  #:use-module (guix tests http)
  #:use-module ((guix store) #:select (%graft?))
  #:use-module (srfi srfi-64)
  #:use-module (web client)
  #:use-module (ice-9 match))

;; Globally disable grafts because they can trigger early builds.
(%graft? #f)

(define test-json
  "{
  \"metadata\" : {
    \"name\" : \"Foo-Bar\",
    \"version\" : \"0.1\"
  }
  \"name\" : \"Foo-Bar-0.1\",
  \"distribution\" : \"Foo-Bar\",
  \"license\" : [
    \"perl_5\"
  ],
  \"dependency\": [
     { \"relationship\": \"requires\",
       \"phase\": \"runtime\",
       \"version\": \"1.05\",
       \"module\": \"Test::Script\"
     }
  ],
  \"abstract\" : \"Fizzle Fuzz\",
  \"download_url\" : \"http://example.com/Foo-Bar-0.1.tar.gz\",
  \"author\" : \"Guix\",
  \"version\" : \"0.1\"
}")

(define test-source
  "foobar")

;; Avoid collisions with other tests.
(%http-server-port 10400)

(test-begin "cpan")

(test-assert "cpan->guix-package"
  (with-http-server `((200 ,test-json)
                      (200 ,test-source)
                      (200 "{ \"distribution\" : \"Test-Script\" }"))
    (parameterize ((%metacpan-base-url (%local-url))
                   (current-http-proxy (%local-url)))
      (match (cpan->guix-package "Foo::Bar")
        (`(package
            (name "perl-foo-bar")
            (version "0.1")
            (source (origin
                      (method url-fetch)
                      (uri (string-append "http://example.com/Foo-Bar-"
                                          version ".tar.gz"))
                      (sha256
                       (base32 ,(? string? hash)))))
            (build-system perl-build-system)
            (propagated-inputs (list perl-test-script))
            (home-page "https://metacpan.org/release/Foo-Bar")
            (synopsis "Fizzle Fuzz")
            (description fill-in-yourself!)
            (license perl-license))
         (string=? (bytevector->nix-base32-string
                    (call-with-input-string test-source port-sha256))
                   hash))
        (x
         (pk 'fail x #f))))))

(test-equal "package-latest-release"
  (list '("http://example.com/Foo-Bar-0.1.tar.gz")
        #f
        (list (upstream-input
               (name "Test-Script")
               (downstream-name "perl-test-script")
               (type 'propagated))))
  (with-http-server `((200 ,test-json)
                      (200 "{ \"distribution\" : \"Test-Script\" }")
                      (200 ,test-source))
    (parameterize ((%metacpan-base-url (%local-url))
                   (current-http-proxy (%local-url)))
      (define source
        (package-latest-release
         (dummy-package "perl-test-script"
           (version "0.0.0")
           (source (dummy-origin
                    (method url-fetch)
                    (uri "mirror://cpan/Foo-Bar-0.0.0.tgz"))))
         (list %cpan-updater)))

      (list (upstream-source-urls source)
            (upstream-source-signature-urls source)
            (upstream-source-inputs source)))))

(test-equal "metacpan-url->mirror-url, http"
  "mirror://cpan/authors/id/T/TE/TEST/Foo-Bar-0.1.tar.gz"
  (metacpan-url->mirror-url
   "http://cpan.metacpan.org/authors/id/T/TE/TEST/Foo-Bar-0.1.tar.gz"))

(test-equal "metacpan-url->mirror-url, https"
  "mirror://cpan/authors/id/T/TE/TEST/Foo-Bar-0.1.tar.gz"
  (metacpan-url->mirror-url
   "https://cpan.metacpan.org/authors/id/T/TE/TEST/Foo-Bar-0.1.tar.gz"))

(test-end "cpan")
lo.scm (skribilo)[arguments]: Likewise. * gnu/packages/smalltalk.scm (smalltalk)[arguments]: Likewise. * gnu/packages/suckless.scm (dmenu, slock)[arguments]: Likewise. * gnu/packages/tcl.scm (expect)[arguments]: Likewise. * gnu/packages/telephony.scm (commoncpp)[arguments]: Likewise. * gnu/packages/textutils.scm (recode, libgtextutils)[arguments]: Likewise. * gnu/packages/time.scm (time)[arguments]: Likewise. * gnu/packages/tor.scm (privoxy)[arguments]: Likewise. * gnu/packages/uucp.scm (uucp)[arguments]: Likewise. * gnu/packages/video.scm (libdvdnav-4)[arguments]: Likewise. * gnu/packages/web-browsers.scm (lynx)[arguments]: Likewise. * gnu/packages/web.scm (tinyproxy)[arguments]: Likewise. * gnu/packages/wicd.scm (wicd)[arguments]: Likewise. * gnu/packages/wm.scm (bspwm)[arguments]: Likewise. * gnu/packages/xdisorg.scm (sxhkd, xcape)[arguments]: Likewise. * gnu/packages/xfce.scm (xfconf)[arguments]: Likewise. * gnu/packages/xfig.scm (transfig)[arguments]: Likewise. * gnu/packages/xorg.scm (imake)[arguments]: Likewise. Kei Kebreau 2017-04-22gnu: Add the Hurd....* gnu/packages/hurd.scm (hurd): New variable. * gnu/packages/patches/hurd-fix-eth-multiplexer-dependency.patch: New file. * gnu/local.mk (dist_patch_DATA): Add it. Manolis Ragkousis 2017-04-22gnu: hurd: Add hurd-source-url procedure....* gnu/packages/hurd.scm (hurd-source-url): New procedure. (hurd-headers)[source]: Adjust accordingly. Manolis Ragkousis 2017-03-30gnu: Use HTTPS for almost all gnu.org HOME-PAGEs....All HTTP gnu.org (and supported subdomain) HOME-PAGEs changed to HTTPS. Tobias Geerinckx-Rice 2017-03-19gnu: Add GNU Mach....* gnu/packages/hurd.scm (gnumach): New variable. Co-authored-by: Rene Saavedra <rennes@openmailbox.org> Co-authored-by: Ludovic Courtès <ludo@gnu.org> Manolis Ragkousis 2017-02-16gnu: hurd: Add gnumach-source-url procedure....* gnu/packages/hurd.scm (gnumach-source-url): New procedure. (gnumach-headers)[source]: Adjust accordingly. Manolis Ragkousis 2017-01-03gnu: Use hurd-triplet? to check if GNU/Hurd....* gnu/packages/make-bootstrap.scm (hurd-triplet?): Move it from here.. * gnu/packages/hurd.scm: ..to here. New exported procedure. * gnu/packages/commencement.scm (glibc-final-with-bootstrap-bash) [arguments]: Replace string-match. [inputs]: Same. * gnu/packages/cross-base.scm (cross-libc)[native-inputs]: Same. Manolis Ragkousis 2016-12-19gnu: hurd-headers: Update to 0.9....* gnu/packages/hurd.scm (hurd-headers): Update to version 0.9. Manolis Ragkousis 2016-12-19gnu: mig: Update to 1.8....* gnu/packages/hurd.scm (mig): Update to version 1.8. Manolis Ragkousis 2016-12-19gnu: gnumach-headers: Update to 1.8....* gnu/packages/hurd.scm (gnumach-headers): Update to version 1.8. Manolis Ragkousis 2016-06-07gnu: hurd: Move configure flags from "hurd-minimal" to "hurd-headers"....* gnu/packages/hurd.scm (hurd-minimal)[arguments]: Move configure-flags from here.. (hurd-headers)[arguments]: ..to here. Manolis Ragkousis 2016-06-07gnu: hurd: Remove inputs no longer needed....* gnu/packages/hurd.scm (hurd-headers, hurd-minimal)[native-inputs]: Remove "autoconf". Manolis Ragkousis 2016-06-07gnu: hurd-headers: Use "--host=i586-pc-gnu" only when not cross-building....* gnu/packages/hurd.scm (hurd-headers)[arguments]: Use "--host=i586-pc-gnu" only when not cross-building. Manolis Ragkousis 2016-06-07gnu: gnumach-headers: Use "--build=i586-pc-gnu" only when not cross-building....* gnu/packages/hurd.scm (gnumach-headers)[arguments]: Use "--build=i586-pc-gnu" only when not cross-building. Manolis Ragkousis 2016-05-26gnu: hurd: Add hurd-core-headers package....* gnu/packages/hurd.scm (hurd-core-headers): New variable. Manolis Ragkousis 2016-05-18gnu: hurd-headers: Update to 0.8....* gnu/packages/hurd.scm (hurd-headers): Update to version 0.8. Manolis Ragkousis 2016-05-18gnu: mig: Update to 1.7....* gnu/packages/hurd.scm (mig): Update to version 1.7. Manolis Ragkousis 2016-05-18gnu: gnumach-headers: Update to 1.7....* gnu/packages/hurd.scm (gnumach-headers): Update to version 1.7. Manolis Ragkousis 2015-11-13gnu: Adjust formatting as recommended by 'guix lint'....* gnu/packages/aidc.scm (barcode, qrencode), gnu/packages/bash.scm (bash, bash-completion), gnu/packages/busybox.scm (busybox), gnu/packages/cdrom.scm (cdparanoia), gnu/packages/cmake.scm (cmake), gnu/packages/conkeror.scm (conkeror), gnu/packages/cook.scm (cook), gnu/packages/curl.scm (curl), gnu/packages/docbook.scm (docbook-xsl), gnu/packages/enlightenment.scm (enlightenment), gnu/packages/games.scm (abbaye), gnu/packages/geeqie.scm (exiv2), gnu/packages/gimp.scm (gegl), gnu/packages/gl.scm (glu, freeglut, ftgl), gnu/packages/glib.scm (glib), gnu/packages/gnome.scm (orbit2, gconf, geocode-glib), gnu/packages/gstreamer.scm (gstreamer, gst-plugins-base), gnu/packages/linux.scm (util-linux), gnu/packages/lisp.scm (gcl, ecl), gnu/packages/maths.scm (gnuplot, hdf5), gnu/packages/ssh.scm (dropbear), gnu/packages/web.scm (json-c): Remove tabulations and trailing white spaces or reformat to fit within 80 columns. * gnu/packages/audio.scm (aubio), gnu/packages/emacs.scm (emacs-s), gnu/packages/engineering.scm (geda-gaf), gnu/packages/games.scm (dosbox), gnu/packages/gnome.scm (gusb), gnu/packages/gtk.scm (gtk+), gnu/packages/guile.scm (guile-wisp), gnu/packages/hurd.scm (hurd-headers), gnu/packages/wm.scm (i3-wm): Adjust synopsis or description. 宋文武 2015-11-01gnu: hurd-headers: Update to 0.7...* gnu/packages/hurd.scm (hurd-headers): Update to version 0.7. Manolis Ragkousis 2015-11-01gnu: mig: Update to 1.6...* gnu/packages/hurd.scm (mig): Update to version 1.6. Manolis Ragkousis 2015-11-01gnu: gnumach-headers: Update to 1.6...* gnu/packages/hurd.scm (gnumach-headers): Update to version 1.6. Manolis Ragkousis 2015-09-04gnu: base: Add glibc-hurd and hurd-minimal....* gnu/packages/base.scm (glibc/hurd, glibc/hurd-headers): New variables. * gnu/packages/hurd.scm (hurd-minimal): New variable. * gnu/packages/patches/glibc-hurd-extern-inline.patch: New file. * gnu/packages/patches/libpthread-glibc-preparation.patch: New file. * gnu-system.am (dist_patch_DATA): Add them. Co-authored-by: Ludovic Courtès <ludo@gnu.org> Co-authored-by: Mark H Weaver <mhw@netris.org> Manolis Ragkousis 2015-09-04gnu: hurd: Add flex as an input to mig....* gnu/packages/hurd (mig): Add flex as an input. Manolis Ragkousis 2015-04-16gnu: mig: Update to 1.5...* gnu/packages/hurd.scm (mig): Update to version 1.5. Manolis Ragkousis 2015-04-16gnu: hurd-headers: Update to 0.6...* gnu/packages/hurd.scm (hurd-headers): Update to version 0.6. Manolis Ragkousis 2015-04-16gnu: gnumach-headers: Update to 1.5...* gnu/packages/hurd.scm (gnumach-headers): Update to version 1.5. Manolis Ragkousis 2014-10-26gnu: Some cleanup based on lint checkers....* gnu/packages/admin.scm, gnu/packages/aidc.scm, gnu/packages/algebra.scm, gnu/packages/apr.scm, gnu/packages/avahi.scm, gnu/packages/backup.scm, gnu/packages/base.scm, gnu/packages/calcurse.scm, gnu/packages/cdrom.scm, gnu/packages/check.scm, gnu/packages/compression.scm, gnu/packages/cook.scm, gnu/packages/crypto.scm, gnu/packages/cryptsetup.scm, gnu/packages/curl.scm, gnu/packages/cyrus-sasl.scm, gnu/packages/databases.scm, gnu/packages/doxygen.scm, gnu/packages/dwm.scm, gnu/packages/elf.scm, gnu/packages/emacs.scm, gnu/packages/feh.scm, gnu/packages/file.scm, gnu/packages/fish.scm, gnu/packages/flex.scm, gnu/packages/fltk.scm, gnu/packages/fontutils.scm, gnu/packages/games.scm, gnu/packages/gcal.scm, gnu/packages/gcc.scm, gnu/packages/geeqie.scm, gnu/packages/ghostscript.scm, gnu/packages/gimp.scm, gnu/packages/gl.scm, gnu/packages/glib.scm, gnu/packages/gnome.scm, gnu/packages/gnunet.scm, gnu/packages/gnupg.scm, gnu/packages/gperf.scm, gnu/packages/grub.scm, gnu/packages/gsasl.scm, gnu/packages/gtk.scm, gnu/packages/guile-wm.scm, gnu/packages/guile.scm, gnu/packages/hurd.scm, gnu/packages/icu4c.scm, gnu/packages/image.scm, gnu/packages/imagemagick.scm, gnu/packages/irssi.scm, gnu/packages/kde.scm, gnu/packages/libdaemon.scm, gnu/packages/libevent.scm, gnu/packages/libidn.scm, gnu/packages/libusb.scm, gnu/packages/linux.scm, gnu/packages/lout.scm, gnu/packages/lsh.scm, gnu/packages/lsof.scm, gnu/packages/lua.scm, gnu/packages/maths.scm, gnu/packages/mcrypt.scm, gnu/packages/mp3.scm, gnu/packages/netpbm.scm, gnu/packages/noweb.scm, gnu/packages/ocaml.scm, gnu/packages/openssl.scm, gnu/packages/pcre.scm, gnu/packages/pdf.scm, gnu/packages/pkg-config.scm, gnu/packages/pretty-print.scm, gnu/packages/python.scm, gnu/packages/qt.scm, gnu/packages/rsync.scm, gnu/packages/scheme.scm, gnu/packages/scrot.scm, gnu/packages/sdl.scm, gnu/packages/skribilo.scm, gnu/packages/ssh.scm, gnu/packages/stalonetray.scm, gnu/packages/tcl.scm, gnu/packages/tcsh.scm, gnu/packages/telephony.scm, gnu/packages/texlive.scm, gnu/packages/tor.scm, gnu/packages/valgrind.scm, gnu/packages/version-control.scm, gnu/packages/vim.scm, gnu/packages/vpn.scm, gnu/packages/w3m.scm, gnu/packages/web.scm, gnu/packages/wordnet.scm, gnu/packages/xiph.scm, gnu/packages/xml.scm, gnu/packages/xorg.scm, gnu/packages/zile.scm, gnu/packages/zip.scm, gnu/packages/zsh.scm [synopsis, description]: Adjust according to lint checkers. * gnu/packages/fltk.scm (fltk)[source]: Wrap long line in uri. * /gnu/packages/xiph.scm (libogg, libtheora, vorbis-tools)[source]: Same. Eric Bavier 2014-09-28gnu: hurd-headers: Use --build instead of --host....* gnu/packages/hurd.scm (hurd-headers): Replace '--host' with '--build'. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Manolis Ragkousis 2014-06-02Revert "gnu: hurd: Add Hurd Minimal."...This reverts commit bc046a94dec2afadbc1ee3957f13098a8d8b393c, which referred to uncommitted things ('glibc/hurd-headers'.) Ludovic Courtès 2014-06-01gnu: hurd: Add Hurd Minimal....* gnu/packages/hurd.scm (hurd-minimal): New variable. * gnu/packages/patches/hurd-minimal.patch: New patch. * gnu-system.am (dist_patch_DATA): Add it. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Manolis Ragkousis 2014-03-01gnu: hurd: Add Hurd headers....* gnu/packages/hurd.scm (hurd-headers): New variable. Co-authored-by: Ludovic Courtès <ludo@gnu.org> Signed-off-by: Ludovic Courtès <ludo@gnu.org> Manolis Ragkousis 2014-02-20gnu: hurd: Add MiG....* gnu/packages/hurd.scm (mig): New variable. Co-authored-by: Ludovic Courtès <ludo@gnu.org> Signed-off-by: Ludovic Courtès <ludo@gnu.org> Manolis Ragkousis 2014-02-16gnu: Add GNU Mach headers....* gnu/packages/hurd.scm: New file * gnu-system.am (GNU_SYSTEM_MODULES): Add hurd.scm Co-authored-by: Ludovic Courtès <ludo@gnu.org> Signed-off-by: Ludovic Courtès <ludo@gnu.org> Manolis Ragkousis