2006-06-06 18:33:48 +02:00
|
|
|
# $NetBSD: extract.mk,v 1.3 2006/06/06 16:33:48 rillig Exp $
|
2005-05-11 06:01:49 +02:00
|
|
|
#
|
|
|
|
# The following variables may be set by the package Makefile and
|
|
|
|
# specify how extraction happens:
|
|
|
|
#
|
|
|
|
# EXTRACT_CMD is a shell command list that extracts the contents of
|
2006-01-21 19:55:10 +01:00
|
|
|
# an archive named by the variable ${DOWNLOADED_DISTFILE} to the
|
2006-01-21 20:39:22 +01:00
|
|
|
# current working directory. The default is ${EXTRACT_CMD_DEFAULT}.
|
|
|
|
#
|
2006-01-21 19:55:10 +01:00
|
|
|
# EXTRACT_OPTS is a list of options to pass to the "extract" script
|
2006-01-21 20:39:22 +01:00
|
|
|
# when using EXTRACT_CMD_DEFAULT. See the comments at the head of
|
|
|
|
# the "extract" script for a definitive list of the available
|
2006-01-21 19:55:10 +01:00
|
|
|
# options. The default list is empty.
|
2005-05-11 06:01:49 +02:00
|
|
|
#
|
2005-05-16 06:22:40 +02:00
|
|
|
# EXTRACT_USING specifies the tool used to extract tar/ustar-format
|
2006-01-21 20:39:22 +01:00
|
|
|
# archives when using EXTRACT_CMD_DEFAULT. The possible values are
|
|
|
|
# "gtar", "nbtar", and "pax". By default, we use the "nbtar" tool
|
|
|
|
# (pkgsrc's pax-as-tar).
|
2005-05-16 06:22:40 +02:00
|
|
|
#
|
2006-01-21 20:39:22 +01:00
|
|
|
# EXTRACT_ELEMENTS is a list of files within the distfile to extract
|
|
|
|
# when using EXTRACT_CMD_DEFAULT. By default, this is empty, which
|
|
|
|
# causes all files within the archive to be extracted.
|
2005-05-11 06:01:49 +02:00
|
|
|
#
|
2006-01-21 19:55:10 +01:00
|
|
|
# The following are read-only variables that may be used within a package
|
|
|
|
# Makefile:
|
|
|
|
#
|
|
|
|
# DOWNLOADED_DISTFILE represents the path to the distfile that is
|
|
|
|
# currently being extracted, and may be used in custom EXTRACT_CMD
|
|
|
|
# overrides, e.g.
|
|
|
|
#
|
|
|
|
# EXTRACT_CMD= ${TAIL} +25 ${DOWNLOADED_DISTFILE} > foo.pl
|
|
|
|
#
|
2006-06-06 18:33:48 +02:00
|
|
|
# EXTRACT_CMD_DEFAULT uses the "extract" script to unpack archives. The
|
|
|
|
# precise manner in which extraction occurs may be tweaked by setting
|
|
|
|
# EXTRACT_OPTS, EXTRACT_USING and EXTRACT_ELEMENTS.
|
|
|
|
#
|
2005-05-11 06:01:49 +02:00
|
|
|
|
2006-06-06 05:05:48 +02:00
|
|
|
_EXTRACT_COOKIE= ${WRKDIR}/.extract_done
|
2005-05-11 06:01:49 +02:00
|
|
|
|
2006-06-06 05:05:48 +02:00
|
|
|
######################################################################
|
|
|
|
### extract (PUBLIC)
|
|
|
|
######################################################################
|
|
|
|
### extract is a public target to perform extraction.
|
2006-01-21 19:55:10 +01:00
|
|
|
###
|
2006-06-06 05:05:48 +02:00
|
|
|
_EXTRACT_TARGETS+= checksum
|
|
|
|
_EXTRACT_TARGETS+= ${WRKDIR}
|
|
|
|
_EXTRACT_TARGETS+= depends
|
Separate out the part of bsd.tools.mk that actually created the tools
into a new file pkgsrc/mk/tools/create.mk. This leaves bsd.tools.mk
as a file that pulls in all of the other ones. Also move the
tools-related targets from bsd.pkg.mk into bsd.tools.mk.
The tools cookie file has been removed, as well as hooks for
{pre,do,post}-tools. Instead, there is now only a single public target
"tools" which may be invoked. Invoking "tools" will always cause all
of the tools in ${TOOLS_DIR} to be created.
The "tools" step has been moved and is now just after the "depends"
step and before sources are extracted. This is the earliest place
where the "tools" step can be taken, and it allows the created tools
to be used in all steps/phases after it, starting with "extract". As
a consequence, we should just invoke tools by their bare names in
targets, e.g. awk, sed, patch, etc., instead of with the ${VARIABLE}
names, e.g. ${AWK}, ${SED}, ${PATCH}, etc.
2006-06-06 08:30:29 +02:00
|
|
|
_EXTRACT_TARGETS+= tools
|
2006-06-06 05:05:48 +02:00
|
|
|
_EXTRACT_TARGETS+= acquire-extract-lock
|
|
|
|
_EXTRACT_TARGETS+= ${_EXTRACT_COOKIE}
|
|
|
|
_EXTRACT_TARGETS+= release-extract-lock
|
|
|
|
|
|
|
|
.PHONY: extract
|
|
|
|
.if !target(extract)
|
|
|
|
extract: ${_EXTRACT_TARGETS}
|
2005-05-11 06:01:49 +02:00
|
|
|
.endif
|
2006-06-06 05:05:48 +02:00
|
|
|
|
|
|
|
.PHONY: acquire-extract-lock release-extract-lock
|
|
|
|
acquire-extract-lock: acquire-lock
|
|
|
|
release-extract-lock: release-lock
|
|
|
|
|
|
|
|
.if !exists(${_EXTRACT_COOKIE})
|
|
|
|
${_EXTRACT_COOKIE}: real-extract
|
|
|
|
.else
|
|
|
|
${_EXTRACT_COOKIE}:
|
|
|
|
@${DO_NADA}
|
2005-05-11 06:01:49 +02:00
|
|
|
.endif
|
2006-06-06 05:05:48 +02:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
### real-extract (PRIVATE)
|
|
|
|
######################################################################
|
|
|
|
### real-extract is a helper target onto which one can hook all of the
|
|
|
|
### targets that do the actual extraction work.
|
|
|
|
###
|
|
|
|
_REAL_EXTRACT_TARGETS+= extract-check-interactive
|
|
|
|
_REAL_EXTRACT_TARGETS+= extract-message
|
|
|
|
_REAL_EXTRACT_TARGETS+= extract-vars
|
|
|
|
_REAL_EXTRACT_TARGETS+= pre-extract
|
|
|
|
_REAL_EXTRACT_TARGETS+= do-extract
|
|
|
|
_REAL_EXTRACT_TARGETS+= post-extract
|
|
|
|
_REAL_EXTRACT_TARGETS+= extract-cookie
|
|
|
|
|
|
|
|
.PHONY: real-extract
|
|
|
|
real-extract: ${_REAL_EXTRACT_TARGETS}
|
|
|
|
|
|
|
|
.PHONY: extract-message
|
|
|
|
extract-message:
|
|
|
|
@${PHASE_MSG} "Extracting for ${PKGNAME}"
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
### extract-check-interactive (PRIVATE)
|
|
|
|
######################################################################
|
|
|
|
### extract-check-interactive checks whether we can do an interactive
|
|
|
|
### extraction or not.
|
|
|
|
###
|
|
|
|
extract-check-interactive:
|
|
|
|
.if !empty(INTERACTIVE_STAGE:Mextract) && defined(BATCH)
|
|
|
|
@${ERROR_MSG} "The extract stage of this package requires user interaction"
|
|
|
|
@${ERROR_MSG} "Please extract manually with:"
|
|
|
|
@${ERROR_MSG} " \"cd ${PKGSRCDIR}/${PKGPATH} && ${MAKE} extract\""
|
|
|
|
@${TOUCH} ${_INTERACTIVE_COOKIE}
|
|
|
|
@${FALSE}
|
|
|
|
.else
|
|
|
|
@${DO_NADA}
|
2005-05-11 06:01:49 +02:00
|
|
|
.endif
|
|
|
|
|
2006-06-06 05:05:48 +02:00
|
|
|
######################################################################
|
|
|
|
### extract-cookie (PRIVATE)
|
|
|
|
######################################################################
|
|
|
|
### extract-cookie creates the "extract" cookie file. The contents
|
|
|
|
### are the name of the package.
|
|
|
|
###
|
|
|
|
.PHONY: extract-cookie
|
|
|
|
extract-cookie:
|
|
|
|
${_PKG_SILENT}${_PKG_DEBUG}${MKDIR} ${_EXTRACT_COOKIE:H}
|
|
|
|
${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${PKGNAME} >> ${_EXTRACT_COOKIE}
|
|
|
|
|
|
|
|
######################################################################
|
|
|
|
### pre-extract, do-extract, post-extract (PUBLIC, override)
|
|
|
|
######################################################################
|
|
|
|
### {pre,do,post}-extract are the heart of the package-customizable
|
|
|
|
### extract targets, and may be overridden within a package Makefile.
|
|
|
|
###
|
|
|
|
.PHONY: pre-extract do-extract post-extract
|
|
|
|
|
|
|
|
EXTRACT_USING?= nbtar
|
|
|
|
EXTRACT_ELEMENTS?= # empty
|
|
|
|
|
2006-01-21 19:55:10 +01:00
|
|
|
###
|
|
|
|
### Build the default extraction command
|
|
|
|
###
|
|
|
|
_EXTRACT_ENV+= ${EXTRACT_OPTS_BIN:D EXTRACT_OPTS_BIN=${EXTRACT_OPTS_BIN:Q}}
|
|
|
|
_EXTRACT_ENV+= ${EXTRACT_OPTS_LHA:D EXTRACT_OPTS_LHA=${EX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EXTRACT_ENV+= ${TOOLS_TAR:D TAR=${TOOLS_TAR:Q}}
|
|
|
|
_EXTRACT_ENV+= ${TOOLS_TEST:D TEST=${TOOLS_TEST:Q}}
|
|
|
|
_EXTRACT_ENV+= ${TOOLS_UNRAR:D UNRAR=${TOOLS_UNRAR:Q}}
|
|
|
|
_EXTRACT_ENV+= ${TOOLS_UNZIP_CMD:D UNZIP_CMD=${TOOLS_UNZIP_CMD:Q}}
|
|
|
|
_EXTRACT_ENV+= ${TOOLS_UNZOO:D UNZOO=${TOOLS_UNZOO:Q}}
|
|
|
|
_EXTRACT_ENV+= ${EXTRACT_ENV}
|
2005-05-11 06:01:49 +02:00
|
|
|
|
2005-05-16 05:04:44 +02:00
|
|
|
.if !empty(EXTRACT_USING:Mgtar)
|
2006-01-21 19:55:10 +01:00
|
|
|
EXTRACT_OPTS+= ${TOOLS_GTAR:D -t ${TOOLS_GTAR}}
|
2005-05-16 20:43:20 +02:00
|
|
|
.elif !empty(EXTRACT_USING:Mnbtar)
|
2006-01-21 19:55:10 +01:00
|
|
|
EXTRACT_OPTS+= ${TOOLS_TAR:D -t ${TOOLS_TAR}}
|
2005-05-16 05:04:44 +02:00
|
|
|
.else
|
2006-01-21 19:55:10 +01:00
|
|
|
EXTRACT_OPTS+= ${TOOLS_PAX:D -t ${TOOLS_PAX}}
|
2005-05-11 06:01:49 +02:00
|
|
|
.endif
|
|
|
|
|
2006-01-21 20:39:22 +01:00
|
|
|
EXTRACT_CMD_DEFAULT= \
|
|
|
|
${SETENV} ${_EXTRACT_ENV} \
|
2006-06-06 05:05:48 +02:00
|
|
|
${SH} ${PKGSRCDIR}//mk/extract/extract \
|
2006-01-21 20:39:22 +01:00
|
|
|
${EXTRACT_OPTS} \
|
|
|
|
${DOWNLOADED_DISTFILE} ${EXTRACT_ELEMENTS}
|
|
|
|
|
|
|
|
EXTRACT_CMD?= ${EXTRACT_CMD_DEFAULT}
|
2005-05-11 06:01:49 +02:00
|
|
|
|
2006-01-21 19:55:10 +01:00
|
|
|
DOWNLOADED_DISTFILE= $${extract_file}
|
2005-05-11 06:01:49 +02:00
|
|
|
|
|
|
|
.if !target(do-extract)
|
|
|
|
do-extract: ${WRKDIR}
|
|
|
|
. for __file__ in ${EXTRACT_ONLY}
|
|
|
|
${_PKG_SILENT}${_PKG_DEBUG} \
|
2006-01-21 19:55:10 +01:00
|
|
|
extract_file=${_DISTDIR:Q}/${__file__:Q}; export extract_file; \
|
|
|
|
cd ${WRKDIR} && ${EXTRACT_CMD}
|
2005-05-11 06:01:49 +02:00
|
|
|
. endfor
|
|
|
|
.endif
|
2006-01-19 20:35:25 +01:00
|
|
|
|
|
|
|
.if !target(pre-extract)
|
|
|
|
pre-extract:
|
|
|
|
@${DO_NADA}
|
|
|
|
.endif
|
|
|
|
.if !target(post-extract)
|
|
|
|
post-extract:
|
|
|
|
@${DO_NADA}
|
|
|
|
.endif
|