Permalink
Browse files

Refactor "fetch" and "extract" code into correspondingly named

subdirectories of pkgsrc/mk.  Move the following files around for
locality:

	pkgsrc/mk/scripts/extract  -> pkgsrc/mk/extract/extract
	pkgsrc/mk/bsd.sites.mk     -> pkgsrc/mk/fetch/sites.mk

Also get rid of the recursive make for the "fetch" and "extract"
targets.  This basically merges the "fetch" and "extract" phases into
the "patch" phase.

There is still much more work to do to simplify the fetch code, but
this is a good start.
  • Loading branch information...
1 parent e1e614c commit 2d97a87fa8042d28745e6b969b4d0419b17af8f1 jlam committed Jun 6, 2006
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.prefs.mk,v 1.222 2006/06/05 17:11:37 joerg Exp $
+# $NetBSD: bsd.prefs.mk,v 1.223 2006/06/06 03:05:48 jlam Exp $
#
# Make file, included to get the site preferences, if any. Should
# only be included by package Makefiles before any .if defined()
@@ -502,7 +502,6 @@ MAKEFLAGS+= _PKGSRCDIR=${_PKGSRCDIR:Q}
.endif
PKGSRCDIR= ${_PKGSRCDIR}
-DISTDIR?= ${PKGSRCDIR}/distfiles
PACKAGES?= ${PKGSRCDIR}/packages
TEMPLATES?= ${PKGSRCDIR}/templates
@@ -559,6 +558,8 @@ PREPEND_PATH+= ${USE_X11:D${X11BASE}/bin} ${LOCALBASE}/bin
.include "${PKGSRCDIR}/mk/flavor/bsd.flavor-vars.mk"
.include "${PKGSRCDIR}/mk/check/bsd.check-vars.mk"
.include "${PKGSRCDIR}/mk/depends/bsd.depends-vars.mk"
+.include "${PKGSRCDIR}/mk/fetch/bsd.fetch-vars.mk"
+.include "${PKGSRCDIR}/mk/extract/bsd.extract-vars.mk"
.include "${PKGSRCDIR}/mk/install/bsd.install-vars.mk"
USE_TOOLS+= awk:pkgsrc cut:pkgsrc echo:pkgsrc pwd:pkgsrc \
@@ -0,0 +1,63 @@
+# $NetBSD: bsd.extract-vars.mk,v 1.1 2006/06/06 03:05:48 jlam Exp $
+#
+# This Makefile fragment is included to bsd.prefs.mk and defines some
+# variables which must be defined earlier than where bsd.extract.mk
+# is included.
+#
+# The following variables may be set by the package Makefile and
+# specify how extraction happens:
+#
+# EXTRACT_ONLY is a list of distfiles relative to ${_DISTDIR} to
+# extract and defaults to ${DISTFILES}.
+#
+# EXTRACT_SUFX is the suffix for the default distfile to be
+# extracted. The default suffix is ".tar.gz".
+#
+
+EXTRACT_ONLY?= ${DISTFILES}
+EXTRACT_SUFX?= .tar.gz
+
+###
+### Discover which tools we need based on the file extensions of the
+### distfiles.
+###
+_EXTRACT_PATTERNS= ${EXTRACT_ONLY} ${EXTRACT_SUFX}
+
+.if !empty(_EXTRACT_PATTERNS:M*.tar) || \
+ !empty(_EXTRACT_PATTERNS:M*.tar.*) || \
+ !empty(_EXTRACT_PATTERNS:M*.tbz) || \
+ !empty(_EXTRACT_PATTERNS:M*.tbz2) || \
+ !empty(_EXTRACT_PATTERNS:M*.tgz) || \
+ !empty(_EXTRACT_PATTERNS:M*-tar.gz) || \
+ !empty(_EXTRACT_PATTERNS:M*_tar.gz)
+. if !empty(EXTRACT_USING:Mgtar)
+USE_TOOLS+= gtar
+. elif !empty(EXTRACT_USING:Mnbtar)
+USE_TOOLS+= tar
+. else
+USE_TOOLS+= pax
+. endif
+.endif
+.if !empty(_EXTRACT_PATTERNS:M*.bz2) || \
+ !empty(_EXTRACT_PATTERNS:M*.tbz) || \
+ !empty(_EXTRACT_PATTERNS:M*.tbz2)
+USE_TOOLS+= bzcat
+.endif
+.if !empty(_EXTRACT_PATTERNS:M*.zip)
+USE_TOOLS+= unzip
+.endif
+.if !empty(_EXTRACT_PATTERNS:M*.lzh) || \
+ !empty(_EXTRACT_PATTERNS:M*.lha)
+USE_TOOLS+= lha
+.endif
+.if !empty(_EXTRACT_PATTERNS:M*.gz) || \
+ !empty(_EXTRACT_PATTERNS:M*.tgz) || \
+ !empty(_EXTRACT_PATTERNS:M*.Z)
+USE_TOOLS+= gzcat
+.endif
+.if !empty(_EXTRACT_PATTERNS:M*.zoo)
+USE_TOOLS+= unzoo
+.endif
+.if !empty(_EXTRACT_PATTERNS:M*.rar)
+USE_TOOLS+= unrar
+.endif
View
@@ -0,0 +1,15 @@
+# $NetBSD: bsd.extract.mk,v 1.1 2006/06/06 03:05:48 jlam Exp $
+#
+# This Makefile fragment is included to bsd.pkg.mk and defines the
+# relevant variables and targets for the "extract" phase.
+#
+# The following are the "public" targets provided by this module:
+#
+# extract
+#
+# The following targets may be overridden in a package Makefile:
+#
+# pre-extract, do-extract, post-extract
+#
+
+.include "${PKGSRCDIR}/mk/extract/extract.mk"
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $NetBSD: extract,v 1.21 2006/05/30 23:51:38 wiz Exp $
+# $NetBSD: extract,v 1.1 2006/06/06 03:05:48 jlam Exp $
#
# Copyright (c) 2006 The NetBSD Foundation, Inc.
# All rights reserved.
@@ -1,17 +1,8 @@
-# $NetBSD: bsd.pkg.extract.mk,v 1.25 2006/06/05 22:49:44 jlam Exp $
-#
-# This Makefile fragment is included to bsd.pkg.mk and defines the
-# relevant variables and targets for the "extract" phase.
+# $NetBSD: extract.mk,v 1.1 2006/06/06 03:05:48 jlam Exp $
#
# The following variables may be set by the package Makefile and
# specify how extraction happens:
#
-# EXTRACT_ONLY is a list of distfiles relative to ${_DISTDIR} to
-# extract and defaults to ${DISTFILES}.
-#
-# EXTRACT_SUFX is the suffix for the default distfile to be
-# extracted. The default suffix is ".tar.gz".
-#
# 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}.
@@ -43,69 +34,97 @@
#
# EXTRACT_CMD= ${TAIL} +25 ${DOWNLOADED_DISTFILE} > foo.pl
#
-# The following targets are defined by bsd.pkg.extract.mk:
-#
-# extract is the target that is invoked by the user to perform
-# extraction.
-#
-# do-extract is the target that causes the actual extraction of
-# the distfiles to occur during the "extract" phase. This target
-# may be overridden in a package Makefile.
-#
-# {pre,post}-extract are the targets that are invoked before and after
-# do-extract, and may be overridden in a package Makefile.
-#
-EXTRACT_ONLY?= ${DISTFILES}
-EXTRACT_SUFX?= .tar.gz
-EXTRACT_USING?= nbtar
-EXTRACT_ELEMENTS?= # empty
+_EXTRACT_COOKIE= ${WRKDIR}/.extract_done
+######################################################################
+### extract (PUBLIC)
+######################################################################
+### extract is a public target to perform extraction.
###
-### Discover which tools we need based on the file extensions of the
-### distfiles.
-###
-_EXTRACT_PATTERNS= ${EXTRACT_ONLY} ${EXTRACT_SUFX}
-
-.if !empty(_EXTRACT_PATTERNS:M*.tar) || \
- !empty(_EXTRACT_PATTERNS:M*.tar.*) || \
- !empty(_EXTRACT_PATTERNS:M*.tbz) || \
- !empty(_EXTRACT_PATTERNS:M*.tbz2) || \
- !empty(_EXTRACT_PATTERNS:M*.tgz) || \
- !empty(_EXTRACT_PATTERNS:M*-tar.gz) || \
- !empty(_EXTRACT_PATTERNS:M*_tar.gz)
-. if !empty(EXTRACT_USING:Mgtar)
-USE_TOOLS+= gtar
-. elif !empty(EXTRACT_USING:Mnbtar)
-USE_TOOLS+= tar
-. else
-USE_TOOLS+= pax
-. endif
-.endif
-.if !empty(_EXTRACT_PATTERNS:M*.bz2) || \
- !empty(_EXTRACT_PATTERNS:M*.tbz) || \
- !empty(_EXTRACT_PATTERNS:M*.tbz2)
-USE_TOOLS+= bzcat
-.endif
-.if !empty(_EXTRACT_PATTERNS:M*.zip)
-USE_TOOLS+= unzip
-.endif
-.if !empty(_EXTRACT_PATTERNS:M*.lzh) || \
- !empty(_EXTRACT_PATTERNS:M*.lha)
-USE_TOOLS+= lha
-.endif
-.if !empty(_EXTRACT_PATTERNS:M*.gz) || \
- !empty(_EXTRACT_PATTERNS:M*.tgz) || \
- !empty(_EXTRACT_PATTERNS:M*.Z)
-USE_TOOLS+= gzcat
+_EXTRACT_TARGETS+= checksum
+_EXTRACT_TARGETS+= ${WRKDIR}
+_EXTRACT_TARGETS+= depends
+_EXTRACT_TARGETS+= acquire-extract-lock
+_EXTRACT_TARGETS+= ${_EXTRACT_COOKIE}
+_EXTRACT_TARGETS+= release-extract-lock
+
+.PHONY: extract
+.if !target(extract)
+extract: ${_EXTRACT_TARGETS}
.endif
-.if !empty(_EXTRACT_PATTERNS:M*.zoo)
-USE_TOOLS+= unzoo
+
+.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}
.endif
-.if !empty(_EXTRACT_PATTERNS:M*.rar)
-USE_TOOLS+= unrar
+
+######################################################################
+### 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}
.endif
+######################################################################
+### 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
+
###
### Build the default extraction command
###
@@ -143,15 +162,14 @@ EXTRACT_OPTS+= ${TOOLS_PAX:D -t ${TOOLS_PAX}}
EXTRACT_CMD_DEFAULT= \
${SETENV} ${_EXTRACT_ENV} \
- ${SH} ${.CURDIR}/../../mk/scripts/extract \
+ ${SH} ${PKGSRCDIR}//mk/extract/extract \
${EXTRACT_OPTS} \
${DOWNLOADED_DISTFILE} ${EXTRACT_ELEMENTS}
EXTRACT_CMD?= ${EXTRACT_CMD_DEFAULT}
DOWNLOADED_DISTFILE= $${extract_file}
-.PHONY: do-extract
.if !target(do-extract)
do-extract: ${WRKDIR}
. for __file__ in ${EXTRACT_ONLY}
@@ -161,55 +179,6 @@ do-extract: ${WRKDIR}
. endfor
.endif
-_EXTRACT_COOKIE= ${WRKDIR}/.extract_done
-
-_EXTRACT_TARGETS+= checksum
-_EXTRACT_TARGETS+= ${WRKDIR}
-_EXTRACT_TARGETS+= depends
-_EXTRACT_TARGETS+= acquire-extract-lock
-_EXTRACT_TARGETS+= ${_EXTRACT_COOKIE}
-_EXTRACT_TARGETS+= release-extract-lock
-
-.ORDER: ${_EXTRACT_TARGETS}
-
-.PHONY: extract
-extract: ${_EXTRACT_TARGETS}
-
-.PHONY: acquire-extract-lock release-extract-lock
-acquire-extract-lock: acquire-lock
-release-extract-lock: release-lock
-
-${_EXTRACT_COOKIE}:
-.if !empty(INTERACTIVE_STAGE:Mextract) && defined(BATCH)
- @${ECHO} "*** The extract stage of this package requires user interaction"
- @${ECHO} "*** Please extract manually with \"cd ${PKGDIR} && ${MAKE} extract\""
- @${TOUCH} ${_INTERACTIVE_COOKIE}
- @${FALSE}
-.else
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-extract DEPENDS_TARGET=${DEPENDS_TARGET:Q} PKG_PHASE=extract
-.endif
-
-_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
-
-.ORDER: ${_REAL_EXTRACT_TARGETS}
-
-.PHONY: extract-message
-extract-message:
- @${PHASE_MSG} "Extracting for ${PKGNAME}"
-
-.PHONY: extract-cookie
-extract-cookie:
- ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${PKGNAME} >> ${_EXTRACT_COOKIE}
-
-.PHONY: real-extract
-real-extract: ${_REAL_EXTRACT_TARGETS}
-
-.PHONY: pre-extract post-extract
.if !target(pre-extract)
pre-extract:
@${DO_NADA}
View
@@ -0,0 +1,22 @@
+# $NetBSD: bsd.fetch-vars.mk,v 1.1 2006/06/06 03:05:48 jlam Exp $
+#
+# This Makefile fragment is included to bsd.prefs.mk and defines some
+# variables which must be defined earlier than where bsd.fetch.mk
+# is included.
+#
+# The following variables may be set by the user:
+#
+# DISTDIR is the top-level directory into which all original
+# distribution files are fetched.
+#
+# The following variables may be set in a package Makefile:
+#
+# DIST_SUBDIR is the subdirectory of ${DISTDIR} in which the original
+# distribution files for the package are fetched.
+#
+# DISTFILES is the list of distribution files that are fetched.
+#
+
+DISTDIR?= ${PKGSRCDIR}/distfiles
+_DISTDIR= ${DISTDIR}/${DIST_SUBDIR}
+DISTFILES?= ${DISTNAME}${EXTRACT_SUFX}
View
@@ -0,0 +1,9 @@
+# $NetBSD: bsd.fetch.mk,v 1.1 2006/06/06 03:05:48 jlam Exp $
+#
+# This Makefile fragment is included by bsd.pkg.mk and defines the
+# relevant variables and targets for the "fetch" step.
+#
+
+.include "${PKGSRCDIR}/mk/fetch/sites.mk"
+.include "${PKGSRCDIR}/mk/fetch/fetch.mk"
+.include "${PKGSRCDIR}/mk/fetch/distclean.mk"
Oops, something went wrong.

0 comments on commit 2d97a87

Please sign in to comment.