package.bbclass: copy dotfiles in root D to PKGD
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.
--- classes/package.bbclass | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-)
classes/package.bbclass +5 -5
@@ -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
Quoted 24 lines · Michael Smith
The previous
system("cp %s/* ...")missed dotfiles/dirs at the top-level.Signed-off-by Michael Smith <[email protected]>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@@ -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
-1python populate_packages () { --1.7.0.4
_______________________________________________
Openembedded-devel mailing list [email protected]
http://lists.linuxtogo.org/cgi-bin/mailman/listinfo/openembedded-devel
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.Signed-off-by Michael Smith <[email protected]>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@@ -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
-1python 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
Quoted 7 lines · Michael Smith
The previous
system("cp %s/* ...")missed dotfiles/dirs at the top-level.Signed-off-by Michael Smith <[email protected]>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@@ -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]
Quoted 6 lines · Frans Meulenbroeks
Signed-off-by Frans Meulenbroeks <[email protected]>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
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
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
Hm,
the overall question here is, why the class is still using os.system instead of subprocess.
Bye Henning
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
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.