Skip to contentSkip to conversation

base.bbclass: Fix oe_unpack_file to unpack files to match new bitbake bb.decodeurl()

PATCH In review Khem Raj 3 participants 3 messages Jul 4, 2010 – Jul 5, 2010

lore
Share & tools
lore

Khem Raj

author
#0 lore raw

PATCH v2 1/1 base.bbclass: Fix oe_unpack_file to unpack files to match new bitbake bb.decodeurl()

* This patch now uses the path which essentially is the path and filename relative to recipe dir. It will create the directories as expected. Suppose if the is says file://pam.d/login in the SRC_URI then it will be copied to $WORKDIR/pam.d/login as it was happening before the fix to decodeurl in bitbake.

* Do not copy the .patch and .diff files into $WORKDIR they are already symlinked in patches/ dir which will be used by quilt.

I have done native-sdk-image build from scratch for arm/x86 using bitbake master and this patch on OE without any problem.

OK for .dev ?

Thanks

-Khem

---
 classes/base.bbclass |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)
classes/base.bbclass +9 -11
index 3995ac8..2da0b7a 100644
@@ -177,6 +177,7 @@ def oe_unpack_file(file, data, url = None):
 	else:
 		efile = file
 	cmd = None
+	(type, host, path, user, pswd, parm) = bb.decodeurl(url)
 	if file.endswith('.tar'):
 		cmd = 'tar x --no-same-owner -f %s' % file
 	elif file.endswith('.tgz') or file.endswith('.tar.gz') or file.endswith('.tar.Z'):
@@ -193,10 +194,12 @@ def oe_unpack_file(file, data, url = None):
 		cmd = 'xz -dc %s > %s' % (file, efile)
 	elif file.endswith('.zip') or file.endswith('.jar'):
 		cmd = 'unzip -q -o'
-		(type, host, path, user, pswd, parm) = bb.decodeurl(url)
 		if 'dos' in parm:
 			cmd = '%s -a' % cmd
 		cmd = "%s '%s'" % (cmd, file)
+	elif (type == "file" and file.endswith('.patch') or file.endswith('.diff')) and parm.get('apply') != 'no':
+	# patch and diff files are special and need not be copied to workdir
+		cmd = ""
 	elif os.path.isdir(file):
 		destdir = "."
 		filespath = bb.data.getVar("FILESPATH", data, 1).split(":")
@@ -212,28 +215,23 @@ def oe_unpack_file(file, data, url = None):
 
 		cmd = 'cp -pPR %s %s/%s/' % (file, os.getcwd(), destdir)
 	else:
-		(type, host, path, user, pswd, parm) = bb.decodeurl(url)
 		if not 'patch' in parm and parm.get('apply') != 'yes':
 			# The "destdir" handling was specifically done for FILESPATH
 			# items.  So, only do so for file:// entries.
 			if type == "file":
-				destdir = bb.decodeurl(url)[1] or "."
+				dest = os.path.dirname(path) or "."
 			else:
-				destdir = "."
-			bb.mkdirhier("%s/%s" % (os.getcwd(), destdir))
-			cmd = 'cp %s %s/%s/' % (file, os.getcwd(), destdir)
-
+				dest = "."
+			bb.mkdirhier("%s" % os.path.join(os.getcwd(),dest))
+			cmd = 'cp %s %s' % (file, os.path.join(os.getcwd(), dest))
 	if not cmd:
 		return True
-
-	dest = os.path.join(os.getcwd(), os.path.basename(file))
+	dest = os.path.join(os.getcwd(), path)
 	if os.path.exists(dest):
 		if os.path.samefile(file, dest):
 			return True
-
 	# Change to subdir before executing command
 	save_cwd = os.getcwd();
-	parm = bb.decodeurl(url)[5]
 	if 'subdir' in parm:
 		newdir = ("%s/%s" % (os.getcwd(), parm['subdir']))
 		bb.mkdirhier(newdir)
Signature · 1 line
1.7.1
Acked-by on v2 1/1
#1 lore raw

В сообщении от Воскресенье 04 июля 2010 21:34:00 автор Khem Raj написал:

Quoted 16 lines

* This patch now uses the path which essentially is the path and filename relative to recipe dir. It will create the directories as expected. Suppose if the is says file://pam.d/login in the SRC_URI then it will be copied to $WORKDIR/pam.d/login as it was happening before the fix to decodeurl in bitbake.

* Do not copy the .patch and .diff files into $WORKDIR they are already symlinked in patches/ dir which will be used by quilt.

I have done native-sdk-image build from scratch for arm/x86 using bitbake
master and this patch on OE without any problem.

OK for .dev ?

Quoted 9 lines

Thanks

-Khem

---
 classes/base.bbclass |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)
Acked-by
#2 lore raw
Quoted 21 lines · Roman I Khimov

В сообщении от Воскресенье 04 июля 2010 21:34:00 автор Khem Raj написал:

Quoted 20 lines

* This patch now uses the path which essentially is the path and filename relative to recipe dir. It will create the directories as expected. Suppose if the is says file://pam.d/login in the SRC_URI then it will be copied to $WORKDIR/pam.d/login as it was happening before the fix to decodeurl in bitbake.

* Do not copy the .patch and .diff files into $WORKDIR they are already symlinked in patches/ dir which will be used by quilt.

I have done native-sdk-image build from scratch for arm/x86 using bitbake
master and this patch on OE without any problem.

OK for .dev ?

Thanks

-Khem

Quoted 8 lines
Quoted 5 lines
---
 classes/base.bbclass |   20 +++++++++-----------
 1 files changed, 9 insertions(+), 11 deletions(-)

Seems reasonable.

Signature · 5 lines
Christopher Larson
clarson at kergoth dot com
Founder - BitBake, OpenEmbedded, OpenZaurus
Maintainer - Tslib
Senior Software Engineer, Mentor Graphics