1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
|
# $NetBSD: extract.mk,v 1.34 2011/09/08 20:17:16 abs Exp $
#
# The following variables may be set by the package Makefile and
# specify how extraction happens:
#
# EXTRACT_DIR
# The directory into which the files are extracted.
#
# Default value: ${WRKDIR}
#
# EXTRACT_DIR.${file}
# The directory into which the file ${file} is extracted.
#
# Default: ${EXTRACT_DIR}
#
# EXTRACTOR is the the the environment and path used to execute the
# all-purpose extract script.
#
# EXTRACT_CMD is a shell command list that extracts the contents of
# an archive named by the variable ${DOWNLOADED_DISTFILE} to the
# current working directory. The default is ${EXTRACT_CMD_DEFAULT}.
#
# EXTRACT_OPTS is a list of options to pass to the "extract" script
# when using EXTRACT_CMD_DEFAULT. See the comments at the head of
# the "extract" script for a definitive list of the available
# options. The default list is empty.
#
# EXTRACT_USING specifies the tool used to extract tar/ustar-format
# archives when using EXTRACT_CMD_DEFAULT. The possible values are
# "bsdtar", "gtar", "nbtar", and "pax".
# By default, we use the "nbtar" tool (pkgsrc's pax-as-tar).
#
# 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.
#
# 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
#
# 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.
#
EXTRACT_DIR?= ${WRKDIR}
.for f in ${EXTRACT_ONLY}
EXTRACT_DIR.${f}?= ${EXTRACT_DIR}
.endfor
_COOKIE.extract= ${WRKDIR}/.extract_done
######################################################################
### extract (PUBLIC)
######################################################################
### extract is a public target to perform extraction.
###
_EXTRACT_TARGETS+= check-vulnerable
_EXTRACT_TARGETS+= tools
_EXTRACT_TARGETS+= acquire-extract-lock
_EXTRACT_TARGETS+= ${_COOKIE.extract}
_EXTRACT_TARGETS+= release-extract-lock
.PHONY: extract
.if !target(extract)
. if exists(${_COOKIE.extract})
extract:
@${DO_NADA}
. elif defined(_PKGSRC_BARRIER)
extract: ${_EXTRACT_TARGETS}
. else
extract: barrier
. endif
.endif
.PHONY: acquire-extract-lock release-extract-lock
acquire-extract-lock: acquire-lock
release-extract-lock: release-lock
.if exists(${_COOKIE.extract})
${_COOKIE.extract}:
@${DO_NADA}
.else
${_COOKIE.extract}: real-extract
.endif
######################################################################
### 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+= extract-dir
_REAL_EXTRACT_TARGETS+= pre-extract
_REAL_EXTRACT_TARGETS+= do-extract
_REAL_EXTRACT_TARGETS+= post-extract
_REAL_EXTRACT_TARGETS+= extract-cookie
_REAL_EXTRACT_TARGETS+= error-check
.PHONY: real-extract
real-extract: ${_REAL_EXTRACT_TARGETS}
.PHONY: extract-message
extract-message:
@${PHASE_MSG} "Extracting for ${PKGNAME}"
.PHONY: extract-dir
extract-dir:
${RUN}${MKDIR} ${EXTRACT_DIR}
.for f in ${EXTRACT_ONLY}
${RUN}${MKDIR} ${EXTRACT_DIR.${f}}
.endfor
######################################################################
### extract-check-interactive (PRIVATE)
######################################################################
### extract-check-interactive checks whether we must do an interactive
### extraction or not.
###
.PHONY: extract-check-interactive
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 ${.CURDIR} && ${MAKE} extract\""
${RUN} ${FALSE}
.else
@${DO_NADA}
.endif
######################################################################
### extract-cookie (PRIVATE)
######################################################################
### extract-cookie creates the "extract" cookie file. The contents
### are the name of the package.
###
.PHONY: extract-cookie
extract-cookie:
${RUN}${TEST} ! -f ${_COOKIE.extract} || ${FALSE}
${RUN}${MKDIR} ${_COOKIE.extract:H}
${RUN}${ECHO} ${PKGNAME} > ${_COOKIE.extract}
######################################################################
### 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
###
### 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=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OOLS_UNZIP_CMD:D UNZIP_CMD=${TOOLS_UNZIP_CMD:Q}}
_EXTRACT_ENV+= ${TOOLS_UNZOO:D UNZOO=${TOOLS_UNZOO:Q}}
_EXTRACT_ENV+= ${TOOLS_XZCAT:D XZCAT=${TOOLS_XZCAT:Q}}
_EXTRACT_ENV+= ${EXTRACT_ENV}
.if !empty(EXTRACT_USING:Mbsdtar)
_EXTRACT_TAR= ${TOOLS_PATH.bsdtar}
.elif !empty(EXTRACT_USING:Mgtar)
_EXTRACT_TAR= ${TOOLS_PATH.gtar}
.elif !empty(EXTRACT_USING:Mnbtar)
_EXTRACT_TAR= ${TOOLS_TAR}
.elif !empty(EXTRACT_USING:Mpax)
_EXTRACT_TAR= ${TOOLS_PAX}
.else
_EXTRACT_TAR=
.endif
.if !empty(_EXTRACT_TAR)
EXTRACT_OPTS+= -t ${_EXTRACT_TAR}
.endif
EXTRACTOR= \
${PKGSRC_SETENV} ${_EXTRACT_ENV} ${SH} ${PKGSRCDIR}/mk/extract/extract
EXTRACT_CMD_DEFAULT= \
${EXTRACTOR} ${EXTRACT_OPTS} ${DOWNLOADED_DISTFILE} ${EXTRACT_ELEMENTS}
EXTRACT_CMD?= ${EXTRACT_CMD_DEFAULT}
DOWNLOADED_DISTFILE= $${extract_file}
.if !target(do-extract)
do-extract: ${WRKDIR}
. for f in ${EXTRACT_ONLY}
${RUN} extract_file=${_DISTDIR:Q}/${f:Q}; export extract_file; \
cd ${WRKDIR} && cd ${EXTRACT_DIR.${f}} && ${EXTRACT_CMD}
. endfor
.endif
.if !target(pre-extract)
pre-extract:
@${DO_NADA}
.endif
.if !target(post-extract)
post-extract:
@${DO_NADA}
.endif
|