pharo: 5.0 -> 6.0

Create a new set of VM packages to keep up with changes in the
upstream Pharo project.
This commit is contained in:
Luke Gorrie
2017-06-28 09:26:59 +00:00
parent 71e495e10f
commit fdb90f6df7
9 changed files with 392 additions and 91 deletions
+80 -53
View File
@@ -1,76 +1,103 @@
{ stdenv, fetchurl, cmake, bash, unzip, glibc, openssl, gcc, mesa, freetype, xorg, alsaLib, cairo, makeDesktopItem }:
{ stdenv, fetchurl, bash, unzip, glibc, openssl, gcc, mesa, freetype, xorg, alsaLib, cairo, libuuid, autoreconfHook, gcc6, ... }:
{ name, src, binary-basename, ... }:
{ name, src, version, source-date, source-url, ... }:
# Build the Pharo VM
stdenv.mkDerivation rec {
inherit name src;
inherit name src binary-basename;
# Command line invocation name.
# Distinct name for 64-bit builds because they only work with 64-bit images.
cmd = if stdenv.is64bit then "pharo-spur64" else "pharo-spur";
# Choose desired VM sources. Separate for 32-bit and 64-bit VM.
# (Could extent to building more VM variants e.g. SpurV3, Sista, etc.)
vm = if stdenv.is64bit then "spur64src" else "spursrc";
# Choose target platform name in the format used by the vm.
flavor =
if stdenv.isLinux && stdenv.isi686 then "linux32x86"
else if stdenv.isLinux && stdenv.isx86_64 then "linux64x64"
else if stdenv.isDarwin && stdenv.isi686 then "macos32x86"
else if stdenv.isDarwin && stdenv.isx86_64 then "macos64x64"
else abort "Unsupported platform: only Linux/Darwin x86/x64 are supported.";
# Shared data (for the sources file)
pharo-share = import ./share.nix { inherit stdenv fetchurl unzip; };
desktopItem = makeDesktopItem {
inherit name;
desktopName = "Pharo VM";
genericName = "Pharo Virtual Machine";
exec = "${binary-basename}-x %F";
icon = "pharo";
terminal = "false";
type="Application";
startupNotify = "false";
categories = "Development;";
mimeType = "application/x-pharo-image";
};
# Note: -fPIC causes the VM to segfault.
hardeningDisable = [ "format" "pic" ];
# Building
# Regenerate the configure script.
# Unnecessary? But the build breaks without this.
autoreconfPhase = ''
(cd opensmalltalk-vm/platforms/unix/config && make)
'';
# Configure with options modeled on the 'mvm' build script from the vm.
configureScript = "platforms/unix/config/configure";
configureFlags = [ "--without-npsqueak"
"--with-vmversion=5.0"
"--with-src=${vm}" ];
CFLAGS = "-msse2 -D_GNU_SOURCE -DCOGMTVM=0 -g -O2 -DNDEBUG -DDEBUGVM=0";
LDFLAGS = "-Wl,-z,now";
# VM sources require some patching before build.
prePatch = ''
patchShebangs opensmalltalk-vm/build.${flavor}
# Fix hard-coded path to /bin/rm in a script
sed -i -e 's:/bin/rm:rm:' opensmalltalk-vm/platforms/unix/config/mkmf
# Fill in mandatory metadata about the VM source version
sed -i -e 's!\$Date\$!$Date: ${source-date} $!' \
-e 's!\$Rev\$!$Rev: ${version} $!' \
-e 's!\$URL\$!$URL: ${source-url} $!' \
opensmalltalk-vm/platforms/Cross/vm/sqSCCSVersion.h
'';
# Note: --with-vmcfg configure option is broken so copy plugin specs to ./
preConfigure = ''
cd build/
cd opensmalltalk-vm
cp build.${flavor}/pharo.cog.spur/plugins.{ext,int} .
'';
resources = ./resources;
# (No special build phase.)
installPhase = ''
mkdir -p "$prefix/lib/$name"
# Install in working directory and then copy
make install-squeak install-plugins prefix=$(pwd)/products
cd ../../results
# Copy binaries & rename from 'squeak' to 'pharo'
mkdir -p $out
cp products/lib/squeak/5.0-*/squeak $out/pharo
mv vm-display-null vm-display-null.so
mv vm-display-X11 vm-display-X11.so
mv vm-sound-null vm-sound-null.so
mv vm-sound-ALSA vm-sound-ALSA.so
mv pharo pharo-vm
cp -r products/lib/squeak/5.0-*/*.so $out
ln -s "${pharo-share}/lib/"*.sources $out
cp * "$prefix/lib/$name"
# Create a shell script to run the VM in the proper environment.
#
# These wrapper puts all relevant libraries into the
# LD_LIBRARY_PATH. This is important because various C code in the VM
# and Smalltalk code in the image will search for them there.
mkdir -p $out/bin
chmod u+w $out/bin
mkdir -p "$prefix/share/applications"
cp "${desktopItem}/share/applications/"* $prefix/share/applications
# Note: include ELF rpath in LD_LIBRARY_PATH for finding libc.
libs=$out:$(patchelf --print-rpath $out/pharo):${cairo}/lib:${mesa}/lib:${freetype}/lib:${openssl}/lib:${libuuid}/lib:${alsaLib}/lib:${xorg.libICE}/lib:${xorg.libSM}/lib
mkdir $prefix/bin
chmod u+w $prefix/bin
cat > $prefix/bin/${binary-basename}-x <<EOF
#!${bash}/bin/bash
# disable parameter expansion to forward all arguments unprocessed to the VM
# Create the script
cat > $out/bin/${cmd} <<EOF
#!/bin/sh
set -f
exec $prefix/lib/$name/pharo-vm "\$@"
LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:$libs" exec $out/pharo "\$@"
EOF
cat > $prefix/bin/${binary-basename}-nox <<EOF
#!${bash}/bin/bash
# disable parameter expansion to forward all arguments unprocessed to the VM
set -f
exec $prefix/lib/$name/pharo-vm -vm-display-null "\$@"
EOF
chmod +x $prefix/bin/${binary-basename}-x $prefix/bin/${binary-basename}-nox
ln -s "${pharo-share}/lib/"*.sources $prefix/lib/$name
chmod +x $prefix/bin/${cmd}
'';
buildInputs = [ bash unzip cmake glibc openssl gcc mesa freetype xorg.libX11 xorg.libICE xorg.libSM alsaLib cairo pharo-share ];
enableParallelBuilding = true;
# Note: Force gcc6 because gcc5 crashes when compiling the VM.
buildInputs = [ bash unzip glibc openssl gcc6 mesa freetype xorg.libX11 xorg.libICE xorg.libSM alsaLib cairo pharo-share libuuid autoreconfHook ];
meta = {
description = "Clean and innovative Smalltalk-inspired environment";
@@ -89,7 +116,7 @@ stdenv.mkDerivation rec {
'';
homepage = http://pharo.org;
license = stdenv.lib.licenses.mit;
maintainers = [ ];
maintainers = [ stdenv.lib.maintainers.lukego ];
# Pharo VM sources are packaged separately for darwin (OS X)
platforms = with stdenv.lib;
intersectLists