Skip to contentSkip to conversation

package.bbclass: copy dotfiles in root D to PKGD

PATCH In review Michael Smith 5 participants 10 messages Oct 18, 2010 – Oct 19, 2010 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 package.bbclass: copy dotfiles in root D to PKGD

The previous system("cp %s/* ...") missed dotfiles/dirs at the top-level.

Cc Enrico Scholz <[email protected]>
Cc Graham Gower <[email protected]>
Cc Frans Meulenbroeks <[email protected]>
---
 classes/package.bbclass |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
classes/package.bbclass +5 -5
index e2a61bf..2769595 100644
@@ -356,15 +356,15 @@ python package_do_split_locales() {
 }
 
 python perform_packagecopy () {
-	dest = bb.data.getVar('D', d, True)
-	dvar = bb.data.getVar('PKGD', d, True)
+	installdest = bb.data.getVar('D', d, True)
+	pkgcopy = bb.data.getVar('PKGD', d, True)
 
-	bb.mkdirhier(dvar)
+	bb.mkdirhier(pkgcopy)
 
 	# Start by package population by taking a copy of the installed 
 	# files to operate on
-	os.system('rm -rf %s/*' % (dvar))
-	os.system('cp -pPR %s/* %s/' % (dest, dvar))
+	os.system('rm -rf %s/*' % (pkgcopy))
+	os.system('cp -pPR %s/. %s/' % (installdest, pkgcopy))
 }
 
 python populate_packages () {
Signature · 1 line
1.7.0.4
#1 lore raw
Quoted 24 lines · Michael Smith

The previous system("cp %s/* ...") missed dotfiles/dirs at the top-level.

Cc Enrico Scholz <[email protected]>
Cc Graham Gower <[email protected]>
Cc Frans Meulenbroeks <[email protected]>

---
 classes/package.bbclass |   10 +++++-----

 1 files changed, 5 insertions(+), 5 deletions(-)
classes/package.bbclass +2 -2
index e2a61bf..2769595 100644
@@ -356,15 +356,15 @@ python package_do_split_locales() {
  }
 
  python perform_packagecopy () {
-       dest = bb.data.getVar('D', d, True)
-       dvar = bb.data.getVar('PKGD', d, True)
+       installdest = bb.data.getVar('D', d, True)
+       pkgcopy = bb.data.getVar('PKGD', d, True)
 

classes/package.bbclass python package_do_split_locales() { · line 368

Quoted 10 lines
classes/package.bbclass +3 -3
-       bb.mkdirhier(dvar)
+       bb.mkdirhier(pkgcopy)
 
        # Start by package population by taking a copy of the installed
        # files to operate on
-       os.system('rm -rf %s/*' % (dvar))
-       os.system('cp -pPR %s/* %s/' % (dest, dvar))
+       os.system('rm -rf %s/*' % (pkgcopy))
+       os.system('cp -pPR %s/. %s/' % (installdest, pkgcopy))
  }

will it also try to copy . and .. ?

Quoted 11 lines
classes/package.bbclass +0 -1
  python populate_packages () {
--

1.7.0.4

_______________________________________________
Openembedded-devel mailing list [email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

#2 lore raw

2010/10/18 Khem Raj <[email protected]>:

Quoted 28 lines · Michael Smith
Quoted 27 lines

The previous system("cp %s/* ...") missed dotfiles/dirs at the top-level.

Cc Enrico Scholz <[email protected]>
Cc Graham Gower <[email protected]>
Cc Frans Meulenbroeks <[email protected]>

---
 classes/package.bbclass |   10 +++++-----

 1 files changed, 5 insertions(+), 5 deletions(-)
classes/package.bbclass +3 -3
index e2a61bf..2769595 100644
@@ -356,15 +356,15 @@ python package_do_split_locales() {
  }
 
  python perform_packagecopy () {
-       dest = bb.data.getVar('D', d, True)
-       dvar = bb.data.getVar('PKGD', d, True)
+       installdest = bb.data.getVar('D', d, True)
+       pkgcopy = bb.data.getVar('PKGD', d, True)
 
-       bb.mkdirhier(dvar)
+       bb.mkdirhier(pkgcopy)
 
Quoted 9 lines

classes/package.bbclass python package_do_split_locales() { · line 368

Quoted 7 lines
classes/package.bbclass +2 -2
        # Start by package population by taking a copy of the installed
        # files to operate on
-       os.system('rm -rf %s/*' % (dvar))
-       os.system('cp -pPR %s/* %s/' % (dest, dvar))
+       os.system('rm -rf %s/*' % (pkgcopy))
+       os.system('cp -pPR %s/. %s/' % (installdest, pkgcopy))
  }

will it also try to copy . and .. ?

No (tested that).

Frans.

Quoted 18 lines
Quoted 7 lines
classes/package.bbclass +0 -1
  python populate_packages () {
--

1.7.0.4

Quoted 5 lines

_______________________________________________
Openembedded-devel mailing list [email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

_______________________________________________
Openembedded-devel mailing list
[email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

Acked-by on v3 1/1
#3 lore raw
In reply to Michael Smith
Quoted 7 lines · Michael Smith

The previous system("cp %s/* ...") missed dotfiles/dirs at the top-level.

Cc Enrico Scholz <[email protected]>
Cc Graham Gower <[email protected]>
Cc Frans Meulenbroeks <[email protected]>
Quoted 38 lines

---
 classes/package.bbclass |   10 +++++-----

 1 files changed, 5 insertions(+), 5 deletions(-)
classes/package.bbclass +5 -6
index e2a61bf..2769595 100644
@@ -356,15 +356,15 @@ python package_do_split_locales() {
  }
 
  python perform_packagecopy () {
-       dest = bb.data.getVar('D', d, True)
-       dvar = bb.data.getVar('PKGD', d, True)
+       installdest = bb.data.getVar('D', d, True)
+       pkgcopy = bb.data.getVar('PKGD', d, True)
 
-       bb.mkdirhier(dvar)
+       bb.mkdirhier(pkgcopy)
 
        # Start by package population by taking a copy of the installed
        # files to operate on
-       os.system('rm -rf %s/*' % (dvar))
-       os.system('cp -pPR %s/* %s/' % (dest, dvar))
+       os.system('rm -rf %s/*' % (pkgcopy))
+       os.system('cp -pPR %s/. %s/' % (installdest, pkgcopy))
  }
 
  python populate_packages () {
--

1.7.0.4

_______________________________________________
Openembedded-devel mailing list [email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw
Quoted 6 lines · Frans Meulenbroeks

but with a minor improvement suggestion.
What aboout elimiating one os.system call by combining the two into one:

os.system('rm -rf %s/*;cp -pPR %s/. %s/' % (pkgcopy, installdest, pkgcopy))

Hi Frans,

Thanks for the SOB. I like it better as two separate lines. I would have preferred shutil.rmtree() if shutil.copytree() worked, actually - but since it doesn't, no point using shutil for one line and not the other.

Mike

#6 lore raw
In reply to Michael Smith

classes/package.bbclass python package_do_split_locales() { · line 366

Quoted 1 line · Michael Smith
classes/package.bbclass +1 -0
+	os.system('rm -rf %s/*' % (pkgcopy))

Can be written as

os.system('rm -rf %s' % (pkgcopy))

Every SUSv3 compliant 'cp' will create the 'pkgcopy' directory.

classes/package.bbclass python package_do_split_locales() { · line 367

Quoted 1 line
classes/package.bbclass +1 -0
+	os.system('cp -pPR %s/. %s/' % (installdest, pkgcopy))

Enrico

#7 lore raw

2010/10/19 Enrico Scholz <[email protected]>:

Quoted 13 lines
Quoted 1 line · Michael Smith

+     os.system('rm -rf %s/*' % (pkgcopy))

Can be written as

 os.system('rm -rf %s' % (pkgcopy))

Every SUSv3 compliant 'cp' will create the 'pkgcopy' directory.

Quoted 1 line

+     os.system('cp -pPR %s/. %s/' % (installdest, pkgcopy))

No this is not good. The rm command you give will also remove the dir. The cp command will copy %s/.
There is a subtle difference with %s (although %s and %s/. refer to the same path)
If you want to use %s instead of %s/* you also need to change the %s/. into %s

Thinking of it doing both changes is better as the effect of os.system('cp -pPR %s/. %s/' % (installdest, pkgcopy)) is different depending on whether pkgcopy already exist or not, while in the new case it is not.
I can submit a patch if needed.

See also this log on hte behaviour of cp

frans@frans-desktop:/tmp$ mkdir tst
frans@frans-desktop:/tmp$ mkdir dest
frans@frans-desktop:/tmp$ date >tst/f
frans@frans-desktop:/tmp$ cp -pPR tst/. dest
frans@frans-desktop:/tmp$ ls -l dest
total 4
-rw-r--r-- 1 frans frans 30 2010-10-19 15:20 f
frans@frans-desktop:/tmp$ rm dest/*
frans@frans-desktop:/tmp$ cp -pPR tst dest
frans@frans-desktop:/tmp$ ls dest
tst
frans@frans-desktop:/tmp$ rm -rf dest
frans@frans-desktop:/tmp$ cp -pPR tst dest
frans@frans-desktop:/tmp$ ls dest
f
frans@frans-desktop:/tmp$

Enjoy, Frans

#8 lore raw

Hm,

the overall question here is, why the class is still using os.system instead of subprocess.

Bye Henning

#9 lore raw
In reply to Frans Meulenbroeks
Quoted 10 lines · Frans Meulenbroeks
Quoted 8 lines
Quoted 1 line

+     os.system('rm -rf %s/*' % (pkgcopy))

Can be written as

 os.system('rm -rf %s' % (pkgcopy))
...

Quoted 1 line

+     os.system('cp -pPR %s/. %s/' % (installdest, pkgcopy))

No this is not good. The rm command you give will also remove the dir.

Why is this bad? The dir is recreated by the 'cp'.

Quoted 1 line

The cp command will copy %s/.

Only the final permissions of <dstdir> may differ between

rm -rf <dstdir>
cp -pPR <srcdir>/. <dstdir>/

and

rm -rf <dstdir>
mkdir <dstdir>
cp -pPR <srcdir>/. <dstdir>/

In first case, <dstdir> gets permissions of <srcdir>. In the second it keeps the permissions from <dstdir>.

Else, content (both the files and their attributes) of <dstdir> will be the same for both operations.

Enrico

#10 lore raw

2010/10/19 Enrico Scholz <[email protected]>:

Quoted 30 lines
Quoted 10 lines · Frans Meulenbroeks
Quoted 8 lines
Quoted 1 line

+     os.system('rm -rf %s/*' % (pkgcopy))

Can be written as

 os.system('rm -rf %s' % (pkgcopy))
...

Quoted 1 line

+     os.system('cp -pPR %s/. %s/' % (installdest, pkgcopy))

No this is not good. The rm command you give will also remove the dir.

Why is this bad?  The dir is recreated by the 'cp'.

Quoted 1 line

The cp command will copy %s/.

Only the final permissions of <dstdir> may differ between

 rm -rf <dstdir>
 cp -pPR <srcdir>/. <dstdir>/

and

 rm -rf <dstdir>
 mkdir <dstdir>
 cp -pPR <srcdir>/. <dstdir>/

Quoted 5 lines

In first case, <dstdir> gets permissions of <srcdir>. In the second it keeps the permissions from <dstdir>.

Else, content (both the files and their attributes) of <dstdir> will be the same for both operations.

Yes, you're right. I accidenlty dropped off the / of the dstdir when I tested this earlier.
Sorry for the noise.
Not sure if there is a gain though.

Frans.