summary refs log tree commit diff
path: root/pkgs/applications/video/gnash/default.nix
blob: 515e2591461fa4c52fe41b4108e948ddc090784c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
{ stdenv, fetchurl, fetchpatch
, SDL, SDL_mixer, gstreamer, gst_plugins_base, gst_plugins_good
, gst_ffmpeg, speex
, libogg, libxml2, libjpeg, mesa, libpng, libungif, libtool
, boost, freetype, agg, dbus, curl, pkgconfig, gettext
, glib, gtk, gtkglext, pangox_compat, x11, ming, dejagnu, python, perl
, freefont_ttf, haxe, swftools
, lib, makeWrapper
, xulrunner }:

assert stdenv ? glibc;

let version = "0.8.10";
    patch_CVE = fetchpatch {
      url = "http://git.savannah.gnu.org/cgit/gnash.git/patch/?id=bb4dc77eecb6ed1b967e3ecbce3dac6c5e6f1527";
      sha256 = "0ghnki5w7xf3qwfl1x6vhijpd6q608niyxrvh0g8dw5xavkvallk";
      name = "CVE-2012-1175.patch";
    };
in

stdenv.mkDerivation rec {
  name = "gnash-${version}";

  src = fetchurl {
    url = "mirror://gnu/gnash/${version}/${name}.tar.bz2";
    sha256 = "090j5lly5r6jzbnvlc3mhay6dsrd9sfrkjcgqaibm4nz8lp0f9cn";
  };

  patchPhase = ''
    patch -p1 < ${patch_CVE}

    # Add all libs to `macros/libslist', a list of library search paths.
    for lib in ${lib.concatStringsSep " "
                                      (map (lib: "\"${lib}\"/lib")
                                           (buildInputs ++ [stdenv.glibc]))}
    do
      echo -n "$lib " >> macros/libslist
    done

    # Make sure to honor $TMPDIR, for chroot builds.
    for file in configure gui/Makefile.in Makefile.in
    do
      sed -i "$file" -es'|/tmp/|$TMPDIR/|g'
    done

    # Provide a default font.
    sed -i "configure" \
        -e 's|/usr/share/fonts/truetype/freefont/|${freefont_ttf}/share/fonts/truetype/|g'
  '';

  enableParallelBuilding = true;

  # XXX: KDE is supported as well so we could make it available optionally.
  buildInputs = [
    gettext x11 SDL SDL_mixer gstreamer gst_plugins_base gst_plugins_good
    gst_ffmpeg speex libtool
    libogg libxml2 libjpeg mesa libpng libungif boost freetype agg
    dbus curl pkgconfig glib gtk gtkglext pangox_compat
    xulrunner
    makeWrapper
  ]

  ++ (stdenv.lib.optionals doCheck [
        ming dejagnu python perl haxe swftools
      ]);

  preConfigure =
    '' configureFlags="                                         \
         --with-sdl-incl=${SDL}/include/SDL                     \
         --with-npapi-plugindir=$out/plugins                    \
         --enable-media=gst                                     \
         --without-gconf
         --enable-gui=gtk"

       # In `libmedia', Gnash compiles with "-I$gst_plugins_base/include",
       # whereas it really needs "-I$gst_plugins_base/include/gstreamer-0.10".
       # Work around this using GCC's $CPATH variable.
       export CPATH="${gst_plugins_base}/include/gstreamer-0.10:${gst_plugins_good}/include/gstreamer-0.10"
       echo "\$CPATH set to \`$CPATH'"

       echo "\$GST_PLUGIN_PATH set to \`$GST_PLUGIN_PATH'"
    '';

  postConfigure = "echo '#define nullptr NULL' >> gnashconfig.h";

  # Make sure `gtk-gnash' gets `libXext' in its `RPATH'.
  NIX_LDFLAGS="-lX11 -lXext";

  # XXX: Tests currently fail.
  doCheck = false;

  preInstall = ''mkdir -p $out/plugins'';
  postInstall = ''
    make install-plugins

    # Wrap programs so the find the GStreamer plug-ins they need
    # (e.g., gst-ffmpeg is needed to watch movies such as YouTube's).
    for prog in "$out/bin/"*
    do
      wrapProgram "$prog" --prefix GST_PLUGIN_SYSTEM_PATH ":" "$GST_PLUGIN_SYSTEM_PATH"
    done
  '';

  meta = {
    homepage = http://www.gnu.org/software/gnash/;
    description = "A libre SWF (Flash) movie player";

    longDescription = ''
      Gnash is a GNU Flash movie player.  Flash is an animation file format
      pioneered by Macromedia which continues to be supported by their
      successor company, Adobe.  Flash has been extended to include audio and
      video content, and programs written in ActionScript, an
      ECMAScript-compatible language.  Gnash is based on GameSWF, and
      supports most SWF v7 features and some SWF v8 and v9.
    '';

    license = stdenv.lib.licenses.gpl3Plus;

    maintainers = [ stdenv.lib.maintainers.ludo ];
    platforms = stdenv.lib.platforms.gnu;
  };
} // {mozillaPlugin = "/plugins";}