public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] PATCH: Use lchown and lchgrp no-op functions when operating on symlinks (#99616)
@ 2005-07-21 14:13 Jason Stubbs
  2005-07-21 17:17 ` Brian D. Harring
  0 siblings, 1 reply; 7+ messages in thread
From: Jason Stubbs @ 2005-07-21 14:13 UTC (permalink / raw
  To: gentoo-portage-dev


[-- Attachment #1.1: Type: text/plain, Size: 429 bytes --]

http://bugs.gentoo.org/show_bug.cgi?id=99616

Similar to the usage of chown on Darwin in bug #98827, ebuild.sh uses chown
on symlinks which can alter the target where the intention is to modify the
symlink. This patch adds no-op lchown and lchgrp functions to ebuild.sh.
Profiles should override these to provide the correct implementation for
the specific userland.

(Apologies to the bug poster!)

-- 
Jason Stubbs

[-- Attachment #1.2: 99616_overridable_lchown_lchgrp.patch --]
[-- Type: text/x-diff, Size: 1447 bytes --]

diff -uNr portage-2.0.51.22-r2/bin/ebuild.sh portage-patched/bin/ebuild.sh
--- portage-2.0.51.22-r2/bin/ebuild.sh	2005-07-19 19:38:32.949904000 +0900
+++ portage-patched/bin/ebuild.sh	2005-07-21 23:03:58.429898000 +0900
@@ -85,6 +85,11 @@
 	export SANDBOX_PREDICT="$SANDBOX_PREDICT:$1"
 }
 
+lchown()
+{ 0; }
+
+lchgrp()
+{ 0; }
 
 # source the existing profile.bashrc's.
 save_IFS
@@ -1075,9 +1080,13 @@
 	local count=0
 	find "${D}/" -user  portage | while read file; do
 		count=$(( $count + 1 ))
-		[[ ! -L ${file} ]] && s=$(stat_perms $file)
-		chown root "$file"
-		[[ ! -L ${file} ]] && chmod "$s" "$file"
+		if [ -L "${file}" ]; then
+			lchown root "${file}"
+		else
+			s=$(stat_perms $file)
+			chown root "$file"
+			chmod "$s" "$file"
+		fi
 	done
 	if (( $count > 0 )); then
 		ewarn "$count files were installed with user portage!"
@@ -1086,13 +1095,13 @@
 	count=0
 	find "${D}/" -group portage | while read file; do
 		count=$(( $count + 1 ))
-		[[ ! -L ${file} ]] && s=$(stat_perms "$file")
-		if [ "$USERLAND" == "BSD" ] || [ "$USERLAND" == "Darwin" ];then
-			chgrp wheel "$file"
+		if [ -L ${file} ]; then
+			lchgrp 0 "${file}"
 		else
-			chgrp root "$file"
+			s=$(stat_perms "$file")
+			chgrp 0 "$file"
+			chmod "$s" "$file"
 		fi
-		[[ ! -L ${file} ]] && chmod "$s" "$file"
 	done
 	if (( $count > 0 )); then
 		ewarn "$count files were installed with group portage!"

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-portage-dev] PATCH: Use lchown and lchgrp no-op functions when operating on symlinks (#99616)
  2005-07-21 14:13 [gentoo-portage-dev] PATCH: Use lchown and lchgrp no-op functions when operating on symlinks (#99616) Jason Stubbs
@ 2005-07-21 17:17 ` Brian D. Harring
  2005-07-21 23:49   ` Jason Stubbs
  0 siblings, 1 reply; 7+ messages in thread
From: Brian D. Harring @ 2005-07-21 17:17 UTC (permalink / raw
  To: gentoo-portage-dev

[-- Attachment #1: Type: text/plain, Size: 609 bytes --]

On Thu, Jul 21, 2005 at 11:13:34PM +0900, Jason Stubbs wrote:
> diff -uNr portage-2.0.51.22-r2/bin/ebuild.sh portage-patched/bin/ebuild.sh
> --- portage-2.0.51.22-r2/bin/ebuild.sh	2005-07-19 19:38:32.949904000 +0900
> +++ portage-patched/bin/ebuild.sh	2005-07-21 23:03:58.429898000 +0900
> @@ -85,6 +85,11 @@
>  	export SANDBOX_PREDICT="$SANDBOX_PREDICT:$1"
>  }
>  
> +lchown()
> +{ 0; }
> +
> +lchgrp()
> +{ 0; }
Default being negation of funcs, and forcing profiles to override it?
Why not reverse it, a default func that works, with profiles 
overriding if/when it doesn't work?
~harring

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-portage-dev] PATCH: Use lchown and lchgrp no-op functions when operating on symlinks (#99616)
  2005-07-21 17:17 ` Brian D. Harring
@ 2005-07-21 23:49   ` Jason Stubbs
  2005-08-05  3:31     ` [gentoo-portage-dev] PATCH: properly handle metadata transfer on first sync of an empty tree (#96410) Brian D. Harring
  0 siblings, 1 reply; 7+ messages in thread
From: Jason Stubbs @ 2005-07-21 23:49 UTC (permalink / raw
  To: gentoo-portage-dev

[-- Attachment #1: Type: text/plain, Size: 1136 bytes --]

On Friday 22 July 2005 02:17, Brian D. Harring wrote:
> On Thu, Jul 21, 2005 at 11:13:34PM +0900, Jason Stubbs wrote:
> > diff -uNr portage-2.0.51.22-r2/bin/ebuild.sh portage-patched/bin/ebuild.sh
> > --- portage-2.0.51.22-r2/bin/ebuild.sh	2005-07-19 19:38:32.949904000 +0900
> > +++ portage-patched/bin/ebuild.sh	2005-07-21 23:03:58.429898000 +0900
> > @@ -85,6 +85,11 @@
> >  	export SANDBOX_PREDICT="$SANDBOX_PREDICT:$1"
> >  }
> >  
> > +lchown()
> > +{ 0; }
> > +
> > +lchgrp()
> > +{ 0; }
>
> Default being negation of funcs, and forcing profiles to override it?
> Why not reverse it, a default func that works, with profiles 
> overriding if/when it doesn't work?

I don't really like the idea of adding yet another >& /dev/null. With a GNU
userland, it would be something like:

lchown()
{ chown -h $* }

If the many errors that will occur when the userland's chown doesn't support
this flag are okay, putting in working defaults are fine. The main reasons I
went with no-ops are that symlink ownership is purely cosmetic (afaik) and
to try to keep userland specific stuff out.

-- 
Jason Stubbs

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [gentoo-portage-dev] PATCH: properly handle metadata transfer on first sync of an empty tree (#96410)
  2005-07-21 23:49   ` Jason Stubbs
@ 2005-08-05  3:31     ` Brian D. Harring
  2005-08-05 11:20       ` Jason Stubbs
  2005-08-06 23:30       ` Zac Medico
  0 siblings, 2 replies; 7+ messages in thread
From: Brian D. Harring @ 2005-08-05  3:31 UTC (permalink / raw
  To: gentoo-portage-dev


[-- Attachment #1.1: Type: text/plain, Size: 462 bytes --]

Hola all, patch (incvs now) to fix up a traceback on first sync with 
an empty tree; bug #96410
http://bugs.gentoo.org/show_bug.cgi?id=96410

The fix isn't exactly what I'd call pretty (creating an intermediate 
portdbapi and config instance to do the updates), but it's a corner 
case; config's categories is a bit of a hack, and tearing it out in 
stable is more work then worth... so this.

Either way, it's attached, poke at it kindly :)
~harring

[-- Attachment #1.2: empty-tree-sync-fix.patch --]
[-- Type: text/plain, Size: 3637 bytes --]

Index: emerge
===================================================================
RCS file: /var/cvsroot/gentoo-src/portage/bin/emerge,v
retrieving revision 1.345.2.33
retrieving revision 1.345.2.36
diff -u -r1.345.2.33 -r1.345.2.36
--- emerge	2 Jun 2005 00:57:52 -0000	1.345.2.33
+++ emerge	5 Aug 2005 03:26:17 -0000	1.345.2.36
@@ -1,7 +1,7 @@
 #!/usr/bin/python -O
 # Copyright 1999-2004 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-src/portage/bin/emerge,v 1.345.2.33 2005/06/02 00:57:52 vapier Exp $
+# $Header: /var/cvsroot/gentoo-src/portage/bin/emerge,v 1.345.2.36 2005/08/05 03:26:17 ferringb Exp $
 
 import os,sys
 os.environ["PORTAGE_CALLER"]="emerge"
@@ -2677,28 +2677,33 @@
 			raise # Needed else can't exit
 		except:
 			pass
-		# we don't make overlay trees cache here.
-		backup_porttrees=portage.portdb.porttrees
+		# we don't make overlay trees cache here, plus we don't trust portage.settings.categories
 		porttree_root = portage.portdb.porttree_root
-		portage.portdb.porttrees=[porttree_root]
-		cp_list=portage.portdb.cp_all()
+		pdb = portage.portdbapi(porttree_root, portage.config(config_profile_path=portage.settings.profile_path[:], \
+			config_incrementals=portage.settings.incrementals[:]))
+		cp_list = pdb.cp_all()
+		if len(cp_list) == 0:
+			print "no metadata to transfer, exiting"
+			sys.exit(0)
 		cp_list.sort()
 		pcnt=0
 		pcntstr=""
 		pcntcount=len(cp_list)/100.0
 		nextupdate=pcntcount
 		current=1
-		def cleanse_cache(cat, saves, porttree_root=porttree_root):
+
+		def cleanse_cache(pdb, cat, saves, porttree_root=porttree_root):
 			if len(saves):
 				d={}
 				for v in saves:
 					d[portage.catsplit(v)[1]] = True
-				for pv in portage.db["/"]["porttree"].dbapi.auxdb[porttree_root][cat].keys():
+				for pv in pdb.auxdb[porttree_root][cat].keys():
 					if pv not in d:
-						portage.db["/"]["porttree"].dbapi.auxdb[porttree_root][cat].del_key(pv)
+						pdb.auxdb[porttree_root][cat].del_key(pv)
 			else:
-				portage.db["/"]["porttree"].dbapi.auxdb[porttree_root][cat].clear()
-				del portage.db["/"]["porttree"].dbapi.auxdb[porttree_root][cat]
+				pdb.auxdb[porttree_root][cat].clear()
+				del pdb.auxdb[porttree_root][cat]
+
 		savelist = []
 		catlist = []
 		oldcat = portage.catsplit(cp_list[0])[0]
@@ -2714,18 +2719,18 @@
 			cat = portage.catsplit(cp)[0]
 			if cat != oldcat:
 				catlist.append(oldcat)
-				cleanse_cache(oldcat, savelist)
+				cleanse_cache(pdb, oldcat, savelist)
 				savelist = []
 				oldcat = cat
-			mymatches = portage.db["/"]["porttree"].dbapi.xmatch("match-all", cp)
+			mymatches = pdb.xmatch("match-all", cp)
 			savelist.extend(mymatches)
 			for cpv in mymatches:
-				try: portage.db["/"]["porttree"].dbapi.aux_get(cpv, ["IUSE"],metacachedir=myportdir+"/metadata/cache",debug=("cachedebug" in portage.features))
+				try: pdb.aux_get(cpv, ["IUSE"],metacachedir=myportdir+"/metadata/cache",debug=("cachedebug" in portage.features))
 				except SystemExit: raise
 				except Exception, e: print "\nFailed cache update:",cpv,e
 		catlist.append(oldcat)
 		catlist.append("local")
-		cleanse_cache(oldcat, savelist)
+		cleanse_cache(pdb, oldcat, savelist)
 		filelist = portage.listdir(cachedir+"/"+myportdir)
 		for x in filelist:
 			found = False
@@ -2737,7 +2742,6 @@
 				portage.spawn("cd /; rm -Rf "+cachedir+"/"+myportdir+"/"+x,portage.settings,free=1,droppriv=1)
 
 
-		portage.portdb.porttrees=backup_porttrees
 		sys.stdout.write("\n\n")
 		sys.stdout.flush()
 

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-portage-dev] PATCH: properly handle metadata transfer on first sync of an empty tree (#96410)
  2005-08-05  3:31     ` [gentoo-portage-dev] PATCH: properly handle metadata transfer on first sync of an empty tree (#96410) Brian D. Harring
@ 2005-08-05 11:20       ` Jason Stubbs
  2005-08-09  7:19         ` Brian Harring
  2005-08-06 23:30       ` Zac Medico
  1 sibling, 1 reply; 7+ messages in thread
From: Jason Stubbs @ 2005-08-05 11:20 UTC (permalink / raw
  To: gentoo-portage-dev

[-- Attachment #1: Type: text/plain, Size: 762 bytes --]

On Friday 05 August 2005 12:31, Brian D. Harring wrote:
> Hola all, patch (incvs now) to fix up a traceback on first sync with
> an empty tree; bug #96410
> http://bugs.gentoo.org/show_bug.cgi?id=96410
>
> The fix isn't exactly what I'd call pretty (creating an intermediate
> portdbapi and config instance to do the updates), but it's a corner
> case; config's categories is a bit of a hack, and tearing it out in
> stable is more work then worth... so this.
>
> Either way, it's attached, poke at it kindly :)

You know the caching fairly well, so I'll ask rather than check. ;)

How does this affect the new version of portage check that follows? Will 
that use the old cache, find that it's out of date and then regen it?

--
Jason Stubbs

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-portage-dev] PATCH: properly handle metadata transfer on first sync of an empty tree (#96410)
  2005-08-05  3:31     ` [gentoo-portage-dev] PATCH: properly handle metadata transfer on first sync of an empty tree (#96410) Brian D. Harring
  2005-08-05 11:20       ` Jason Stubbs
@ 2005-08-06 23:30       ` Zac Medico
  1 sibling, 0 replies; 7+ messages in thread
From: Zac Medico @ 2005-08-06 23:30 UTC (permalink / raw
  To: gentoo-portage-dev

Brian D. Harring wrote:
> Hola all, patch (incvs now) to fix up a traceback on first sync with 
> an empty tree; bug #96410
> http://bugs.gentoo.org/show_bug.cgi?id=96410
> 
> The fix isn't exactly what I'd call pretty (creating an intermediate 
> portdbapi and config instance to do the updates), but it's a corner 
> case; config's categories is a bit of a hack, and tearing it out in 
> stable is more work then worth... so this.
> 
> Either way, it's attached, poke at it kindly :)
> ~harring
> 

This patch seems good to me.  I tested it a few times with things like "emerge metadata" and "rm -r /var/cache/edb/dep".  I didn't do any rigorous testing but there were no noticeable problems.

Zac
-- 
gentoo-portage-dev@gentoo.org mailing list



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-portage-dev] PATCH: properly handle metadata transfer on first sync of an empty tree (#96410)
  2005-08-05 11:20       ` Jason Stubbs
@ 2005-08-09  7:19         ` Brian Harring
  0 siblings, 0 replies; 7+ messages in thread
From: Brian Harring @ 2005-08-09  7:19 UTC (permalink / raw
  To: gentoo-portage-dev

[-- Attachment #1: Type: text/plain, Size: 1068 bytes --]

On Fri, Aug 05, 2005 at 08:20:52PM +0900, Jason Stubbs wrote:
> On Friday 05 August 2005 12:31, Brian D. Harring wrote:
> > Hola all, patch (incvs now) to fix up a traceback on first sync with
> > an empty tree; bug #96410
> > http://bugs.gentoo.org/show_bug.cgi?id=96410
> >
> > The fix isn't exactly what I'd call pretty (creating an intermediate
> > portdbapi and config instance to do the updates), but it's a corner
> > case; config's categories is a bit of a hack, and tearing it out in
> > stable is more work then worth... so this.
> >
> > Either way, it's attached, poke at it kindly :)
> 
> You know the caching fairly well, so I'll ask rather than check. ;)
> 
> How does this affect the new version of portage check that follows? Will 
> that use the old cache, find that it's out of date and then regen it?
The ugly inlining of code in portage.py makes this play nice actually, 
due to the forced reload of portage prior to checking for an updated 
portage being available (specifically, the config instance is 
recreated).
~harring

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-08-09  7:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-21 14:13 [gentoo-portage-dev] PATCH: Use lchown and lchgrp no-op functions when operating on symlinks (#99616) Jason Stubbs
2005-07-21 17:17 ` Brian D. Harring
2005-07-21 23:49   ` Jason Stubbs
2005-08-05  3:31     ` [gentoo-portage-dev] PATCH: properly handle metadata transfer on first sync of an empty tree (#96410) Brian D. Harring
2005-08-05 11:20       ` Jason Stubbs
2005-08-09  7:19         ` Brian Harring
2005-08-06 23:30       ` Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox