Patchwork [1/1] apt-native: fix the creation of apt.conf.sample

login
register
mail settings
Submitter Hongxu Jia
Date Jan. 10, 2013, 7:58 a.m.
Message ID <afd12099abb637398c7af294282cb2131f0bc2ee.1357801217.git.hongxu.jia@windriver.com>
Download mbox | patch
Permalink /patch/42427/
State New
Headers show

Comments

Hongxu Jia - Jan. 10, 2013, 7:58 a.m.
1.The file of "apt.conf.sample" is in the outdir, and outdir is assigned
by "os.path.join" with the params of ${D}, ${sysconfdir} and "apt". But
${sysconfdir} is an absolute dir and that let ${D} be discarded.

The following is the help on function os.path.join(a, *p):
     Join two or more pathname components, inserting '/' as needed.
     If any component is an absolute path, all previous path components
     will be discarded.
Use oe.path.join instead which don't have this problem.

2. Create apt.conf.sample if it doesn't exist.

[YOCTO #3677]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/recipes-devtools/apt/apt-native.inc |    7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Patch

diff --git a/meta/recipes-devtools/apt/apt-native.inc b/meta/recipes-devtools/apt/apt-native.inc
index ab89f71..c7e7e42 100644
--- a/meta/recipes-devtools/apt/apt-native.inc
+++ b/meta/recipes-devtools/apt/apt-native.inc
@@ -14,17 +14,18 @@  python do_install () {
 
 python do_install_config () {
     indir = os.path.dirname(d.getVar('FILE',1))
-    infile = file(os.path.join(indir, 'files', 'apt.conf'), 'r')
+    infile = file(oe.path.join(indir, 'files', 'apt.conf'), 'r')
     data = infile.read()
     infile.close()
 
     data = d.expand(data)
 
-    outdir = os.path.join(d.getVar('D', True), d.getVar('sysconfdir', True), 'apt')
+    outdir = oe.path.join(d.getVar('D', True), d.getVar('sysconfdir', True), 'apt')
     if not os.path.exists(outdir):
         os.makedirs(outdir)
-        outpath = os.path.join(outdir, 'apt.conf.sample')
 
+    outpath = oe.path.join(outdir, 'apt.conf.sample')
+    if not os.path.exists(outpath):
         outfile = file(outpath, 'w')
         outfile.write(data)
         outfile.close()