Skip to contentSkip to conversation

package classes: count dotfiles as non-empty

PATCH In review Michael Smith 2 participants 4 messages Jul 11, 2009 – Jul 13, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 package classes: count dotfiles as non-empty

Allow a package to be built that contains only dotfiles or dot directories under '/'.

---
 classes/package.bbclass     |    2 +-
 classes/package_deb.bbclass |    2 +-
 classes/package_ipk.bbclass |    2 +-
 classes/package_tar.bbclass |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
classes/package.bbclass +1 -1
index 3360dcb..f6bd7c5 100644
@@ -539,7 +539,7 @@ python emit_pkgdata() {
 			allow_empty = bb.data.getVar('ALLOW_EMPTY', d, 1)
 		root = "%s/install/%s" % (workdir, pkg)
 		os.chdir(root)
-		g = glob('*')
+		g = glob('*') + glob('.[!.]*')
 		if g or allow_empty == "1":
 			packagedfile = pkgdatadir + '/runtime/%s.packaged' % pkg
 			file(packagedfile, 'w').close()
classes/package_deb.bbclass +1 -1
index 5127d32..e5339a9 100644
@@ -130,7 +130,7 @@ python do_package_deb () {
 
         os.chdir(root)
         from glob import glob
-        g = glob('*')
+        g = glob('*') + glob('.[!.]*')
         try:
             del g[g.index('DEBIAN')]
             del g[g.index('./DEBIAN')]
classes/package_ipk.bbclass +1 -1
index 1f1b5c9..e3a7522 100644
@@ -186,7 +186,7 @@ python do_package_ipk () {
 		bb.mkdirhier(pkgoutdir)
 		os.chdir(root)
 		from glob import glob
-		g = glob('*')
+		g = glob('*') + glob('.[!.]*')
 		try:
 			del g[g.index('CONTROL')]
 			del g[g.index('./CONTROL')]
classes/package_tar.bbclass +1 -1
index 76f48ca..cb70a5f 100644
@@ -84,7 +84,7 @@ python do_package_tar () {
 		tarfn = bb.data.getVar('PKGFN', localdata, 1)
 		os.chdir(root)
 		from glob import glob
-		if not glob('*'):
+		if not glob('*') + glob('.[!.]*'):
 			bb.note("Not creating empty archive for %s-%s" % (pkg, bb.data.expand('${PV}-${PR}${DISTRO_PR}', d, True)))
 			continue
 		ret = os.system("tar -czf %s %s" % (tarfn, '.'))
Signature · 1 line
1.6.3
#1 lore raw

PATCH 2/2 package.bbclass: preserve modes for non-empty dirs

Extend commit b1cbbae1 by setting the mode for all dirs, not just empty dirs.

---
 classes/package.bbclass |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
classes/package.bbclass +5 -5
index f6bd7c5..fc12932 100644
@@ -377,10 +377,14 @@ python populate_packages () {
 				file = '.' + file
 			if not os.path.islink(file):
 				if os.path.isdir(file):
+					bb.mkdirhier(os.path.join(root,file))
+					os.chmod(os.path.join(root,file),
+							os.stat(file).st_mode)
 					newfiles =  [ os.path.join(file,x) for x in os.listdir(file) ]
 					if newfiles:
 						files += newfiles
-						continue
+					continue
+
 			globbed = glob.glob(file)
 			if globbed:
 				if [ file ] != globbed:
@@ -395,10 +399,6 @@ python populate_packages () {
 			if file in seen:
 				continue
 			seen.append(file)
-			if os.path.isdir(file) and not os.path.islink(file):
-				bb.mkdirhier(os.path.join(root,file))
-				os.chmod(os.path.join(root,file), os.stat(file).st_mode)
-				continue
 			fpath = os.path.join(root,file)
 			dpath = os.path.dirname(fpath)
 			bb.mkdirhier(dpath)
Signature · 1 line
1.6.3
#2 lore raw
In reply to Michael Smith
Quoted 10 lines · Michael Smith

Allow a package to be built that contains only dotfiles or dot directories under '/'.

---
 classes/package.bbclass     |    2 +-
 classes/package_deb.bbclass |    2 +-
 classes/package_ipk.bbclass |    2 +-
 classes/package_tar.bbclass |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

Thanks, I checked this in. It makes me wonder whether there is some way that this logic could be abstracted out into package.bbclass rather than maintained separately for each format, but I guess that's a problem for another day.

p.

#3 lore raw
Quoted 1 line · Phil Blundell

Thanks, I checked this in.

Thanks. Please ignore the second patch -- it causes lots of empty .debug directories to appear in non-debug packages. It'd be nice if populate_packages() could preserve the permissions of the directories above the files it copies, but for now it's easy enough to work around in a populate_packages_append for the rare cases where it matters.

Mike