build-gtk3.sh 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #!/bin/bash
  2. # Use "build-gtk.sh" or "build-gtk.sh 64" to build a 64-bits tarball for tooltool.
  3. # Use "build-gtk.sh 32" to build a 32-bits tarball for tooltool.
  4. # Mock environments used:
  5. # - 64-bits:
  6. # https://s3.amazonaws.com/mozilla-releng-mock-archive/67b65e51eb091fba7941a04d249343924a3ee653
  7. # + libxml2-devel.x86_64 gettext.x86_64 libjpeg-devel.x86_64
  8. # - 32-bits:
  9. # https://s3.amazonaws.com/mozilla-releng-mock-archive/58d76c6acca148a1aedcbec7fc1b8212e12807b4
  10. # + libxml2-devel.i686 gettext.i686 libjpeg-devel.i686
  11. set -e
  12. pkg_config_version=0.28
  13. fontconfig_version=2.8.0
  14. libffi_version=3.0.13
  15. glib_version=2.34.3
  16. gdk_pixbuf_version=2.26.5
  17. pixman_version=0.20.2
  18. cairo_version=1.10.2
  19. pango_version=1.30.1
  20. atk_version=2.2.0
  21. gtk__version=3.4.4
  22. pkg_config_url=http://pkgconfig.freedesktop.org/releases/pkg-config-${pkg_config_version}.tar.gz
  23. fontconfig_url=http://www.freedesktop.org/software/fontconfig/release/fontconfig-${fontconfig_version}.tar.gz
  24. libffi_url=ftp://sourceware.org/pub/libffi/libffi-${libffi_version}.tar.gz
  25. glib_url=http://ftp.gnome.org/pub/gnome/sources/glib/${glib_version%.*}/glib-${glib_version}.tar.xz
  26. gdk_pixbuf_url=http://ftp.gnome.org/pub/gnome/sources/gdk-pixbuf/${gdk_pixbuf_version%.*}/gdk-pixbuf-${gdk_pixbuf_version}.tar.xz
  27. pixman_url=http://cairographics.org/releases/pixman-${pixman_version}.tar.gz
  28. cairo_url=http://cairographics.org/releases/cairo-${cairo_version}.tar.gz
  29. pango_url=http://ftp.gnome.org/pub/GNOME/sources/pango/${pango_version%.*}/pango-${pango_version}.tar.xz
  30. atk_url=http://ftp.gnome.org/pub/GNOME/sources/atk/${atk_version%.*}/atk-${atk_version}.tar.xz
  31. gtk__url=http://ftp.gnome.org/pub/gnome/sources/gtk+/${gtk__version%.*}/gtk+-${gtk__version}.tar.xz
  32. cwd=$(pwd)
  33. root_dir=$(mktemp -d)
  34. cd $root_dir
  35. if test -z $TMPDIR; then
  36. TMPDIR=/tmp/
  37. fi
  38. make_flags=-j12
  39. build() {
  40. name=$1
  41. shift
  42. pkg=$(echo $name | tr '+-' '__')
  43. version=$(eval echo \$${pkg}_version)
  44. url=$(eval echo \$${pkg}_url)
  45. wget -c -P $TMPDIR $url
  46. tar -axf $TMPDIR/$name-$version.tar.*
  47. mkdir -p build/$name
  48. cd build/$name
  49. eval ../../$name-$version/configure --disable-static $* $configure_args
  50. make $make_flags
  51. make install DESTDIR=$root_dir/gtk3
  52. find $root_dir/gtk3 -name \*.la -delete
  53. cd ../..
  54. }
  55. case "$1" in
  56. 32)
  57. configure_args='--host=i686-pc-linux --build=i686-pc-linux CC="gcc -m32" CXX="g++ -m32"'
  58. lib=lib
  59. ;;
  60. *)
  61. configure_args=
  62. lib=lib64
  63. ;;
  64. esac
  65. export PKG_CONFIG_LIBDIR=/usr/$lib/pkgconfig:/usr/share/pkgconfig
  66. # The pkg-config version in the mock images is buggy is how it handles
  67. # PKG_CONFIG_SYSROOT_DIR. So we need our own.
  68. build pkg-config
  69. ln -sf /usr/include $root_dir/gtk3/usr/
  70. ln -sf /usr/$lib $root_dir/gtk3/usr/
  71. if [ "$lib" = lib64 ]; then
  72. ln -s lib $root_dir/gtk3/usr/local/lib64
  73. fi
  74. export PKG_CONFIG_PATH=$root_dir/gtk3/usr/local/lib/pkgconfig
  75. export PKG_CONFIG_SYSROOT_DIR=$root_dir/gtk3
  76. export LD_LIBRARY_PATH=$root_dir/gtk3/usr/local/lib
  77. export PATH=$root_dir/gtk3/usr/local/bin:${PATH}
  78. build fontconfig
  79. build libffi
  80. build glib
  81. build gdk-pixbuf --without-libtiff
  82. build pixman --disable-gtk
  83. build cairo --enable-tee
  84. build pango
  85. build atk
  86. make_flags="$make_flags GLIB_COMPILE_SCHEMAS=glib-compile-schemas"
  87. build gtk+
  88. rm -rf $root_dir/gtk3/usr/local/share/gtk-doc
  89. rm -rf $root_dir/gtk3/usr/local/share/locale
  90. # mock build environment doesn't have fonts in /usr/share/fonts, but
  91. # has some in /usr/share/X11/fonts. Add this directory to the
  92. # fontconfig configuration without changing the gtk3 tooltool package.
  93. cat << EOF > $root_dir/gtk3/usr/local/etc/fonts/local.conf
  94. <?xml version="1.0"?>
  95. <!DOCTYPE fontconfig SYSTEM "fonts.dtd">
  96. <fontconfig>
  97. <dir>/usr/share/X11/fonts</dir>
  98. </fontconfig>
  99. EOF
  100. cat <<EOF > $root_dir/gtk3/setup.sh
  101. #!/bin/sh
  102. cd \$(dirname \$0)
  103. HERE=\$(pwd)
  104. # pango expects absolute paths in pango.modules, and TOOLTOOL_DIR may vary...
  105. LD_LIBRARY_PATH=\$HERE/usr/local/lib \
  106. PANGO_SYSCONFDIR=\$HERE/usr/local/etc \
  107. PANGO_LIBDIR=\$HERE/usr/local/lib \
  108. \$HERE/usr/local/bin/pango-querymodules > \$HERE/usr/local/etc/pango/pango.modules
  109. # same with gdb-pixbuf and loaders.cache
  110. LD_LIBRARY_PATH=\$HERE/usr/local/lib \
  111. GDK_PIXBUF_MODULE_FILE=\$HERE/usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache \
  112. GDK_PIXBUF_MODULEDIR=\$HERE/usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders \
  113. \$HERE/usr/local/bin/gdk-pixbuf-query-loaders > \
  114. \$HERE/usr/local/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache
  115. # The fontconfig version in the tooltool package has known uses of
  116. # uninitialized memory when creating its cache, and while most users
  117. # will already have an existing cache, running Firefox on automation
  118. # will create it. Combined with valgrind, this generates irrelevant
  119. # errors.
  120. # So create the fontconfig cache beforehand.
  121. FONTCONFIG_PATH=\$HERE/usr/local/etc/fonts \
  122. LD_LIBRARY_PATH=\$HERE/usr/local/lib \
  123. \$HERE/usr/local/bin/fc-cache
  124. EOF
  125. chmod +x $root_dir/gtk3/setup.sh
  126. cd $cwd
  127. tar -C $root_dir -Jcf gtk3.tar.xz gtk3