dex.spec 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. ##
  2. ## dex.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2021 OpenPKG Project <http://openpkg.org/>
  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_dex_base 2.30.1
  25. %define V_dex_snap 20211115
  26. # package information
  27. Name: dex
  28. Summary: OpenID/OAUTH2 Provider
  29. URL: https://github.com/dexidp/dex
  30. Vendor: CoreOS
  31. Packager: OpenPKG Project
  32. Distribution: OpenPKG Community
  33. Class: EVAL
  34. Group: Networking
  35. License: Apache
  36. Version: %{V_dex_base}.%{V_dex_snap}
  37. Release: 20211115
  38. # package options
  39. %option with_pgsql no
  40. # list of sources
  41. Source0: http://download.openpkg.org/components/versioned/dex/dex-%{V_dex_snap}.tar.xz
  42. Source1: rc.dex
  43. Source2: dex-setup.sh
  44. Source3: dex.yaml
  45. # build information
  46. BuildPreReq: OpenPKG, openpkg >= 20160101, go
  47. PreReq: OpenPKG, openpkg >= 20160101, openssl
  48. %if "%{with_pgsql}" == "yes"
  49. PreReq: postgresql
  50. %endif
  51. %description
  52. DEX is a federated identity management service. It provides OpenID
  53. Connect (OIDC) and OAuth 2.0 to users, and can proxy to multiple
  54. remote identity providers (IdP) to drive actual authentication, as
  55. well as managing local username/password credentials.
  56. %track
  57. prog dex:release = {
  58. version = %{V_dex_base}
  59. url = https://github.com/dexidp/dex/releases
  60. regex = v(__VER__)\.tar\.gz
  61. }
  62. prog dex:snapshot = {
  63. version = %{V_dex_snap}
  64. url = http://download.openpkg.org/components/versioned/dex/
  65. regex = dex-(__VER__)\.tar\.xz
  66. }
  67. %prep
  68. %setup -q -n dex
  69. %build
  70. # build program
  71. export GOPATH=`pwd`
  72. cd src/github.com/dexidp/dex
  73. go build -v -ldflags "-X main.version=%{V_dex_base}" -o bin/dex ./cmd/dex/
  74. %install
  75. # create directory hierarchy
  76. %{l_shtool} mkdir -f -p -m 755 \
  77. $RPM_BUILD_ROOT%{l_prefix}/sbin \
  78. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d \
  79. $RPM_BUILD_ROOT%{l_prefix}/etc/dex \
  80. $RPM_BUILD_ROOT%{l_prefix}/share/dex \
  81. $RPM_BUILD_ROOT%{l_prefix}/var/dex/log \
  82. $RPM_BUILD_ROOT%{l_prefix}/var/dex/run \
  83. $RPM_BUILD_ROOT%{l_prefix}/var/dex/db
  84. # install program
  85. %{l_shtool} install -c -s -m 755 \
  86. src/github.com/dexidp/dex/bin/dex \
  87. $RPM_BUILD_ROOT%{l_prefix}/sbin/
  88. # install web files
  89. cp -rp src/github.com/dexidp/dex/web/* \
  90. $RPM_BUILD_ROOT%{l_prefix}/share/dex/
  91. # install setup script
  92. %if "%{with_pgsql}" == "yes"
  93. db_type="pgsql"
  94. %else
  95. db_type="sqlite"
  96. %endif
  97. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  98. -e "s;@db_type@;$db_type;g" \
  99. %{SOURCE dex-setup.sh} \
  100. $RPM_BUILD_ROOT%{l_prefix}/sbin/dex-setup
  101. # install run-command script
  102. %{l_shtool} install -c -m 755 %{l_value -s -a} \
  103. %{SOURCE rc.dex} \
  104. $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
  105. # install default configuration
  106. %if "%{with_pgsql}" == "yes"
  107. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  108. -e '/^#SQLITE#/d' \
  109. -e 's/^#PGSQL#//' \
  110. %{SOURCE dex.yaml} $RPM_BUILD_ROOT%{l_prefix}/etc/dex/
  111. %else
  112. %{l_shtool} install -c -m 644 %{l_value -s -a} \
  113. -e '/^#PGSQL#/d' \
  114. -e 's/^#SQLITE#//' \
  115. %{SOURCE dex.yaml} $RPM_BUILD_ROOT%{l_prefix}/etc/dex/
  116. %endif
  117. # determine installation files
  118. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
  119. %{l_files_std} \
  120. '%config %{l_prefix}/etc/dex/*' \
  121. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/etc/dex' \
  122. '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/dex/*'
  123. %files -f files
  124. %clean
  125. %post
  126. if [ $1 -eq 1 ]; then
  127. # on initial installation, give hints about next steps
  128. ( echo "1. To complete this installation of DEX please"
  129. %if "%{with_pgsql}" == "yes"
  130. echo " start PostgreSQL and initialize the DEX database like this:"
  131. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc postgresql start"
  132. echo " \$ $RPM_INSTALL_PREFIX/sbin/dex-setup install"
  133. echo " This will create a database named 'dex' in the RDBMS"
  134. echo " with the owner 'dex' and password 'dex'."
  135. %else
  136. echo " initialize the DEX database like this:"
  137. echo " \$ $RPM_INSTALL_PREFIX/sbin/dex-setup install"
  138. %endif
  139. echo "2. Now start DEX:"
  140. echo " \$ $RPM_INSTALL_PREFIX/bin/openpkg rc dex start"
  141. echo "3. Finally, you can access DEX unter the base URL:"
  142. echo " http://127.0.0.1:5556/"
  143. ) | %{l_rpmtool} msg -b -t notice
  144. elif [ $1 -eq 2 ]; then
  145. # after upgrade, restart service
  146. eval `%{l_rc} dex status 2>/dev/null`
  147. [ ".$dex_active" = .yes ] && %{l_rc} dex restart
  148. fi
  149. exit 0
  150. %preun
  151. if [ $1 -eq 0 ]; then
  152. # stop service
  153. %{l_rc} dex stop 2>/dev/null
  154. # remove database
  155. $RPM_INSTALL_PREFIX/sbin/dex-setup uninstall >/dev/null 2>&1 || true
  156. # remove run-time files
  157. rm -f $RPM_INSTALL_PREFIX/var/dex/log/* >/dev/null 2>&1 || true
  158. rm -f $RPM_INSTALL_PREFIX/var/dex/run/* >/dev/null 2>&1 || true
  159. rm -rf $RPM_INSTALL_PREFIX/var/dex/db/* >/dev/null 2>&1 || true
  160. fi
  161. exit 0