postgraphql.spec 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. ##
  2. ## postgraphql.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 version
  24. %define V_postgraphql 1.8.1
  25. %define V_postgraphql_dist 1.8.1
  26. %define V_postgraphql_snap 20160731
  27. # package information
  28. Name: postgraphql
  29. Summary: GraphSQL Frontend Service to PostgreSQL RDBMS
  30. URL: https://github.com/calebmer/postgraphql
  31. Vendor: Sebastian McKenzie
  32. Packager: OpenPKG Foundation e.V.
  33. Distribution: OpenPKG Community
  34. Class: EVAL
  35. Group: Language
  36. License: MIT
  37. Version: %{V_postgraphql}
  38. Release: 20160731
  39. # list of sources
  40. Source0: http://download.openpkg.org/components/versioned/postgraphql/postgraphql-%{V_postgraphql_dist}-%{V_postgraphql_snap}.tar.xz
  41. Source1: rc.postgraphql
  42. # build information
  43. BuildPreReq: OpenPKG, openpkg >= 20160101
  44. PreReq: OpenPKG, openpkg >= 20160101, node
  45. %description
  46. PostGraphQL is a frontend service to the PostgreSQL RDBMS. It
  47. provides a GraphQL schema created by reflection over a PostgreSQL
  48. schema.
  49. %track
  50. prog postgraphql:dist = {
  51. version = %{V_postgraphql_dist}
  52. url = https://github.com/calebmer/postgraphql/releases
  53. regex = v(\d+\.\d+\.\d+)\.tar\.gz
  54. }
  55. prog postgraphql:snap = {
  56. version = %{V_postgraphql_snap}
  57. url = http://download.openpkg.org/components/versioned/postgraphql/
  58. regex = postgraphql-\d+\.\d+\.\d+-(\d+)\.tar\.xz
  59. }
  60. %prep
  61. %setup -q -c
  62. %build
  63. # prune files
  64. find . -name example -type d -print | xargs rm -rf
  65. find . -name test -type d -print | xargs rm -rf
  66. find . -name .npmignore -type f -print | xargs rm -f
  67. find . -name LICENCE -type f -print | xargs rm -f
  68. find . -name LICENSE -type f -print | xargs rm -f
  69. find . -name LICENSE.txt -type f -print | xargs rm -f
  70. find . -name LICENSE.md -type f -print | xargs rm -f
  71. find . -name license.md -type f -print | xargs rm -f
  72. find . -name license -type f -print | xargs rm -f
  73. find . -name CHANGELOG.md -type f -print | xargs rm -f
  74. find . -name README -type f -print | xargs rm -f
  75. find . -name README.md -type f -print | xargs rm -f
  76. find . -name readme.md -type f -print | xargs rm -f
  77. find . -name .travis.yml -type f -print | xargs rm -f
  78. find . -name .jshintrc -type f -print | xargs rm -f
  79. %install
  80. # create installation hierarchy
  81. %{l_shtool} mkdir -f -p -m 755 \
  82. $RPM_BUILD_ROOT%{l_prefix}/bin \
  83. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  84. $RPM_BUILD_ROOT%{l_prefix}/lib/postgraphql \
  85. $RPM_BUILD_ROOT%{l_prefix}/var/postgraphql/run \
  86. $RPM_BUILD_ROOT%{l_prefix}/var/postgraphql/log
  87. # install program
  88. cp -rp \
  89. node_modules/* \
  90. $RPM_BUILD_ROOT%{l_prefix}/lib/postgraphql/
  91. # create executable wrapper
  92. ( echo "#!/bin/sh"
  93. echo "NODE_PATH=%{l_prefix}/lib/postgraphql; export NODE_PATH"
  94. echo "exec %{l_prefix}/bin/node %{l_prefix}/lib/postgraphql/postgraphql/dist/main.js \${1+\"\$@\"}"
  95. ) >postgraphql
  96. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  97. postgraphql $RPM_BUILD_ROOT%{l_prefix}/bin/postgraphql
  98. # install run-command script
  99. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  100. %{SOURCE rc.postgraphql} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  101. # determine installation files
  102. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  103. %{l_files_std} \
  104. '%attr(-,%{l_nusr},%{l_ngrp}) %{l_prefix}/var/postgraphql/*'
  105. %files -f files
  106. %clean
  107. %post
  108. # after upgrade, restart service
  109. [ $1 -eq 2 ] || exit 0
  110. eval `%{l_rc} postgraphql status 2>/dev/null`
  111. [ ".$postgraphql_active" = .yes ] && %{l_rc} postgraphql restart
  112. exit 0
  113. %preun
  114. # before erase, stop service and remove log files
  115. [ $1 -eq 0 ] || exit 0
  116. %{l_rc} postgraphql stop 2>/dev/null
  117. rm -f $RPM_INSTALL_PREFIX/var/postgraphql/log/* >/dev/null 2>&1 || true
  118. rm -f $RPM_INSTALL_PREFIX/var/postgraphql/run/* >/dev/null 2>&1 || true
  119. exit 0