unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#36033] Add Smalltalk Pharo VM
@ 2019-05-31 19:46 Brian Woodcox
  2019-05-31 23:30 ` Brian Woodcox
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Brian Woodcox @ 2019-05-31 19:46 UTC (permalink / raw)
  To: 36033

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

Hello,

I have added the Pharo Smalltalk VM package with this patch.

After installing this package, a user can launch an image by executing pharos-vm in the directory that contains the pharos-vm.

To keep things consistent with the current Pharo release, I decided to use the sdl2@2.0.7 and libgit2@0.25.1.  If someone feels I should use the latest releases of these packages, I can submit a new patch.

Because of the way Pharo constructs the version and commit date for use internally in the Pharo VM, it is necessary to add this information to the package i.e. commit-info.

This is my first package, so go easy on me. :)

Cheers!


[-- Attachment #2: 0001-Add-pharo-vm-package.patch --]
[-- Type: application/octet-stream, Size: 11947 bytes --]

From 49683e04e51cd904571008fa7979a3f58ae0134c Mon Sep 17 00:00:00 2001
From: "Brian C. Woodcox" <bw@InSkyData.com>
Date: Fri, 31 May 2019 13:14:54 -0600
Subject: [PATCH] Add pharo-vm package

---
 gnu/packages/smalltalk.scm | 206 +++++++++++++++++++++++++++++++++++++
 1 file changed, 206 insertions(+)

diff --git a/gnu/packages/smalltalk.scm b/gnu/packages/smalltalk.scm
index 9b36d83a80..f46cdd229e 100644
--- a/gnu/packages/smalltalk.scm
+++ b/gnu/packages/smalltalk.scm
@@ -4,6 +4,7 @@
 ;;; Copyright © 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr>
 ;;; Copyright © 2016 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2018 Tobias Geerinckx-Rice <me@tobias.gr>
+;;; Copyright © 2019 Brian Woodcox <bw@inskydata.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -26,18 +27,27 @@
   #:use-module (guix download)
   #:use-module (guix build-system cmake)
   #:use-module (guix build-system gnu)
+  #:use-module (guix git-download)
+  #:use-module (guix utils)
   #:use-module (gnu packages audio)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages curl)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages gl)
   #:use-module (gnu packages glib)
+  #:use-module (gnu packages gtk)
   #:use-module (gnu packages libffi)
   #:use-module (gnu packages libsigsegv)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages pulseaudio)
+  #:use-module (gnu packages python)
+  #:use-module (gnu packages sdl)
+  #:use-module (gnu packages ssh)
+  #:use-module (gnu packages tls)
+  #:use-module (gnu packages version-control)
   #:use-module (gnu packages xorg))
 
 (define-public smalltalk
@@ -151,3 +161,199 @@ also includes a customisable framework for creating dynamic HTTP servers and
 interactively extensible Web sites.")
     (home-page "http://www.squeakvm.org")
     (license license:x11)))
+
+(define sdl2-for-pharo-vm
+  (package
+   (inherit sdl2)
+   (version "2.0.7")
+   (source (origin
+            (method url-fetch)
+            (uri (string-append "http://www.libsdl.org/release/SDL2-" version ".tar.gz"))
+           (sha256
+            (base32
+             "0pjdpxla5kh1w1b0shxrx97a116vyy31njxi0jhyvqhk8d6cfdgf"))))))
+
+(define libgit2-for-pharo-vm
+  (package
+   (name "libgit2")
+   (version "0.25.1")
+   (source (origin
+            (method url-fetch)
+            (uri (string-append "https://github.com/libgit2/libgit2/"
+                                "archive/v" version ".tar.gz"))
+            (file-name (string-append name "-" version ".tar.gz"))
+            (sha256
+             (base32
+              "0ywcxw1mwd56c8qc14hbx31bf198gxck3nja3laxyglv7l57qp26"))))
+   (build-system cmake-build-system)
+   (arguments
+    `(#:phases
+      (modify-phases %standard-phases
+                     (add-after 'unpack 'fix-hardcoded-paths
+                                (lambda _
+                                  (substitute* "tests/repo/init.c"
+                                               (("#!/bin/sh") (string-append "#!" (which "sh"))))
+                                  (substitute* "tests/clar/fs.h"
+                                               (("/bin/cp") (which "cp"))
+                                               (("/bin/rm") (which "rm")))
+                                  #t))
+                     ;; Run checks more verbosely.
+                     (replace 'check
+                              (lambda _ (zero? (system* "./libgit2_clar" "-v" "-Q")))))))
+           (inputs
+            `(("libssh2" ,libssh2)
+              ("libcurl" ,curl)
+              ("python" ,python)
+              ("openssl" ,openssl)))
+           (native-inputs
+            `(("pkg-config" ,pkg-config)))
+           (home-page "http://libgit2.github.com/")
+           (synopsis "Library providing Git core methods")
+           (description
+            "Libgit2 is a portable, pure C implementation of the Git core methods
+provided as a re-entrant linkable library with a solid API, allowing you to
+write native speed custom Git applications in any language with bindings.")
+           (license license:gpl2)))
+
+(define %commit "5a38b3483dc5c82c7ecc85a590fdf1b095377a1f")
+
+(define %pharo-vm-version "5.0")
+
+(define %url "https://github.com/OpenSmalltalk/opensmalltalk-vm.git")
+
+;; Git commit info i.e. version and commit date
+;; When a new version of the pharo vm is released, the values are contained in
+;; in the payload of the git commit.
+
+(define commit-info '("201901172323" . "Fri Jan 18 00:23:50 2019 +0100"))
+
+(define %version (string-append %pharo-vm-version "-" (car commit-info)))
+
+(define-public pharo-vm
+  (package
+    (name "pharo-vm")
+    (version %version)
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url %url)
+                    (commit %commit)))
+              (file-name (string-append name "-" %commit "-checkout"))
+              (sha256
+               (base32
+                "0idmviam289aqd8ldh8yv38av1b20ifas4n0jjx5vp3hrphqaav5"))))
+    (build-system gnu-build-system)
+    (native-inputs `(("python" ,python)))
+    (inputs
+     `(("mesa" ,mesa)
+       ("cairo" ,cairo)
+       ("freetype" ,freetype)
+       ("git" ,git)
+       ("libcurl" ,curl)
+       ("guile-curl", guile-curl)
+       ("openssl" ,openssl)
+       ("libssh2" ,libssh2)
+       ("libgit2" ,libgit2-for-pharo-vm)
+       ("sdl2" ,sdl2-for-pharo-vm)))
+    (arguments
+     `(#:tests? #f ;; no tests available
+       #:configure-flags (list "--without-npsqueak"
+                               (string-append """--with-vmversion=""" ,%pharo-vm-version)
+                               "--with-src=spur64src"
+                               "TARGET_ARCH=-m64"
+                               "CFLAGS=-g -O2 -DNDEBUG -DDEBUGVM=0 -DPharoVM -msse2 -DCOGMTVM=0"
+                               (string-append "LDFLAGS=-Wl,-rpath="
+                                              (assoc-ref %outputs "out")
+                                              "/lib"))
+       #:make-flags (list (string-append "prefix=" (assoc-ref %outputs "out")))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'patch-source-shebangs 'chdir
+           (lambda _
+             (chdir "build.linux64x64/pharo.cog.spur/build") #t))
+         (add-before 'configure 'pre-configure
+           (lambda _
+             (define pharo-version (string-append "$Rev: " ,(car commit-info) " $"))
+             (define pharo-date (string-append "$Date: " ,(cdr commit-info) " $"))
+             (define pharo-url (string-append "$URL: " ,%url " $"))
+             (define pharo-hash (string-append "$CommitHash: " (string-take ,%commit 8)  " $"))
+             (copy-file "../plugins.int" "plugins.int")
+             (copy-file "../plugins.ext" "plugins.ext")
+             ;; Fix version info
+             (substitute* '("../../../platforms/Cross/plugins/sqPluginsSCCSVersion.h"
+                            "../../../platforms/Cross/vm/sqSCCSVersion.h")
+               (("\\$Rev\\$") pharo-version)
+               (("\\$Date\\$") pharo-date)
+               (("\\$URL\\$") pharo-url)
+               (("\\$CommitHash\\$") pharo-hash))
+             ;; Fix hard coded paths
+             (substitute* '("../../../platforms/unix/config/squeak.sh.in"
+                            "../../../platforms/unix/config/bin.squeak.sh.in")
+               (("/usr/bin/dirname") (which "dirname"))
+               (("/usr/bin/ldd") (which "ldd"))
+               (("/bin/fgrep") (which "fgrep")))
+             (substitute* '("../../../platforms/unix/config/configure")
+               (("SHELL=\\$\\{CONFIG_SHELL-/bin/sh\\}")
+                (string-append "SHELL=" (which "sh"))))
+             #t))
+         (replace 'configure
+           (lambda* (#:key outputs (configure-flags '()) #:allow-other-keys)
+             (substitute* '("../../../platforms/unix/plugins/FT2Plugin/Makefile.in")
+               (("-I/usr/include/freetype2")
+                (string-append "-I" (assoc-ref %build-inputs "freetype")
+                               "/include/freetype2")))
+             (apply invoke "../../../platforms/unix/config/configure"
+                    (string-append "--prefix=" (assoc-ref outputs "out")) configure-flags)
+             #t))
+         (add-after 'install 'post-install
+           (lambda* (#:key outputs #:allow-other-keys)
+             ;; Currently have to hard code version
+             (define pharo-version ,%version)
+             (let ((out (assoc-ref outputs "out")))
+               ;; rename and replace in file with pharo
+               (let ((src-file (string-append out "/squeak"))
+                     (dst-file (string-append out "/pharo")))
+                 (unless (file-exists? dst-file)
+                   (rename-file src-file dst-file)
+                   (substitute* dst-file (("squeak") "pharo"))))
+               ;; rename and replace in file with pharo
+               (let ((src-file (string-append out "/bin/squeak"))
+                     (dst-file (string-append out "/bin/pharo")))
+                 (unless (file-exists? dst-file)
+                   (rename-file src-file dst-file)
+                   (substitute* dst-file (("squeak") "pharo"))))
+               ;; rename executable file to pharo
+               (let ((src-file (string-append out "/lib/squeak/" pharo-version "/squeak"))
+                     (dst-file (string-append out "/lib/squeak/" pharo-version "/pharo")))
+                 (unless (file-exists? dst-file)
+                   (rename-file src-file dst-file)))
+               ;; rename folder to pharo
+               (let ((src-folder (string-append out "/lib/squeak"))
+                     (dst-folder (string-append out "/lib/pharo")))
+                 (unless (file-exists? dst-folder)
+                   (copy-recursively (string-append src-folder "/" pharo-version)
+                                     (string-append dst-folder "/" pharo-version)
+                                     #:keep-mtime? #t)
+                   (delete-file-recursively src-folder)))
+               ;; remove folders
+               (let ((src-folder (string-append out "/doc")))
+                 (if (file-exists? src-folder)
+                     (delete-file-recursively src-folder)))
+               (let ((src-folder (string-append out "/share")))
+                 (if (file-exists? src-folder)
+                     (delete-file-recursively src-folder)))
+               ;; add symlinks
+               (symlink (string-append (assoc-ref %build-inputs "libgit2") "/lib/libgit2.so")
+                        (string-append out "/lib/pharo/" pharo-version "/libgit2.so"))
+               (symlink (string-append (assoc-ref %build-inputs "libssh2") "/lib/libssh2.so")
+                        (string-append out "/lib/pharo/" pharo-version "/libssh2.so"))
+               (symlink (string-append (assoc-ref %build-inputs "openssl") "/lib/libssl.so")
+                        (string-append out "/lib/pharo/" pharo-version "/libssl.so"))
+               (symlink (string-append (assoc-ref %build-inputs "freetype")"/lib/libfreetype.so.6")
+                        (string-append out "/lib/pharo/" pharo-version "/libfreetype.so.6")))
+             #t)))))
+    (home-page "https://github.com/OpenSmalltalk/opensmalltalk-vm")
+    (synopsis "Pharo Smalltalk virtual machine")
+    (description
+     "The virtual machine below the Pharo Smalltalk dialect")
+    (license license:expat)))
-- 
2.21.0


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

end of thread, other threads:[~2019-06-13  8:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-31 19:46 [bug#36033] Add Smalltalk Pharo VM Brian Woodcox
2019-05-31 23:30 ` Brian Woodcox
2019-05-31 23:33 ` Brian Woodcox
2019-06-01 13:23 ` Ludovic Courtès
2019-06-01 15:08   ` Brian Woodcox
2019-06-13  8:46     ` Ludovic Courtès

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).