On 10/5/06, Grobian <[EMAIL PROTECTED]> wrote:
On 03-10-2006 16:34:48 -0600, m h wrote:
> Here is a series of patches for portage and what they do.
>
> rpm - Improves the ability of portage to generate rpms and dependencies of
> rpms

I contacted the portage team about this, and it has been given to
another user working on it.  If you like I can give you contact
information.  I think I'll upload it to bugzilla anyway, if you won't do
it yourself, as it's not related to prefix IMHO.

Are you giving it to antarus?  Yes, this is not prefix specific so it
should go upstream as well....


> double_prefix - some sanity checks for double prefixing
> various_fixes - some minor fixes for issues we have run accross
> (mostly adding EPREFIX where needed)

comments inline

> hooks - allows one to run arbitrary code after emerge stages finish

I don't see the need for now, so I didn't apply it (yet).  Isn't it also
a generic feature?


this is generic, we use it to update test results to our test
reporting mechanism.

> tests - allows enabling tests on a per package basis, by looking at a
> package.test file

I applied this because it looked like having a prefix fix.  What's the
rationale behind package.test?  Also, the functionality itself sounds
more generic than just prefix specific.


Again, this is generic and used by us for testing

> cygwin - allows for building under cygwin (need a cygwin ebuild tree for
> this).

Didn't apply this.  It looks cool, and I'd certainly like to include it
once, if it can be integrated with our own tree, and a bootstrap
howto/document can be written.

ok, I guess I put a few of the cygwin fixes in the fixes patch.  Most
of the root "/" changes are cygwin specifc.

A portage-cygwin tree might be nice.  My coworker tells me that (pure)
java and python
packages "just work" under cygwin.


> Note that these were created in the order of the numbers on them.  One
> should be able to able all of them and they should not break any
> current functionality.
>
> Comments/questions/feedback welcome.
>
> -matt

> Index: prefix-portage-2.1.13.4497/bin/dispatch-conf
> ===================================================================
> --- prefix-portage-2.1.13.4497.orig/bin/dispatch-conf
> +++ prefix-portage-2.1.13.4497/bin/dispatch-conf
> @@ -78,6 +78,9 @@ class dispatch:
>          #
>
>          for path in config_paths.split ():
> +         if (path[0:len(EPREFIX)] != EPREFIX):
> +                path=EPREFIX+path
> +

Being a python illiterate, it looks to me like you prefix path if it
isn't prefixed yet.  Why?  Where is this exactly?  And why is path
allowed not to have prefix here?  What does it break?


looks like you can read python;) (though I would write "if not
path.startswith(EPREFIX):").  I believe this is because the
CONFIG_PROTECT paths were left un-prefixed

>              if not os.path.exists (path):
>                  continue
>
> Index: prefix-portage-2.1.13.4497/bin/emaint
> ===================================================================
> --- prefix-portage-2.1.13.4497.orig/bin/emaint
> +++ prefix-portage-2.1.13.4497/bin/emaint
> @@ -16,7 +16,7 @@ class WorldHandler(object):
>               self.invalid = []
>               self.not_installed = []
>               self.okay = []
> -             self.world_file = os.path.join("/", portage_const.WORLD_FILE)
> +             self.world_file = os.path.join(portage_const.EPREFIX+"/", 
portage_const.WORLD_FILE)

applied

believe this is a cygwin fix...


>               self.found = os.access(self.world_file, os.R_OK)
>
>               for atom in open(self.world_file).read().split():
> Index: prefix-portage-2.1.13.4497/bin/emerge
> ===================================================================
> --- prefix-portage-2.1.13.4497.orig/bin/emerge
> +++ prefix-portage-2.1.13.4497/bin/emerge
> @@ -1368,6 +1368,7 @@ class depgraph:
>                       portage.db[splitski[1]]["merge"].append(splitski)
>                       mygraph.delnode(mycurkey)
>               for x in dolist:
> +                     if x == "/" and x != portage.root: continue

Again, basically why?

This is relevant in case of Cygwin, where the portage.root is not '/'
but something like /cygdrive/c/cygwin. Without this change, each package
to be merged is listed and processed twice by emerge - once with root=/
and once with root=portage.root (/cygdrive/c/cygwin).


>                       for y in portage.db[x]["merge"]:
>                               retlist.append(y)
>               return retlist
> Index: prefix-portage-2.1.13.4497/bin/etc-update
> ===================================================================
> --- prefix-portage-2.1.13.4497.orig/bin/etc-update
> +++ prefix-portage-2.1.13.4497/bin/etc-update
> @@ -42,7 +42,11 @@ function scan() {
>               exit 1
>       fi
>
> +     prefix_len=${#EPREFIX}
>       for path in ${CONFIG_PROTECT} ; do
> +             if [ "${path::${prefix_len}}" != "${EPREFIX}" ]; then
> +                     path=${EPREFIX}${path}
> +             fi

applied, IIRC this was the idea behind it (not to have to use EPREFIX,
because etc-update could simply prefix it)

>               [ ! -d ${path} ] && continue
>
>               ofile=""
> Index: prefix-portage-2.1.13.4497/bin/misc-functions.sh
> ===================================================================
> --- prefix-portage-2.1.13.4497.orig/bin/misc-functions.sh
> +++ prefix-portage-2.1.13.4497/bin/misc-functions.sh
> @@ -363,12 +363,14 @@ dyn_package() {
>       install_mask "${PORTAGE_BUILDDIR}/image" ${PKG_INSTALL_MASK}
>       local pkg_dest="${PKGDIR}/All/${PF}.tbz2"
>       local pkg_tmp="${PKGDIR}/All/${PF}.tbz2.$$"
> +     addwrite "${PKGDIR}"
> +

feels scary

Need to investigate this one...



>       # Sandbox is disabled in case the user wants to use a symlink
>       # for $PKGDIR and/or $PKGDIR/All.
>       export SANDBOX_ON="0"
>       tar cpvf - ./ | bzip2 -f > "${pkg_tmp}" || die "Failed to create 
tarball"
>       cd ..
> -     python -c "import xpak; t=xpak.tbz2('${pkg_tmp}'); 
t.recompose('${PORTAGE_BUILDDIR}/build-info')"
> +     PYTHONPATH=${EPREFIX}/usr/lib/portage/pym python -c "import xpak; 
t=xpak.tbz2('${pkg_tmp}'); t.recompose('${PORTAGE_BUILDDIR}/build-info')"

I can agree on the PYTHONPATH, so why the addwrite?  I applied it
anyway.
On a side-note; did/do you guys have sandbox running on Linux?


A believe a co-worker tried sandbox and it was broken and we haven't
done much with it since.  Are any others using sandbox?


>       if [ $? -ne 0 ]; then
>               rm -f "${pkg_tmp}"
>               die "Failed to append metadata to the tbz2 file"
> Index: prefix-portage-2.1.13.4497/pym/dispatch_conf.py
> ===================================================================
> --- prefix-portage-2.1.13.4497.orig/pym/dispatch_conf.py
> +++ prefix-portage-2.1.13.4497/pym/dispatch_conf.py
> @@ -12,6 +12,7 @@ import os, sys, commands, shutil
>
>  sys.path = ["/usr/lib/portage/pym"]+sys.path
>  import portage
> +from portage_const import EPREFIX
>
>  RCS_BRANCH = '1.1.1'
>  RCS_LOCK = 'rcs -ko -M -l'
> @@ -23,12 +24,12 @@ DIFF3_MERGE = 'diff3 -mE %s %s %s >%s'
>
>  def read_config(mandatory_opts):
>      try:
> -        opts = portage.getconfig('/etc/dispatch-conf.conf')
> +        opts = portage.getconfig(EPREFIX+'/etc/dispatch-conf.conf')
>      except:
>          opts = None
>
>      if not opts:
> -        print >> sys.stderr, 'dispatch-conf: Error reading 
/etc/dispatch-conf.conf; fatal'
> +        print >> sys.stderr, 'dispatch-conf: Error reading 
'+EPREFIX+'/etc/dispatch-conf.conf; fatal'

applied

>          sys.exit(1)
>
>      for key in mandatory_opts:
> Index: prefix-portage-2.1.13.4497/pym/portage.py
> ===================================================================
> --- prefix-portage-2.1.13.4497.orig/pym/portage.py
> +++ prefix-portage-2.1.13.4497/pym/portage.py
> @@ -1071,7 +1071,9 @@ class config:
>
>                       try:
>                               # XXX: Should depend on root?
> -                             
self.mygcfg=getconfig("/"+MAKE_CONF_FILE,allow_sourcing=True)
> +                             ## Yes, Should depend on root!! (npac)
> +                             global root
> +                             
self.mygcfg=getconfig(root+MAKE_CONF_FILE,allow_sourcing=True)
>                               if self.mygcfg == None:
>                                       self.mygcfg = {}
>                       except SystemExit, e:
> @@ -2610,7 +2612,7 @@ def prepare_build_dirs(myroot, mysetting
>                       mysettings["LOG_PF"] != mysettings["PF"]:
>                               mysettings["LOG_PF"] = mysettings["PF"]
>                               mysettings["LOG_COUNTER"] = \
> -                                     
str(db[myroot]["vartree"].dbapi.get_counter_tick_core("/"))
> +                                     
str(db[myroot]["vartree"].dbapi.get_counter_tick_core(root))
>
>               if not logging_enabled:
>                       writemsg("!!! Permission issues with PORT_LOGDIR='%s'\n" % 
mysettings["PORT_LOGDIR"])
> @@ -4830,7 +4832,8 @@ class portdbapi(dbapi):
>                                       writemsg("Uncaught handled exception: 
%(exception)s\n" % {"exception":str(e)})
>                                       raise
>
> -                     
myret=doebuild(myebuild,"depend","/",self.mysettings,dbkey=mydbkey,tree="porttree")
> +                     # Use root, instead of "/" (npac)
> +                     
myret=doebuild(myebuild,"depend",root,self.mysettings,dbkey=mydbkey,tree="porttree")
>                       if myret:
>                               portage_locks.unlockfile(mylock)
>                               self.lock_held = 0

I hope you are right, applied ;)
All of this is again relevant for Windows where root is not '/'.
Basically, here's the deal on Windows:

If root is set to '/' and prefix is set to '/opt/prefix', Cygwin tries
merging files to //opt/prefix and fails because '//' is treated as a
network drive location on Windows. Therefore, we set the root to
'/cygdrive/c/cygwin' and PREFIX to '/opt/prefix'. Portage will then
merge files to '/cygdrive/c/cygwin/opt/prefix' and everything is well.

A lot of portage code seems to assume that "root" is always '/' and uses
these two things interchangeably. This works fine on all UNIX-like
systems, but fails as soon as the assumption turns out to be invalid.


> @@ -6475,6 +6478,9 @@ def pkgmerge(mytbz2,myroot,mysettings):
>  # XXX Fix this
>  if os.environ.has_key("ROOT"):
>       root=os.environ["ROOT"]
> +     ## cchan - HACK for when portage is being called within an ebuild/eclass
> +     if root == portage_const.EPREFIX: root="/"
> +
>       if not len(root):
>               root="/"
>       elif root[-1]!="/":

This hunk looks like some documentation, in the wrong place.  I dropped
it.  Would have clashed with a change I made right below this point
anyway.


Chris answered this one.

Thanks for the patches!


No problem.  Thanks for coordinating all this effort.


--
Fabian Groffen
Gentoo on a different level
--
[EMAIL PROTECTED] mailing list


--
[EMAIL PROTECTED] mailing list

Reply via email to