npm.spec 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. ##
  2. ## npm.spec -- OpenPKG RPM Package Specification
  3. ## Copyright (c) 2000-2020 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_npm 6.14.8
  25. %define V_node14 14.11.0
  26. %define V_node12 12.18.4
  27. %define V_node10 10.22.1
  28. %define V_node8 8.17.0
  29. # package information
  30. Name: npm
  31. Summary: Node Package Manager
  32. URL: https://www.npmjs.com/
  33. Vendor: npm, Inc.
  34. Packager: OpenPKG Project
  35. Distribution: OpenPKG Community
  36. Class: PLUS
  37. Group: Archiver
  38. License: MIT
  39. Version: %{V_npm}
  40. Release: 20200922
  41. # list of sources
  42. Source0: https://github.com/npm/cli/archive/v%{V_npm}.tar.gz
  43. Source1: http://nodejs.org/download/release/v%{V_node14}/node-v%{V_node14}-headers.tar.gz
  44. Source2: http://nodejs.org/download/release/v%{V_node12}/node-v%{V_node12}-headers.tar.gz
  45. Source3: http://nodejs.org/download/release/v%{V_node10}/node-v%{V_node10}-headers.tar.gz
  46. Source4: http://nodejs.org/download/release/v%{V_node8}/node-v%{V_node8}-headers.tar.gz
  47. Patch0: npm.patch
  48. # build information
  49. BuildPreReq: OpenPKG, openpkg >= 20160101
  50. PreReq: OpenPKG, openpkg >= 20160101, node, python2
  51. %description
  52. Node Package Manager (NPM) is the package manager for the
  53. Node.js/JavaScript and Web/JavaScript ecosystems.
  54. %track
  55. prog npm:npm = {
  56. version = %{V_npm}
  57. url = https://github.com/npm/cli/releases
  58. regex = v(__VER__)\.tar\.gz
  59. }
  60. prog npm:node14 = {
  61. version = %{V_node14}
  62. url = https://nodejs.org/download/release/
  63. regex = v(\d+\.\d+\.\d+)
  64. }
  65. prog npm:node12 = {
  66. version = %{V_node12}
  67. url = https://nodejs.org/download/release/
  68. regex = v(12.\d+\.\d+)
  69. }
  70. prog npm:node10 = {
  71. version = %{V_node10}
  72. url = https://nodejs.org/download/release/
  73. regex = v(10\.\d+\.\d+)
  74. }
  75. prog npm:node8 = {
  76. version = %{V_node8}
  77. url = https://nodejs.org/download/release/
  78. regex = v(8\.\d+\.\d+)
  79. }
  80. %prep
  81. %setup -q -n cli-%{V_npm}
  82. %patch -p0
  83. %build
  84. # configure NPM
  85. CC="%{l_cc}" \
  86. CFLAGS="%{l_cflags -O}" \
  87. CPPFLAGS="%{l_cppflags}" \
  88. LDFLAGS="%{l_ldflags}" \
  89. %{l_bash} ./configure \
  90. --prefix=%{l_prefix} \
  91. --disable-shared \
  92. --disable-nls
  93. # ensure the right Node executable is used
  94. %{l_shtool} subst \
  95. -e 's;/usr/bin/env node;%{l_prefix}/bin/node;g' \
  96. bin/npm-cli.js \
  97. bin/npx-cli.js \
  98. scripts/index-build.js \
  99. node_modules/semver/bin/semver \
  100. node_modules/which/bin/which \
  101. node_modules/nopt/bin/nopt.js
  102. %install
  103. # create installation hierarchy
  104. %{l_shtool} mkdir -f -p -m 755 \
  105. $RPM_BUILD_ROOT%{l_prefix}/bin \
  106. $RPM_BUILD_ROOT%{l_prefix}/lib/node/pkg/npm \
  107. $RPM_BUILD_ROOT%{l_prefix}/share/npm/node-gyp
  108. # install startup wrapper
  109. ( echo "#!/bin/sh"
  110. echo "exec %{l_prefix}/bin/node \\%{l_nil}"
  111. echo " --max-old-space-size=4096 \\%{l_nil}"
  112. echo " %{l_prefix}/lib/node/pkg/npm/bin/npm-cli.js \\%{l_nil}"
  113. echo " \${1+\"\$@\"}"
  114. ) >npm.sh
  115. %{l_shtool} install -c -m 755 \
  116. npm.sh $RPM_BUILD_ROOT%{l_prefix}/bin/npm
  117. ( echo "#!/bin/sh"
  118. echo "exec %{l_prefix}/bin/node \\%{l_nil}"
  119. echo " --max-old-space-size=4096 \\%{l_nil}"
  120. echo " %{l_prefix}/lib/node/pkg/npm/bin/npx-cli.js \\%{l_nil}"
  121. echo " \${1+\"\$@\"}"
  122. ) >npx.sh
  123. %{l_shtool} install -c -m 755 \
  124. npx.sh $RPM_BUILD_ROOT%{l_prefix}/bin/npx
  125. # install node-gyp wrapper
  126. ( echo "#!/bin/sh"
  127. echo "NODE_GYP=\"%{l_prefix}/share/npm/node-gyp\""
  128. echo "export NODE_GYP"
  129. echo "exec %{l_prefix}/bin/node \\%{l_nil}"
  130. echo " --max-old-space-size=4096 \\%{l_nil}"
  131. echo " %{l_prefix}/lib/node/pkg/npm/node_modules/node-gyp/bin/node-gyp.js \\%{l_nil}"
  132. echo " \${1+\"\$@\"}"
  133. ) >npm-node-gyp.sh
  134. %{l_shtool} install -c -m 755 \
  135. npm-node-gyp.sh $RPM_BUILD_ROOT%{l_prefix}/bin/npm-node-gyp
  136. # install NPM sources
  137. rm -f bin/npm.cmd bin/npm
  138. rm -rf test
  139. rm -rf doc
  140. rm -rf html
  141. rm -f AUTHORS CHANGELOG.md CONTRIBUTING.md LICENSE README.md
  142. rm -f node_modules/columnify/node_modules/.bin/strip-ansi
  143. rm -f node_modules/request/node_modules/har-validator/node_modules/chalk/node_modules/.bin/strip-ansi
  144. cp -rp * \
  145. $RPM_BUILD_ROOT%{l_prefix}/lib/node/pkg/npm/
  146. # provide an unpacked verson of the Node sources
  147. ( cd $RPM_BUILD_ROOT%{l_prefix}/share/npm/node-gyp
  148. %{l_gzip} -d -c %{SOURCE1} | %{l_tar} xf -
  149. mv node-v%{V_node14} %{V_node14}
  150. %{l_gzip} -d -c %{SOURCE2} | %{l_tar} xf -
  151. mv node-v%{V_node12} %{V_node12}
  152. %{l_gzip} -d -c %{SOURCE3} | %{l_tar} xf -
  153. mv node-v%{V_node10} %{V_node10}
  154. echo "9" >%{V_node10}/installVersion
  155. %{l_gzip} -d -c %{SOURCE4} | %{l_tar} xf -
  156. mv node-v%{V_node8} %{V_node8}
  157. echo "9" >%{V_node8}/installVersion
  158. ) || exit $?
  159. # determine installation files
  160. %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}
  161. %files -f files
  162. %clean