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

login
register
mail settings
Submitter Hongxu Jia
Date Jan. 8, 2013, 10:23 a.m.
Message ID <b26787f62090d0760758b854627e94de25d6ccca.1357640488.git.hongxu.jia@windriver.com>
Download mbox | patch
Permalink /patch/42299/
State New
Headers show

Comments

Hongxu Jia - Jan. 8, 2013, 10:23 a.m.
The file of apt.conf.sample is kept in 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 is not allowed by "os.path.join".

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.

So remove "/" in ${sysconfdir} to create "apt.conf.sample" if it doesn't
exist, not by the existance of prefix dir.

[YOCTO #3677]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 meta/recipes-devtools/apt/apt-native.inc |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
Richard Purdie - Jan. 8, 2013, 10:47 a.m.
On Tue, 2013-01-08 at 18:23 +0800, Hongxu Jia wrote:
> The file of apt.conf.sample is kept in 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 is not allowed by "os.path.join".
> 
> 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.
> 
> So remove "/" in ${sysconfdir} to create "apt.conf.sample" if it doesn't
> exist, not by the existance of prefix dir.

Use oe.path.join() instead which doesn't have this problem iirc.

Cheers,

Richard

Patch

diff --git a/meta/recipes-devtools/apt/apt-native.inc b/meta/recipes-devtools/apt/apt-native.inc
index ab89f71..ae03f6e 100644
--- a/meta/recipes-devtools/apt/apt-native.inc
+++ b/meta/recipes-devtools/apt/apt-native.inc
@@ -20,11 +20,13 @@  python do_install_config () {
 
     data = d.expand(data)
 
-    outdir = os.path.join(d.getVar('D', True), d.getVar('sysconfdir', True), 'apt')
+    # os.path.join does not allow sysconfdir to be a absolute dir
+    outdir = os.path.join(d.getVar('D', True), d.getVar('sysconfdir', True)[1:], 'apt')
     if not os.path.exists(outdir):
         os.makedirs(outdir)
-        outpath = os.path.join(outdir, 'apt.conf.sample')
 
+    outpath = os.path.join(outdir, 'apt.conf.sample')
+    if not os.path.exists(outpath):
         outfile = file(outpath, 'w')
         outfile.write(data)
         outfile.close()