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-462613-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1SU2YX-00015N-TG
	for garchives@archives.gentoo.org; Mon, 14 May 2012 21:11:50 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 96FB6E0A97;
	Mon, 14 May 2012 21:11:41 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id 6C2B2E0A97
	for <gentoo-commits@lists.gentoo.org>; Mon, 14 May 2012 21:11:41 +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 D58841B419A
	for <gentoo-commits@lists.gentoo.org>; Mon, 14 May 2012 21:11:40 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by hornbill.gentoo.org (Postfix) with ESMTP id 8E22AE5429
	for <gentoo-commits@lists.gentoo.org>; Mon, 14 May 2012 21:11:39 +0000 (UTC)
From: "Zac Medico" <zmedico@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" <zmedico@gentoo.org>
Message-ID: <1337029862.72fad479b79ff9cb81b65a552fcd2ccaedbdaef7.zmedico@gentoo>
Subject: [gentoo-commits] proj/portage:master commit in: bin/ebuild-helpers/
X-VCS-Repository: proj/portage
X-VCS-Files: bin/ebuild-helpers/prepstrip
X-VCS-Directories: bin/ebuild-helpers/
X-VCS-Committer: zmedico
X-VCS-Committer-Name: Zac Medico
X-VCS-Revision: 72fad479b79ff9cb81b65a552fcd2ccaedbdaef7
X-VCS-Branch: master
Date: Mon, 14 May 2012 21:11:39 +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: 2bb6084d-c654-48d3-8041-592913f9cf6c
X-Archives-Hash: 87c110920abd95907b6625eb2010b0e1

commit:     72fad479b79ff9cb81b65a552fcd2ccaedbdaef7
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon May 14 20:53:36 2012 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon May 14 21:11:02 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a=
=3Dcommit;h=3D72fad479

prepstrip: fix hardlink handling for subshells

---
 bin/ebuild-helpers/prepstrip |   36 +++++++++++++++++++++++-------------
 1 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/bin/ebuild-helpers/prepstrip b/bin/ebuild-helpers/prepstrip
index a58a83b..c00fb37 100755
--- a/bin/ebuild-helpers/prepstrip
+++ b/bin/ebuild-helpers/prepstrip
@@ -67,16 +67,15 @@ multijob_init
 # Setup $T filesystem layout that we care about.
 tmpdir=3D"${T}/prepstrip"
 rm -rf "${tmpdir}"
-mkdir -p "${tmpdir}"/{splitdebug,sources}
-
-unset ${!INODE_*}
+mkdir -p "${tmpdir}"/{inodes,splitdebug,sources}
=20
 # Usage: inode_var_name: <file>
-inode_var_name() {
+inode_file_link() {
+	echo -n "${tmpdir}/inodes/"
 	if  [[ ${USERLAND} =3D=3D "BSD" ]] ; then
-		stat -f 'INODE_%d_%i' "$1"
+		stat -f '%i' "$1"
 	else
-		stat -c 'INODE_%d_%i' "$1"
+		stat -c '%i' "$1"
 	fi
 }
=20
@@ -93,9 +92,13 @@ save_elf_sources() {
 		return 0
 	fi
=20
-	local x=3D$1
-	local inode=3D$(inode_var_name "${x}")
-	[[ -n ${!inode} ]] && return 0
+	local x=3D$1 y inode=3D$(inode_file_link "${x}")
+	if [[ -f ${inode} ]] ; then
+		y=3D${ED}usr/lib/debug/${x:${#D}}.debug
+		mkdir -p "${y%/*}"
+		ln "${inode}" "${y}"
+		return 0
+	fi
=20
 	# since we're editing the ELF here, we should recompute the build-id
 	# (the -i flag below).  save that output so we don't need to recompute
@@ -124,11 +127,10 @@ save_elf_debug() {
=20
 	mkdir -p "${y%/*}"
=20
-	local inode=3D$(inode_var_name "${x}")
-	if [[ -n ${!inode} ]] ; then
-		ln "${ED}usr/lib/debug/${!inode:${#D}}.debug" "${y}"
+	local inode=3D$(inode_file_link "${x}")
+	if [[ -f ${inode} ]] ; then
+		ln "${inode}" "${y}"
 	else
-		eval ${inode}=3D\${x}
 		if [[ -n ${splitdebug} ]] ; then
 			mv "${splitdebug}" "${y}"
 		else
@@ -140,6 +142,12 @@ save_elf_debug() {
 		local args=3D"a-x,o-w"
 		[[ -g ${x} || -u ${x} ]] && args+=3D",go-r"
 		chmod ${args} "${y}"
+		if ! ln "${y}" "${inode}" ; then
+			# This means a parallel process has already created the
+			# inode link. So, replace ${y} with a link to that inode.
+			rm -f "${y}"
+			ln "${inode}" "${y}"
+		fi
 	fi
=20
 	# if we don't already have build-id from debugedit, look it up
@@ -304,3 +312,5 @@ then
 		>> "${emptydir}"/.keepdir
 	done < <(find "${D}${prepstrip_sources_dir}/" -type d -empty -print0)
 fi
+
+rm -rf "${tmpdir}"