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 (expand / 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,14 +1,14 @@ @@ -1,14 +1,14 @@
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#
@@ -130,26 +130,28 @@ OVERRIDE_GEMSPEC?= # default is empty @@ -130,26 +130,28 @@ OVERRIDE_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}"); \
@@ -216,29 +218,29 @@ DISTFILES?= ${DISTNAME}${EXTRACT_SUFX} @@ -216,29 +218,29 @@ DISTFILES?= ${DISTNAME}${EXTRACT_SUFX}
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
@@ -252,30 +254,30 @@ PLIST_SUBST+= GEM_DOCDIR=${GEM_DOCDIR} @@ -252,30 +254,30 @@ PLIST_SUBST+= GEM_DOCDIR=${GEM_DOCDIR}
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
@@ -350,32 +352,35 @@ _gem-build-install-root-check: @@ -350,32 +352,35 @@ _gem-build-install-root-check:
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= \