sbt-0.13.11.ebuild 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI="5"
  4. # repoman gives LIVEVCS.unmasked even with EGIT_COMMIT, so create snapshot
  5. inherit eutils java-pkg-2 # git-r3
  6. MY_PV="0.13.11"
  7. L_PN="sbt-launch"
  8. L_P="${L_PN}-${MY_PV}"
  9. SV="2.10"
  10. DESCRIPTION="sbt is a build tool for Scala and Java projects that aims to do the basics well"
  11. HOMEPAGE="http://www.scala-sbt.org/"
  12. EGIT_COMMIT="v${PV}"
  13. EGIT_REPO_URI="https://github.com/sbt/sbt.git"
  14. SRC_URI="!binary?
  15. (
  16. https://dev.gentoo.org/~gienah/snapshots/${P}-src.tar.bz2
  17. https://dev.gentoo.org/~gienah/snapshots/${P}-ivy2-deps.tar.bz2
  18. https://dev.gentoo.org/~gienah/snapshots/${P}-sbt-deps.tar.bz2
  19. http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/${L_PN}/${MY_PV}/${L_PN}.jar -> ${L_P}.jar
  20. )
  21. binary? ( https://dev.gentoo.org/~gienah/files/dist/${P}-gentoo-binary.tar.bz2 )
  22. "
  23. LICENSE="BSD"
  24. SLOT="0"
  25. KEYWORDS="~amd64 ~x86"
  26. IUSE="binary"
  27. DEPEND=">=virtual/jdk-1.7
  28. >=dev-lang/scala-2.10.6:${SV}"
  29. RDEPEND=">=virtual/jre-1.7
  30. dev-lang/scala:*"
  31. # test hangs or fails
  32. RESTRICT="test"
  33. # Note: to bump sbt, some things to try are:
  34. # 1. Create the sbt src snapshot:
  35. # git clone https://github.com/sbt/sbt.git sbt-0.13.11
  36. # cd sbt-0.13.11
  37. # git checkout v0.13.11
  38. # cd ..
  39. # tar --owner=portage --group=portage -cjf /usr/portage/distfiles/sbt-0.13.11-src.tar.bz2 \
  40. # sbt-0.13.11
  41. # 2. remove the https://dev.gentoo.org/~gienah/snapshots/${P}-ivy2-deps.tar.bz2
  42. # https://dev.gentoo.org/~gienah/snapshots/${P}-sbt-deps.tar.bz2 and
  43. # https://dev.gentoo.org/~gienah/snapshots/${P}-test-deps.tar.bz2
  44. # binary? ( https://dev.gentoo.org/~gienah/files/dist/${P}-gentoo-binary.tar.bz2 )
  45. # from SRC_URI
  46. # 3. Comment the sbt publishLocal line in src_compile.
  47. # 4. try:
  48. # FEATURES='noclean -test' emerge -v -1 dev-java/sbt
  49. # It should fail in src_install since the sbt publishLocal is not done.
  50. # Check if it downloads more stuff in
  51. # src_compile to ${WORKDIR}/.ivy2 and ${WORKDIR}/.sbt.
  52. # 5. If some of the downloads fail, it might be necessary to run the sbt compile
  53. # again manually to obtain all the dependencies, if so (with jdk 1.6):
  54. # cd to ${S}
  55. # export EROOT=/
  56. # export WORKDIR='/var/tmp/portage/dev-java/sbt-0.13.11/work'
  57. # export SV="2.10"
  58. # export L_P=sbt-0.13.11
  59. # export PATH="/usr/share/scala-${SV}/bin:${WORKDIR}/${L_P}:${PATH}"
  60. # sbt compile
  61. # cd ${WORKDIR}
  62. # find .ivy2 .sbt -uid 0 -exec chown portage:portage {} \;
  63. # 6. cd ${WORKDIR}
  64. # tar -cjf /usr/portage/distfiles/sbt-0.13.11-ivy2-deps.tar.bz2 .ivy2
  65. # tar -cjf /usr/portage/distfiles/sbt-0.13.11-sbt-deps.tar.bz2 .sbt
  66. # Uncomment the sbt publishLocal line in src_compile.
  67. # 7. It *might* download more dependencies for src_test, however the presence of some of these may cause
  68. # the src_compile to fail. So download them seperately as root so we can identify the
  69. # additional files. Note: src_test creates some files in ${WORKDIR}/.m2 which are can
  70. # hopefully be ignored. As root:
  71. # cd ${S}
  72. # ${S}/sbt-0.13.11 test
  73. # cd ${WORKDIR}
  74. # tar --owner=portage --group=portage -cjf /usr/portage/distfiles/sbt-0.13.11-test-deps.tar.bz2 \
  75. # $(find .ivy2 .sbt -uid 0 -type f -print)
  76. # Note: It might not download anything in src_test, in which case sbt-0.13.11-test-deps.tar.bz2
  77. # is not required.
  78. # 8. Create the binary
  79. # cd $WORDKIR
  80. # tar --owner=portage --group=portage -cjf /usr/portage/distfiles/sbt-0.13.11-gentoo-binary.tar.bz2 \
  81. # sbt-0.13.11 .ivy2/local
  82. # 9. Undo the earlier temporary edits to the ebuild.
  83. src_unpack() {
  84. # if ! use binary; then
  85. # git-r3_src_unpack
  86. # fi
  87. # Unpack tar files only.
  88. for f in ${A} ; do
  89. [[ ${f} == *".tar."* ]] && unpack ${f}
  90. done
  91. }
  92. java_prepare() {
  93. if ! use binary; then
  94. mkdir "${WORKDIR}/${L_P}" || die
  95. cp -p "${DISTDIR}/${L_P}.jar" "${WORKDIR}/${L_P}/${L_PN}.jar" || die
  96. cat <<- EOF > "${WORKDIR}/${L_P}/sbt"
  97. #!/bin/sh
  98. SBT_OPTS="-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512M"
  99. java -Djavac.args="-encoding UTF-8" -Duser.home="${WORKDIR}" \${SBT_OPTS} -jar "${WORKDIR}/${L_P}/sbt-launch.jar" "\$@"
  100. EOF
  101. cat <<- EOF > "${S}/${P}"
  102. #!/bin/sh
  103. SBT_OPTS="-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=512M"
  104. java -Djavac.args="-encoding UTF-8" -Duser.home="${WORKDIR}" \${SBT_OPTS} -jar "${S}/launch/target/sbt-launch.jar" "\$@"
  105. EOF
  106. chmod u+x "${WORKDIR}/${L_P}/sbt" "${S}/${P}" || die
  107. local SCALA_PVR="$(java-config --query=PVR --package=scala-${SV})"
  108. local SFV="${SCALA_PVR/-*}"
  109. sed -e "s@scalaVersion := \"2.10.4\",@scalaVersion := \"${SFV}\",\n scalaHome := Some(file(\"/usr/share/scala-${SV}\")),@" \
  110. -i "${S}/build.sbt" || die
  111. fi
  112. }
  113. src_compile() {
  114. if ! use binary; then
  115. export PATH="${EROOT}usr/share/scala-${SV}/bin:${WORKDIR}/${L_P}:${PATH}"
  116. einfo "=== sbt compile ..."
  117. "${WORKDIR}/${L_P}/sbt" -Dsbt.log.noformat=true compile || die
  118. einfo "=== sbt publishLocal with jdk $(java-pkg_get-vm-version) ..."
  119. cat <<- EOF | "${WORKDIR}/${L_P}/sbt" -Dsbt.log.noformat=true || die
  120. set every javaVersionPrefix in javaVersionCheck := Some("$(java-pkg_get-vm-version)")
  121. publishLocal
  122. EOF
  123. fi
  124. }
  125. src_test() {
  126. if ! use binary; then
  127. export PATH="${EROOT}usr/share/scala-${SV}/bin:${S}:${PATH}"
  128. "${S}/${P}" -Dsbt.log.noformat=true test || die
  129. fi
  130. }
  131. src_install() {
  132. # Place sbt-launch.jar at the end of the CLASSPATH
  133. java-pkg_dojar $(find "${WORKDIR}"/.ivy2/local -name \*.jar -print | grep -v sbt-launch.jar) \
  134. $(find "${WORKDIR}"/.ivy2/local -name sbt-launch.jar -print)
  135. local ja="-Dsbt.version=${PV} -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled"
  136. java-pkg_current-vm-matches "1.7" && ja+=" -XX:MaxPermSize=512M"
  137. java-pkg_dolauncher sbt --jar sbt-launch.jar --java_args "${ja}"
  138. }