From b711786c8fe6231a2d33b0a3070355339cbeb36d Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 14 Aug 2012 19:55:19 -0700 Subject: [PATCH] emerge-webrsync: preserve ownership for usersync --- bin/emerge-webrsync | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/bin/emerge-webrsync b/bin/emerge-webrsync index 0a036d29e..80d62947f 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' \ -- 2.26.2