diff options
Diffstat (limited to 'nixpkgs/pkgs/development/libraries/glib')
8 files changed, 404 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/development/libraries/glib/darwin-compilation.patch b/nixpkgs/pkgs/development/libraries/glib/darwin-compilation.patch new file mode 100644 index 000000000000..f215eef798af --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glib/darwin-compilation.patch @@ -0,0 +1,24 @@ +Fix compilation on Mac OS X with gcc 4.8. + +diff -ru glib-2.40.0-orig/gio/gdummyfile.c glib-2.40.0/gio/gdummyfile.c +--- glib-2.40.0-orig/gio/gdummyfile.c 2014-02-03 18:40:41.000000000 +0100 ++++ glib-2.40.0/gio/gdummyfile.c 2014-07-15 10:58:31.000000000 +0200 +@@ -454,7 +454,8 @@ + result = g_malloc (escaped_string_end - escaped_string + 1); + + out = result; +- for (in = escaped_string; in < escaped_string_end; in++) ++ in = escaped_string; ++ for (; in < escaped_string_end; in++) + { + character = *in; + if (*in == '%') +@@ -551,6 +552,7 @@ + + decoded->scheme = g_malloc (p - uri); + out = decoded->scheme; +- for (in = uri; in < p - 1; in++) ++ in = uri; ++ for (; in < p - 1; in++) + *out++ = g_ascii_tolower (*in); + *out = 0; diff --git a/nixpkgs/pkgs/development/libraries/glib/default.nix b/nixpkgs/pkgs/development/libraries/glib/default.nix new file mode 100644 index 000000000000..db4eee38b6e4 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glib/default.nix @@ -0,0 +1,195 @@ +{ config, stdenv, fetchurl, fetchpatch, gettext, meson, ninja, pkgconfig, perl, python3, glibcLocales +, libiconv, zlib, libffi, pcre, libelf, gnome3, libselinux, bash, gnum4, gtk-doc, docbook_xsl, docbook_xml_dtd_45 +# use utillinuxMinimal to avoid circular dependency (utillinux, systemd, glib) +, utillinuxMinimal ? null +, buildPackages + +# this is just for tests (not in the closure of any regular package) +, doCheck ? config.doCheckByDefault or false +, coreutils, dbus, libxml2, tzdata +, desktop-file-utils, shared-mime-info +, darwin +}: + +with stdenv.lib; + +assert stdenv.isLinux -> utillinuxMinimal != null; + +# TODO: +# * Add gio-module-fam +# Problem: cyclic dependency on gamin +# Possible solution: build as a standalone module, set env. vars +# * Make it build without python +# Problem: an example (test?) program needs it. +# Possible solution: disable compilation of this example somehow +# Reminder: add 'sed -e 's@python2\.[0-9]@python@' -i +# $out/bin/gtester-report' to postInstall if this is solved +/* + * Use --enable-installed-tests for GNOME-related packages, + and use them as a separately installed tests runned by Hydra + (they should test an already installed package) + https://wiki.gnome.org/GnomeGoals/InstalledTests + * Support org.freedesktop.Application, including D-Bus activation from desktop files +*/ +let + # Some packages don't get "Cflags" from pkgconfig correctly + # and then fail to build when directly including like <glib/...>. + # This is intended to be run in postInstall of any package + # which has $out/include/ containing just some disjunct directories. + flattenInclude = '' + for dir in "''${!outputInclude}"/include/*; do + cp -r "$dir"/* "''${!outputInclude}/include/" + rm -r "$dir" + ln -s . "$dir" + done + ln -sr -t "''${!outputInclude}/include/" "''${!outputInclude}"/lib/*/include/* 2>/dev/null || true + ''; + + binPrograms = optional (!stdenv.isDarwin) "gapplication" ++ [ "gdbus" "gio" "gsettings" ]; + version = "2.60.2"; +in + +stdenv.mkDerivation rec { + name = "glib-${version}"; + + src = fetchurl { + url = "mirror://gnome/sources/glib/${stdenv.lib.versions.majorMinor version}/${name}.tar.xz"; + sha256 = "1nc0iyday7866hq0hb78h7lxa44an998lzis8jhgvp8a0rsm9w9f"; + }; + + patches = optional stdenv.isDarwin ./darwin-compilation.patch + ++ optional doCheck ./skip-timer-test.patch + ++ optionals stdenv.hostPlatform.isMusl [ + ./quark_init_on_demand.patch + ./gobject_init_on_demand.patch + ] ++ [ + ./schema-override-variable.patch + # Require substituteInPlace in postPatch + ./fix-gio-launch-desktop-path.patch + ]; + + outputs = [ "bin" "out" "dev" "devdoc" ]; + outputBin = "dev"; + + setupHook = ./setup-hook.sh; + + buildInputs = [ + libelf setupHook pcre + bash gnum4 # install glib-gettextize and m4 macros for other apps to use + ] ++ optionals stdenv.isLinux [ + libselinux + utillinuxMinimal # for libmount + ] ++ optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ + AppKit Carbon Cocoa CoreFoundation CoreServices Foundation + # Needed for CFURLCreateFromFSRef, etc. which have deen deprecated + # since 10.9 and are not part of swift-corelibs CoreFoundation. + darwin.cf-private + ]); + + nativeBuildInputs = [ + meson ninja pkgconfig perl python3 gettext gtk-doc docbook_xsl docbook_xml_dtd_45 glibcLocales + ]; + + propagatedBuildInputs = [ zlib libffi gettext libiconv ]; + + mesonFlags = [ + # Avoid the need for gobject introspection binaries in PATH in cross-compiling case. + # Instead we just copy them over from the native output. + "-Dgtk_doc=${if stdenv.hostPlatform == stdenv.buildPlatform then "true" else "false"}" + "-Dnls=enabled" + ]; + + LC_ALL = "en_US.UTF-8"; + + NIX_CFLAGS_COMPILE = (optional stdenv.isSunOS "-DBSD_COMP") + ++ [ "-Wno-error=nonnull" ]; + + postPatch = '' + # substitute fix-gio-launch-desktop-path.patch + substituteInPlace gio/gdesktopappinfo.c --replace "@bindir@" "$out/bin" + + chmod +x gio/tests/gengiotypefuncs.py + patchShebangs gio/tests/gengiotypefuncs.py + patchShebangs glib/gen-unicode-tables.pl + patchShebangs tests/gen-casefold-txt.py + patchShebangs tests/gen-casemap-txt.py + ''; + + LIBELF_CFLAGS = optional stdenv.isFreeBSD "-I${libelf}"; + LIBELF_LIBS = optional stdenv.isFreeBSD "-L${libelf} -lelf"; + + DETERMINISTIC_BUILD = 1; + + postInstall = '' + mkdir -p $bin/bin + for app in ${concatStringsSep " " binPrograms}; do + mv "$dev/bin/$app" "$bin/bin" + done + + '' + optionalString (!stdenv.isDarwin) '' + # Add gio-launch-desktop to $out so we can refer to it from $dev + mkdir $out/bin + mv "$dev/bin/gio-launch-desktop" "$out/bin/" + ln -s "$out/bin/gio-launch-desktop" "$bin/bin/" + + '' + '' + moveToOutput "share/glib-2.0" "$dev" + substituteInPlace "$dev/bin/gdbus-codegen" --replace "$out" "$dev" + sed -i "$dev/bin/glib-gettextize" -e "s|^gettext_dir=.*|gettext_dir=$dev/share/glib-2.0/gettext|" + + # This file is *included* in gtk3 and would introduce runtime reference via __FILE__. + sed '1i#line 1 "${name}/include/glib-2.0/gobject/gobjectnotifyqueue.c"' \ + -i "$dev"/include/glib-2.0/gobject/gobjectnotifyqueue.c + '' + optionalString (stdenv.hostPlatform != stdenv.buildPlatform) '' + cp -r ${buildPackages.glib.devdoc} $devdoc + ''; + + checkInputs = [ tzdata libxml2 desktop-file-utils shared-mime-info ]; + + preCheck = optionalString doCheck '' + export LD_LIBRARY_PATH="$NIX_BUILD_TOP/${name}/glib/.libs:$LD_LIBRARY_PATH" + export TZDIR="${tzdata}/share/zoneinfo" + export XDG_CACHE_HOME="$TMP" + export XDG_RUNTIME_HOME="$TMP" + export HOME="$TMP" + export XDG_DATA_DIRS="${desktop-file-utils}/share:${shared-mime-info}/share" + export G_TEST_DBUS_DAEMON="${dbus.daemon}/bin/dbus-daemon" + export PATH="$PATH:$(pwd)/gobject" + echo "PATH=$PATH" + + substituteInPlace gio/tests/desktop-files/home/applications/epiphany-weather-for-toronto-island-9c6a4e022b17686306243dada811d550d25eb1fb.desktop \ + --replace "Exec=/bin/true" "Exec=${coreutils}/bin/true" + # Needs machine-id, comment the test + sed -e '/\/gdbus\/codegen-peer-to-peer/ s/^\/*/\/\//' -i gio/tests/gdbus-peer.c + sed -e '/g_test_add_func/ s/^\/*/\/\//' -i gio/tests/gdbus-unix-addresses.c + # All gschemas fail to pass the test, upstream bug? + sed -e '/g_test_add_data_func/ s/^\/*/\/\//' -i gio/tests/gschema-compile.c + # Cannot reproduce the failing test_associations on hydra + sed -e '/\/appinfo\/associations/d' -i gio/tests/appinfo.c + # Needed because of libtool wrappers + sed -e '/g_subprocess_launcher_set_environ (launcher, envp);/a g_subprocess_launcher_setenv (launcher, "PATH", g_getenv("PATH"), TRUE);' -i gio/tests/gsubprocess.c + ''; + + inherit doCheck; + + passthru = { + gioModuleDir = "lib/gio/modules"; + inherit flattenInclude; + updateScript = gnome3.updateScript { packageName = "glib"; }; + }; + + meta = with stdenv.lib; { + description = "C library of programming buildings blocks"; + homepage = https://www.gtk.org/; + license = licenses.lgpl21Plus; + maintainers = with maintainers; [ lovek323 raskin ]; + platforms = platforms.unix; + + longDescription = '' + GLib provides the core application building blocks for libraries + and applications written in C. It provides the core object + system used in GNOME, the main loop implementation, and a large + set of utility functions for strings and common data structures. + ''; + }; +} diff --git a/nixpkgs/pkgs/development/libraries/glib/fix-gio-launch-desktop-path.patch b/nixpkgs/pkgs/development/libraries/glib/fix-gio-launch-desktop-path.patch new file mode 100644 index 000000000000..4fdec2dd7e7d --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glib/fix-gio-launch-desktop-path.patch @@ -0,0 +1,11 @@ +--- a/gio/gdesktopappinfo.c ++++ b/gio/gdesktopappinfo.c +@@ -2725,7 +2725,7 @@ g_desktop_app_info_launch_uris_with_spawn (GDesktopAppInfo *info, + + /* Fall back on usual searching in $PATH */ + if (tmp == NULL) +- tmp = "gio-launch-desktop"; ++ tmp = "@bindir@/gio-launch-desktop"; + g_once_init_leave (&gio_launch_desktop_path, tmp); + } + diff --git a/nixpkgs/pkgs/development/libraries/glib/gobject_init_on_demand.patch b/nixpkgs/pkgs/development/libraries/glib/gobject_init_on_demand.patch new file mode 100644 index 000000000000..d72d0b61dca2 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glib/gobject_init_on_demand.patch @@ -0,0 +1,87 @@ +--- glib-source/gobject/gtype.c 2016-08-17 17:20:47.000000000 +0200 ++++ glib-source/gobject/gtype.c 2016-09-01 21:56:31.777406646 +0200 +@@ -209,6 +209,9 @@ + static gboolean type_node_is_a_L (TypeNode *node, + TypeNode *iface_node); + ++#if !defined(__GLIBC__) ++static void gobject_init (void); ++#endif + + /* --- enumeration --- */ + +@@ -2631,7 +2634,10 @@ + GTypeFlags flags) + { + TypeNode *node; +- ++ ++#if !defined(__GLIBC__) ++ gobject_init(); ++#endif + g_assert_type_system_initialized (); + g_return_val_if_fail (type_id > 0, 0); + g_return_val_if_fail (type_name != NULL, 0); +@@ -2749,6 +2755,9 @@ + TypeNode *pnode, *node; + GType type = 0; + ++#if !defined(__GLIBC__) ++ gobject_init(); ++#endif + g_assert_type_system_initialized (); + g_return_val_if_fail (parent_type > 0, 0); + g_return_val_if_fail (type_name != NULL, 0); +@@ -2804,6 +2813,9 @@ + TypeNode *pnode, *node; + GType type; + ++#if !defined(__GLIBC__) ++ gobject_init(); ++#endif + g_assert_type_system_initialized (); + g_return_val_if_fail (parent_type > 0, 0); + g_return_val_if_fail (type_name != NULL, 0); +@@ -3319,6 +3331,9 @@ + { + TypeNode *node; + ++#if !defined(__GLIBC__) ++ gobject_init(); ++#endif + g_assert_type_system_initialized (); + + node = lookup_type_node_I (type); +@@ -4343,6 +4358,9 @@ + void + g_type_init_with_debug_flags (GTypeDebugFlags debug_flags) + { ++#if !defined(__GLIBC__) ++ gobject_init(); ++#endif + g_assert_type_system_initialized (); + + if (debug_flags) +@@ -4361,6 +4379,9 @@ + void + g_type_init (void) + { ++#if !defined(__GLIBC__) ++ gobject_init(); ++#endif + g_assert_type_system_initialized (); + } + +@@ -4372,6 +4393,12 @@ + TypeNode *node; + GType type; + ++#if !defined(__GLIBC__) ++ static int gobject_initialized = 0; ++ if (gobject_initialized) ++ return; ++ gobject_initialized = 1; ++#endif + /* Ensure GLib is initialized first, see + * https://bugzilla.gnome.org/show_bug.cgi?id=756139 + */ diff --git a/nixpkgs/pkgs/development/libraries/glib/quark_init_on_demand.patch b/nixpkgs/pkgs/development/libraries/glib/quark_init_on_demand.patch new file mode 100644 index 000000000000..168086484314 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glib/quark_init_on_demand.patch @@ -0,0 +1,33 @@ +--- glib-source/glib/gquark.c 2016-08-17 17:20:47.000000000 +0200 ++++ glib-source/glib/gquark.c 2016-08-30 07:49:13.298234757 +0200 +@@ -57,6 +57,9 @@ + void + g_quark_init (void) + { ++ if (quark_ht) ++ return; ++ + g_assert (quark_seq_id == 0); + quark_ht = g_hash_table_new (g_str_hash, g_str_equal); + quarks = g_new (gchar*, QUARK_BLOCK_SIZE); +@@ -138,9 +141,12 @@ + return 0; + + G_LOCK (quark_global); ++#if !defined(__GLIBC__) ++ g_quark_init (); ++#endif + quark = GPOINTER_TO_UINT (g_hash_table_lookup (quark_ht, string)); + G_UNLOCK (quark_global); + + return quark; + } + +@@ -280,6 +286,7 @@ + GQuark quark; + gchar **quarks_new; + ++ g_quark_init (); + if (quark_seq_id % QUARK_BLOCK_SIZE == 0) + { + quarks_new = g_new (gchar*, quark_seq_id + QUARK_BLOCK_SIZE); diff --git a/nixpkgs/pkgs/development/libraries/glib/schema-override-variable.patch b/nixpkgs/pkgs/development/libraries/glib/schema-override-variable.patch new file mode 100644 index 000000000000..1cb5a730351b --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glib/schema-override-variable.patch @@ -0,0 +1,12 @@ +--- a/gio/gsettingsschema.c ++++ b/gio/gsettingsschema.c +@@ -352,6 +352,9 @@ + + try_prepend_data_dir (g_get_user_data_dir ()); + ++ if ((path = g_getenv ("NIX_GSETTINGS_OVERRIDES_DIR")) != NULL) ++ try_prepend_dir (path); ++ + if ((path = g_getenv ("GSETTINGS_SCHEMA_DIR")) != NULL) + try_prepend_dir (path); + diff --git a/nixpkgs/pkgs/development/libraries/glib/setup-hook.sh b/nixpkgs/pkgs/development/libraries/glib/setup-hook.sh new file mode 100644 index 000000000000..a1cb1f40c58a --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glib/setup-hook.sh @@ -0,0 +1,25 @@ + +make_glib_find_gsettings_schemas() { + # For packages that need gschemas of other packages (e.g. empathy) + if [ -d "$1"/share/gsettings-schemas/*/glib-2.0/schemas ]; then + addToSearchPath GSETTINGS_SCHEMAS_PATH "$1/share/gsettings-schemas/"* + fi +} +addEnvHooks "$hostOffset" make_glib_find_gsettings_schemas + +# Install gschemas, if any, in a package-specific directory +glibPreInstallPhase() { + makeFlagsArray+=("gsettingsschemadir=${!outputLib}/share/gsettings-schemas/$name/glib-2.0/schemas/") +} +preInstallPhases+=" glibPreInstallPhase" + +glibPreFixupPhase() { + # Move gschemas in case the install flag didn't help + if [ -d "$prefix/share/glib-2.0/schemas" ]; then + mkdir -p "${!outputLib}/share/gsettings-schemas/$name/glib-2.0" + mv "$prefix/share/glib-2.0/schemas" "${!outputLib}/share/gsettings-schemas/$name/glib-2.0/" + fi + + addToSearchPath GSETTINGS_SCHEMAS_PATH "${!outputLib}/share/gsettings-schemas/$name" +} +preFixupPhases+=" glibPreFixupPhase" diff --git a/nixpkgs/pkgs/development/libraries/glib/skip-timer-test.patch b/nixpkgs/pkgs/development/libraries/glib/skip-timer-test.patch new file mode 100644 index 000000000000..942f3e7864c4 --- /dev/null +++ b/nixpkgs/pkgs/development/libraries/glib/skip-timer-test.patch @@ -0,0 +1,17 @@ +Description: Skip test which performs some unreliable floating point comparisons +Forwarded: https://bugzilla.gnome.org/show_bug.cgi?id=722604 + +Index: b/glib/tests/timer.c +=================================================================== +--- a/glib/tests/timer.c ++++ b/glib/tests/timer.c +@@ -203,7 +203,7 @@ + { + g_test_init (&argc, &argv, NULL); + +- g_test_add_func ("/timer/basic", test_timer_basic); ++/* g_test_add_func ("/timer/basic", test_timer_basic);*/ +- g_test_add_func ("/timer/stop", test_timer_stop); ++/* g_test_add_func ("/timer/stop", test_timer_stop);*/ + g_test_add_func ("/timer/continue", test_timer_continue); + g_test_add_func ("/timer/reset", test_timer_reset); |