2019-05-07 21:36:43 +02:00
|
|
|
# $NetBSD: extract.mk,v 1.38 2019/05/07 19:36:44 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:
|
|
|
|
#
|
2008-03-12 16:48:21 +01:00
|
|
|
# EXTRACT_DIR
|
2006-10-09 04:31:57 +02:00
|
|
|
# The directory into which the files are extracted.
|
|
|
|
#
|
2007-01-09 06:13:27 +01:00
|
|
|
# Default value: ${WRKDIR}
|
2006-10-09 04:31:57 +02:00
|
|
|
#
|
2010-10-15 22:22:27 +02:00
|
|
|
# EXTRACT_DIR.${file}
|
|
|
|
# The directory into which the file ${file} is extracted.
|
|
|
|
#
|
|
|
|
# Default: ${EXTRACT_DIR}
|
|
|
|
#
|
2014-03-02 10:45:42 +01:00
|
|
|
# EXTRACT_ENV is the shell environment that is exported to the extract
|
|
|
|
# process.
|
|
|
|
#
|
2008-03-12 16:51:39 +01:00
|
|
|
# EXTRACTOR is the the the environment and path used to execute the
|
|
|
|
# all-purpose extract script.
|
|
|
|
#
|
2005-05-11 06:01:49 +02:00
|
|
|
# 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
|
2008-05-26 15:39:08 +02:00
|
|
|
# "bsdtar", "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-10-09 04:37:32 +02:00
|
|
|
EXTRACT_DIR?= ${WRKDIR}
|
2010-10-15 22:22:27 +02:00
|
|
|
.for f in ${EXTRACT_ONLY}
|
|
|
|
EXTRACT_DIR.${f}?= ${EXTRACT_DIR}
|
|
|
|
.endfor
|
2006-10-09 04:37:32 +02:00
|
|
|
|
2006-07-07 23:24:27 +02:00
|
|
|
_COOKIE.extract= ${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-07-05 11:08:35 +02:00
|
|
|
_EXTRACT_TARGETS+= check-vulnerable
|
2006-07-27 15:47:29 +02:00
|
|
|
_EXTRACT_TARGETS+= tools
|
2006-06-06 05:05:48 +02:00
|
|
|
_EXTRACT_TARGETS+= acquire-extract-lock
|
2006-07-07 23:24:27 +02:00
|
|
|
_EXTRACT_TARGETS+= ${_COOKIE.extract}
|
2006-06-06 05:05:48 +02:00
|
|
|
_EXTRACT_TARGETS+= release-extract-lock
|
|
|
|
|
|
|
|
.PHONY: extract
|
|
|
|
.if !target(extract)
|
2019-05-07 21:36:43 +02:00
|
|
|
. if exists(${_COOKIE.extract}) && !${_CLEANING}
|
2006-07-05 11:08:35 +02:00
|
|
|
extract:
|
|
|
|
@${DO_NADA}
|
2006-07-22 18:31:35 +02:00
|
|
|
. elif defined(_PKGSRC_BARRIER)
|
Flatten out recursive makes into a single re-invocation of make by
introducing the concept of a "barrier". We separate the user-invokable
targets into ones that must happen before the barrier, and ones that
must happen after the barrier. The ones that happen after the barrier
are run in a sub-make process. In this case, the targets that must
be run after the barrier are from the "wrapper" step and beyond. We
rewrite the various "flow" targets, e.g. wrapper, configure, build,
etc., so that they of the right form to use the barrier target.
This now completely removes the concept of PKG_PHASE from pkgsrc. It
is replaced with the concept of "before" and "after" the barrier, and
this state can be checked by testing for the existence of the barrier
cookie file. Because we've removed most of the recursive makes, there
is now nowhere to hook the PKG_ERROR_HANDLER.* commands, so remove
them for now.
As part of this commit, put back the logic that conditionalized the
sources for the various cookie files. Because the sources are all
"phony" targets, they were always run, regardless of whether or not
the cookie file already existed. Now, if a cookie file exists, then
that entire phase associated with that cookie file is skipped.
Lastly, fix a thinko in configure/bsd.configure.mk where setting
NO_CONFIGURE in a package Makefile would manage to skip the "wrapper"
step altogether. Fix this by correctly noting "wrapper" and not
"patch" as the preceding step to "configure".
2006-07-06 00:21:02 +02:00
|
|
|
extract: ${_EXTRACT_TARGETS}
|
2006-07-21 16:21:28 +02:00
|
|
|
. else
|
|
|
|
extract: barrier
|
2006-07-05 11:08:35 +02:00
|
|
|
. endif
|
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
|
|
|
|
|
2019-05-07 21:36:43 +02:00
|
|
|
.if exists(${_COOKIE.extract}) && !${_CLEANING}
|
2006-07-07 23:24:27 +02:00
|
|
|
${_COOKIE.extract}:
|
Flatten out recursive makes into a single re-invocation of make by
introducing the concept of a "barrier". We separate the user-invokable
targets into ones that must happen before the barrier, and ones that
must happen after the barrier. The ones that happen after the barrier
are run in a sub-make process. In this case, the targets that must
be run after the barrier are from the "wrapper" step and beyond. We
rewrite the various "flow" targets, e.g. wrapper, configure, build,
etc., so that they of the right form to use the barrier target.
This now completely removes the concept of PKG_PHASE from pkgsrc. It
is replaced with the concept of "before" and "after" the barrier, and
this state can be checked by testing for the existence of the barrier
cookie file. Because we've removed most of the recursive makes, there
is now nowhere to hook the PKG_ERROR_HANDLER.* commands, so remove
them for now.
As part of this commit, put back the logic that conditionalized the
sources for the various cookie files. Because the sources are all
"phony" targets, they were always run, regardless of whether or not
the cookie file already existed. Now, if a cookie file exists, then
that entire phase associated with that cookie file is skipped.
Lastly, fix a thinko in configure/bsd.configure.mk where setting
NO_CONFIGURE in a package Makefile would manage to skip the "wrapper"
step altogether. Fix this by correctly noting "wrapper" and not
"patch" as the preceding step to "configure".
2006-07-06 00:21:02 +02:00
|
|
|
@${DO_NADA}
|
|
|
|
.else
|
2006-07-07 23:24:27 +02:00
|
|
|
${_COOKIE.extract}: real-extract
|
Flatten out recursive makes into a single re-invocation of make by
introducing the concept of a "barrier". We separate the user-invokable
targets into ones that must happen before the barrier, and ones that
must happen after the barrier. The ones that happen after the barrier
are run in a sub-make process. In this case, the targets that must
be run after the barrier are from the "wrapper" step and beyond. We
rewrite the various "flow" targets, e.g. wrapper, configure, build,
etc., so that they of the right form to use the barrier target.
This now completely removes the concept of PKG_PHASE from pkgsrc. It
is replaced with the concept of "before" and "after" the barrier, and
this state can be checked by testing for the existence of the barrier
cookie file. Because we've removed most of the recursive makes, there
is now nowhere to hook the PKG_ERROR_HANDLER.* commands, so remove
them for now.
As part of this commit, put back the logic that conditionalized the
sources for the various cookie files. Because the sources are all
"phony" targets, they were always run, regardless of whether or not
the cookie file already existed. Now, if a cookie file exists, then
that entire phase associated with that cookie file is skipped.
Lastly, fix a thinko in configure/bsd.configure.mk where setting
NO_CONFIGURE in a package Makefile would manage to skip the "wrapper"
step altogether. Fix this by correctly noting "wrapper" and not
"patch" as the preceding step to "configure".
2006-07-06 00:21:02 +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
|
2006-10-09 04:31:57 +02:00
|
|
|
_REAL_EXTRACT_TARGETS+= extract-dir
|
2006-06-06 05:05:48 +02:00
|
|
|
_REAL_EXTRACT_TARGETS+= pre-extract
|
|
|
|
_REAL_EXTRACT_TARGETS+= do-extract
|
|
|
|
_REAL_EXTRACT_TARGETS+= post-extract
|
|
|
|
_REAL_EXTRACT_TARGETS+= extract-cookie
|
2006-06-09 15:59:06 +02:00
|
|
|
_REAL_EXTRACT_TARGETS+= error-check
|
2006-06-06 05:05:48 +02:00
|
|
|
|
|
|
|
.PHONY: real-extract
|
|
|
|
real-extract: ${_REAL_EXTRACT_TARGETS}
|
|
|
|
|
|
|
|
.PHONY: extract-message
|
|
|
|
extract-message:
|
|
|
|
@${PHASE_MSG} "Extracting for ${PKGNAME}"
|
|
|
|
|
2006-10-09 04:31:57 +02:00
|
|
|
.PHONY: extract-dir
|
|
|
|
extract-dir:
|
2008-01-23 15:59:35 +01:00
|
|
|
${RUN}${MKDIR} ${EXTRACT_DIR}
|
2010-10-15 22:22:27 +02:00
|
|
|
.for f in ${EXTRACT_ONLY}
|
|
|
|
${RUN}${MKDIR} ${EXTRACT_DIR.${f}}
|
|
|
|
.endfor
|
2006-10-09 04:31:57 +02:00
|
|
|
|
2006-06-06 05:05:48 +02:00
|
|
|
######################################################################
|
|
|
|
### extract-check-interactive (PRIVATE)
|
|
|
|
######################################################################
|
2006-06-08 17:45:52 +02:00
|
|
|
### extract-check-interactive checks whether we must do an interactive
|
2006-06-06 05:05:48 +02:00
|
|
|
### extraction or not.
|
|
|
|
###
|
2006-07-26 20:29:46 +02:00
|
|
|
.PHONY: extract-check-interactive
|
2006-06-06 05:05:48 +02:00
|
|
|
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:"
|
2006-06-09 10:20:30 +02:00
|
|
|
@${ERROR_MSG} " \"cd ${.CURDIR} && ${MAKE} extract\""
|
2007-12-01 12:11:53 +01:00
|
|
|
${RUN} ${FALSE}
|
2006-06-06 05:05:48 +02:00
|
|
|
.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:
|
2008-01-23 15:59:35 +01:00
|
|
|
${RUN}${TEST} ! -f ${_COOKIE.extract} || ${FALSE}
|
|
|
|
${RUN}${MKDIR} ${_COOKIE.extract:H}
|
|
|
|
${RUN}${ECHO} ${PKGNAME} > ${_COOKIE.extract}
|
2006-06-06 05:05:48 +02:00
|
|
|
|
|
|
|
######################################################################
|
|
|
|
### 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=${EXTRACT_OPTS_LHA:Q}}
|
|
|
|
_EXTRACT_ENV+= ${EXTRACT_OPTS_PAX:D EXTRACT_OPTS_PAX=${EXTRACT_OPTS_PAX:Q}}
|
|
|
|
_EXTRACT_ENV+= ${EXTRACT_OPTS_RAR:D EXTRACT_OPTS_RAR=${EXTRACT_OPTS_RAR:Q}}
|
2007-07-31 19:42:40 +02:00
|
|
|
_EXTRACT_ENV+= ${EXTRACT_OPTS_RPM:D EXTRACT_OPTS_LHA=${EXTRACT_OPTS_RPM:Q}}
|
2006-01-21 19:55:10 +01:00
|
|
|
_EXTRACT_ENV+= ${EXTRACT_OPTS_TAR:D EXTRACT_OPTS_TAR=${EXTRACT_OPTS_TAR:Q}}
|
|
|
|
_EXTRACT_ENV+= ${EXTRACT_OPTS_ZIP:D EXTRACT_OPTS_ZIP=${EXTRACT_OPTS_ZIP:Q}}
|
|
|
|
_EXTRACT_ENV+= ${EXTRACT_OPTS_ZOO:D EXTRACT_OPTS_ZOO=${EXTRACT_OPTS_ZOO:Q}}
|
2010-02-07 09:00:51 +01:00
|
|
|
_EXTRACT_ENV+= ${TOOLS_CMDLINE_BZCAT:D BZCAT=${TOOLS_CMDLINE_BZCAT:Q}}
|
2006-01-21 19:55:10 +01:00
|
|
|
_EXTRACT_ENV+= ${TOOLS_CAT:D CAT=${TOOLS_CAT:Q}}
|
|
|
|
_EXTRACT_ENV+= ${TOOLS_CP:D CP=${TOOLS_CP:Q}}
|
|
|
|
_EXTRACT_ENV+= ${TOOLS_ECHO:D ECHO=${TOOLS_ECHO:Q}}
|
2006-01-23 15:43:50 +01:00
|
|
|
_EXTRACT_ENV+= ${TOOLS_CMDLINE.gzcat:D GZCAT=${TOOLS_CMDLINE.gzcat:Q}}
|
2006-01-21 19:55:10 +01:00
|
|
|
_EXTRACT_ENV+= ${TOOLS_LHA:D LHA=${TOOLS_LHA:Q}}
|
|
|
|
_EXTRACT_ENV+= ${TOOLS_MKDIR:D MKDIR=${TOOLS_MKDIR:Q}}
|
|
|
|
_EXTRACT_ENV+= ${TOOLS_RM:D RM=${TOOLS_RM:Q}}
|
2007-07-31 19:42:40 +02:00
|
|
|
_EXTRACT_ENV+= ${TOOLS_RPM2PKG:D RPM2PKG=${TOOLS_RPM2PKG:Q}}
|
2006-01-21 19:55:10 +01:00
|
|
|
_EXTRACT_ENV+= ${TOOLS_PAX:D PAX=${TOOLS_PAX:Q}}
|
|
|
|
_EXTRACT_ENV+= ${TOOLS_SH:D SH=${TOOLS_SH:Q}}
|
|
|
|
_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}}
|
2009-07-08 15:27:52 +02:00
|
|
|
_EXTRACT_ENV+= ${TOOLS_XZCAT:D XZCAT=${TOOLS_XZCAT:Q}}
|
2012-10-07 00:16:08 +02:00
|
|
|
_EXTRACT_ENV+= ${TOOLS_7ZA:D P7ZA=${TOOLS_7ZA:Q}}
|
2006-01-21 19:55:10 +01:00
|
|
|
_EXTRACT_ENV+= ${EXTRACT_ENV}
|
2005-05-11 06:01:49 +02:00
|
|
|
|
2008-05-25 22:02:02 +02:00
|
|
|
.if !empty(EXTRACT_USING:Mbsdtar)
|
|
|
|
_EXTRACT_TAR= ${TOOLS_PATH.bsdtar}
|
|
|
|
.elif !empty(EXTRACT_USING:Mgtar)
|
2007-12-30 14:37:18 +01:00
|
|
|
_EXTRACT_TAR= ${TOOLS_PATH.gtar}
|
2005-05-16 20:43:20 +02:00
|
|
|
.elif !empty(EXTRACT_USING:Mnbtar)
|
2007-12-30 14:37:18 +01:00
|
|
|
_EXTRACT_TAR= ${TOOLS_TAR}
|
|
|
|
.elif !empty(EXTRACT_USING:Mpax)
|
|
|
|
_EXTRACT_TAR= ${TOOLS_PAX}
|
2005-05-16 05:04:44 +02:00
|
|
|
.else
|
2007-12-30 14:37:18 +01:00
|
|
|
_EXTRACT_TAR=
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !empty(_EXTRACT_TAR)
|
|
|
|
EXTRACT_OPTS+= -t ${_EXTRACT_TAR}
|
2005-05-11 06:01:49 +02:00
|
|
|
.endif
|
|
|
|
|
2008-03-12 16:51:39 +01:00
|
|
|
EXTRACTOR= \
|
2011-09-08 22:17:15 +02:00
|
|
|
${PKGSRC_SETENV} ${_EXTRACT_ENV} ${SH} ${PKGSRCDIR}/mk/extract/extract
|
2008-03-12 16:51:39 +01:00
|
|
|
EXTRACT_CMD_DEFAULT= \
|
|
|
|
${EXTRACTOR} ${EXTRACT_OPTS} ${DOWNLOADED_DISTFILE} ${EXTRACT_ELEMENTS}
|
2006-01-21 20:39:22 +01:00
|
|
|
|
|
|
|
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}
|
2008-01-23 15:59:35 +01:00
|
|
|
. for f in ${EXTRACT_ONLY}
|
|
|
|
${RUN} extract_file=${_DISTDIR:Q}/${f:Q}; export extract_file; \
|
2010-10-15 22:22:27 +02:00
|
|
|
cd ${WRKDIR} && cd ${EXTRACT_DIR.${f}} && ${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
|