From mboxrd@z Thu Jan  1 00:00:00 1970
Received: from lists.gentoo.org ([140.105.134.102] helo=robin.gentoo.org)
	by nuthatch.gentoo.org with esmtp (Exim 4.43)
	id 1E8yMI-0004yU-FU
	for garchives@archives.gentoo.org; Sat, 27 Aug 2005 10:56:23 +0000
Received: from robin.gentoo.org (localhost [127.0.0.1])
	by robin.gentoo.org (8.13.4/8.13.4) with SMTP id j7RAsFI4015701;
	Sat, 27 Aug 2005 10:54:15 GMT
Received: from smtp.gentoo.org (smtp.gentoo.org [134.68.220.30])
	by robin.gentoo.org (8.13.4/8.13.4) with ESMTP id j7RAsEdk024448
	for <gentoo-portage-dev@lists.gentoo.org>; Sat, 27 Aug 2005 10:54:15 GMT
Received: from cpe-65-26-255-237.wi.res.rr.com ([65.26.255.237] helo=nightcrawler)
	by smtp.gentoo.org with esmtpa (Exim 4.43)
	id 1E8yLj-0005fT-EQ
	for gentoo-portage-dev@lists.gentoo.org; Sat, 27 Aug 2005 10:55:47 +0000
Date: Sat, 27 Aug 2005 05:53:57 -0500
From: Brian Harring <ferringb@gentoo.org>
To: gentoo-portage-dev@lists.gentoo.org
Subject: [gentoo-portage-dev] PATCH: initial EAPI awareness
Message-ID: <20050827105357.GY1701@nightcrawler>
Precedence: bulk
List-Post: <mailto:gentoo-portage-dev@lists.gentoo.org>
List-Help: <mailto:gentoo-portage-dev+help@gentoo.org>
List-Unsubscribe: <mailto:gentoo-portage-dev+unsubscribe@gentoo.org>
List-Subscribe: <mailto:gentoo-portage-dev+subscribe@gentoo.org>
List-Id: Gentoo Linux mail <gentoo-portage-dev.gentoo.org>
X-BeenThere: gentoo-portage-dev@gentoo.org
Reply-to: gentoo-portage-dev@lists.gentoo.org
Mime-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha1;
	protocol="application/pgp-signature"; boundary="HJ7DkX9BXQhna2ov"
Content-Disposition: inline
User-Agent: Mutt/1.5.8i
X-Archives-Salt: f3409d9d-8dd4-4a37-a907-55c9dd214580
X-Archives-Hash: 65c8c7c4fea74aa735871a0369e893b2


--HJ7DkX9BXQhna2ov
Content-Type: multipart/mixed; boundary="csgZZokDzjk698W/"
Content-Disposition: inline


--csgZZokDzjk698W/
Content-Type: text/plain; charset=utf8
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hola.

Attached is a patch that=20
A) adds EAPI awareness to portage; mainly, if >0, complain and be=20
   unwilling to merge the package
B) tweaks to portage_db_flat, addition of portage_db_metadata, and=20
   portage_db_flat_hash

Flat_hash is the replacement cache format for metadata/cache; assuming=20
nobody does anything stupid with EAPI, it will allow us to deploy new=20
metadata in the tree without forcing a breakage every time we do so.

portage_db_metadata.py is a compability implementation; basically=20
detects if it's flat_list (portage_db_flat), or flat_hash and calls=20
accordingly.

Aside from that, tried to keep changes as minimal as possible.  The=20
patch isn't complete due to the fact we need to add an EAPI cache=20
compatibility check for --metadata transfer, but can't do that till I=20
get some feedback from -dev ml regarding a bit of tree cleanup that=20
will go along with it.

Please test this out; if you want to test the EAPI checking, tag=20
EAPI=3D1 into an ebuild, and try making emerge bail.

If you're less adventurous, please test the compatibility cache=20
testing;=20
in /etc/portage/modules
portdbapi.metadbmodule=3Dportage_db_metadata.database

Will enable the autodetection.  Additionally,=20
portdbapi.auxdbmodule=3Dportage_db_flat_hash.database

being flipped on would be appreciated, although you will have to wipe=20
your cache and run emerge --metadata; with the settings above, you're=20
testing the auto-detect functionality, and the new format.

Thanks,
~harring

--csgZZokDzjk698W/
Content-Type: text/plain; charset=utf8
Content-Disposition: attachment; filename="2.0.51-eapi-awareness.patch"
Content-Transfer-Encoding: quoted-printable

diff -urN portage-old/bin/emerge portage/bin/emerge
--- portage-old/bin/emerge	2005-08-27 05:28:09.000000000 -0500
+++ portage/bin/emerge	2005-08-27 05:27:17.000000000 -0500
@@ -612,7 +612,7 @@
 	help()
 	sys.exit(0)
 elif portage.secpass!=3D2:
-	if myaction in ["search", "info", "regen"]:
+	if myaction in ["search", "info", "regen", "metadata"]:
 		pass
 	elif (not myaction) and (not myfiles):
 		pass
@@ -1497,7 +1497,7 @@
 		myfetchlist=3D[]
 		for x in mylist:
 			fetch=3D" "
-
+			stupid_if_logic_hack =3D True
 			if x[0]=3D=3D"blocks":
 				addl=3D""+red("B")+"  "+fetch+"  "
 				resolved=3Dportage.db[x[1]]["vartree"].resolve_key(x[2])
@@ -1512,7 +1512,22 @@
 						print red("(is blocking "+x[3]+")")
 					else:
 						print
+				stupid_if_logic_hack =3D False
+
 			else:
+				if x[0] =3D=3D "ebuild":	source =3D "porttree"
+				elif x[0] =3D=3D "binary":	source =3D "bintree"
+				elif x[0] =3D=3D ("nomerge", "blocker"):	source =3D None
+				else:
+					print "EAPI check, unknown source "+str(x[0])+" for "+x[2]+", this sh=
ouldn't occur",mylist
+					sys.exit(1)
+				if source:
+					needed =3D portage.db[x[1]][source].dbapi.aux_get(x[2], ["EAPI"])[0]
+					if needed > portage.EAPI:
+						print '[%s] %s %s, EAPI:%i installed portage EAPI:%i' % (x[0].ljust(=
13), x[2], red("UNMERGABLE"),needed, portage.EAPI)
+						stupid_if_logic_hack =3D True
+
+			if stupid_if_logic_hack:
 				if (x[0]!=3D"binary") and ("fetch" in string.split(portage.portdb.aux_=
get(x[2],["RESTRICT"])[0])):
 					fetch =3D red("F")
 					if portage.portdb.fetch_check(x[2], portage.settings):
@@ -1830,6 +1845,34 @@
 		self.pkgsettings["FEATURES"]=3Dstring.join(myfeat)
=20
 		mergecount=3D0
+	=09
+		unmergable =3D []
+		for source, root, cpv, action in mymergelist:
+			if source =3D=3D "ebuild":	source =3D "porttree"
+			elif source =3D=3D "binary": source =3D "bintree"
+			elif source in ("nomerge", "blocks"):
+				continue
+			else:
+				print "EAPI check, unknown source "+str(source)+" for "+cpv+", this sh=
ouldn't occur",mymergelist
+				sys.exit(1)
+			needed =3D portage.db[root][source].dbapi.aux_get(cpv, ["EAPI"])[0]
+			if portage.EAPI < needed:
+				unmergable.append((needed, cpv))
+
+		if len(unmergable):
+			print
+			print red("!!!")
+			print red("!!!")+" %s" % red("Ebuild API incompatibility")
+			print red("!!!")+" installed portage EAPI is %i, the following packages=
 require a higher version" % portage.EAPI
+			print red("!!!")+" This version of portage is incapable of installing t=
he higher version"
+			print red("!!!")+" A portage upgrade should solve this"
+			print red("!!!")
+			for needed, cpv in unmergable:
+				print ">>>    %s requires EAPI %s" % (cpv, red(str(needed)))
+			print
+			if not ("--fetchonly" in myopts or "--fetch-all-uri" in myopts or "--pr=
etend" in myopts):
+				sys.exit(1)
+
 		for x in mymergelist:
 			mergecount+=3D1
 			myroot=3Dx[1]
diff -urN portage-old/pym/portage.py portage/pym/portage.py
--- portage-old/pym/portage.py	2005-08-27 05:28:02.000000000 -0500
+++ portage/pym/portage.py	2005-08-27 05:27:26.000000000 -0500
@@ -81,7 +81,7 @@
 	  MOVE_BINARY, PRELINK_BINARY, WORLD_FILE, MAKE_CONF_FILE, MAKE_DEFAULTS_=
FILE, \
 	  DEPRECATED_PROFILE_FILE, USER_VIRTUALS_FILE, EBUILD_SH_ENV_FILE, \
 	  INVALID_ENV_FILE, CUSTOM_MIRRORS_FILE, SANDBOX_PIDS_FILE, CONFIG_MEMORY=
_FILE,\
-	  INCREMENTALS, STICKIES
+	  INCREMENTALS, STICKIES, EAPI
=20
 	from portage_data import ostype, lchown, userland, secpass, uid, wheelgid=
, \
 	                         portage_uid, portage_gid
@@ -5077,9 +5071,9 @@
   'DEPEND',    'RDEPEND',   'SLOT',      'SRC_URI',
 	'RESTRICT',  'HOMEPAGE',  'LICENSE',   'DESCRIPTION',
 	'KEYWORDS',  'INHERITED', 'IUSE',      'CDEPEND',
-	'PDEPEND',   'PROVIDE',
+	'PDEPEND',   'PROVIDE', 'EAPI',
 	'UNUSED_01', 'UNUSED_02', 'UNUSED_03', 'UNUSED_04',
-	'UNUSED_05', 'UNUSED_06', 'UNUSED_07', 'UNUSED_08',
+	'UNUSED_05', 'UNUSED_06', 'UNUSED_07',
 	]
 auxdbkeylen=3Dlen(auxdbkeys)
=20
@@ -5373,10 +5367,15 @@
 		mydata   =3D self.auxdb[mylocation][cat][pkg]
 		returnme =3D []
 		for x in mylist:
-			if mydata.has_key(x):
-				returnme.append(mydata[x])
-			else:
-				returnme.append("")
+			returnme.append(mydata.get(x,""))
+
+		if "EAPI" in mylist:
+			idx =3D mylist.index("EAPI")
+			try:
+				returnme[idx] =3D int(returnme[idx])
+			except ValueError:
+				# string
+				returnme[idx] =3D 0
=20
 		return returnme
=20
diff -urN portage-old/pym/portage_db_flat.py portage/pym/portage_db_flat.py
--- portage-old/pym/portage_db_flat.py	2005-08-27 05:27:59.000000000 -0500
+++ portage/pym/portage_db_flat.py	2005-08-27 05:27:43.000000000 -0500
@@ -9,6 +9,10 @@
=20
 import portage_db_template
=20
+# since this format is massively deprecated,=20
+# we're hardcoding the previously weird line count
+magic_line_count =3D 22
+
 class database(portage_db_template.database):
 	def module_init(self):
 		self.lastkey  =3D None # Cache
@@ -42,39 +46,39 @@
 				mykeys +=3D [x]
 		return mykeys
=20
-	def get_values(self,key):
+	def get_values(self,key, data=3DNone):
+		""" do not use data unless you know what it does."""
+
 		if not key:
 			raise KeyError, "key is not set to a valid value"
=20
-		try:
-			# give buffering a hint of the pretty much maximal cache size we deal w=
ith
-			myf =3D open(self.fullpath+key, "r", 8192)
-		except OSError, oe:
-			# either the file didn't exist, or it was removed under our feet.
-			return None=20
-	=09
+		mydict =3D {}
+		if data =3D=3D None:
+			try:
+				# give buffering a hint of the pretty much maximal cache size we deal =
with
+				myf =3D open(self.fullpath+key, "r", 8192)
+			except OSError:
+				# either the file didn't exist, or it was removed under our feet.
+				raise KeyError("failed reading key")
+
+			# nuke the newlines right off the batt.
+			data =3D myf.read().splitlines()
+			mydict["_mtime_"] =3D os.fstat(myf.fileno()).st_mtime
+			myf.close()
+		else:
+			mydict["_mtime_"] =3D data.pop(-1)
=20
-		# nuke the newlines right off the batt.
-		data =3D myf.read().splitlines()
-		mdict =3D {}
-	=09
 		# rely on exceptions to note differing line counts.
 		try:
-			for x in range(0, len(self.dbkeys)):
-				mdict[self.dbkeys[x]] =3D data[x]
-
-			# do this now, rather then earlier- possible that earlier it might have=
 been wasted
-			# if key count mismatched
-			mdict["_mtime_"] =3D os.fstat(myf.fileno()).st_mtime
+			for x in range(magic_line_count):
+				mydict[self.dbkeys[x]] =3D data[x]
=20
 		except IndexError:
-			myf.close()
 			raise ValueError, "Key count mistmatch"
=20
-		myf.close()
-		return mdict
+		return mydict
 =09
-	def set_values(self,key,val):
+	def set_values(self,key, val, raw=3DFalse):
 		if not key:
 			raise KeyError, "No key provided. key:%s val:%s" % (key,val)
 		if not val:
@@ -86,12 +90,19 @@
=20
 		update_fp =3D self.fullpath + ".update." + str(os.getpid()) + "." + key
 		myf =3D open(update_fp,"w")
-		myf.writelines( [ val[x] +"\n" for x in self.dbkeys] )
+		if not raw:
+			myf.writelines( [ val[x] +"\n" for x in self.dbkeys] )
+			if len(self.dbkeys) !=3D magic_line_count:
+				myf.writelines(["\n"] * len(self.dbkeys) - magic_line_count)
+			mtime =3D val["_mtime_"]
+		else:
+			mtime =3D val.pop(-1)
+			myf.writelines(val)
 		myf.close()
 	=09
 		os.chown(update_fp, self.uid, self.gid)
 		os.chmod(update_fp, 0664)
-		os.utime(update_fp, (-1,long(val["_mtime_"])))
+		os.utime(update_fp, (-1,long(mtime)))
 		os.rename(update_fp, self.fullpath+key)
=20
 	def del_key(self,key):
diff -urN portage-old/pym/portage_db_flat_hash.py portage/pym/portage_db_fl=
at_hash.py
--- portage-old/pym/portage_db_flat_hash.py	1969-12-31 18:00:00.000000000 -=
0600
+++ portage/pym/portage_db_flat_hash.py	2005-08-27 05:27:43.000000000 -0500
@@ -0,0 +1,38 @@
+# Copyright 2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-src/portage/pym/Attic/portage_db_flat.py,v =
1.13.2.6 2005/04/19 07:14:17 ferringb Exp $
+cvs_id_string=3D"$Id: portage_db_flat.py,v 1.13.2.6 2005/04/19 07:14:17 fe=
rringb Exp $"[5:-2]
+
+import portage_db_flat, os
+
+class database(portage_db_flat.database):
+=09
+	def get_values(self, key, data=3DNone):
+		""" do not specify data unless you know what it does"""
+		if not key:
+			raise KeyError("key is not valid")
+	=09
+		if data =3D=3D None:
+			try:
+				myf =3D open(self.fullpath + key, "r")
+			except OSError:
+				raise KeyError("failed pulling key")
+
+			data =3D dict(map(lambda x: x.split("=3D",1), myf.read().splitlines()))
+			data["_mtime_"] =3D os.fstat(myf.fileno()).st_mtime
+			myf.close()
+
+		mydict =3D {}
+		for x in self.dbkeys:
+			mydict[x] =3D data.get(x, "")
+		mydict["_mtime_"] =3D long(data["_mtime_"])
+		return mydict
+	=09
+	def set_values(self, key, values):
+		l =3D []
+		for x in values.keys():
+			if values[x] and x !=3D "_mtime_":
+				l.append("%s=3D%s\n" % (x, values[x]))
+		l.append(values["_mtime_"])
+		portage_db_flat.database.set_values(self, key, l, raw=3DTrue)
+	=09
diff -urN portage-old/pym/portage_db_metadata.py portage/pym/portage_db_met=
adata.py
--- portage-old/pym/portage_db_metadata.py	1969-12-31 18:00:00.000000000 -0=
600
+++ portage/pym/portage_db_metadata.py	2005-08-27 05:27:43.000000000 -0500
@@ -0,0 +1,49 @@
+# Copyright 2004 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-src/portage/pym/Attic/portage_db_flat.py,v =
1.13.2.6 2005/04/19 07:14:17 ferringb Exp $
+cvs_id_string=3D"$Id: portage_db_flat.py,v 1.13.2.6 2005/04/19 07:14:17 fe=
rringb Exp $"[5:-2]
+
+import os, portage_db_flat_hash, portage_db_flat
+
+class database(portage_db_flat_hash.database):
+=09
+	def get_values(self, key):
+		if not key:
+			raise KeyError("key is not valid")
+	=09
+		try:
+			myf =3D open(self.fullpath + key, "r")
+		except OSError:
+			raise KeyError("key is not valid")
+		mtime =3D os.fstat(myf.fileno()).st_mtime
+		data =3D myf.read().splitlines()
+	=09
+		# easy attempt first.
+		if len(data) !=3D portage_db_flat.magic_line_count:
+			d =3D dict(map(lambda x: x.split("=3D",1), data))
+			d["_mtime_"] =3D mtime
+			return portage_db_flat_hash.database.get_values(self, key, d)
+		# this one's interesting.
+		d =3D {}
+
+		for line in data:
+			# yes, meant to iterate over a string.
+			hashed =3D False
+			for idx, c in enumerate(line):
+				if not c.isalpha():
+					if c =3D=3D "=3D" and idx > 0:
+						hashed =3D True
+						d[line[:idx]] =3D line[idx + 1:]
+					elif c =3D=3D "_" or c.isdigit():
+						continue
+					break
+				elif not c.isupper():
+					break
+
+			if not hashed:
+				# non hashed.
+				data.append(mtime)
+				return portage_db_flat.database.get_values(self, key, data=3Ddata)
+
+		d["_mtime_"] =3D mtime
+		return portage_db_flat_hash.database.get_values(self, key, data=3Dd)
--- portage-old/pym/portage_const.py	2005-04-28 23:56:35.000000000 -0500
+++ portage/pym/portage_const.py	2005-08-27 03:59:09.000000000 -0500
@@ -43,6 +43,9 @@
 INCREMENTALS=3D["USE","FEATURES","ACCEPT_KEYWORDS","ACCEPT_LICENSE","CONFI=
G_PROTECT_MASK","CONFIG_PROTECT","PRELINK_PATH","PRELINK_PATH_MASK"]
 STICKIES=3D["KEYWORDS_ACCEPT","USE","CFLAGS","CXXFLAGS","MAKEOPTS","EXTRA_=
ECONF","EXTRA_EINSTALL","EXTRA_EMAKE"]
=20
+# supported EBUILD api versions.
+EAPI =3D 0
+
 # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D
 # END OF CONSTANTS -- END OF CONSTANTS -- END OF CONSTANTS -- END OF CONST=
ANT
 # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D

--csgZZokDzjk698W/--

--HJ7DkX9BXQhna2ov
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQFDEEZFvdBxRoA3VU0RAhfDAJ9zXIvyLLMEB2lYUUm3wAS0W5yvEgCfaHWY
iF6URv2DTt6CvPseS27cDu8=
=1zRL
-----END PGP SIGNATURE-----

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