Sun Jul 7 15:16:38 2013 UTC ()
Fix gem handling.

o Don't assume _DISTDIR end with '/' (by DESTDIR).
o A small clean up to GEM_CLEANBUILD handling.

A few clean up.


(taca)
diff -r1.20 -r1.21 pkgsrc/lang/ruby/gem.mk

cvs diff -r1.20 -r1.21 pkgsrc/lang/ruby/gem.mk (switch to unified diff)

--- pkgsrc/lang/ruby/gem.mk 2013/04/08 11:17:15 1.20
+++ pkgsrc/lang/ruby/gem.mk 2013/07/07 15:16:38 1.21
@@ -1,405 +1,410 @@ @@ -1,405 +1,410 @@
1# $NetBSD: gem.mk,v 1.20 2013/04/08 11:17:15 rodent Exp $ 1# $NetBSD: gem.mk,v 1.21 2013/07/07 15:16:38 taca Exp $
2# 2#
3# This Makefile fragment is intended to be included by packages that build 3# This Makefile fragment is intended to be included by packages that build
4# and install Ruby gems. 4# and install Ruby gems.
5# 5#
6# Package-settable variables: 6# Package-settable variables:
7# 7#
8# RUBYGEMS_REQD 8# RUBYGEMS_REQD
9# Minimum version of required rubygems. Ruby base packages contain: 9# Minimum version of required rubygems. Ruby base packages contain:
10# 10#
11# ruby18-base: none 11# ruby18-base: none
12# ruby193-base: 1.8.11 12# ruby193-base: 1.8.11
13# ruby200-base: 2.0.0 13# ruby200-base: 2.0.0
14# 14#
15# If newer version of rubygems is resuiqred, set RUBYGEMS_REQD to 15# If newer version of rubygems is resuiqred, set RUBYGEMS_REQD to
16# minimum version. 16# minimum version.
17# 17#
18# Default: not defined 18# Default: not defined
19# 19#
20# OVERRIDE_GEMSPEC 20# OVERRIDE_GEMSPEC
21# Fix version of depending gem or modify files in gemspec. 21# Fix version of depending gem or modify files in gemspec.
22# 22#
23# (1) Specify as gem and dependency pattern as usual pkgsrc's one. 23# (1) Specify as gem and dependency pattern as usual pkgsrc's one.
24# 24#
25# Example: 25# Example:
26# When gemspec contains "json~>1.4.7" as runtime dependency 26# When gemspec contains "json~>1.4.7" as runtime dependency
27# (i.e. json>=1.4.7<1.5) and if you want to relax it to 27# (i.e. json>=1.4.7<1.5) and if you want to relax it to
28# "json>=1.4.6" then use: 28# "json>=1.4.6" then use:
29# 29#
30# OVERRIDE_GEMSPEC+= json>=1.4.6 30# OVERRIDE_GEMSPEC+= json>=1.4.6
31# 31#
32# If you want to change depending gem to "json_pure>=1.4.6" 32# If you want to change depending gem to "json_pure>=1.4.6"
33# then use: 33# then use:
34# 34#
35# OVERRIDE_GEMSPEC+= json:json_pure>=1.4.6 35# OVERRIDE_GEMSPEC+= json:json_pure>=1.4.6
36# 36#
37# You can also remove dependency: 37# You can also remove dependency:
38# 38#
39# OVERRIDE_GEMSPEC+= json: 39# OVERRIDE_GEMSPEC+= json:
40# 40#
41# (2) Modify instance of gemspec. 41# (2) Modify instance of gemspec.
42# 42#
43# Example: 43# Example:
44# Rename gem's name to "foo" (setting instance @name): 44# Rename gem's name to "foo" (setting instance @name):
45# 45#
46# OVERRIDE_GEMSPEC+= :name=foo 46# OVERRIDE_GEMSPEC+= :name=foo
47# 47#
48# Example: 48# Example:
49# Remove files (a.rb and b.rb) from 'files': 49# Remove files (a.rb and b.rb) from 'files':
50# 50#
51# OVERRIDE_GEMSPEC+= :files a.rb= b.rb= 51# OVERRIDE_GEMSPEC+= :files a.rb= b.rb=
52# 52#
53# Example: 53# Example:
54# Add a file (exec.rb) to 'executables': 54# Add a file (exec.rb) to 'executables':
55# 55#
56# OVERRIDE_GEMSPEC+= :executables exec.rb 56# OVERRIDE_GEMSPEC+= :executables exec.rb
57# 57#
58# Example: 58# Example:
59# Rename a file (from 'ruby' to 'ruby193') in 'files': 59# Rename a file (from 'ruby' to 'ruby193') in 'files':
60# 60#
61# OVERRIDE_GEMSPEC+= :files ruby=ruby193 61# OVERRIDE_GEMSPEC+= :files ruby=ruby193
62# 62#
63# Note: Because of limited parser, argumetns for (1) must preceed to (2). 63# Note: Because of limited parser, argumetns for (1) must preceed to (2).
64# 64#
65# Default: (empty) 65# Default: (empty)
66# 66#
67# GEM_PATH 67# GEM_PATH
68# Set GEM_PATH; search path for rubygems 68# Set GEM_PATH; search path for rubygems
69# 69#
70# Default: ${PREFIX}/${GEM_HOME} 70# Default: ${PREFIX}/${GEM_HOME}
71# 71#
72# BUILD_TARGET 72# BUILD_TARGET
73# The Rakefile target that creates a local gem if using the 73# The Rakefile target that creates a local gem if using the
74# ``rake'' GEM_BUILD method. 74# ``rake'' GEM_BUILD method.
75# 75#
76# Default: gem 76# Default: gem
77# 77#
78# GEM_BUILD 78# GEM_BUILD
79# The method used to build the local gem. 79# The method used to build the local gem.
80# 80#
81# Possible: gemspec, rake 81# Possible: gemspec, rake
82# Default: gemspec 82# Default: gemspec
83# 83#
84# GEM_CLEANBUILD 84# GEM_CLEANBUILD
85# A list of shell globs representing files to remove from the 85# A list of shell globs representing files to remove from the
86# gem installed in the installation root. The file is removed 86# gem installed in the installation root. The file is removed
87# if the path matches the glob and is not in ${WRKSRC}. The 87# if the path matches the glob and is not in ${WRKSRC}. The
88# default is "ext/*" 88# default is "ext/*"
89# 89#
90# Example: 90# Example:
91# 91#
92# GEM_CLEANBUILD= *.o *.${RUBY_DLEXT} mkmf.log 92# GEM_CLEANBUILD= *.o *.${RUBY_DLEXT} mkmf.log
93# 93#
94# GEM_NAME 94# GEM_NAME
95# The name of the gem to install. The default value is ${DISTNAME}. 95# The name of the gem to install. The default value is ${DISTNAME}.
96# 96#
97# GEM_SPECFILE 97# GEM_SPECFILE
98# The path to the gemspec file to use when building a gem using 98# The path to the gemspec file to use when building a gem using
99# the ``gemspec'' GEM_BUILD method. It defaults to 99# the ``gemspec'' GEM_BUILD method. It defaults to
100# ${WRKDIR}/${DISTNAME}.gemspec. 100# ${WRKDIR}/${DISTNAME}.gemspec.
101# 101#
102# RUBYGEM_OPTIONS 102# RUBYGEM_OPTIONS
103# Optional parameter to pass to gem on install stage. 103# Optional parameter to pass to gem on install stage.
104# 104#
105# 105#
106# Variables defined in this file: 106# Variables defined in this file:
107# 107#
108# GEM_DOCDIR 108# GEM_DOCDIR
109# The relative path from PREFIX to the directory in the local gem 109# The relative path from PREFIX to the directory in the local gem
110# repository that holds the documentation for the installed gem. 110# repository that holds the documentation for the installed gem.
111# 111#
112# GEM_LIBDIR 112# GEM_LIBDIR
113# The relative path from PREFIX to the directory in the local gem 113# The relative path from PREFIX to the directory in the local gem
114# repository that holds the contents of the installed gem. 114# repository that holds the contents of the installed gem.
115# 115#
116# RUBYGEM 116# RUBYGEM
117# The path to the rubygems ``gem'' script. 117# The path to the rubygems ``gem'' script.
118# 118#
119.if !defined(_RUBYGEM_MK) 119.if !defined(_RUBYGEM_MK)
120_RUBYGEM_MK= # defined 120_RUBYGEM_MK= # defined
121 121
122# replace interpeter bin default 122# replace interpeter bin default
123REPLACE_RUBY_DIRS?= bin 123REPLACE_RUBY_DIRS?= bin
124REPLACE_RUBY_PAT?= * 124REPLACE_RUBY_PAT?= *
125 125
126# Default to using rake to build the local gem from the unpacked files. 126# Default to using rake to build the local gem from the unpacked files.
127GEM_BUILD?= gemspec 127GEM_BUILD?= gemspec
128 128
129OVERRIDE_GEMSPEC?= # default is empty 129OVERRIDE_GEMSPEC?= # default is empty
130 130
131RUBYGEM_LANG?= en_US.UTF-8 131RUBYGEM_LANG?= en_US.UTF-8
132RUBYGEM_ENV?= LANG=${RUBYGEM_LANG} LC_CTYPE=${RUBYGEM_LANG} 132RUBYGEM_ENV?= LANG=${RUBYGEM_LANG} LC_CTYPE=${RUBYGEM_LANG}
133 133
134.if !empty(OVERRIDE_GEMSPEC) 134.if !empty(OVERRIDE_GEMSPEC)
135UPDATE_GEMSPEC= ../../lang/ruby/files/update-gemspec.rb 135UPDATE_GEMSPEC= ../../lang/ruby/files/update-gemspec.rb
136.endif 136.endif
137 137
138.if ${GEM_BUILD} == "rake" 138.if ${GEM_BUILD} == "rake"
139USE_RAKE?= YES 139USE_RAKE?= YES
140.endif 140.endif
141 141
142# print-PLIST support 142# print-PLIST support
 143PRINT_PLIST_AWK+= /${GEM_NAME}\.info$$/ \
 144 { gsub(/${GEM_NAME}\.info/, "$${GEM_NAME}.info"); }
143PRINT_PLIST_AWK+= /${GEM_NAME}\.(gem|gemspec)$$/ \ 145PRINT_PLIST_AWK+= /${GEM_NAME}\.(gem|gemspec)$$/ \
144 { gsub(/${GEM_NAME}\.gem/, "$${GEM_NAME}.gem"); } 146 { gsub(/${GEM_NAME}\.gem/, "$${GEM_NAME}.gem"); }
145PRINT_PLIST_AWK+= /${GEM_NAME:S/./[.]/g}[.](gem|gemspec)$$/ \ 147PRINT_PLIST_AWK+= /${GEM_NAME:S/./[.]/g}[.](gem|gemspec)$$/ \
146 { gsub(/${PKGVERSION_NOREV:S|/|\\/|g}[.]gem/, "$${PKGVERSION}.gem"); } 148 { gsub(/${PKGVERSION_NOREV:S|/|\\/|g}[.]gem/, "$${PKGVERSION}.gem"); }
147PRINT_PLIST_AWK+= /^${GEM_LIBDIR:S|/|\\/|g}/ \ 149PRINT_PLIST_AWK+= /^${GEM_LIBDIR:S|/|\\/|g}/ \
148 { gsub(/${GEM_LIBDIR:S|/|\\/|g}/, "$${GEM_LIBDIR}"); print; next; } 150 { gsub(/${GEM_LIBDIR:S|/|\\/|g}/, "$${GEM_LIBDIR}"); print; next; }
149PRINT_PLIST_AWK+= /^${GEM_DOCDIR:S|/|\\/|g}/ \ 151PRINT_PLIST_AWK+= /^${GEM_DOCDIR:S|/|\\/|g}/ \
150 { next; } 152 { next; }
151PRINT_PLIST_AWK+= /^${GEM_HOME:S|/|\\/|g}/ \ 153PRINT_PLIST_AWK+= /^${GEM_HOME:S|/|\\/|g}/ \
152 { gsub(/${GEM_HOME:S|/|\\/|g}/, "$${GEM_HOME}"); \ 154 { gsub(/${GEM_HOME:S|/|\\/|g}/, "$${GEM_HOME}"); \
153 print; next; } 155 print; next; }
154PRINT_PLIST_AWK+= /^${RUBY_GEM_BASE:S|/|\\/|g}/ \ 156PRINT_PLIST_AWK+= /^${RUBY_GEM_BASE:S|/|\\/|g}/ \
155 { gsub(/${RUBY_GEM_BASE:S|/|\\/|g}/, "$${RUBY_GEM_BASE}"); \ 157 { gsub(/${RUBY_GEM_BASE:S|/|\\/|g}/, "$${RUBY_GEM_BASE}"); \
156 print; next; } 158 print; next; }
157 159
158# Include this early in case some of its target are needed 160# Include this early in case some of its target are needed
159.include "../../lang/ruby/modules.mk" 161.include "../../lang/ruby/modules.mk"
160 162
161# Build and run-time dependencies for Ruby prior to 1.9. 163# Build and run-time dependencies for Ruby prior to 1.9.
162# 164#
163# We need rubygems>=1.1.0 to actually build the package, but the 165# We need rubygems>=1.1.0 to actually build the package, but the
164# resulting installed gem can run with older versions of rubygems. 166# resulting installed gem can run with older versions of rubygems.
165# 167#
166# If we're using rake to build the local gem, then include it as a 168# If we're using rake to build the local gem, then include it as a
167# build tool. 169# build tool.
168# 170#
169 171
170.if ${RUBY_VER} == "18" 172.if ${RUBY_VER} == "18"
171BUILD_DEPENDS+= ${RUBY_PKGPREFIX}-rubygems>=1.1.0:../../misc/rubygems 173BUILD_DEPENDS+= ${RUBY_PKGPREFIX}-rubygems>=1.1.0:../../misc/rubygems
172DEPENDS+= ${RUBY_PKGPREFIX}-rubygems>=1.0.1:../../misc/rubygems 174DEPENDS+= ${RUBY_PKGPREFIX}-rubygems>=1.0.1:../../misc/rubygems
173.else # !ruby18 175.else # !ruby18
174. if defined(RUBYGEMS_REQD) 176. if defined(RUBYGEMS_REQD)
175 177
176RUBY193_RUBYGEMS_VERS= 1.8.11 178RUBY193_RUBYGEMS_VERS= 1.8.11
177RUBY200_RUBYGEMS_VERS= 2.0.0 179RUBY200_RUBYGEMS_VERS= 2.0.0
178 180
179_RUBYGEMS_REQD_MAJOR= ${RUBYGEMS_REQD:C/\.[0-9\.]+$//} 181_RUBYGEMS_REQD_MAJOR= ${RUBYGEMS_REQD:C/\.[0-9\.]+$//}
180_RUBYGEMS_REQD_MINORS= ${RUBYGEMS_REQD:C/^([0-9]+)\.*//} 182_RUBYGEMS_REQD_MINORS= ${RUBYGEMS_REQD:C/^([0-9]+)\.*//}
181 183
182. if ${RUBY_VER} == "193" 184. if ${RUBY_VER} == "193"
183_RUBYGEMS_MAJOR= ${RUBY193_RUBYGEMS_VERS:C/\.[0-9\.]+$//} 185_RUBYGEMS_MAJOR= ${RUBY193_RUBYGEMS_VERS:C/\.[0-9\.]+$//}
184_RUBYGEMS_MINORS= ${RUBY193_RUBYGEMS_VERS:C/^([0-9]+)\.*//} 186_RUBYGEMS_MINORS= ${RUBY193_RUBYGEMS_VERS:C/^([0-9]+)\.*//}
185. elif ${RUBY_VER} == "200" 187. elif ${RUBY_VER} == "200"
186_RUBYGEMS_MAJOR= ${RUBY200_RUBYGEMS_VERS:C/\.[0-9\.]+$//} 188_RUBYGEMS_MAJOR= ${RUBY200_RUBYGEMS_VERS:C/\.[0-9\.]+$//}
187_RUBYGEMS_MINORS= ${RUBY200_RUBYGEMS_VERS:C/^([0-9]+)\.*//} 189_RUBYGEMS_MINORS= ${RUBY200_RUBYGEMS_VERS:C/^([0-9]+)\.*//}
188. else 190. else
189PKG_FAIL_REASON+= "Unknown Ruby version specified: ${RUBY_VER}." 191PKG_FAIL_REASON+= "Unknown Ruby version specified: ${RUBY_VER}."
190. endif 192. endif
191 193
192_RUBYGEMS_REQD= NO 194_RUBYGEMS_REQD= NO
193 195
194. if ${_RUBYGEMS_REQD_MAJOR} > ${_RUBYGEMS_MAJOR} 196. if ${_RUBYGEMS_REQD_MAJOR} > ${_RUBYGEMS_MAJOR}
195_RUBYGEMS_REQD= YES 197_RUBYGEMS_REQD= YES
196. elif ${_RUBYGEMS_REQD_MAJOR} == ${_RUBYGEMS_MAJOR} 198. elif ${_RUBYGEMS_REQD_MAJOR} == ${_RUBYGEMS_MAJOR}
197. if !empty(_RUBYGEMS_MINORS) && ${_RUBYGEMS_REQD_MINORS} > ${_RUBYGEMS_MINORS} 199. if !empty(_RUBYGEMS_MINORS) && ${_RUBYGEMS_REQD_MINORS} > ${_RUBYGEMS_MINORS}
198_RUBYGEMS_REQD= YES 200_RUBYGEMS_REQD= YES
199. endif 201. endif
200. endif 202. endif
201 203
202. if empty(_RUBYGEMS_REQD:M[nN][oO]) 204. if empty(_RUBYGEMS_REQD:M[nN][oO])
203DEPENDS+= ${RUBY_PKGPREFIX}-rubygems>=${RUBYGEMS_REQD}:../../misc/rubygems 205DEPENDS+= ${RUBY_PKGPREFIX}-rubygems>=${RUBYGEMS_REQD}:../../misc/rubygems
204. endif 206. endif
205. endif 207. endif
206.endif # !ruby18 208.endif # !ruby18
207 209
208CATEGORIES+= ruby 210CATEGORIES+= ruby
209MASTER_SITES?= ${MASTER_SITE_RUBYGEMS} 211MASTER_SITES?= ${MASTER_SITE_RUBYGEMS}
210 212
211EXTRACT_SUFX?= .gem 213EXTRACT_SUFX?= .gem
212DISTFILES?= ${DISTNAME}${EXTRACT_SUFX} 214DISTFILES?= ${DISTNAME}${EXTRACT_SUFX}
213 215
214# If any of the DISTFILES are gems, then skip the normal do-extract actions 216# If any of the DISTFILES are gems, then skip the normal do-extract actions
215# and extract them ourselves in gem-extract. 217# and extract them ourselves in gem-extract.
216# 218#
217.if !empty(DISTFILES:M*.gem) 219.if !empty(DISTFILES:M*.gem)
218EXTRACT_ONLY?= # empty 220EXTRACT_ONLY?= # empty
219.endif 221.endif
220 222
221# Specify GEM_PATH 223# Specify GEM_PATH
222GEM_PATH?= ${PREFIX}/${GEM_HOME} 224GEM_PATH?= ${PREFIX}/${GEM_HOME}
223 225
224# Base directory for Gems 226# Base directory for Gems
225MAKE_ENV+= GEM_PATH=${GEM_PATH} 227MAKE_ENV+= GEM_PATH=${GEM_PATH}
226 228
227# Directory for the Gem to install 229# Directory for the Gem to install
228GEM_NAME?= ${DISTNAME} 230GEM_NAME?= ${DISTNAME}
229GEM_LIBDIR= ${GEM_HOME}/gems/${GEM_NAME} 
230GEM_DOCDIR= ${GEM_HOME}/doc/${GEM_NAME} 
231GEM_CACHEDIR= ${GEM_HOME}/cache 231GEM_CACHEDIR= ${GEM_HOME}/cache
 232GEM_DOCDIR= ${GEM_HOME}/doc/${GEM_NAME}
 233GEM_LIBDIR= ${GEM_HOME}/gems/${GEM_NAME}
232 234
233# Installed gems have wrapper scripts that call the right interpreter, 235# Installed gems have wrapper scripts that call the right interpreter,
234# regardless of the #! line at the head of a script, so we can skip 236# regardless of the #! line at the head of a script, so we can skip
235# the interpreter path check for gems. ANd it is also true for files' 237# the interpreter path check for gems. ANd it is also true for files'
236# permission. 238# permission.
237# 239#
238CHECK_INTERPRETER_SKIP+= ${GEM_LIBDIR}/* 240CHECK_INTERPRETER_SKIP+= ${GEM_LIBDIR}/*
239CHECK_PERMS_SKIP+= ${GEM_LIBDIR}/* 241CHECK_PERMS_SKIP+= ${GEM_LIBDIR}/*
240 242
241# RUBYGEM holds the path to RubyGems' gem command 243# RUBYGEM holds the path to RubyGems' gem command
242EVAL_PREFIX+= RUBYGEM_PREFIX=${RUBYGEM_NAME} 244EVAL_PREFIX+= RUBYGEM_PREFIX=${RUBYGEM_NAME}
243RUBYGEM= ${RUBYGEM_PREFIX}/bin/${RUBYGEM_NAME} 245RUBYGEM= ${RUBYGEM_PREFIX}/bin/${RUBYGEM_NAME}
244 246
245# PLIST support 247# PLIST support
246PLIST_SUBST+= GEM_NAME=${GEM_NAME} 248PLIST_SUBST+= GEM_NAME=${GEM_NAME}
247PLIST_SUBST+= GEM_LIBDIR=${GEM_LIBDIR} 249PLIST_SUBST+= GEM_LIBDIR=${GEM_LIBDIR}
248PLIST_SUBST+= GEM_DOCDIR=${GEM_DOCDIR} 250PLIST_SUBST+= GEM_DOCDIR=${GEM_DOCDIR}
249 251
250### 252###
251### gem-extract 253### gem-extract
252### 254###
253### The gem-extract target extracts a standard gem file. It is an 255### The gem-extract target extracts a standard gem file. It is an
254### automatic dependency for the post-extract target so it doesn't 256### automatic dependency for the post-extract target so it doesn't
255### disturb the usual do-extract actions. 257### disturb the usual do-extract actions.
256### 258###
257GEM_SPECFILE?= ${WRKDIR}/${DISTNAME}.gemspec 259GEM_SPECFILE?= ${WRKDIR}/${DISTNAME}.gemspec
258 260
259.PHONY: gem-extract 261.PHONY: gem-extract
260post-extract: gem-extract 262post-extract: gem-extract
261.if !target(gem-extract) 263.if !target(gem-extract)
262gem-extract: fake-home 264gem-extract: fake-home
263. for _gem_ in ${DISTFILES:M*.gem} 265. for _gem_ in ${DISTFILES:M*.gem}
264 ${RUN} cd ${WRKDIR} && ${SETENV} ${MAKE_ENV} ${RUBYGEM_ENV} \ 266 ${RUN} cd ${WRKDIR} && ${SETENV} ${MAKE_ENV} ${RUBYGEM_ENV} \
265 ${RUBYGEM} unpack ${_DISTDIR:Q}${_gem_:Q} 267 ${RUBYGEM} unpack ${_DISTDIR:Q}/${_gem_:Q}
266 ${RUN} cd ${WRKDIR} && \ 268 ${RUN} cd ${WRKDIR} && \
267 ${SETENV} ${MAKE_ENV} TZ=UTC ${RUBYGEM_ENV} \ 269 ${SETENV} ${MAKE_ENV} TZ=UTC ${RUBYGEM_ENV} \
268 ${RUBYGEM} spec --ruby ${_DISTDIR:Q}${_gem_:Q} > ${_gem_}spec 270 ${RUBYGEM} spec --ruby ${_DISTDIR:Q}/${_gem_:Q} > ${_gem_}spec
269. endfor 271. endfor
270.endif 272.endif
271 273
272### 274###
273### gem-build 275### gem-build
274### 276###
275### The gem-build target builds a new local gem from the extracted gem's 277### The gem-build target builds a new local gem from the extracted gem's
276### contents. The new gem as created as ${WRKSRC}/${GEM_NAME}.gem. 278### contents. The new gem as created as ${WRKSRC}/${GEM_NAME}.gem.
277### The local gem is then installed into a special build root under 279### The local gem is then installed into a special build root under
278### ${WRKDIR} (${RUBYGEM_INSTALL_ROOT}), possibly compiling any extensions. 280### ${WRKDIR} (${RUBYGEM_INSTALL_ROOT}), possibly compiling any extensions.
279### 281###
280GEM_CLEANBUILD?= ext/* 282GEM_CLEANBUILD?= ext/*
281 283
282.if !empty(GEM_CLEANBUILD:M/*) || !empty(GEM_CLEANBUILD:M*../*) 284.if !empty(GEM_CLEANBUILD:M/*) || !empty(GEM_CLEANBUILD:M*../*)
283PKG_FAIL_REASON= "GEM_CLEANBUILD must be relative to "${PREFIX}/${GEM_LIBDIR:Q}"." 285PKG_FAIL_REASON= "GEM_CLEANBUILD must be relative to "${PREFIX}/${GEM_LIBDIR:Q}"."
284.endif 286.endif
285 287
286.PHONY: gem-build 288.PHONY: gem-build
287do-build: _gem-pre-build gem-build 289do-build: _gem-pre-build gem-build
288 290
289_gem-pre-build: 291_gem-pre-build:
290.if !empty(OVERRIDE_GEMSPEC) 292.if !empty(OVERRIDE_GEMSPEC)
291 @${STEP_MSG} Override gemspec dependency 293 @${STEP_MSG} Override gemspec dependency
292 @${RUBY} ${.CURDIR}/${UPDATE_GEMSPEC} ${WRKDIR}/${GEM_NAME}.gemspec \ 294 @${RUBY} ${.CURDIR}/${UPDATE_GEMSPEC} ${WRKDIR}/${GEM_NAME}.gemspec \
293 ${OVERRIDE_GEMSPEC:Q} 295 ${OVERRIDE_GEMSPEC:Q}
294.endif 296.endif
295 @${STEP_MSG} "Removing backup files of patch before build" 297 @${STEP_MSG} "Removing backup files of patch before build"
296 @find ${WRKSRC} -name \*.orig -exec rm {} \; 298 @find ${WRKSRC} -name \*.orig -exec rm {} \;
297 299
298gem-build: _gem-${GEM_BUILD}-build 300gem-build: _gem-${GEM_BUILD}-build
299 301
300.PHONY: _gem-gemspec-build 302.PHONY: _gem-gemspec-build
301_gem-gemspec-build: 303_gem-gemspec-build:
302 ${RUN} cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${RUBYGEM_ENV} \ 304 ${RUN} cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${RUBYGEM_ENV} \
303 ${RUBYGEM} build ${GEM_SPECFILE} 305 ${RUBYGEM} build ${GEM_SPECFILE}
304 ${RUN} ${TEST} -f ${WRKSRC}/${GEM_NAME}.gem || \ 306 ${RUN} ${TEST} -f ${WRKSRC}/${GEM_NAME}.gem || \
305 ${FAIL_MSG} "Build of ${GEM_NAME}.gem failed." 307 ${FAIL_MSG} "Build of ${GEM_NAME}.gem failed."
306 308
307BUILD_TARGET?= gem 309BUILD_TARGET?= gem
308 310
309.PHONY: _gem-rake-build 311.PHONY: _gem-rake-build
310_gem-rake-build: 312_gem-rake-build:
311 ${RUN} cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${RAKE} ${BUILD_TARGET} 313 ${RUN} cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${RAKE} ${BUILD_TARGET}
312 ${RUN} cd ${WRKSRC} && rm -f ${GEM_NAME}.gem 314 ${RUN} cd ${WRKSRC} && rm -f ${GEM_NAME}.gem
313 ${RUN} cd ${WRKSRC} && find . -name ${GEM_NAME}.gem -print | \ 315 ${RUN} cd ${WRKSRC} && find . -name ${GEM_NAME}.gem -print | \
314 while read file; do \ 316 while read file; do \
315 ln -fs "$$file" ${GEM_NAME}.gem; \ 317 ln -fs "$$file" ${GEM_NAME}.gem; \
316 exit 0; \ 318 exit 0; \
317 done 319 done
318 320
319RUBYGEM_INSTALL_ROOT= ${WRKDIR}/.inst 321RUBYGEM_INSTALL_ROOT= ${WRKDIR}/.inst
320_RUBYGEM_OPTIONS= --no-update-sources # don't cache the gem index 322_RUBYGEM_OPTIONS= --no-update-sources # don't cache the gem index
321_RUBYGEM_OPTIONS+= --install-dir ${PREFIX}/${GEM_HOME} 323_RUBYGEM_OPTIONS+= --install-dir ${PREFIX}/${GEM_HOME}
322_RUBYGEM_OPTIONS+= ${RUBYGEM_INSTALL_ROOT_OPTION} 324_RUBYGEM_OPTIONS+= ${RUBYGEM_INSTALL_ROOT_OPTION}
323_RUBYGEM_OPTIONS+= --ignore-dependencies 325_RUBYGEM_OPTIONS+= --ignore-dependencies
324_RUBYGEM_OPTIONS+= --local ${WRKSRC}/${GEM_NAME}.gem 326_RUBYGEM_OPTIONS+= --local ${WRKSRC}/${GEM_NAME}.gem
325.if !empty(RUBY_BUILD_RI:M[nN][oO]) 327.if !empty(RUBY_BUILD_RI:M[nN][oO])
326_RUBYGEM_OPTIONS+= --no-ri 328_RUBYGEM_OPTIONS+= --no-ri
327.endif 329.endif
328.if !empty(RUBY_BUILD_RDOC:M[nN][oO]) 330.if !empty(RUBY_BUILD_RDOC:M[nN][oO])
329_RUBYGEM_OPTIONS+= --no-rdoc 331_RUBYGEM_OPTIONS+= --no-rdoc
330.endif 332.endif
331.if !empty(CONFIGURE_ARGS) 333.if !empty(CONFIGURE_ARGS)
332_RUBYGEM_OPTIONS+= -- --build-args ${CONFIGURE_ARGS} 334_RUBYGEM_OPTIONS+= -- --build-args ${CONFIGURE_ARGS}
333.endif 335.endif
334 336
335RUBYGEM_INSTALL_ROOT_OPTION= --install-root ${RUBYGEM_INSTALL_ROOT} 337RUBYGEM_INSTALL_ROOT_OPTION= --install-root ${RUBYGEM_INSTALL_ROOT}
336 338
337.PHONY: _gem-build-install-root 339.PHONY: _gem-build-install-root
338_gem-build-install-root: 340_gem-build-install-root:
339 @${STEP_MSG} "Installing gem into installation root" 341 @${STEP_MSG} "Installing gem into installation root"
340 ${RUN} ${SETENV} ${MAKE_ENV} ${RUBYGEM_ENV} \ 342 ${RUN} ${SETENV} ${MAKE_ENV} ${RUBYGEM_ENV} \
341 ${RUBYGEM} install --backtrace ${RUBYGEM_OPTIONS} ${_RUBYGEM_OPTIONS} 343 ${RUBYGEM} install --backtrace ${RUBYGEM_OPTIONS} ${_RUBYGEM_OPTIONS}
342 344
343# The ``gem'' command doesn't exit with a non-zero result even if the 345# The ``gem'' command doesn't exit with a non-zero result even if the
344# install of the gem failed, so we do the check and return the proper exit 346# install of the gem failed, so we do the check and return the proper exit
345# code ourselves. 347# code ourselves.
346# 348#
347.PHONY: _gem-build-install-root-check 349.PHONY: _gem-build-install-root-check
348_gem-build-install-root-check: 350_gem-build-install-root-check:
349 ${RUN} ${TEST} -f ${RUBYGEM_INSTALL_ROOT}${PREFIX}/${GEM_CACHEDIR}/${GEM_NAME}.gem || \ 351 ${RUN} ${TEST} -f ${RUBYGEM_INSTALL_ROOT}${PREFIX}/${GEM_CACHEDIR}/${GEM_NAME}.gem || \
350 ${FAIL_MSG} "Installing ${GEM_NAME}.gem into installation root failed." 352 ${FAIL_MSG} "Installing ${GEM_NAME}.gem into installation root failed."
351 353
352.if !empty(GEM_CLEANBUILD) 354.if !empty(GEM_CLEANBUILD)
353.PHONY: _gem-build-cleanbuild 355.PHONY: _gem-build-cleanbuild
354_gem-build-cleanbuild: 356_gem-build-cleanbuild:
355 @${STEP_MSG} "Cleaning intermediate gem build files" 357 @${STEP_MSG} "Cleaning intermediate gem build files"
356 ${RUN} cd ${RUBYGEM_INSTALL_ROOT}${PREFIX}/${GEM_LIBDIR} && \ 358 ${RUN} cd ${RUBYGEM_INSTALL_ROOT}${PREFIX}/${GEM_LIBDIR} && \
357 find . -print | sort -r | \ 359 find . -print | sort -r | \
358 while read file; do \ 360 while read file; do \
359 case $$file in \ 361 case $$file in \
360 ${GEM_CLEANBUILD:@.p.@./${.p.}) ;;@} \ 362 ${GEM_CLEANBUILD:@.p.@./${.p.}) ;;@} \
361 *) continue ;; \ 363 *) continue ;; \
362 esac; \ 364 esac; \
363 [ ! -e ${WRKSRC:Q}"/$$file" ] || continue; \ 365 if [ -e ${WRKSRC:Q}"/$$file" ]; then \
364 if [ -d "$$file" ]; then \ 366 && continue; \
365 ${ECHO} "rmdir "${GEM_NAME}"/$$file"; \ 367 elif [ -d "$$file" ]; then \
 368 rfile=`echo $$file | ${SED} -e 's|^\./||'`; \
 369 ${ECHO} "rmdir "${GEM_NAME}"/$$rfile"; \
366 rmdir $$file; \ 370 rmdir $$file; \
367 else \ 371 elif [ -f "$$file" ]; then \
368 ${ECHO} "rm "${GEM_NAME}"/$$file"; \ 372 rfile=`echo $$file | ${SED} -e 's|^\./||'`; \
 373 ${ECHO} "rm "${GEM_NAME}"/$$rfile"; \
369 rm -f $$file; \ 374 rm -f $$file; \
370 fi; \ 375 fi; \
371 done 376 done
372.endif 377.endif
373 378
374### 379###
375### gem-install 380### gem-install
376### 381###
377### The gem-install target installs the gem in ${_RUBY_INSTALL_ROOT} into 382### The gem-install target installs the gem in ${_RUBY_INSTALL_ROOT} into
378### the actual gem repository. 383### the actual gem repository.
379### 384###
380GENERATE_PLIST+= ${RUBYGEM_GENERATE_PLIST} 385GENERATE_PLIST+= ${RUBYGEM_GENERATE_PLIST}
381RUBYGEM_GENERATE_PLIST= \ 386RUBYGEM_GENERATE_PLIST= \
382 ${ECHO} "@comment The following lines are automatically generated." && \ 387 ${ECHO} "@comment The following lines are automatically generated." && \
383 ( cd ${RUBYGEM_INSTALL_ROOT}${PREFIX} && test -d ${GEM_DOCDIR} && \ 388 ( cd ${RUBYGEM_INSTALL_ROOT}${PREFIX} && test -d ${GEM_DOCDIR} && \
384 ${FIND} ${GEM_DOCDIR} \! -type d -print | ${SORT} ) || true; 389 ${FIND} ${GEM_DOCDIR} \! -type d -print | ${SORT} ) || true;
385 390
386_GEM_INSTALL_TARGETS= _gem-build-install-root 391_GEM_INSTALL_TARGETS= _gem-build-install-root
387_GEM_INSTALL_TARGETS+= _gem-build-install-root-check 392_GEM_INSTALL_TARGETS+= _gem-build-install-root-check
388.if !empty(GEM_CLEANBUILD) 393.if !empty(GEM_CLEANBUILD)
389_GEM_INSTALL_TARGETS+= _gem-build-cleanbuild 394_GEM_INSTALL_TARGETS+= _gem-build-cleanbuild
390.endif 395.endif
391_GEM_INSTALL_TARGETS+= _gem-install 396_GEM_INSTALL_TARGETS+= _gem-install
392 397
393.ORDER: ${_GEM_INSTALL_TARGETS} 398.ORDER: ${_GEM_INSTALL_TARGETS}
394 399
395USE_TOOLS+= pax 400USE_TOOLS+= pax
396 401
397do-install: ${_GEM_INSTALL_TARGETS} 402do-install: ${_GEM_INSTALL_TARGETS}
398 403
399.PHONY: _gem-install 404.PHONY: _gem-install
400_gem-install: 405_gem-install:
401 @${STEP_MSG} "gem install" 406 @${STEP_MSG} "gem install"
402 ${RUN} cd ${RUBYGEM_INSTALL_ROOT}${PREFIX} && \ 407 ${RUN} cd ${RUBYGEM_INSTALL_ROOT}${PREFIX} && \
403 pax -rwpe . ${DESTDIR}${PREFIX} 408 pax -rwpe . ${DESTDIR}${PREFIX}
404 409
405.endif 410.endif