pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk Separate out the variables and targets for the "pat...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/8504e343411e
branches:  trunk
changeset: 493777:8504e343411e
user:      jlam <jlam%pkgsrc.org@localhost>
date:      Sat May 14 19:37:53 2005 +0000

description:
Separate out the variables and targets for the "patch" phase into a
separate file pkgsrc/mk/bsd.pkg.patch.mk.  Also, include this file
ahead of the inclusion of bsd.tools.mk so that tools required to
patch are created by the tools framework.

diffstat:

 mk/bsd.pkg.mk       |  215 +---------------------------------------------------
 mk/bsd.pkg.patch.mk |  215 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 219 insertions(+), 211 deletions(-)

diffs (truncated from 462 to 300 lines):

diff -r 81263f125fce -r 8504e343411e mk/bsd.pkg.mk
--- a/mk/bsd.pkg.mk     Sat May 14 19:16:16 2005 +0000
+++ b/mk/bsd.pkg.mk     Sat May 14 19:37:53 2005 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.pkg.mk,v 1.1650 2005/05/14 07:15:29 jlam Exp $
+#      $NetBSD: bsd.pkg.mk,v 1.1651 2005/05/14 19:37:53 jlam Exp $
 #
 # This file is in the public domain.
 #
@@ -445,106 +445,6 @@
 
 TOUCH_FLAGS?=          -f
 
-.if (defined(PATCHFILES) && !empty(PATCHFILES)) || \
-    (defined(PATCHDIR) && exists(${PATCHDIR}))
-.  if empty(_USE_NEW_TOOLS:M[yY][eE][sS])
-USE_GNU_TOOLS+=                patch
-.  else
-PKGSRC_USE_TOOLS+=     patch
-.  endif
-.endif
-
-.if defined(PATCH_DEBUG) || defined(PKG_VERBOSE)
-PATCH_DEBUG_TMP=       yes
-.else
-PATCH_DEBUG_TMP=       no
-.endif
-
-PATCH_STRIP?=          -p0
-.if ${PATCH_DEBUG_TMP} == "yes"
-PATCH_ARGS?=           -d ${WRKSRC} -E ${PATCH_STRIP}
-.else
-PATCH_ARGS?=           -d ${WRKSRC} --forward --quiet -E ${PATCH_STRIP}
-.endif
-.if defined(BATCH)
-PATCH_ARGS+=           --batch
-.endif
-.if defined(_PATCH_CAN_BACKUP) && (${_PATCH_CAN_BACKUP} == "yes")
-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.
-#
-# 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.
-#
-# For each of these variables, there is a patch-specific variant that
-# may be set, i.e. PATCH_DIST_STRIP.<patch>, PATCH_DIST_ARGS.<patch>,
-# PATCH_DIST_CAT.<patch>.
-#
-PATCH_DIST_STRIP?=             -p0
-.for i in ${PATCHFILES}
-PATCH_DIST_STRIP.${i:S/=/--/}?=        ${PATCH_DIST_STRIP}
-.  if defined(PATCH_DIST_ARGS)
-PATCH_DIST_ARGS.${i:S/=/--/}?= ${PATCH_DIST_ARGS}
-.  elif ${PATCH_DEBUG_TMP} == "yes"
-PATCH_DIST_ARGS.${i:S/=/--/}?= -d ${WRKSRC} -E ${PATCH_DIST_STRIP.${i:S/=/--/}}
-.  else
-PATCH_DIST_ARGS.${i:S/=/--/}?= -d ${WRKSRC} --forward --quiet -E ${PATCH_DIST_STRIP.${i:S/=/--/}}
-.  endif
-.endfor
-.if defined(BATCH)
-PATCH_DIST_ARGS+=              --batch
-.  for i in ${PATCHFILES}
-PATCH_DIST_ARGS.${i:S/=/--/}+= --batch
-.  endfor
-.endif
-.if defined(_PATCH_CAN_BACKUP) && (${_PATCH_CAN_BACKUP} == "yes")
-PATCH_DIST_ARGS+=              ${_PATCH_BACKUP_ARG} .orig_dist
-.  for i in ${PATCHFILES}
-PATCH_DIST_ARGS.${i:S/=/--/}+= ${_PATCH_BACKUP_ARG} .orig_dist
-.  endfor
-.endif
-PATCH_DIST_CAT?=       { case $$patchfile in                           \
-                         *.Z|*.gz) ${GZCAT} $$patchfile ;;             \
-                         *.bz2)    ${BZCAT} $$patchfile ;;             \
-                         *)        ${CAT} $$patchfile ;;               \
-                         esac; }
-.for i in ${PATCHFILES}
-PATCH_DIST_CAT.${i:S/=/--/}?=  { patchfile=${i}; ${PATCH_DIST_CAT}; }
-.endfor
-
-.if empty(PKGSRC_SHOW_PATCH_ERRORMSG:M[yY][eE][sS])
-PKGSRC_PATCH_FAIL=     exit 1
-.else
-PKGSRC_PATCH_FAIL=                                                     \
-if [ -n "${PKG_OPTIONS}" ] || [ -n "${_LOCALPATCHFILES}" ]; 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
-.endif
-
-# We need bzip2 for PATCHFILES with .bz2 suffix.
-.if defined(PATCHFILES)
-.  if !empty(PATCHFILES:M*.bz2)
-.    if !empty(_USE_NEW_TOOLS:M[yY][eE][sS])
-PKGSRC_USE_TOOLS+=     bzcat
-.    elif exists(/usr/bin/bzcat)
-BZCAT=                 /usr/bin/bzcat
-.    else
-BZCAT=                 ${LOCALBASE}/bin/bzcat
-BUILD_DEPENDS+=                bzip2>=0.9.0b:../../archivers/bzip2
-.    endif # !exists bzcat
-.  endif
-.endif # defined(PATCHFILES)
-
 # Figure out where the local mtree file is
 MTREE_FILE?=   ${PKGSRCDIR}/mk/${OPSYS}.pkg.dist
 MTREE_ARGS?=   -U -f ${MTREE_FILE} -d -e -p
@@ -944,6 +844,9 @@
 # Extract
 .include "../../mk/bsd.pkg.extract.mk"
 
+# Patch
+.include "../../mk/bsd.pkg.patch.mk"
+
 # this must come before tools/bsd.tools.mk is included
 .if ${PKGSRC_LOCKTYPE} != "none"
 PKGSRC_USE_TOOLS+=     shlock
@@ -1742,116 +1645,6 @@
 .endif # WRKOBJDIR
 
 
-# Patch
-
-# LOCALPATCHES contains the location of local patches to packages
-#      that are maintained in a directory tree reflecting the same
-#      hierarchy as the pkgsrc tree, i.e. local patches for www/apache
-#      would be found as ${LOCALPATCHES}/www/apache/*.
-#
-.if defined(LOCALPATCHES)
-_DFLT_LOCALPATCHFILES= ${LOCALPATCHES}/${PKGPATH}/*
-_LOCALPATCHFILES=      ${_DFLT_LOCALPATCHFILES}
-.endif
-
-.PHONY: do-patch
-.if !target(do-patch)
-do-patch: uptodate-digest
-.  if defined(PATCHFILES)
-       @${ECHO_MSG} "${_PKGSRC_IN}> Applying distribution patches for ${PKGNAME}"
-.    for i in ${PATCHFILES}
-       ${_PKG_SILENT}${_PKG_DEBUG}cd ${_DISTDIR};                      \
-       if [ ${PATCH_DEBUG_TMP} = yes ]; then                           \
-               ${ECHO_MSG} "${_PKGSRC_IN}> Applying distribution patch ${i}"; \
-       fi;                                                             \
-       ${PATCH_DIST_CAT.${i:S/=/--/}} |                                \
-       ${PATCH} ${PATCH_DIST_ARGS.${i:S/=/--/}}                        \
-               || { ${ECHO} "Patch ${i} failed"; ${PKGSRC_PATCH_FAIL}; }
-.    endfor
-.  endif
-       ${_PKG_SILENT}${_PKG_DEBUG}                                     \
-       patchlist="";                                                   \
-       if [ -d ${PATCHDIR} ]; then                                     \
-               if [ "`${ECHO} ${PATCHDIR}/patch-*`" = "${PATCHDIR}/patch-*" ]; then \
-                       ${ECHO_MSG} "${_PKGSRC_IN}> Ignoring empty patch directory"; \
-                       if [ -d ${PATCHDIR}/CVS ]; then                 \
-                               ${ECHO_MSG} "${_PKGSRC_IN}> Perhaps you forgot the -P flag to 'cvs checkout' or 'cvs update'?"; \
-                       fi;                                             \
-               else                                                    \
-                       patchlist=`${ECHO} ${PATCHDIR}/patch-*`;        \
-               fi;                                                     \
-       fi;                                                             \
-       if [ "X${_LOCALPATCHFILES}" = "X${_DFLT_LOCALPATCHFILES}" ]; then \
-               localpatchfiles="`${ECHO} ${_LOCALPATCHFILES}`";        \
-               if [ "$${localpatchfiles}" != "${_LOCALPATCHFILES}" ]; then \
-                       patchlist="$${patchlist} $${localpatchfiles}";  \
-               fi;                                                     \
-       else                                                            \
-               patchlist=`${ECHO} $${patchlist} ${_LOCALPATCHFILES}`;  \
-       fi;                                                             \
-       if [ -n "$${patchlist}" ]; then                                 \
-               ${ECHO_MSG} "${_PKGSRC_IN}> Applying pkgsrc patches for ${PKGNAME}" ; \
-               fail="";                                                \
-               for i in $${patchlist}; do                              \
-                       if [ ! -f "$$i" ]; then                         \
-                               ${ECHO_MSG} "${_PKGSRC_IN}> $$i is not a valid patch file - skipping"; \
-                               continue;                               \
-                       fi;                                             \
-                       case $$i in                                     \
-                       *.orig|*.rej|*~)                                \
-                               ${ECHO_MSG} "${_PKGSRC_IN}> Ignoring patchfile $$i"; \
-                               continue;                               \
-                               ;;                                      \
-                       ${PATCHDIR}/patch-local-*)                      \
-                               ;;                                      \
-                       ${PATCHDIR}/patch-*)                            \
-                               if [ -f ${DISTINFO_FILE} ]; then        \
-                                       filename=`expr $$i : '.*/\(.*\)'`; \
-                                       algsum=`${AWK} 'NF == 4 && $$2 == "('$$filename')" && $$3 == "=" {print $$1 " " $$4}' ${DISTINFO_FILE} || ${TRUE}`; \
-                                       if [ "X$$algsum" != "X" ]; then \
-                                               alg=`${ECHO} $$algsum | ${AWK} '{ print $$1 }'`; \
-                                               recorded=`${ECHO} $$algsum | ${AWK} '{ print $$2 }'`; \
-                                               calcsum=`${SED} -e '/\$$NetBSD.*/d' $$i | ${DIGEST} $$alg`; \
-                                               if [ ${PATCH_DEBUG_TMP} = yes ]; then \
-                                                       ${ECHO_MSG} "=> Verifying $$filename (using digest algorithm $$alg)"; \
-                                               fi;                     \
-                                       fi;                             \
-                                       if [ "X$$algsum" = "X" -o "X$$recorded" = "X" ]; then \
-                                               ${ECHO_MSG} "**************************************"; \
-                                               ${ECHO_MSG} "Ignoring unknown patch file: $$i"; \
-                                               ${ECHO_MSG} "**************************************"; \
-                                               continue;               \
-                                       fi;                             \
-                                       if [ "X$$calcsum" != "X$$recorded" ]; then \
-                                               ${ECHO_MSG} "**************************************"; \
-                                               ${ECHO_MSG} "Patch file $$i has been modified"; \
-                                               ${ECHO_MSG} "**************************************"; \
-                                               fail="$$fail $$filename"; \
-                                               continue;               \
-                                       fi;                             \
-                               else                                    \
-                                       ${ECHO_MSG} "**************************************"; \
-                                       ${ECHO_MSG} "Ignoring unknown patch file: $$i"; \
-                                       ${ECHO_MSG} "**************************************"; \
-                                       continue;                       \
-                               fi;                                     \
-                               ;;                                      \
-                       esac;                                           \
-                       if [ ${PATCH_DEBUG_TMP} = yes ]; then           \
-                               ${ECHO_MSG} "${_PKGSRC_IN}> Applying pkgsrc patch $$i" ; \
-                       fi;                                             \
-                       fuzz="";                                        \
-                       ${PATCH} -v > /dev/null 2>&1 && fuzz="${PATCH_FUZZ_FACTOR}"; \
-                       ${PATCH} $$fuzz ${PATCH_ARGS} < $$i ||          \
-                               { ${ECHO} Patch $$i failed ; ${PKGSRC_PATCH_FAIL}; }; \
-               done;                                                   \
-               if [ "X$$fail" != "X" ]; then                           \
-                       ${ECHO_MSG} "Patching failed due to modified patch file(s): $$fail"; \
-                       ${PKGSRC_PATCH_FAIL};                           \
-               fi;                                                     \
-       fi
-.endif
-
 # Configure
 
 # _CONFIGURE_PREREQ is a list of targets to run after pre-configure but before
diff -r 81263f125fce -r 8504e343411e mk/bsd.pkg.patch.mk
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/mk/bsd.pkg.patch.mk       Sat May 14 19:37:53 2005 +0000
@@ -0,0 +1,215 @@
+# $NetBSD: bsd.pkg.patch.mk,v 1.1 2005/05/14 19:37:53 jlam Exp $
+#
+# This Makefile fragment is included by bsd.pkg.mk and defines the
+# relevant variables and targets for the "patch" phase.
+#
+
+.if (defined(PATCHFILES) && !empty(PATCHFILES)) || \
+    (defined(PATCHDIR) && exists(${PATCHDIR}))
+.  if empty(_USE_NEW_TOOLS:M[yY][eE][sS])
+USE_GNU_TOOLS+=                patch
+.  else
+PKGSRC_USE_TOOLS+=     patch
+.  endif
+.endif
+
+.if defined(PATCH_DEBUG) || defined(PKG_VERBOSE)
+PATCH_DEBUG_TMP=       yes
+.else
+PATCH_DEBUG_TMP=       no
+.endif
+
+PATCH_STRIP?=          -p0
+.if ${PATCH_DEBUG_TMP} == "yes"
+PATCH_ARGS?=           -d ${WRKSRC} -E ${PATCH_STRIP}
+.else
+PATCH_ARGS?=           -d ${WRKSRC} --forward --quiet -E ${PATCH_STRIP}
+.endif
+.if defined(BATCH)
+PATCH_ARGS+=           --batch
+.endif
+.if defined(_PATCH_CAN_BACKUP) && (${_PATCH_CAN_BACKUP} == "yes")
+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.
+#
+# 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.
+#
+# For each of these variables, there is a patch-specific variant that
+# may be set, i.e. PATCH_DIST_STRIP.<patch>, PATCH_DIST_ARGS.<patch>,
+# PATCH_DIST_CAT.<patch>.
+#
+PATCH_DIST_STRIP?=             -p0
+.for i in ${PATCHFILES}
+PATCH_DIST_STRIP.${i:S/=/--/}?=        ${PATCH_DIST_STRIP}
+.  if defined(PATCH_DIST_ARGS)
+PATCH_DIST_ARGS.${i:S/=/--/}?= ${PATCH_DIST_ARGS}
+.  elif ${PATCH_DEBUG_TMP} == "yes"
+PATCH_DIST_ARGS.${i:S/=/--/}?= -d ${WRKSRC} -E ${PATCH_DIST_STRIP.${i:S/=/--/}}



Home | Main Index | Thread Index | Old Index