public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] portage r9828 - in main/branches/2.1.2: bin pym
@ 2008-04-11  3:28 Zac Medico (zmedico)
  0 siblings, 0 replies; only message in thread
From: Zac Medico (zmedico) @ 2008-04-11  3:28 UTC (permalink / raw
  To: gentoo-commits

Author: zmedico
Date: 2008-04-11 03:28:02 +0000 (Fri, 11 Apr 2008)
New Revision: 9828

Modified:
   main/branches/2.1.2/bin/emerge
   main/branches/2.1.2/pym/portage.py
Log:
Copy group mode bits from $PKGDIR when creating subdirectories.
(trunk r9827)


Modified: main/branches/2.1.2/bin/emerge
===================================================================
--- main/branches/2.1.2/bin/emerge	2008-04-11 02:46:52 UTC (rev 9827)
+++ main/branches/2.1.2/bin/emerge	2008-04-11 03:28:02 UTC (rev 9828)
@@ -4960,6 +4960,12 @@
 						bintree = self.trees[myroot]["bintree"]
 						if bintree.populated:
 							bintree.inject(pkg_key)
+						else:
+							# Copy group permissions for new directories that
+							# may have been created.
+							for path in ("All", portage.catsplit(pkg.cpv)[0]):
+								bintree._ensure_dir(
+									os.path.join(bintree.pkgdir, path))
 						if "--buildpkgonly" not in self.myopts:
 							msg = " === (%s of %s) Merging (%s::%s)" % \
 								(mergecount, len(mymergelist), pkg_key, y)

Modified: main/branches/2.1.2/pym/portage.py
===================================================================
--- main/branches/2.1.2/pym/portage.py	2008-04-11 02:46:52 UTC (rev 9827)
+++ main/branches/2.1.2/pym/portage.py	2008-04-11 03:28:02 UTC (rev 9828)
@@ -7835,12 +7835,7 @@
 			self._pkg_paths[mynewcpv] = os.path.join(
 				*new_path.split(os.path.sep)[-2:])
 			if new_path != mytbz2:
-				try:
-					os.makedirs(os.path.dirname(new_path))
-				except OSError, e:
-					if e.errno != errno.EEXIST:
-						raise
-					del e
+				self._ensure_dir(os.path.dirname(new_path))
 				_movefile(tbz2path, new_path, mysettings=self.settings)
 				self._remove_symlink(mycpv)
 				if new_path.split(os.path.sep)[-2] == "All":
@@ -7873,13 +7868,8 @@
 		exist in the location of the symlink will first be removed."""
 		mycat, mypkg = catsplit(cpv)
 		full_path = os.path.join(self.pkgdir, mycat, mypkg + ".tbz2")
+		self._ensure_dir(os.path.dirname(full_path))
 		try:
-			os.makedirs(os.path.dirname(full_path))
-		except OSError, e:
-			if e.errno != errno.EEXIST:
-				raise
-			del e
-		try:
 			os.unlink(full_path)
 		except OSError, e:
 			if e.errno != errno.ENOENT:
@@ -7922,6 +7912,26 @@
 		internal state for future calls to getname()."""
 		self._move_to_all(cpv)
 
+	def _ensure_dir(self, path):
+		"""
+		Create the specified directory. Also, copy gid and group mode
+		bits from self.pkgdir if possible.
+		@param cat_dir: Absolute path of the directory to be created.
+		@type cat_dir: String
+		"""
+		try:
+			pkgdir_st = os.stat(self.pkgdir)
+		except OSError:
+			portage_util.ensure_dirs(path)
+			return
+		pkgdir_gid = pkgdir_st.st_gid
+		pkgdir_grp_mode = 02070 & pkgdir_st.st_mode
+		try:
+			portage_util.ensure_dirs(path, gid=pkgdir_gid, mode=pkgdir_grp_mode, mask=0)
+		except portage_exception.PortageException:
+			if not os.path.isdir(path):
+				raise
+
 	def _move_to_all(self, cpv):
 		"""If the file exists, move it.  Whether or not it exists, update state
 		for future getname() calls."""
@@ -7933,12 +7943,7 @@
 		except OSError, e:
 			mystat = None
 		if mystat and stat.S_ISREG(mystat.st_mode):
-			try:
-				os.makedirs(os.path.join(self.pkgdir, "All"))
-			except OSError, e:
-				if e.errno != errno.EEXIST:
-					raise
-				del e
+			self._ensure_dir(os.path.join(self.pkgdir, "All"))
 			dest_path = os.path.join(self.pkgdir, "All", myfile)
 			_movefile(src_path, dest_path, mysettings=self.settings)
 			self._create_symlink(cpv)
@@ -7952,12 +7957,7 @@
 		myfile = mypkg + ".tbz2"
 		mypath = os.path.join(mycat, myfile)
 		dest_path = os.path.join(self.pkgdir, mypath)
-		try:
-			os.makedirs(os.path.dirname(dest_path))
-		except OSError, e:
-			if e.errno != errno.EEXIST:
-				raise
-			del e
+		self._ensure_dir(os.path.dirname(dest_path))
 		src_path = os.path.join(self.pkgdir, "All", myfile)
 		_movefile(src_path, dest_path, mysettings=self.settings)
 		self._pkg_paths[cpv] = mypath
@@ -8093,6 +8093,7 @@
 
 	def inject(self,cpv):
 		self.dbapi.cpv_inject(cpv)
+		self._ensure_dir(os.path.join(self.pkgdir, "All"))
 		self._create_symlink(cpv)
 
 	def exists_specific(self,cpv):
@@ -8169,10 +8170,7 @@
 				writemsg("Resuming download of this tbz2, but it is possible that it is corrupt.\n",
 					noiselevel=-1)
 		mydest = self.pkgdir+"/All/"
-		try:
-			os.makedirs(mydest, 0775)
-		except (OSError, IOError):
-			pass
+		self._ensure_dir(mydest)
 		from urlparse import urlparse
 		# urljoin doesn't work correctly with unrecognized protocols like sftp
 		url = self.settings["PORTAGE_BINHOST"].rstrip("/") + "/" + tbz2name

-- 
gentoo-commits@lists.gentoo.org mailing list



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-04-11  3:28 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-11  3:28 [gentoo-commits] portage r9828 - in main/branches/2.1.2: bin pym Zac Medico (zmedico)

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