dgraph.spec 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. ##
  2. ## dgraph.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2016 OpenPKG Foundation e.V. <http://openpkg.net/>
  4. ##
  5. ## Permission to use, copy, modify, and distribute this software for
  6. ## any purpose with or without fee is hereby granted, provided that
  7. ## the above copyright notice and this permission notice appear in all
  8. ## copies.
  9. ##
  10. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  11. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  12. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  13. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  14. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  15. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  16. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  17. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  18. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  19. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  20. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  21. ## SUCH DAMAGE.
  22. ##
  23. # package information
  24. %define V_dgraph_base 0.4.2
  25. %define V_dgraph_snap 20160724
  26. # package information
  27. Name: dgraph
  28. Summary: Scalable Distributed Low-Latency Graph Database
  29. URL: https://dgraph.io/
  30. Vendor: Manish R. Jain
  31. Packager: OpenPKG Foundation e.V.
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Database
  35. License: Apache
  36. Version: %{V_dgraph_base}
  37. Release: 20160724
  38. # list of sources
  39. Source0: http://download.openpkg.org/components/versioned/dgraph/dgraph-%{V_dgraph_snap}.tar.xz
  40. Source1: dgraph.cf
  41. Source2: rc.dgraph
  42. Patch0: dgraph.patch
  43. # build information
  44. BuildPreReq: OpenPKG, openpkg >= 20160101, go
  45. PreReq: OpenPKG, openpkg >= 20160101
  46. BuildPreReq: rocksdb
  47. PreReq: rocksdb
  48. %description
  49. DGraph's goal is to provide production level scale and throughput,
  50. with low enough latency to be serving real time user queries, over
  51. terabytes of structured data. DGraph supports GraphQL as query
  52. language, and responds in JSON.
  53. %track
  54. prog dgraph = {
  55. version = %{V_dgraph_base}
  56. url = https://github.com/dgraph-io/dgraph/releases
  57. regex = v(\d+\.\d+(?:\.\d+)?)\.tar\.gz
  58. }
  59. %prep
  60. %setup -q -n dgraph
  61. %patch -p0
  62. %build
  63. # build program
  64. ( export GOPATH=`pwd`
  65. export CGO_CFLAGS="%{l_cflags -O} %{l_cppflags}"
  66. export CGO_CXXFLAGS="%{l_cxxflags -O} %{l_cppflags}"
  67. export CGO_LDFLAGS="%{l_ldflags}"
  68. cd $GOPATH/src/github.com/dgraph-io/dgraph
  69. for cmd in dgraph dgraphassigner dgraphloader dgraphlist dgraphmerge; do
  70. go build -x -o $cmd cmd/$cmd/main.go
  71. done
  72. ) || exit $?
  73. %install
  74. # create directory hierarchy
  75. %{l_shtool} mkdir -f -p -m 755 \
  76. $RPM_BUILD_ROOT%{l_prefix}/bin \
  77. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  78. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  79. $RPM_BUILD_ROOT%{l_prefix}/etc/dgraph \
  80. $RPM_BUILD_ROOT%{l_prefix}/var/dgraph/run \
  81. $RPM_BUILD_ROOT%{l_prefix}/var/dgraph/log \
  82. $RPM_BUILD_ROOT%{l_prefix}/var/dgraph/db/postings \
  83. $RPM_BUILD_ROOT%{l_prefix}/var/dgraph/db/mutations \
  84. $RPM_BUILD_ROOT%{l_prefix}/var/dgraph/db/uids
  85. # install program
  86. %{l_shtool} install -c -s -m 755 \
  87. src/github.com/dgraph-io/dgraph/dgraph \
  88. src/github.com/dgraph-io/dgraph/dgraphassigner \
  89. src/github.com/dgraph-io/dgraph/dgraphloader \
  90. src/github.com/dgraph-io/dgraph/dgraphlist \
  91. src/github.com/dgraph-io/dgraph/dgraphmerge \
  92. $RPM_BUILD_ROOT%{l_prefix}/sbin/
  93. # install default configuration
  94. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  95. %{SOURCE dgraph.cf} $RPM_BUILD_ROOT%{l_prefix}/etc/dgraph/
  96. # install run-command script
  97. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  98. %{SOURCE rc.dgraph} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  99. # determine installation files
  100. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  101. %{l_files_std} \
  102. '%config %{l_prefix}/etc/dgraph/*' \
  103. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/dgraph/*' \
  104. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/dgraph/*/*'
  105. %files -f files
  106. %clean
  107. %post
  108. if [ $1 -eq 2 ]; then
  109. # after upgrade, restart service
  110. eval `%{l_rc} dgraph status 2>/dev/null`
  111. [ ".$dgraph_active" = .yes ] && %{l_rc} dgraph restart
  112. fi
  113. exit 0
  114. %preun
  115. if [ $1 -eq 0 ]; then
  116. # before erase, stop service and remove log files
  117. %{l_rc} dgraph stop 2>/dev/null
  118. rm -rf $RPM_INSTALL_PREFIX/var/dgraph/log/* >/dev/null 2>&1 || true
  119. rm -rf $RPM_INSTALL_PREFIX/var/dgraph/run/* >/dev/null 2>&1 || true
  120. rm -rf $RPM_INSTALL_PREFIX/var/dgraph/db/*/* >/dev/null 2>&1 || true
  121. fi
  122. exit 0