aboutsummaryrefslogtreecommitdiff
path: root/Mk/bsd.port.mk
diff options
context:
space:
mode:
authorJohn Marino <marino@FreeBSD.org>2014-10-30 23:04:03 +0000
committerJohn Marino <marino@FreeBSD.org>2014-10-30 23:04:03 +0000
commitb340da6eb8dccae77b803ce6c8035ad161e33d2a (patch)
tree3078cfaf30562e7354eaf9a415ac03813715cfb6 /Mk/bsd.port.mk
parent3f4557f4249ab4681d423000cf3599cf7c0d8018 (diff)
downloadports-b340da6eb8dccae77b803ce6c8035ad161e33d2a.tar.gz
ports-b340da6eb8dccae77b803ce6c8035ad161e33d2a.zip
Notes
Diffstat (limited to 'Mk/bsd.port.mk')
-rw-r--r--Mk/bsd.port.mk30
1 files changed, 24 insertions, 6 deletions
diff --git a/Mk/bsd.port.mk b/Mk/bsd.port.mk
index e85f7624001e..bcd1ef6ac109 100644
--- a/Mk/bsd.port.mk
+++ b/Mk/bsd.port.mk
@@ -1147,21 +1147,39 @@ STRIPBIN= ${STRIP_CMD}
.else
-# Look for ${PATCH_WRKSRC}/.../*.orig files, and (re-)create
-# ${FILEDIR}/patch-* files from them.
+# Look for files named "*.orig" under ${PATCH_WRKSRC} and (re-)generate
+# ${FILESDIR}/patch-* files from them. By popular demand, we currently
+# use '_' (underscore) to replace path separators in patch file names.
+#
+# If a file name happens to contain character which is also a separator
+# replacement character, it will be doubled in the resulting patch name.
+#
+# To minimize gratuitous patch renames, newly generated patches will be
+# written under existing file names when they use any of the previously
+# common path separators ([-+_]) or legacy double underscore (__).
.if !target(makepatch)
+PATCH_PATH_SEPARATOR= _
makepatch:
@${MKDIR} ${FILESDIR}
@(cd ${PATCH_WRKSRC}; \
- for f in `${FIND} . -type f -name '*.orig'`; do \
+ for f in `${FIND} -s . -type f -name '*.orig'`; do \
ORIG=$${f#./}; \
NEW=$${ORIG%.orig}; \
cmp -s $${ORIG} $${NEW} && continue; \
- PATCH=`${ECHO} $${NEW} | ${SED} -e 's|/|__|g'`; \
+ ! for _lps in `${ECHO} _ - + | ${SED} -e \
+ 's|${PATCH_PATH_SEPARATOR}|__|'`; do \
+ PATCH=`${ECHO} $${NEW} | ${SED} -e "s|/|$${_lps}|g"`; \
+ test -f "${FILESDIR}/patch-$${PATCH}" && break; \
+ done || ${ECHO} $${_SEEN} | ${GREP} -q /$${PATCH} && { \
+ PATCH=`${ECHO} $${NEW} | ${SED} -e \
+ 's|${PATCH_PATH_SEPARATOR}|&&|g' -e \
+ 's|/|${PATCH_PATH_SEPARATOR}|g'`; \
+ _SEEN=$${_SEEN}/$${PATCH}; \
+ }; \
OUT=${FILESDIR}/patch-$${PATCH}; \
- ${ECHO} ${DIFF} -ud $${ORIG} $${NEW} '>' $${OUT}; \
- TZ=UTC ${DIFF} -ud $${ORIG} $${NEW} | ${SED} -e \
+ ${ECHO} ${DIFF} -udp $${ORIG} $${NEW} '>' $${OUT}; \
+ TZ=UTC ${DIFF} -udp $${ORIG} $${NEW} | ${SED} -e \
'/^---/s|\.[0-9]* +0000$$| UTC|' -e \
'/^+++/s|\([[:blank:]][-0-9:.+]*\)*$$||' \
> $${OUT} || ${TRUE}; \