[Asterisk-cvs] asterisk Makefile,1.137,1.138

markster at lists.digium.com markster at lists.digium.com
Fri Mar 11 02:28:07 CST 2005


Update of /usr/cvsroot/asterisk
In directory mongoose.digium.com:/tmp/cvs-serv11043

Modified Files:
	Makefile 
Log Message:
Add sample experimental patch to show "make apply", "make unapply", "make patchlist", and "make update" targets


Index: Makefile
===================================================================
RCS file: /usr/cvsroot/asterisk/Makefile,v
retrieving revision 1.137
retrieving revision 1.138
diff -u -d -r1.137 -r1.138
--- Makefile	5 Mar 2005 21:06:25 -0000	1.137
+++ Makefile	11 Mar 2005 08:24:23 -0000	1.138
@@ -387,6 +387,16 @@
 
 update: 
 	@if [ -d CVS ]; then \
+		if [ -f patches/.applied ]; then \
+			patches=`cat patches/.applied`; \
+		fi; \
+		if ! [ -z "$$patches" ]; then \
+			for x in $$patches; do \
+				echo "Unapplying $$x..."; \
+				patch -R -p0 < patches/$$x; \
+			done; \
+			rm -f patches/.applied; \
+		fi ; \
 		echo "Updating from CVS..." ; \
 		cvs -q -z3 update -Pd | tee update.out; \
 		rm -f .version; \
@@ -395,6 +405,17 @@
 			grep ^C update.out | cut -d' ' -f2- ; \
 		fi ; \
 		rm -f update.out; \
+		if ! [ -z "$$patches" ]; then \
+			for x in $$patches; do \
+				if [ -f patches/$$x ]; then \
+					echo "Applying patch $$x..."; \
+					patch -p0 < patches/$$x; \
+					echo $$x >> patches/.applied; \
+				else \
+					echo "Patch $$x no longer relevant"; \
+				fi; \
+			done; \
+		fi; \
 	else \
 		echo "Not CVS";  \
 	fi
@@ -607,3 +628,49 @@
 	if ! cmp -s .cleancount .lastclean ; then \
 		$(MAKE) clean; cp -f .cleancount .lastclean;\
 	fi
+
+patchlist:
+	@echo "Experimental Patches:"
+	@for x in patches/*; do \
+		patch=`basename $$x`; \
+		if [ "$$patch" = "CVS" ]; then \
+			continue; \
+		fi; \
+		if grep -q ^$$patch$$ patches/.applied; then \
+			echo "$$patch (applied)"; \
+		else \
+			echo "$$patch (available)"; \
+		fi; \
+	done
+		
+	
+apply: 
+	@if [ -z "$(PATCH)" ]; then \
+		echo "Usage: make PATCH=<patchname> applypatch"; \
+	elif grep -q ^$(PATCH)$$ patches/.applied 2>/dev/null; then \
+		echo "Patch $(PATCH) is already applied"; \
+	elif [ -f "patches/$(PATCH)" ]; then \
+		echo "Applying patch $(PATCH)"; \
+		patch -p0 < patches/$(PATCH); \
+		echo "$(PATCH)" >> patches/.applied; \
+	else \
+		echo "No such patch $(PATCH) in patches directory"; \
+	fi
+	
+unapply: 
+	@if [ -z "$(PATCH)" ]; then \
+		echo "Usage: make PATCH=<patchname> unapplypatch"; \
+	elif !grep -q ^$(PATCH)$$ patches/.applied 2>/dev/null; then \
+		echo "Patch $(PATCH) is not applied"; \
+	elif [ -f "patches/$(PATCH)" ]; then \
+		echo "Un-applying patch $(PATCH)"; \
+		patch -p0 -R < patches/$(PATCH); \
+		rm -f patches/.tmpapplied || :; \
+		mv patches/.applied patches/.tmpapplied; \
+		cat patches/.tmpapplied | grep -v ^$(PATCH)$$ > patches/.applied; \
+		rm -f patches/.tmpapplied; \
+	else \
+		echo "No such patch $(PATCH) in patches directory"; \
+	fi
+
+		




More information about the svn-commits mailing list