From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from <gentoo-commits+bounces-437900-garchives=archives.gentoo.org@lists.gentoo.org>) id 1S6Zw2-0006lk-6c for garchives@archives.gentoo.org; Sun, 11 Mar 2012 03:59:06 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E4840E062B; Sun, 11 Mar 2012 03:58:54 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id B5B5BE062B for <gentoo-commits@lists.gentoo.org>; Sun, 11 Mar 2012 03:58:54 +0000 (UTC) Received: from hornbill.gentoo.org (hornbill.gentoo.org [94.100.119.163]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 269C71B400B for <gentoo-commits@lists.gentoo.org>; Sun, 11 Mar 2012 03:58:54 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by hornbill.gentoo.org (Postfix) with ESMTP id E3DE2E5402 for <gentoo-commits@lists.gentoo.org>; Sun, 11 Mar 2012 03:58:52 +0000 (UTC) From: "Mike Frysinger" <vapier@gentoo.org> To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" <vapier@gentoo.org> Message-ID: <1331438263.157c9c0de811b64326ebf09cc95a59b34cbc0547.vapier@gentoo> Subject: [gentoo-commits] proj/portage:master commit in: bin/ X-VCS-Repository: proj/portage X-VCS-Files: bin/etc-update X-VCS-Directories: bin/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 157c9c0de811b64326ebf09cc95a59b34cbc0547 X-VCS-Branch: master Date: Sun, 11 Mar 2012 03:58:52 +0000 (UTC) Precedence: bulk List-Post: <mailto:gentoo-commits@lists.gentoo.org> List-Help: <mailto:gentoo-commits+help@lists.gentoo.org> List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org> List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org> List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org> X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: b47357d4-6536-4623-b747-9a5e52dd6b49 X-Archives-Hash: 7119494423a8eb17aa0ec7fbc76327ea commit: 157c9c0de811b64326ebf09cc95a59b34cbc0547 Author: Mike Frysinger <vapier <AT> gentoo <DOT> org> AuthorDate: Sun Mar 11 03:57:43 2012 +0000 Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org> CommitDate: Sun Mar 11 03:57:43 2012 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3D157c9c0d etc-update: handle symlinked files If the config file is symlinked somewhere, then update the target rather then discarding the symlink and replacing it with a real file. URL: http://bugs.gentoo.org/330221 Reported-by: Jack Byer <ftn768 <AT> gmail.com> Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org> --- bin/etc-update | 26 ++++++++++++++++++++++---- 1 files changed, 22 insertions(+), 4 deletions(-) diff --git a/bin/etc-update b/bin/etc-update index 7b05f11..644512a 100755 --- a/bin/etc-update +++ b/bin/etc-update @@ -43,6 +43,24 @@ diff_command() { ${cmd//%file2/$2} } =20 +# Usage: do_mv_ln [options] <src> <dst> +# Files have to be the last two args, and has to be +# files so we can handle symlinked target sanely. +do_mv_ln() { + local opts=3D( ${@:1:$(( $# - 2 ))} ) + local src=3D${@:$(( $# - 1 )):1} + local dst=3D${@:$(( $# - 0 )):1} + + if [[ -L ${dst} ]] ; then #330221 + local lfile=3D$(readlink "${dst}") + [[ ${lfile} =3D=3D /* ]] || lfile=3D"${dst%/*}/${lfile}" + echo " Target is a symlink; replacing ${lfile}" + dst=3D${lfile} + fi + + mv "${opts[@]}" "${src}" "${dst}" +} + scan() { echo "Scanning Configuration files..." rm -rf "${TMP}"/files > /dev/null 2>&1 @@ -121,7 +139,7 @@ scan() { =20 if [[ ${MATCHES} =3D=3D 1 ]] ; then echo "Automerging trivial changes in: ${live_file}" - mv "${cfg_file}" "${live_file}" + do_mv_ln "${cfg_file}" "${live_file}" continue else : $(( ++count )) @@ -404,12 +422,12 @@ do_cfg() { =20 case ${my_input} in 1) echo "Replacing ${ofile} with ${file}" - mv ${mv_opts} ${file} ${ofile} + do_mv_ln ${mv_opts} "${file}" "${ofile}" [ -n "${OVERWRITE_ALL}" ] && my_input=3D-1 continue ;; 2) echo "Deleting ${file}" - rm ${rm_opts} ${file} + rm ${rm_opts} "${file}" [ -n "${DELETE_ALL}" ] && my_input=3D-1 continue ;; @@ -474,7 +492,7 @@ do_merge() { chown --reference=3D"${ofile}" "${mfile}" chmod --reference=3D"${ofile}" "${mfile}" fi - mv ${mv_opts} "${mfile}" "${ofile}" + do_mv_ln ${mv_opts} "${mfile}" "${ofile}" rm ${rm_opts} "${file}" return 255 ;;