From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <gentoo-commits+bounces-496169-garchives=archives.gentoo.org@lists.gentoo.org>
Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80])
	by finch.gentoo.org (Postfix) with ESMTP id C51981381F4
	for <garchives@archives.gentoo.org>; Wed, 15 Aug 2012 02:56:03 +0000 (UTC)
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id D1E93E09B0;
	Wed, 15 Aug 2012 02:55:50 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id 9A5F1E09B0
	for <gentoo-commits@lists.gentoo.org>; Wed, 15 Aug 2012 02:55:50 +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 084B71B4065
	for <gentoo-commits@lists.gentoo.org>; Wed, 15 Aug 2012 02:55:50 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by hornbill.gentoo.org (Postfix) with ESMTP id BAE07E543A
	for <gentoo-commits@lists.gentoo.org>; Wed, 15 Aug 2012 02:55:48 +0000 (UTC)
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: 8bit
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" <zmedico@gentoo.org>
Message-ID: <1344999319.b711786c8fe6231a2d33b0a3070355339cbeb36d.zmedico@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: bin/
X-VCS-Repository: proj/portage
X-VCS-Files: bin/emerge-webrsync
X-VCS-Directories: bin/
X-VCS-Committer: zmedico
X-VCS-Committer-Name: Zac Medico
X-VCS-Revision: b711786c8fe6231a2d33b0a3070355339cbeb36d
X-VCS-Branch: master
Date: Wed, 15 Aug 2012 02:55:48 +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
X-Archives-Salt: 29718947-d02b-4df9-bf1a-23a4b1ca237e
X-Archives-Hash: dfae3db3d53e111ab4af26010eb1de02

commit:     b711786c8fe6231a2d33b0a3070355339cbeb36d
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Aug 15 02:55:19 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Aug 15 02:55:19 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b711786c

emerge-webrsync: preserve ownership for usersync

---
 bin/emerge-webrsync |   22 +++++++++++++++++-----
 1 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync
index 0a036d2..80d6294 100755
--- a/bin/emerge-webrsync
+++ b/bin/emerge-webrsync
@@ -42,7 +42,7 @@ fi
 eval $("${portageq}" envvar -v DISTDIR FEATURES FETCHCOMMAND GENTOO_MIRRORS \
 	PORTAGE_BIN_PATH PORTAGE_GPG_DIR \
 	PORTAGE_NICENESS PORTAGE_RSYNC_EXTRA_OPTS PORTAGE_TMPDIR PORTDIR \
-	SYNC http_proxy ftp_proxy)
+	SYNC USERLAND http_proxy ftp_proxy)
 export http_proxy ftp_proxy
 
 # If PORTAGE_NICENESS is overriden via the env then it will
@@ -187,9 +187,21 @@ sync_local() {
 
 	vecho "Syncing local tree ..."
 
+	local ownership="portage:portage"
+	if has usersync ${FEATURES} ; then
+		case "${USERLAND}" in
+			BSD)
+				ownership=$(stat -f '%Su:%Sg' "${PORTDIR}")
+				;;
+			*)
+				ownership=$(stat -c '%U:%G' "${PORTDIR}")
+				;;
+		esac
+	fi
+
 	if type -P tarsync > /dev/null ; then
-		local chown_opts="-o portage -g portage"
-		chown portage:portage portage > /dev/null 2>&1 || chown_opts=""
+		local chown_opts="-o ${ownership%:*} -g ${ownership#*:}"
+		chown ${ownership} "${PORTDIR}" > /dev/null 2>&1 || chown_opts=""
 		if ! tarsync $(vvecho -v) -s 1 ${chown_opts} \
 			-e /distfiles -e /packages -e /local "${file}" "${PORTDIR}"; then
 			eecho "tarsync failed; tarball is corrupt? (${file})"
@@ -205,8 +217,8 @@ sync_local() {
 		# Free disk space
 		${keep} || rm -f "${file}"
 
-		chown portage:portage portage > /dev/null 2>&1 && \
-			chown -R portage:portage portage
+		chown ${ownership} portage > /dev/null 2>&1 && \
+			chown -R ${ownership} portage
 		cd portage
 		rsync -av --progress --stats --delete --delete-after \
 			--exclude='/distfiles' --exclude='/packages' \