summaryrefslogtreecommitdiff
path: root/mk
diff options
context:
space:
mode:
authorjlam <jlam>2006-06-06 04:48:19 +0000
committerjlam <jlam>2006-06-06 04:48:19 +0000
commit51c3172eb2aadde196ae68480c80480886236ae2 (patch)
treed254119ba3260d7cb6e773ab9cda08b02d15f9b5 /mk
parent7655473a22e9e8b4c440684e825ed1f20b7c2994 (diff)
downloadpkgsrc-51c3172eb2aadde196ae68480c80480886236ae2.tar.gz
Refactor "patch" code into correspondingly named subdirectory of
pkgsrc/mk. Also get rid of the recursive make for the "patch" target. This basically merges the "patch" phase into the "tools" phase. There should eventually be a standalone script that can be used to verify checksums listed in distinfo that should be used instead of the roll-your-own code in the do-pkgsrc-patch target.
Diffstat (limited to 'mk')
-rw-r--r--mk/bsd.pkg.mk8
-rw-r--r--mk/bsd.prefs.mk4
-rw-r--r--mk/patch/bsd.patch-vars.mk44
-rw-r--r--mk/patch/bsd.patch.mk15
-rw-r--r--mk/patch/patch.mk (renamed from mk/bsd.pkg.patch.mk)279
5 files changed, 197 insertions, 153 deletions
diff --git a/mk/bsd.pkg.mk b/mk/bsd.pkg.mk
index 4976dc1f39b..73334b59e3c 100644
--- a/mk/bsd.pkg.mk
+++ b/mk/bsd.pkg.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.pkg.mk,v 1.1840 2006/06/06 03:05:48 jlam Exp $
+# $NetBSD: bsd.pkg.mk,v 1.1841 2006/06/06 04:48:19 jlam Exp $
#
# This file is in the public domain.
#
@@ -536,9 +536,6 @@ USE_TOOLS+= tee tsort
USE_TOOLS+= shlock sleep
.endif
-# Patch
-.include "../../mk/bsd.pkg.patch.mk"
-
# Tools
.include "../../mk/tools/bsd.tools.mk"
@@ -1155,6 +1152,9 @@ do-test:
# Extract
.include "${PKGSRCDIR}/mk/extract/bsd.extract.mk"
+# Patch
+.include "${PKGSRCDIR}/mk/patch/bsd.patch.mk"
+
# Install
.include "${PKGSRCDIR}/mk/install/bsd.install.mk"
diff --git a/mk/bsd.prefs.mk b/mk/bsd.prefs.mk
index f15e31c7fbe..8758b29da75 100644
--- a/mk/bsd.prefs.mk
+++ b/mk/bsd.prefs.mk
@@ -1,4 +1,4 @@
-# $NetBSD: bsd.prefs.mk,v 1.223 2006/06/06 03:05:48 jlam Exp $
+# $NetBSD: bsd.prefs.mk,v 1.224 2006/06/06 04:48:19 jlam Exp $
#
# Make file, included to get the site preferences, if any. Should
# only be included by package Makefiles before any .if defined()
@@ -505,7 +505,6 @@ PKGSRCDIR= ${_PKGSRCDIR}
PACKAGES?= ${PKGSRCDIR}/packages
TEMPLATES?= ${PKGSRCDIR}/templates
-PATCHDIR?= ${.CURDIR}/patches
SCRIPTDIR?= ${.CURDIR}/scripts
FILESDIR?= ${.CURDIR}/files
PKGDIR?= ${.CURDIR}
@@ -560,6 +559,7 @@ PREPEND_PATH+= ${USE_X11:D${X11BASE}/bin} ${LOCALBASE}/bin
.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/patch/bsd.patch-vars.mk"
.include "${PKGSRCDIR}/mk/install/bsd.install-vars.mk"
USE_TOOLS+= awk:pkgsrc cut:pkgsrc echo:pkgsrc pwd:pkgsrc \
diff --git a/mk/patch/bsd.patch-vars.mk b/mk/patch/bsd.patch-vars.mk
new file mode 100644
index 00000000000..6ebb08d1729
--- /dev/null
+++ b/mk/patch/bsd.patch-vars.mk
@@ -0,0 +1,44 @@
+# $NetBSD: bsd.patch-vars.mk,v 1.1 2006/06/06 04:48:19 jlam Exp $
+#
+# This Makefile fragment is included to bsd.prefs.mk and defines some
+# variables which must be defined earlier than where bsd.patch.mk is
+# included.
+#
+# The following variables may be set in a package Makefile:
+#
+# PATCHFILES is a list of distribution patches relative to
+# ${_DISTDIR} that are applied first to the package.
+#
+# PATCHDIR is the location of the pkgsrc patches for the package.
+# This defaults to the "patches" subdirectory of the package
+# directory.
+#
+# The following variables may be set by the user:
+#
+# LOCALPATCHES is the location of local patches that are maintained
+# in a directory tree reflecting the same hierarchy as the pkgsrc
+# tree, e.g., local patches for www/apache would be found in
+# ${LOCALPATCHES}/www/apache. These patches are applied after
+# the patches in ${PATCHDIR}.
+#
+
+PATCHDIR?= ${.CURDIR}/patches
+
+.if (defined(PATCHFILES) && !empty(PATCHFILES)) || \
+ (defined(PATCHDIR) && exists(${PATCHDIR})) || \
+ (defined(LOCALPATCHES) && exists(${LOCALPATCHES}/${PKGPATH}))
+USE_TOOLS+= patch
+.endif
+
+# These tools are used to output the contents of the distribution patches
+# to stdout.
+#
+.if defined(PATCHFILES)
+USE_TOOLS+= cat
+. if !empty(PATCHFILES:M*.Z) || !empty(PATCHFILES:M*.gz)
+USE_TOOLS+= gzcat
+. endif
+. if !empty(PATCHFILES:M*.bz2)
+USE_TOOLS+= bzcat
+. endif
+.endif
diff --git a/mk/patch/bsd.patch.mk b/mk/patch/bsd.patch.mk
new file mode 100644
index 00000000000..ee47e320363
--- /dev/null
+++ b/mk/patch/bsd.patch.mk
@@ -0,0 +1,15 @@
+# $NetBSD: bsd.patch.mk,v 1.1 2006/06/06 04:48:19 jlam Exp $
+#
+# This Makefile fragment is included by bsd.pkg.mk and defines the
+# relevant variables and targets for the "patch" phase.
+#
+# The following are the "public" targets provided by this module:
+#
+# patch
+#
+# The following targets may be overridden in a package Makefile:
+#
+# pre-patch, do-patch, post-patch
+#
+
+.include "${PKGSRCDIR}/mk/patch/patch.mk"
diff --git a/mk/bsd.pkg.patch.mk b/mk/patch/patch.mk
index 8807421f40d..dac7d56e2e3 100644
--- a/mk/bsd.pkg.patch.mk
+++ b/mk/patch/patch.mk
@@ -1,7 +1,4 @@
-# $NetBSD: bsd.pkg.patch.mk,v 1.23 2006/06/05 22:49:44 jlam Exp $
-#
-# This Makefile fragment is included by bsd.pkg.mk and defines the
-# relevant variables and targets for the "patch" phase.
+# $NetBSD: patch.mk,v 1.1 2006/06/06 04:48:19 jlam Exp $
#
# The following variables may be set in a package Makefile and control
# how pkgsrc patches are applied.
@@ -17,9 +14,6 @@
# The following variables may be set in a package Makefile and control
# how "distribution" patches are applied.
#
-# PATCHFILES is a list of distribution patches relative to
-# ${_DISTDIR} that are applied first to the package.
-#
# PATCH_DIST_STRIP is a patch(1) argument that sets the pathname
# strip count to help find the correct files to patch. See the
# patch(1) man page for more details. Defaults to "-p0".
@@ -48,50 +42,111 @@
# fuzz to accept when applying pkgsrc patches. See the patch(1)
# man page for more details. Defaults to "-F0" for zero fuzz.
#
-# LOCALPATCHES is the location of local patches that are maintained
-# in a directory tree reflecting the same hierarchy as the pkgsrc
-# tree, e.g., local patches for www/apache would be found in
-# ${LOCALPATCHES}/www/apache. These patches are applied after
-# the patches in ${PATCHDIR}.
-#
-# The following targets are defined by bsd.pkg.patch.mk:
-#
-# patch is the target that is invoked by the user to perform the
-# "patch" action.
-#
-# do-patch is the target that causes the actual patching of the
-# extracted sources to occur during the "patch" phase. This
-# target may be overridden in a package Makefile.
-#
-# {pre,post}-patch are the targets that are invoked before and after
-# do-patch, and may be overridden in a package Makefile.
-#
-.if (defined(PATCHFILES) && !empty(PATCHFILES)) || \
- (defined(PATCHDIR) && exists(${PATCHDIR})) || \
- (defined(LOCALPATCHES) && exists(${LOCALPATCHES}/${PKGPATH}))
-USE_TOOLS+= patch
+_PATCH_APPLIED_FILE= ${WRKDIR}/.patch
+_PATCH_COOKIE= ${WRKDIR}/.patch_done
+
+######################################################################
+### patch (PUBLIC)
+######################################################################
+### patch is a public target to apply the distribution and pkgsrc
+### patches to the extracted sources for the package.
+###
+_PATCH_TARGETS+= extract
+_PATCH_TARGETS+= acquire-patch-lock
+_PATCH_TARGETS+= ${_PATCH_COOKIE}
+_PATCH_TARGETS+= release-patch-lock
+
+.PHONY: patch
+patch: ${_PATCH_TARGETS}
+
+.PHONY: acquire-patch-lock release-patch-lock
+acquire-patch-lock: acquire-lock
+release-patch-lock: release-lock
+
+.if !exists(${_PATCH_COOKIE})
+${_PATCH_COOKIE}: real-patch
+.else
+${_PATCH_COOKIE}:
+ @${DO_NADA}
.endif
-# These tools are used to output the contents of the distribution patches
-# to stdout.
-#
+######################################################################
+### real-patch (PRIVATE)
+######################################################################
+### real-patch is a helper target onto which one can hook all of the
+### targets that do the actual patching work.
+###
+_REAL_PATCH_TARGETS+= patch-message
+_REAL_PATCH_TARGETS+= patch-vars
+_REAL_PATCH_TARGETS+= pre-patch
+_REAL_PATCH_TARGETS+= do-patch
+_REAL_PATCH_TARGETS+= post-patch
+_REAL_PATCH_TARGETS+= patch-cookie
+
+.PHONY: real-patch
+real-patch: ${_REAL_PATCH_TARGETS}
+
+.PHONY: patch-message
+patch-message:
+ @${PHASE_MSG} "Patching for ${PKGNAME}"
+
+######################################################################
+### patch-cookie (PRIVATE)
+######################################################################
+### patch-cookie creates the "patch" cookie file. The contents are
+### the paths to the patches that were applied (if any).
+###
+.PHONY: patch-cookie
+patch-cookie:
+ ${_PKG_SILENT}${_PKG_DEBUG} \
+ if ${TEST} -f ${_PATCH_APPLIED_FILE:Q}; then \
+ ${MV} -f ${_PATCH_APPLIED_FILE:Q} ${_PATCH_COOKIE:Q}; \
+ else \
+ ${TOUCH} ${TOUCH_FLAGS} ${_PATCH_COOKIE:Q}; \
+ fi
+
+######################################################################
+### pre-patch, do-patch, post-patch (PUBLIC, override)
+######################################################################
+### {pre,do,post}-patch are the heart of the package-customizable
+### patch targets, and may be overridden within a package Makefile.
+###
+.PHONY: pre-patch do-patch post-patch
+
+_PKGSRC_PATCH_TARGETS+= uptodate-digest
.if defined(PATCHFILES)
-USE_TOOLS+= cat
-. if !empty(PATCHFILES:M*.Z) || !empty(PATCHFILES:M*.gz)
-USE_TOOLS+= gzcat
-. endif
-. if !empty(PATCHFILES:M*.bz2)
-USE_TOOLS+= bzcat
-. endif
+_PKGSRC_PATCH_TARGETS+= distribution-patch-message
+_PKGSRC_PATCH_TARGETS+= do-distribution-patch
+.endif
+.if (defined(PATCHDIR) && exists(${PATCHDIR})) || \
+ (defined(LOCALPATCHES) && exists(${LOCALPATCHES}/${PKGPATH}))
+_PKGSRC_PATCH_TARGETS+= pkgsrc-patch-message
+_PKGSRC_PATCH_TARGETS+= do-pkgsrc-patch
+.endif
+
+.PHONY: do-patch
+.if !target(do-patch)
+do-patch: ${_PKGSRC_PATCH_TARGETS}
.endif
+.if !target(pre-patch)
+pre-patch:
+ @${DO_NADA}
+.endif
+.if !target(post-patch)
+post-patch:
+ @${DO_NADA}
+.endif
+
+######################################################################
+
.if defined(PATCH_DEBUG) || defined(PKG_VERBOSE)
_PATCH_DEBUG= yes
-ECHO_PATCH_MSG?= ${ECHO_MSG}
+ECHO_PATCH_MSG?= ${STEP_MSG}
.else
_PATCH_DEBUG= no
-ECHO_PATCH_MSG?= ${TRUE}
+ECHO_PATCH_MSG?= ${SHCOMMENT}
.endif
PATCH_STRIP?= -p0
@@ -108,9 +163,25 @@ PATCH_ARGS+= ${_PATCH_BACKUP_ARG} .orig
.endif
PATCH_FUZZ_FACTOR?= -F0 # Default to zero fuzz
-# The following variables control how "distribution" patches are extracted
-# and applied to the package sources.
-#
+_PKGSRC_PATCH_FAIL= \
+if ${TEST} -n ${PKG_OPTIONS:Q}"" || \
+ ${TEST} -n ${LOCALPATCHES:Q}"" -a -d ${LOCALPATCHES:Q}/${PKGPATH:Q}; then \
+ ${ERROR_MSG} "=========================================================================="; \
+ ${ERROR_MSG}; \
+ ${ERROR_MSG} "Some of the selected build options and/or local patches may be incompatible."; \
+ ${ERROR_MSG} "Please try building with fewer options or patches."; \
+ ${ERROR_MSG}; \
+ ${ERROR_MSG} "=========================================================================="; \
+fi; exit 1
+
+######################################################################
+### do-distribution-patch (PRIVATE)
+######################################################################
+### do-distribution-patch applies the distribution patches (specified
+### in PATCHFILES) to the extracted sources.
+###
+.PHONY: distribution-patch-message do-distribution-patch
+
# PATCH_DIST_STRIP is a patch option that sets the pathname strip count.
# PATCH_DIST_ARGS is the list of arguments to pass to the patch command.
# PATCH_DIST_CAT is the command that outputs the patch to stdout.
@@ -151,59 +222,27 @@ PATCH_DIST_CAT?= { case $$patchfile in \
PATCH_DIST_CAT.${i:S/=/--/}?= { patchfile=${i}; ${PATCH_DIST_CAT}; }
.endfor
-_PKGSRC_PATCH_TARGETS= uptodate-digest
-.if defined(PATCHFILES)
-_PKGSRC_PATCH_TARGETS+= distribution-patch-message do-distribution-patch
-.endif
-.if (defined(PATCHDIR) && exists(${PATCHDIR})) || \
- (defined(LOCALPATCHES) && exists(${LOCALPATCHES}/${PKGPATH}))
-_PKGSRC_PATCH_TARGETS+= pkgsrc-patch-message do-pkgsrc-patch
-.endif
-
-.PHONY: do-patch
-.if !target(do-patch)
-.ORDER: ${_PKGSRC_PATCH_TARGETS}
-do-patch: ${_PKGSRC_PATCH_TARGETS}
-.endif
-
-_PKGSRC_PATCH_FAIL= \
-if ${TEST} -n ${PKG_OPTIONS:Q}"" || \
- ${TEST} -n ${LOCALPATCHES:Q}"" -a -d ${LOCALPATCHES:Q}/${PKGPATH:Q}; then \
- ${ECHO} "=========================================================================="; \
- ${ECHO}; \
- ${ECHO} "Some of the selected build options and/or local patches may be incompatible."; \
- ${ECHO} "Please try building with fewer options or patches."; \
- ${ECHO}; \
- ${ECHO} "=========================================================================="; \
-fi; exit 1
-
-_PATCH_COOKIE_TMP= ${_PATCH_COOKIE}.tmp
-_GENERATE_PATCH_COOKIE= \
- if ${TEST} -f ${_PATCH_COOKIE_TMP:Q}; then \
- ${CAT} ${_PATCH_COOKIE_TMP:Q} >> ${_PATCH_COOKIE:Q}; \
- ${RM} -f ${_PATCH_COOKIE_TMP:Q}; \
- else \
- ${TOUCH} ${TOUCH_FLAGS} ${_PATCH_COOKIE:Q}; \
- fi
-
-.PHONY: distribution-patch-message do-distribution-patch
-
distribution-patch-message:
@${PHASE_MSG} "Applying distribution patches for ${PKGNAME}"
-.if !target(do-distribution-patch)
do-distribution-patch:
-. for i in ${PATCHFILES}
+.for i in ${PATCHFILES}
@${ECHO_PATCH_MSG} "Applying distribution patch ${i}"
${_PKG_SILENT}${_PKG_DEBUG}cd ${_DISTDIR}; \
${PATCH_DIST_CAT.${i:S/=/--/}} | \
- ${PATCH} ${PATCH_DIST_ARGS.${i:S/=/--/}} \
- || { ${ECHO} "Patch ${i} failed"; ${_PKGSRC_PATCH_FAIL}; }
- ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${i:Q} >> ${_PATCH_COOKIE_TMP:Q}
-. endfor
-.endif
+ ${PATCH} ${PATCH_DIST_ARGS.${i:S/=/--/}} || \
+ { ${ERROR_MSG} "Patch ${i} failed"; ${_PKGSRC_PATCH_FAIL}; }
+ ${_PKG_SILENT}${_PKG_DEBUG}${ECHO} ${_DISTDIR:Q}/${i:Q} >> ${_PATCH_APPLIED_FILE:Q}
+.endfor
+
+######################################################################
+### do-pkgsrc-patch (PRIVATE)
+######################################################################
+### do-pkgsrc-patch applies the pkgsrc patches to the extracted
+### sources.
+###
+.PHONY: pkgsrc-patch-message do-pkgsrc-patch
-_PKGSRC_PATCHES= # empty
.if defined(PATCHDIR) && exists(${PATCHDIR})
_PKGSRC_PATCHES+= ${PATCHDIR}/patch-*
.endif
@@ -211,12 +250,9 @@ _PKGSRC_PATCHES+= ${PATCHDIR}/patch-*
_PKGSRC_PATCHES+= ${LOCALPATCHES}/${PKGPATH}/*
.endif
-.PHONY: pkgsrc-patch-message do-pkgsrc-patch
-
pkgsrc-patch-message:
@${PHASE_MSG} "Applying pkgsrc patches for ${PKGNAME}"
-.if !target(do-pkgsrc-patch)
do-pkgsrc-patch:
${_PKG_SILENT}${_PKG_DEBUG} \
fail=; \
@@ -250,7 +286,7 @@ do-pkgsrc-patch:
alg="$$1"; \
recorded="$$2"; \
calcsum=`${SED} -e '/\$$NetBSD.*/d' $$i | ${DIGEST} $$alg`; \
- ${ECHO_PATCH_MSG} "=> Verifying $$filename (using digest algorithm $$alg)"; \
+ ${ECHO_PATCH_MSG} "Verifying $$filename (using digest algorithm $$alg)"; \
if ${TEST} "$$calcsum" != "$$recorded"; then \
patch_warning "Ignoring patch file $$i: invalid checksum"; \
fail="$$fail $$i"; \
@@ -264,67 +300,16 @@ do-pkgsrc-patch:
fuzz_flags=${PATCH_FUZZ_FACTOR:Q}; \
fi; \
if ${PATCH} $$fuzz_flags ${PATCH_ARGS} < $$i; then \
- ${ECHO} "$$i" >> ${_PATCH_COOKIE_TMP:Q}; \
+ ${ECHO} "$$i" >> ${_PATCH_APPLIED_FILE:Q}; \
else \
${ECHO_MSG} "Patch $$i failed"; \
fail="$$fail $$i"; \
fi; \
done; \
if ${TEST} -n "$$fail"; then \
- ${ECHO_MSG} "Patching failed due to modified or broken patch file(s):"; \
+ ${ERROR_MSG} "Patching failed due to modified or broken patch file(s):"; \
for i in $$fail; do \
- ${ECHO_MSG} " $$i"; \
+ ${ERROR_MSG} " $$i"; \
done; \
${_PKGSRC_PATCH_FAIL}; \
fi
-.endif
-
-_PATCH_COOKIE= ${WRKDIR}/.patch_done
-
-_PATCH_TARGETS+= extract
-_PATCH_TARGETS+= acquire-patch-lock
-_PATCH_TARGETS+= ${_PATCH_COOKIE}
-_PATCH_TARGETS+= release-patch-lock
-
-.ORDER: ${_PATCH_TARGETS}
-
-.PHONY: patch
-patch: ${_PATCH_TARGETS}
-
-.PHONY: acquire-patch-lock release-patch-lock
-acquire-patch-lock: acquire-lock
-release-patch-lock: release-lock
-
-${_PATCH_COOKIE}:
- ${_PKG_SILENT}${_PKG_DEBUG}cd ${.CURDIR} && ${MAKE} ${MAKEFLAGS} real-patch PKG_PHASE=patch
-
-_REAL_PATCH_TARGETS+= patch-message
-_REAL_PATCH_TARGETS+= patch-vars
-_REAL_PATCH_TARGETS+= pre-patch
-_REAL_PATCH_TARGETS+= do-patch
-_REAL_PATCH_TARGETS+= post-patch
-_REAL_PATCH_TARGETS+= patch-cookie
-
-.ORDER: ${_REAL_PATCH_TARGETS}
-
-.PHONY: patch-message
-patch-message:
- @${PHASE_MSG} "Patching for ${PKGNAME}"
-
-.PHONY: patch-cookie
-patch-cookie:
- ${_PKG_SILENT}${_PKG_DEBUG}${_GENERATE_PATCH_COOKIE}
-
-.PHONY: real-patch
-
-real-patch: ${_REAL_PATCH_TARGETS}
-
-.PHONY: pre-patch post-patch
-.if !target(pre-patch)
-pre-patch:
- @${DO_NADA}
-.endif
-.if !target(post-patch)
-post-patch:
- @${DO_NADA}
-.endif