From owner-svn-src-head@freebsd.org Fri Dec 4 03:17:09 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 27E9BA40B98; Fri, 4 Dec 2015 03:17:09 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E94651A0C; Fri, 4 Dec 2015 03:17:08 +0000 (UTC) (envelope-from bdrewery@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tB43H8fB047126; Fri, 4 Dec 2015 03:17:08 GMT (envelope-from bdrewery@FreeBSD.org) Received: (from bdrewery@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tB43H8oY047125; Fri, 4 Dec 2015 03:17:08 GMT (envelope-from bdrewery@FreeBSD.org) Message-Id: <201512040317.tB43H8oY047125@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bdrewery set sender to bdrewery@FreeBSD.org using -f From: Bryan Drewery Date: Fri, 4 Dec 2015 03:17:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291732 - head/share/mk X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Dec 2015 03:17:09 -0000 Author: bdrewery Date: Fri Dec 4 03:17:07 2015 New Revision: 291732 URL: https://svnweb.freebsd.org/changeset/base/291732 Log: DIRDEPS_BUILD: Install new Makefile.depend files atomically. Sponsored by: EMC / Isilon Storage Division Modified: head/share/mk/install-new.mk Modified: head/share/mk/install-new.mk ============================================================================== --- head/share/mk/install-new.mk Fri Dec 4 03:17:04 2015 (r291731) +++ head/share/mk/install-new.mk Fri Dec 4 03:17:07 2015 (r291732) @@ -32,9 +32,23 @@ CmpCp= CmpCp() { \ cp $$src $$target; \ fi; } +# Replace the file if they are different and make a backup if desired +CmpReplace= CmpReplace() { \ + src=$$1 target=$$2 _bak=$$3; \ + if ! test -s $$target || ! cmp -s $$target $$src; then \ + trap "" 1 2 3 15; \ + if test -s $$target; then \ + if test "x$$_bak" != x; then \ + rm -f $$target$$_bak; \ + cp -f $$target $$target$$_bak; \ + fi; \ + fi; \ + mv -f $$src $$target; \ + fi; } + # If the .new file is different, we want it. # Note: this function will work as is for *.new$RANDOM" -InstallNew= ${CmpCp}; InstallNew() { \ +InstallNew= ${CmpReplace}; InstallNew() { \ _t=-e; _bak=; \ while :; do \ case "$$1" in \ @@ -46,7 +60,7 @@ InstallNew= ${CmpCp}; InstallNew() { \ for new in "$$@"; do \ if test $$_t $$new; then \ target=`expr $$new : '\(.*\).new'`; \ - CmpCp $$new $$target $$_bak; \ + CmpReplace $$new $$target $$_bak; \ fi; \ rm -f $$new; \ done; :; }