3
0
Fork 0
forked from mirrors/nixpkgs

ruby: rewrite sup package

This commit is contained in:
Charles Strahan 2015-01-21 15:20:42 -05:00
parent 5f1622e95f
commit f52c32fcfc
10 changed files with 248 additions and 132 deletions

View file

@ -1,6 +1,8 @@
source "https://rubygems.org"
#gem "sup", "0.20.0"
#gem 'sup', '~> 0.20.0'
#gem 'gpgme'
gem 'gpgme', '2.0.7'
gem 'sup'
gem 'gpgme'
# Sup tries to `xapian-ruby` in its extconf instead of listing it as a
# dependency.
gem 'xapian-ruby', "~> 1.2.15"

View file

@ -1,12 +1,34 @@
GEM
remote: https://rubygems.org/
specs:
chronic (0.9.1)
gpgme (2.0.7)
mini_portile (>= 0.5.0, <= 0.6.0)
highline (1.6.21)
locale (2.1.0)
lockfile (2.1.3)
mime-types (1.25.1)
mini_portile (0.6.0)
ncursesw (1.4.9)
rmail-sup (1.0.1)
sup (0.20.0)
chronic (~> 0.9.1)
highline
locale (~> 2.0)
lockfile
mime-types (~> 1.0)
ncursesw (~> 1.4.0)
rmail-sup (~> 1.0.1)
trollop (>= 1.12)
unicode (~> 0.4.4)
trollop (2.1.1)
unicode (0.4.4.2)
xapian-ruby (1.2.19.1)
PLATFORMS
ruby
DEPENDENCIES
gpgme (= 2.0.7)
gpgme
sup
xapian-ruby (~> 1.2.15)

View file

@ -1,79 +1,52 @@
{ stdenv, fetchurl, ruby, rake, rubygems, makeWrapper, ncursesw_sup
, xapian_ruby, gpgme, libiconvOrEmpty, mime_types, chronic, trollop, lockfile
, gettext, iconv, locale, text, highline, rmail_sup, unicode, gnupg, which
, bundler, git }:
{ stdenv, lib, bundlerEnv, gpgme, ruby, ncurses, writeText, zlib, xapian, pkgconfig, which }:
stdenv.mkDerivation rec {
version = "0.18.0";
name = "sup-${version}";
bundlerEnv {
name = "sup-0.20.0";
meta = {
inherit ruby;
gemfile = ./Gemfile;
lockfile = ./Gemfile.lock;
gemset = ./gemset.nix;
fixes.gpgme = attrs: {
buildInputs = [ gpgme ];
};
fixes.ncursesw = attrs: {
buildInputs = [ ncurses ];
buildArgs = [
"--with-cflags=-I${ncurses}/include"
"--with-ldflags=-L${ncurses}/lib"
];
};
fixes.xapian-ruby = attrs: {
# use the system xapian
buildInputs = [ xapian pkgconfig zlib ];
postPatch = ''
cp ${./xapian-Rakefile} Rakefile
'';
preInstall = ''
export XAPIAN_CONFIG=${xapian}/bin/xapian-config
'';
};
fixes.sup = attrs: {
# prevent sup from trying to dynamically install `xapian-ruby`.
postPatch = ''
cp ${./mkrf_conf_xapian.rb} ext/mkrf_conf_xapian.rb
substituteInPlace lib/sup/crypto.rb \
--replace 'which gpg2' \
'${which}/bin/which gpg2'
'';
};
meta = with lib; {
description = "A curses threads-with-tags style email client";
homepage = http://supmua.org;
license = stdenv.lib.licenses.gpl2;
maintainers = with stdenv.lib.maintainers; [ lovek323 ];
platforms = stdenv.lib.platforms.unix;
broken = true;
license = with licenses; gpl2;
maintainers = with maintainers; [ cstrahan lovek323 ];
platforms = platforms.unix;
};
dontStrip = true;
src = fetchurl {
url = "https://github.com/sup-heliotrope/sup/archive/release-${version}.tar.gz";
sha256 = "1dhg0i2v0ddhwi32ih5lc56x00kbaikd2wdplgzlshq0nljr9xy0";
};
buildInputs =
[ rake ruby rubygems makeWrapper gpgme ncursesw_sup xapian_ruby
libiconvOrEmpty git ];
phases = [ "unpackPhase" "buildPhase" "installPhase" ];
buildPhase = ''
# the builder uses git to get a listing of the files
export EMAIL="nobody@in.here"
git init >/dev/null
git add .
git commit -m "message" >/dev/null
gem build sup.gemspec
'';
installPhase = ''
export HOME=$TMP/home; mkdir -pv "$HOME"
GEM_PATH="$GEM_PATH:$out/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${chronic}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${gettext}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${gpgme}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${highline}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${iconv}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${locale}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${lockfile}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${mime_types}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${ncursesw_sup}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${rmail_sup}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${text}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${trollop}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${unicode}/${ruby.gemPath}"
GEM_PATH="$GEM_PATH:${xapian_ruby}/${ruby.gemPath}"
# Don't install some dependencies -- we have already installed
# the dependencies but gem doesn't acknowledge this
gem install --no-verbose --install-dir "$out/${ruby.gemPath}" \
--bindir "$out/bin" --no-rdoc --no-ri sup-${version}.gem \
--ignore-dependencies >/dev/null
# specify ruby interpreter explicitly
sed -i '1 s|^.*$|#!${ruby}/bin/ruby|' bin/sup-sync-back-maildir
cp bin/sup-sync-back-maildir "$out/bin"
for prog in $out/bin/*; do
wrapProgram "$prog" --prefix GEM_PATH : "$GEM_PATH" --prefix PATH : "${gnupg}/bin:${which}/bin"
done
for prog in $out/gems/*/bin/*; do
[[ -e "$out/bin/$(basename $prog)" ]]
done
'';
}

View file

@ -1,7 +1,14 @@
{
gpgme = {
"chronic" = {
version = "0.9.1";
source = {
type = "gem";
sha256 = "0kspaxpfy7yvyk1lvpx31w852qfj8wb9z04mcj5bzi70ljb9awqk";
};
};
"gpgme" = {
version = "2.0.7";
src = {
source = {
type = "gem";
sha256 = "1p84zhiri2ihcld7py9mwc2kg5xs5da8fk11zhndrhmw05yvf5mr";
};
@ -9,11 +16,92 @@
"mini_portile"
];
};
mini_portile = {
"highline" = {
version = "1.6.21";
source = {
type = "gem";
sha256 = "06bml1fjsnrhd956wqq5k3w8cyd09rv1vixdpa3zzkl6xs72jdn1";
};
};
"locale" = {
version = "2.1.0";
source = {
type = "gem";
sha256 = "18bb0g24flq9dr8qv4j7pm7w9i2vmvmqrbmry95ibf1r1c4s60yj";
};
};
"lockfile" = {
version = "2.1.3";
source = {
type = "gem";
sha256 = "0dij3ijywylvfgrpi2i0k17f6w0wjhnjjw0k9030f54z56cz7jrr";
};
};
"mime-types" = {
version = "1.25.1";
source = {
type = "gem";
sha256 = "0mhzsanmnzdshaba7gmsjwnv168r1yj8y0flzw88frw1cickrvw8";
};
};
"mini_portile" = {
version = "0.6.0";
src = {
source = {
type = "gem";
sha256 = "09kcn4g63xrdirgwxgjikqg976rr723bkc9bxfr29pk22cj3wavn";
};
};
"ncursesw" = {
version = "1.4.9";
source = {
type = "gem";
sha256 = "154cls3b237imdbhih7rni5p85nw6mpbpkzdw08jxzvqaml7q093";
};
};
"rmail-sup" = {
version = "1.0.1";
source = {
type = "gem";
sha256 = "1xswk101s560lxqaax3plqh8vjx7jjspnggdwb3q80m358f92q9g";
};
};
"sup" = {
version = "0.20.0";
source = {
type = "gem";
sha256 = "1lpqgrqkv29xr1h1142qsbmknlshpgys7fc3w1nkyhib8s3ikamg";
};
dependencies = [
"chronic"
"highline"
"locale"
"lockfile"
"mime-types"
"ncursesw"
"rmail-sup"
"trollop"
"unicode"
];
};
"trollop" = {
version = "2.1.1";
source = {
type = "gem";
sha256 = "0z5dvh7glwqjprlihsjx67hfzy4whsjfhqj9akyyrby9q5va1i4k";
};
};
"unicode" = {
version = "0.4.4.2";
source = {
type = "gem";
sha256 = "15fggljzan8zvmr8h12b5m7pcj1gvskmmnx367xs4p0rrpnpil8g";
};
};
"xapian-ruby" = {
version = "1.2.19.1";
source = {
type = "gem";
sha256 = "1crfrmc8kf6qq1xcfcmgf213zg66badpg4d86n7y9x3i1f5lxlbv";
};
};
}

View file

@ -0,0 +1,14 @@
require 'rubygems'
require 'rubygems/command.rb'
require 'rubygems/dependency_installer.rb'
require 'rbconfig'
begin
Gem::Command.build_args = ARGV
rescue NoMethodError
end
# create dummy rakefile to indicate success
f = File.open(File.join(File.dirname(__FILE__), "Rakefile"), "w")
f.write("task :default\n")
f.close

View file

@ -0,0 +1,38 @@
# encoding: utf-8
# Install the xapian binaries into the lib folder of the gem
require 'rbconfig'
c = RbConfig::CONFIG
def system!(cmd)
puts cmd
system(cmd) or raise
end
source_dir = 'xapian_source'
bindings = Dir["#{source_dir}/xapian-bindings-*"].first
bindings = File.basename(bindings, ".tar.xz")
task :default do
system! "tar -xJf #{source_dir}/#{bindings}.tar.xz"
prefix = Dir.pwd
ENV['LDFLAGS'] = "-L#{prefix}/lib"
system! "mkdir -p lib"
Dir.chdir bindings do
ENV['RUBY'] ||= "#{c['bindir']}/#{c['RUBY_INSTALL_NAME']}"
system! "./configure --prefix=#{prefix} --exec-prefix=#{prefix} --with-ruby"
system! "make clean all"
end
system! "cp -r #{bindings}/ruby/.libs/_xapian.* lib"
system! "cp #{bindings}/ruby/xapian.rb lib"
system! "rm lib/*.la"
system! "rm lib/*.lai"
system! "rm -R #{bindings}"
system! "rm -R #{source_dir}"
end

View file

@ -1,6 +1,5 @@
{ stdenv, runCommand, writeText, writeScript, writeScriptBin, ruby, lib
, callPackage , gemFixes, fetchurl, fetchgit, buildRubyGem
#, bundler_PATCHED
, bundler_HEAD
, git
}@defs:
@ -10,7 +9,9 @@
{ name, gemset, gemfile, lockfile, ruby ? defs.ruby, fixes ? gemFixes
, enableParallelBuilding ? false # TODO: this might not work, given the env-var shinanigans.
, documentation ? false}@args:
, documentation ? false
, meta ? {}
}@args:
let
@ -127,22 +128,26 @@ let
needsPreInstall = attrs:
(attrs ? preInstall) || (attrs ? buildInputs) || (attrs ? nativeBuildInputs);
createPreInstallers = lib.fold (next: acc:
# TODO: support cross compilation? look at stdenv/generic/default.nix.
runPreInstallers = lib.fold (next: acc:
if !needsPreInstall next
then acc
else acc + ''
cp ${writeScript "${next.name}-pre-install" ''
${writeScript "${next.name}-pre-install" ''
#!${stdenv.shell}
buildInputs="${toString (next.buildInputs or [])}"
nativeBuildInputs="${toString (next.nativeBuildInputs or [])}"
export nativeBuildInputs="${toString ((next.nativeBuildInputs or []) ++ (next.buildInputs or []))}"
source ${stdenv}/setup
header "running pre-install script for ${next.name}"
${next.preInstall or ""}
${ruby}/bin/ruby -e 'print ENV.inspect' > env/${next.name}
''} pre-installers/${next.name}
stopNest
''}
''
) "" (attrValues instantiated);
@ -245,18 +250,23 @@ in
stdenv.mkDerivation {
inherit name;
buildInputs = [
ruby
bundler
git
];
phases = [ "installPhase" "fixupPhase" ];
outputs = [
"out" # the installed libs/bins
"bundle" # supporting files for bundler
];
installPhase = ''
# Copy the Gemfile and Gemfile.lock
mkdir -p $bundle
export BUNDLE_GEMFILE=$bundle/Gemfile
cp ${gemfile} $BUNDLE_GEMFILE
@ -273,8 +283,7 @@ stdenv.mkDerivation {
${copyGems}
mkdir env
mkdir pre-installers
${createPreInstallers}
${runPreInstallers}
${allBuildArgs}
@ -289,8 +298,11 @@ stdenv.mkDerivation {
export RUBYOPT="-rmonkey_patches.rb -I $(pwd -P)"
bundler install --frozen --binstubs ${lib.optionalString enableParallelBuilding "--jobs $NIX_BUILD_CORES"}
'';
passthru = {
inherit ruby;
inherit bundler;
};
inherit meta;
}

View file

@ -133,14 +133,9 @@ Bundler::Installer.class_eval do
# and then set it back to what it was originally.
alias original_install_gem_from_spec install_gem_from_spec
def install_gem_from_spec(spec, standalone = false, worker = 0)
pre_installer = "pre-installers/#{spec.name}"
if File.exist?(pre_installer)
system(pre_installer)
unless $?.success?
Bundler.ui.error "The pre-installer script for #{spec.name} failed!"
exit 1
end
env = eval(Bundler.read_file("env/#{spec.name}"))
env_dump = "env/#{spec.name}"
if File.exist?(env_dump)
env = eval(Bundler.read_file(env_dump))
unless env
Bundler.ui.error "The environment variables for #{spec.name} could not be loaded!"
exit 1

View file

@ -1,11 +1,11 @@
{ stdenv, fetchurl, libuuid, zlib }:
stdenv.mkDerivation {
name = "xapian-1.2.8";
name = "xapian-1.2.19";
src = fetchurl {
url = http://oligarchy.co.uk/xapian/1.2.8/xapian-core-1.2.8.tar.gz;
sha256 = "00411ebac66a5592b87fc57ccfeb234c84b929ed23c185befb5df9929df3d4f9";
url = http://oligarchy.co.uk/xapian/1.2.19/xapian-core-1.2.19.tar.xz;
sha256 = "11a7lm3w3pchk4rx144nc2p31994spyqmldm18ph86zzi01jcy2a";
};
buildInputs = [ libuuid zlib ];

View file

@ -10643,42 +10643,14 @@ let
pcmanfm = callPackage ../applications/misc/pcmanfm { };
ruby_gpgme = callPackage ../development/libraries/ruby_gpgme {
ruby = ruby_1_9_3;
hoe = rubyPackages.hoe;
};
ruby_ncursesw_sup = callPackage ../development/libraries/ruby_ncursesw_sup { };
shotcut = callPackage ../applications/video/shotcut { mlt = mlt-qt5; };
smplayer = callPackage ../applications/video/smplayer { };
smtube = callPackage ../applications/video/smtube {};
sup = with rubyPackages; callPackage ../applications/networking/mailreaders/sup {
ruby = ruby_1_9_3.override {
cursesSupport = true;
};
inherit gettext highline iconv locale lockfile
text trollop xapian_ruby which;
rmail_sup = ""; # missing
unicode = "";
# See https://github.com/NixOS/nixpkgs/issues/1804 and
# https://github.com/NixOS/nixpkgs/issues/2146
bundler = pkgs.lib.overrideDerivation pkgs.rubyPackages.bundler (
oldAttrs: {
dontPatchShebangs = 1;
}
);
chronic = chronic;
gpgme = ruby_gpgme;
mime_types = mime_types;
ncursesw_sup = ruby_ncursesw_sup;
rake = rake;
sup = callPackage ../applications/networking/mailreaders/sup {
ruby = ruby_1_9_3.override { cursesSupport = true; };
};
synfigstudio = callPackage ../applications/graphics/synfigstudio {