Subversion Repositories DevTools

Rev

Rev 2053 | Rev 2076 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2053 Rev 2074
Line 194... Line 194...
194
	fi);
194
	fi);
195
endef
195
endef
196
 
196
 
197
#.. Install/uninstall the specified file
197
#.. Install/uninstall the specified file
198
#
198
#
199
#   Usage:      $(call InstallFile,dest,file,path,fmode)
199
#   Usage:      $(call InstallFile,dest,file,fmode)
200
#               $(call UninstallFile,file)
200
#               $(call UninstallFile,file)
201
#
201
#
202
define InstallFile
202
define InstallFile
203
    $(call CopyFile,installing,$1,$2,$3,$4)
203
    $(call CopyFile,installing,$1,$2,$3,)
204
endef
204
endef
205
 
205
 
206
define UninstallFile
206
define UninstallFile
207
    $(call UncopyFile,uninstalling,$1)
207
    $(call UncopyFile,uninstalling,$1)
208
endef
208
endef
209
 
209
 
210
#.. Package/Unpackage the specified file
210
#.. Package/Unpackage the specified file
211
#
211
#
212
#   Usage:      $(call PackageFile,dest,file,path,fmode)
212
#   Usage:      $(call PackageFile,dest,file,fmode)
213
#               $(call UnpackageFile,file)
213
#               $(call UnpackageFile,file)
214
#
214
#
215
define PackageFile
215
define PackageFile
216
    $(call CopyFile,packaging,$1,$2,$3,$4)
216
    $(call CopyFile,packaging,$1,$2,$3,)
217
endef
217
endef
218
 
218
 
219
define UnpackageFile
219
define UnpackageFile
220
    $(call UncopyFile,unpackaging,$1)
220
    $(call UncopyFile,unpackaging,$1)
221
endef
221
endef
222
 
222
 
223
#.. Generic Copy/Remove the specified file
223
#.. Generic Copy/Remove the specified file
224
#
224
#
225
#   Usage:      $(call CopyFile,Text,dest,file,path,fmode)
225
#   Usage:      $(call CopyFile,Text,dest,file,fmode)
226
#               $(call UncopyFile,Text,file)
226
#               $(call UncopyFile,Text,file)
227
#
227
#
228
#   Notes:
228
#   Notes:
229
#       dest, file and path
229
#       dest, file and path
230
#	May have spaces in them
230
#	May have spaces in them
231
#		These will have been escaped with a '\' which will
231
#		These will have been escaped with a '\' which will
232
#		need to be removed. The '\ ' is required to keep make
232
#		need to be removed. The '\ ' is required to keep make
233
#		happy elsewhere.
233
#		happy elsewhere.
234
#
234
#
-
 
235
#	Current implementation uses a dedicated JATS-internal program to perform
-
 
236
#	the operations. This is much better than the previous implementation
-
 
237
#	which was shell-based. Its problems included:
-
 
238
#		1) Very slow under Windows
-
 
239
#		2) Special handling on $
-
 
240
#		3) Windows Path length limitation of < ~260 characters
-
 
241
#
-
 
242
#	Implementation note:
-
 
243
#		1) Do not get the shell involved in invoking the command
235
#	May have '$' in them which we will need to escape
244
#	           Quote args in '' not "" as "" will trigger shell usage
-
 
245
#		   This is good as we don't need/want shell expansion either
-
 
246
#		2) Paths use '/'. This is passed though to the utility
236
#
247
#
237
#       Windows copy has limitations.
-
 
238
#		Abs path length must < 260
-
 
239
#		Passing a relative path does not solve the problem
-
 
240
#		Moreover, if the relative path contains one or more ../
-
 
241
#		sequences, then the 'cp' command creates a complete path
-
 
242
#		before removing the zzz/.. sequences - and this must not exceed
-
 
243
#		259 characters.
-
 
244
#
-
 
245
#		At the moment we get the most out of the windows 'cp' by
-
 
246
#		passing it a clean absolute pathname, but there is still
-
 
247
#		a limit of ~259 characters. This affects many programs, not just
-
 
248
#		cp but make, rm, chmod ...
-
 
249
#
-
 
250
#
-
 
251
#	Nice Macros
248
#	Macros
252
#	AbsName	- convert a '\ ' pathname into an absolute path with plain spaces
-
 
253
#                 and $ escaped with a \.
-
 
254
#		  In the process 'spaces' need to be replaced with something to
-
 
255
#		  keep abspath from splitting on space.
-
 
256
#	NiceName - convert a '\ ' pathname into an string with plain spaces
249
#	NiceName - convert a '\ ' pathname into an string with plain spaces
257
#                 and $ escaped with a \.
-
 
258
#
250
#
259
AbsName = $(subst $$,\$$,$(subst $(spacealt),$(space),$(abspath $(subst \$(space),$(spacealt),$1))))
-
 
260
NiceName = $(subst $$,\$$,$(subst \$(space),$(space),$1))
251
NiceName = $(subst \$(space),$(space),$1)
261
 
-
 
262
define CopyFileNotWorking
-
 
263
	$(AA_PRE)(\
-
 
264
        set -vx;udest="$(call NiceName,$2)"; \
-
 
265
        dest="$(call AbsName,$2)"; \
-
 
266
        file="$(call NiceName,$3)"; \
-
 
267
        path="$(call AbsName,$4)"; \
-
 
268
        fmode="$(5)"; \
-
 
269
	echo "------ $1 $$udest"; \
-
 
270
        install -D --verbose "$$file" "$$dest"; \
-
 
271
        if [ $$? -gt 0 ] ; then echo "$1 copy error" ; exit 1; fi ;\
-
 
272
        if [ ! -f "$$dest" ] ; then echo "$1 file not found after copy: $$dest" ; exit 1; fi; \
-
 
273
        );
-
 
274
endef
-
 
275
 
252
 
276
define CopyFile
253
define CopyFile
277
	$(AA_PRE)(\
-
 
278
        udest="$(call NiceName,$2)"; \
-
 
279
        dest="$(call AbsName,$2)"; \
-
 
280
        file="$(call NiceName,$3)"; \
254
	$(AA_PRE)CopyFile 'c0' '$1' '$(call NiceName,$2)' '$(call NiceName,$3)' '$4'
281
        path="$(call AbsName,$4)"; \
-
 
282
        fmode="$(5)"; \
-
 
283
	echo "------ $1 $$udest"; \
-
 
284
        if [ ! -f "$$file" ] ; then echo "$1 source file not found: $$file" ; exit 1; fi;\
-
 
285
	if [ ! -d "$$path" ] ; then $(mkdir) -p "$$path"; fi; \
-
 
286
	if [ -f "$$dest" -a ! -w "$$dest" ]; then $(chmod) -f +w "$$dest"; fi; \
-
 
287
	$(rm) -f "$$dest"; \
-
 
288
        $(cp) "$$file" "$$dest" ;\
-
 
289
        if [ $$? -gt 0 ] ; then echo "$1 copy error" ; exit 1; fi ;\
-
 
290
        $(if $(5),$(chmod) -f $$fmode "$$dest") ; \
-
 
291
        if [ ! -f "$$dest" ] ; then echo "$1 file not found after copy: $$dest" ; exit 1; fi; \
-
 
292
        );
-
 
293
endef
255
endef
294
 
256
 
295
define UncopyFile
257
define UncopyFile
296
	$(AA_PRE)(\
-
 
297
        udest="$(call NiceName,$2)"; \
258
	$(AA_PRE)CopyFile 'd0' '$1' '$(call NiceName,$2)'
298
        file="$(call AbsName,$2)"; \
-
 
299
	echo "------ $1 $$udest"; \
-
 
300
	if [ -f "$$file" ]; then \
-
 
301
		if [ ! -w "$$file" ]; then $(chmod) -f +w "$$file"; fi; \
-
 
302
		$(rm) -f "$$file"; \
-
 
303
	fi);
-
 
304
endef
259
endef
305
 
260
 
306
##
261
##