template 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. # Template file for 'ruby'
  2. _ruby_abiver=2.7.0
  3. pkgname=ruby
  4. version=2.7.2
  5. # Liberation: Adds pure Ruby json version
  6. _jsonver=2.3.0
  7. revision=1
  8. build_style=gnu-configure
  9. configure_args="--enable-shared --disable-rpath
  10. DOXYGEN=/usr/bin/doxygen DOT=/usr/bin/dot PKG_CONFIG=/usr/bin/pkg-config"
  11. make_build_args="all capi"
  12. hostmakedepends="pkg-config bison groff"
  13. makedepends="zlib-devel readline-devel libffi-devel libressl-devel
  14. gdbm-devel libyaml-devel pango-devel"
  15. checkdepends="tzdata"
  16. short_desc="Ruby programming language"
  17. homepage="http://www.ruby-lang.org/en/"
  18. maintainer="Leah Neukirchen <leah@vuxu.org>"
  19. license="Ruby, BSD-2-Clause"
  20. # Liberation: Adds pure Ruby json distfile
  21. distfiles="https://cache.ruby-lang.org/pub/ruby/${version%.*}/${pkgname}-${version}.tar.bz2
  22. https://github.com/flori/json/archive/v${_jsonver}.tar.gz"
  23. checksum="65a590313d244d48dc2ef9a9ad015dd8bc6faf821621bbb269aa7462829c75ed
  24. b8a7576b9b6dfb997d9b3911e13b2e5b1bde50ff1f5aea46b116c560649ec1a4"
  25. case "$XBPS_TARGET_MACHINE" in
  26. *-musl) # Broken on the builders but successfully built locally
  27. # As a workaround disable all docs
  28. configure_args+=" --disable-install-doc"
  29. ;;
  30. *)
  31. hostmakedepends+=" doxygen graphviz"
  32. configure_args+=" DOXYGEN=/usr/bin/doxygen DOT=/usr/bin/dot"
  33. ;;
  34. esac
  35. case "$XBPS_TARGET_MACHINE" in
  36. arm*-musl) # Default is ucontext
  37. configure_args+=" --with-coroutine=arm32"
  38. ;;
  39. ppc64*) # Default is ucontext on BE, but ppc64le really just means ELFv2
  40. configure_args+=" --with-coroutine=ppc64le"
  41. ;;
  42. mips*-musl|ppc-musl)
  43. _need_libucontext=yes
  44. makedepends+=" libucontext-devel"
  45. configure_args+=" LIBS=-lucontext"
  46. ;;
  47. esac
  48. if [ "$CROSS_BUILD" ]; then
  49. hostmakedepends+=" ruby"
  50. fi
  51. post_patch() {
  52. [ "$XBPS_TARGET_LIBC" = "glibc" ] && return 0
  53. echo "Patching out using binary gems for non-glibc..."
  54. patch -sNp1 -i ${FILESDIR}/rubygems-avoid-platform-specific-gems.patch
  55. # Liberation: Implement pure Ruby json
  56. # Some codes are taken from:
  57. # https://git.parabola.nu/abslibre.git/tree/libre/ruby/PKGBUILD
  58. cd "${XBPS_BUILDDIR}/json-${_jsonver}"
  59. # Modify 'json' so that it doesn't try to load (non-free!) 'json/ext'
  60. echo "applying json-libre.patch to json"
  61. rm -rf -- json.gemspec ext lib/json/ext*
  62. patch -p1 -i "${FILESDIR}/json-libre.patch"
  63. # Now remove the json ext from the ruby sources
  64. cd "${XBPS_BUILDDIR}/${wrksrc}"
  65. rm -r ext/json test/json
  66. # and insert the json_pure lib instead
  67. cp -r ../json-${_jsonver}/lib/* -t lib/
  68. cp ../json-${_jsonver}/json_pure.gemspec -t lib/json/
  69. cp -rT ../json-${_jsonver}/tests test/json
  70. # Clean up the original json sources
  71. rm -rf "{XBPS_BUILDDIR}/json-${_jsonver}"
  72. }
  73. pre_configure() {
  74. # this allows the test suite to pass without crashing
  75. export CFLAGS+=" -fno-omit-frame-pointer -fno-strict-aliasing"
  76. export CPPFLAGS+=" -fno-omit-frame-pointer -fno-strict-aliasing"
  77. case "$XBPS_TARGET_MACHINE" in
  78. ppc64le*) ;;
  79. ppc*)
  80. # Random segfaults otherwise
  81. export CFLAGS+=" -Os"
  82. export CPPFLAGS+=" -Os"
  83. ;;
  84. esac
  85. # force this to pass on systems with these as macros (musl)
  86. export ac_cv_func_isnan=yes
  87. export ac_cv_func_isinf=yes
  88. }
  89. pre_build() {
  90. # Force getaddrinfo detection.
  91. sed -e 's,\(checking_for("wide getaddrinfo") {try_\)run,\1link,' -i ext/socket/extconf.rb
  92. # Hack for cross-builds.
  93. touch ext/ripper/check
  94. # Set -fno-stack-protector for i686* or otherwise linking fails with
  95. # ...: undefined reference to '__stack_chk_fail_local'
  96. case "$XBPS_TARGET_MACHINE" in
  97. i686*) sed -i Makefile \
  98. -e "s;-fstack-protector-strong;;" \
  99. -e "s;-fstack-protector;-fno-stack-protector;"
  100. ;;
  101. esac
  102. }
  103. post_install() {
  104. # Remove references to the cross compiler
  105. if [ "$CROSS_BUILD" ]; then
  106. sed -e "s,${XBPS_CROSS_TRIPLET}-,,g" -i ${DESTDIR}/usr/lib/ruby/${_ruby_abiver}/*/rbconfig.rb
  107. fi
  108. # Replace reference to the install(1) wrapper
  109. sed -e "s,${XBPS_WRAPPERDIR},/usr/bin,g" -i \
  110. ${DESTDIR}/usr/lib/ruby/${_ruby_abiver}/*/rbconfig.rb
  111. # Remove references to hardening -specs.
  112. sed -e "s|\(-specs=.*hardened-ld\)||g" -e "s|\(-specs=.*hardened-cc1\)||g" -i \
  113. ${DESTDIR}/usr/lib/ruby/${_ruby_abiver}/*/rbconfig.rb
  114. vlicense COPYING
  115. }
  116. ruby-devel-doc_package() {
  117. short_desc+=" - HTML C API documentation files"
  118. pkg_install() {
  119. if [ -d "${DESTDIR}/usr/share/doc" ]; then
  120. vmove usr/share/doc
  121. else
  122. vmkdir usr/share/doc/ruby
  123. echo "Currently not available." > \
  124. ${PKGDESTDIR}/usr/share/doc/ruby/README
  125. fi
  126. }
  127. }
  128. ruby-devel_package() {
  129. depends="ruby-${version}_${revision} gmp-devel"
  130. if [ "$_need_libucontext" ]; then
  131. depends+=" libucontext-devel"
  132. fi
  133. short_desc+=" - development files"
  134. pkg_install() {
  135. vmove usr/include
  136. vmove usr/lib/ruby/${_ruby_abiver}/mkmf.rb
  137. vmove usr/lib/pkgconfig
  138. }
  139. }
  140. ruby-ri_package() {
  141. depends="ruby-${version}_${revision}"
  142. short_desc="Ruby Interactive reference"
  143. pkg_install() {
  144. vmove usr/bin/ri
  145. if [ -d "${DESTDIR}/usr/share/ri" ]; then
  146. vmove usr/share/ri
  147. fi
  148. vmove "usr/share/man/man1/ri*"
  149. }
  150. }