rqlite-3.0.1.ebuild 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. # Copyright 1999-2016 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. EAPI=5
  4. if [[ ${PV} == *9999* ]]; then
  5. inherit git-r3
  6. fi
  7. inherit golang-build
  8. KEYWORDS="~amd64"
  9. DESCRIPTION="Replicated SQLite using the Raft consensus protocol"
  10. EGO_PN="github.com/rqlite/rqlite/..."
  11. HOMEPAGE="https://${EGO_PN%/*} http://www.philipotoole.com/tag/rqlite/"
  12. LICENSE="MIT"
  13. SLOT="0/${PVR}"
  14. IUSE=""
  15. EGIT_REPO_URI="https://github.com/rqlite/rqlite.git"
  16. EGIT_COMMIT="v${PV}"
  17. SRC_URI="https://${EGO_PN%/*}/archive/${EGIT_COMMIT}.tar.gz -> ${P}.tar.gz
  18. https://github.com/armon/go-metrics/archive/345426c77237ece5dab0e1605c3e4b35c3f54757.tar.gz -> go-metrics-345426c77237ece5dab0e1605c3e4b35c3f54757.tar.gz
  19. https://github.com/boltdb/bolt/archive/ee4a0888a9abe7eefe5a0992ca4cb06864839873.tar.gz -> bolt-ee4a0888a9abe7eefe5a0992ca4cb06864839873.tar.gz
  20. https://github.com/hashicorp/go-msgpack/archive/fa3f63826f7c23912c15263591e65d54d080b458.tar.gz -> go-msgpack-fa3f63826f7c23912c15263591e65d54d080b458.tar.gz
  21. https://github.com/hashicorp/raft/archive/057b893fd996696719e98b6c44649ea14968c811.tar.gz -> hashicorp-raft-057b893fd996696719e98b6c44649ea14968c811.tar.gz
  22. https://github.com/hashicorp/raft-boltdb/archive/d1e82c1ec3f15ee991f7cc7ffd5b67ff6f5bbaee.tar.gz -> hashicorp-boltdb-d1e82c1ec3f15ee991f7cc7ffd5b67ff6f5bbaee.tar.gz
  23. https://github.com/mattn/go-sqlite3/archive/10876d7dac65f02064c03d7372a2f1dfb90043fe.tar.gz -> go-sqlite3-1.1.0_p20160307.tar.gz"
  24. get_archive_go_package() {
  25. local archive=${1} uri x
  26. for x in ${SRC_URI}; do
  27. if [[ ${x} == http* ]]; then
  28. uri=${x}
  29. elif [[ ${x} == ${archive} ]]; then
  30. break
  31. fi
  32. done
  33. uri=${uri#https://}
  34. echo ${uri%/archive/*}
  35. }
  36. unpack_go_packages() {
  37. local go_package x
  38. # Unpack packages to appropriate locations for GOPATH
  39. for x in ${A}; do
  40. unpack ${x}
  41. if [[ ${x} == *.tar.gz ]]; then
  42. go_package=$(get_archive_go_package ${x})
  43. if [[ ${x%.tar.gz} -ef ${S} ]]; then
  44. mv "${S}"{,_} || die
  45. mkdir -p "${S}/src/${go_package%/*}" || die
  46. mv "${S}"_ "${S}/src/${go_package}" || die || die
  47. else
  48. mkdir -p "${S}/src/${go_package%/*}" || die
  49. for x in "${go_package##*/}"-*; do
  50. if [[ ! ${x} -ef ${S} ]]; then
  51. mv "${x}" "${S}/src/${go_package}" || die
  52. fi
  53. done
  54. fi
  55. fi
  56. done
  57. }
  58. src_unpack() {
  59. if [[ ${PV} == *9999* ]]; then
  60. git-r3_src_unpack
  61. mv "${S}"{,_} || die
  62. mkdir -p "$(dirname "${S}/src/${EGO_PN%/*}")" || die
  63. mv "${S}_" "${S}/src/${EGO_PN%/*}" || die
  64. fi
  65. unpack_go_packages
  66. }
  67. src_compile() {
  68. # Omit $(get_golibdir_gopath) from GOPATH, in order to avoid
  69. # interference from installed rqlite sources.
  70. GOPATH="${WORKDIR}/${P}" \
  71. go install -v -work -x ${EGO_BUILD_FLAGS} "${EGO_PN}" || die
  72. }
  73. src_install() {
  74. golang_install_pkgs
  75. }
  76. golang_install_pkgs() {
  77. dobin bin/${PN}d
  78. insinto $(dirname "${EPREFIX}$(get_golibdir)/src/${EGO_PN%/*}")
  79. rm -rf "${S}"/src/${EGO_PN%/*}/.git*
  80. doins -r "${S}"/src/${EGO_PN%/*}
  81. insinto $(dirname "${EPREFIX}$(get_golibdir)/pkg/$(go env GOOS)_$(go env GOARCH)/${EGO_PN%/*}")
  82. doins -r "${S}"/pkg/$(go env GOOS)_$(go env GOARCH)/${EGO_PN%/*}{,.a}
  83. dodoc "${S}/src/${EGO_PN%/*}/"*.md
  84. }