rqlite-2.1.ebuild 3.1 KB

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