Skip to contentSkip to conversation

Add function to package source codes tree to source rpm and tar packages

PATCH In review Xiaofeng Yan 3 participants 8 messages Jan 8, 2012 – Jan 13, 2012

lore
Share & tools
lore
#0 lore raw

cover Add function to package source codes tree to source rpm and tar packages

From: Xiaofeng Yan <[email protected]>

Add file "tar_archive.bbclass" and modify file "package_rpm.bbclass" for packaging source codes tree to source rpm and tar packages. After adding srpm function in file "package_rpm.bbclass", user can get source rpm packages beside rpm package. User also get tar packages of source codes tree according to the requirement from bug 1655. The final result is as follow:
Take qemux86 for an example:
Get source rpm pakcages
1 Inherit tar_archive.bbclass in package_rpm.bbclass.
2 Select the type of packaging source code tree in conf/local.conf(ARCHIVE_TYPE ?= "SRPM")
3 Run the following command

  $ bitbake core-image-sato -c copysources
4 Get source rpm packages:
  $ tree build/tmp/deploy/sources
  build/tmp/deploy/sources/
  └── qemux86
    ├── all-poky-linux
    │   ├── encodings-1.0.4-r2.1.src.rpm
        ......
    ├── i586-poky-linux
    │   ├── acl-2.2.51-r2.src.rpm
        ......
    └── qemux86-poky-linux
        ├── base-files-3.0.14-r70.src.rpm
        ......
Get tar packages:
1 Inherit tar_archive.bbclass in an suitable position (for example, package_rpm.bbclass).
2 Select the type of packaging source code tree in conf/local.conf(ARCHIVE_TYPE ?= "TARGZ")
3 Run the following command 
  $ bitbake core-image-sato -c copysources
4 Get tar packages: 
  $ tree build/tmp/deploy/sources
  buildx86/tmp/deploy/sources
  └── qemux86
    ├── all-poky-linux
    │   ├── encodings-1_1.0.4-r2.1
    │   │   ├── encodings-1_1.0.4-r2.1.tar.gz
    │   │   └── log.tar.gz
            ......
    ├── i586-poky-linux
    │   ├── acl-2.2.51-r2
    │   │   ├── acl-2.2.51-r2.tar.gz
            └── log.tar.gz
            ......
    └── qemux86-poky-linux
        ├── core-image-sato-1.0-r0
        ├── libzypp-0.0-git1+15b6c52260bbc52b3d8e585e271b67e10cc7c433-r17
        │   ├── libzypp-0.0-git1+15b6c52260bbc52b3d8e585e271b67e10cc7c433-r17.tar.gz
        │   └── log.tar.gz
            ......

if inheriting tar_archive.bbclass in one bb file, then only package source codes tree of this file. Take zlib for an example:
Get source rpm pakcage of zlib
1 Inherit tar_archive.bbclass in zlib_1.2.5.bb.
2 Select the type of packaging source code tree in conf/local.conf(ARCHIVE_TYPE ?= "SRPM") 3 Run the following command

  $ bitbake zlib
4 Get source rpm package:
  $ ls build/tmp/work/i586-poky-linux/zlib-1.2.5-r3/deploy-srpm/i586/
    zlib-1.2.5-r3.src.rpm

Get tar package of zlib
1 Inherit tar_archive.bbclass in zlib_1.2.5.bb.
2 Select the type of packaging source code tree in conf/local.conf(ARCHIVE_TYPE ?= "TARGZ") 3 Run the following command

  $ bitbake zlib 
4 Get tar package:
  $ ls build/tmp/work/i586-poky-linux/zlib-1.2.5-r3/
    zlib-1.2.5-r3.tar.gz log.tar.gz ......

Pull URL: git://git.pokylinux.org/poky-contrib.git
Branch: xiaofeng/1655
Browse: http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=xiaofeng/1655

Thanks,
Xiaofeng Yan <[email protected]>
---

Xiaofeng Yan (2):
package_rpm.bbclass: add srpm function in spec file tar_archive.bbclass: Package source codes and log files to tar
package

 meta/classes/package_rpm.bbclass |   65 ++++++++++--
 meta/classes/tar_archive.bbclass |  216 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 271 insertions(+), 10 deletions(-)
 create mode 100644 meta/classes/tar_archive.bbclass
Signature · 1 line
1.7.7
#1 lore raw

PATCH 1/2 package_rpm.bbclass: add srpm function in spec file

From: Xiaofeng Yan <[email protected]>

For packaging source codes to source rpm package, adding Sources,\
Patches and prep stage in spec file.
"Sources" include source codes (type of tar.gz) and \
log files including log.do_patch and log.do_configure (type of tar.gz) "Patches" include all patches called in bb file.
"prep" is for user viewing the result in the stage of doing patch and configuration for example:
User can use the following command to run the stage of prep.
$rpmbuild -bp package.spec
<show the result of log.do_patch and log.configure>

[YOCTO #1655]

---
 meta/classes/package_rpm.bbclass |   65 ++++++++++++++++++++++++++++++++------
 1 files changed, 55 insertions(+), 10 deletions(-)
meta/classes/package_rpm.bbclass +55 -10
index d03dc3f..3e0ca15 100644
@@ -6,6 +6,7 @@ RPM="rpm"
 RPMBUILD="rpmbuild"
 
 PKGWRITEDIRRPM = "${WORKDIR}/deploy-rpms"
+PKGWRITEDIRSRPM = "${WORKDIR}/deploy-srpm"
 
 python package_rpm_fn () {
 	d.setVar('PKGFN', d.getVar('PKG'))
@@ -422,6 +423,19 @@ python write_specfile () {
 	import textwrap
 	import oe.packagedata
 
+	def add_prep(spec_files_bottom):
+		bb.build.exec_func('not_srpm', d)
+		if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+			spec_files_bottom.append('%%prep -n %s' % d.getVar('PN', True) )
+			spec_files_bottom.append('%s' % "set +x")
+			spec_files_bottom.append('%s' % "cd $RPM_SOURCE_BUILD")
+			spec_files_bottom.append('%s' % "tar zxvf $RPM_SOURCE_DIR/log.tar.gz")
+			spec_files_bottom.append('%s' % "echo \"============ do patch ==============\"")
+			spec_files_bottom.append('%s' % "cat log.do_patch*")
+			spec_files_bottom.append('%s' % "echo \"============ do configure ==========\"")
+			spec_files_bottom.append('%s' % "cat log.do_configure*")
+			spec_files_bottom.append('')
+
 	# We need a simple way to remove the MLPREFIX from the package name,
 	# and dependency information...
 	def strip_multilib(name, d):
@@ -533,6 +547,13 @@ python write_specfile () {
 	srcmaintainer  = d.getVar('MAINTAINER', True)
 	srchomepage    = d.getVar('HOMEPAGE', True)
 	srcdescription = d.getVar('DESCRIPTION', True) or "."
+	
+	bb.build.exec_func('not_srpm', d)
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+		tpkg_name = d.getVar('PF',True)
+		srctargz  = tpkg_name + ".tar.gz"
+		logtargz = "log.tar.gz"
+
 
 	srcdepends     = strip_multilib(d.getVar('DEPENDS', True), d)
 	srcrdepends    = []
@@ -557,6 +578,11 @@ python write_specfile () {
 	spec_files_top = []
 	spec_files_bottom = []
 
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+		srcpatches = []	
+		bb.build.exec_func('get_patches', d)
+		srcpatches = d.getVar('PLIST',True)
+	
 	for pkg in packages.split():
 		localdata = bb.data.createCopy(d)
 
@@ -637,7 +663,7 @@ python write_specfile () {
 				else:
 					bb.note("Creating EMPTY RPM Package for %s" % splitname)
 				spec_files_top.append('')
-
+				
 			bb.utils.unlockfile(lf)
 			continue
 
@@ -714,7 +740,7 @@ python write_specfile () {
 			spec_scriptlets_bottom.append('# %s - %s' % (splitname, script))
 			spec_scriptlets_bottom.append(scriptvar)
 			spec_scriptlets_bottom.append('')
-
+		
 		# Now process files
 		file_list = []
 		walk_files(root, file_list, conffiles)
@@ -732,7 +758,8 @@ python write_specfile () {
 
 		del localdata
 		bb.utils.unlockfile(lf)
-
+	
+	add_prep(spec_files_bottom)
 	spec_preamble_top.append('Summary: %s' % srcsummary)
 	spec_preamble_top.append('Name: %s' % srcname)
 	spec_preamble_top.append('Version: %s' % srcversion)
@@ -743,6 +770,11 @@ python write_specfile () {
 	spec_preamble_top.append('Group: %s' % srcsection)
 	spec_preamble_top.append('Packager: %s' % srcmaintainer)
 	spec_preamble_top.append('URL: %s' % srchomepage)
+	
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+		spec_preamble_top.append('Source: %s' % srctargz)
+		spec_preamble_top.append('Source1: %s' % logtargz)
+
 
 	# Replaces == Obsoletes && Provides
 	if srcrreplaces and srcrreplaces.strip() != "":
@@ -764,6 +796,11 @@ python write_specfile () {
 	print_deps(srcrsuggests, 	"Recommends", spec_preamble_top, d)
 	print_deps(srcrprovides, 	"Provides", spec_preamble_top, d)
 	print_deps(srcrobsoletes, 	"Obsoletes", spec_preamble_top, d)
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+		numid = 1
+		for patch in srcpatches:
+			print_deps(patch, "Patch" + str(numid), spec_preamble_top, d)
+			numid += 1
 
 	# conflicts can not be in a provide!  We will need to filter it.
 	if srcrconflicts:
@@ -817,12 +854,6 @@ python write_specfile () {
 	except OSError:
 		raise bb.build.FuncFailed("unable to open spec file for writing.")
 
-	# RPMSPEC_PREAMBLE is a way to add arbitrary text to the top
-	# of the generated spec file
-	external_preamble = d.getVar("RPMSPEC_PREAMBLE", True)
-	if external_preamble:
-		specfile.write(external_preamble + "\n")
-
 	for line in spec_preamble_top:
 		specfile.write(line + "\n")
 
@@ -947,9 +978,14 @@ python do_package_rpm () {
 		d.setVar('PACKAGE_ARCH_EXTEND', package_arch)
 	pkgwritedir = bb.data.expand('${PKGWRITEDIRRPM}/${PACKAGE_ARCH_EXTEND}', d)
 	pkgarch = bb.data.expand('${PACKAGE_ARCH_EXTEND}${TARGET_VENDOR}-${TARGET_OS}', d)
-	magicfile = bb.data.expand('${STAGING_DIR_NATIVE}${datadir_native}/misc/magic.mgc', d)
+	magicfile = bb.data.expand('${STAGING_DIR_NATIVE}/usr/share/misc/magic.mgc', d)
 	bb.mkdirhier(pkgwritedir)
 	os.chmod(pkgwritedir, 0755)
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True):
+		pkgwritesrpmdir = bb.data.expand('${PKGWRITEDIRSRPM}/${PACKAGE_ARCH_EXTEND}', d)
+		bb.mkdirhier(pkgwritesrpmdir)
+		os.chmod(pkgwritesrpmdir, 0755)
+	
 
 	cmd = rpmbuild
 	cmd = cmd + " --nodeps --short-circuit --target " + pkgarch + " --buildroot " + pkgd
@@ -962,8 +998,17 @@ python do_package_rpm () {
 	cmd = cmd + " --define 'debug_package %{nil}'"
 	cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'"
 	cmd = cmd + " --define '_tmppath " + workdir + "'"
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+		cmdsrpm = cmd + " --define '_sourcedir " + workdir + "' --define '_srcrpmdir " + pkgwritesrpmdir + "'"
+		cmdsrpm = cmdsrpm + " -bs " + outspecfile
 	cmd = cmd + " -bb " + outspecfile
 
+	# Build the source rpm package !
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+		d.setVar('SBUILDSPEC', cmdsrpm + "\n")
+		d.setVarFlag('SBUILDSPEC', 'func', '1')
+		bb.build.exec_func('SBUILDSPEC', d)
+
 	# Build the rpm package!
 	d.setVar('BUILDSPEC', cmd + "\n")
 	d.setVarFlag('BUILDSPEC', 'func', '1')
Signature · 1 line
1.7.7
#2 lore raw

Re: [PATCH 1/2] package_rpm.bbclass: add srpm function in spec file

Quoted 38 lines · Xiaofeng Yan

From: Xiaofeng Yan<[email protected]>

For packaging source codes to source rpm package, adding Sources,\
Patches and prep stage in spec file.
"Sources" include source codes (type of tar.gz) and \
log files including log.do_patch and log.do_configure (type of tar.gz) "Patches" include all patches called in bb file.
"prep" is for user viewing the result in the stage of doing patch and configuration for example:
User can use the following command to run the stage of prep.
$rpmbuild -bp package.spec
<show the result of log.do_patch and log.configure>

[YOCTO #1655]

---
  meta/classes/package_rpm.bbclass |   65 ++++++++++++++++++++++++++++++++------
  1 files changed, 55 insertions(+), 10 deletions(-)
meta/classes/package_rpm.bbclass +3 -0
index d03dc3f..3e0ca15 100644
@@ -6,6 +6,7 @@ RPM="rpm"
  RPMBUILD="rpmbuild"
 
  PKGWRITEDIRRPM = "${WORKDIR}/deploy-rpms"
+PKGWRITEDIRSRPM = "${WORKDIR}/deploy-srpm"
 
  python package_rpm_fn () {
  	d.setVar('PKGFN', d.getVar('PKG'))
@@ -422,6 +423,19 @@ python write_specfile () {
  	import textwrap
  	import oe.packagedata
 
+	def add_prep(spec_files_bottom):
+		bb.build.exec_func('not_srpm', d)

meta/classes/package_rpm.bbclass python write_specfile () { · line 437

Quoted 10 lines
meta/classes/package_rpm.bbclass +10 -0
+		if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+			spec_files_bottom.append('%%prep -n %s' % d.getVar('PN', True) )
+			spec_files_bottom.append('%s' % "set +x")
+			spec_files_bottom.append('%s' % "cd $RPM_SOURCE_BUILD")
+			spec_files_bottom.append('%s' % "tar zxvf $RPM_SOURCE_DIR/log.tar.gz")
+			spec_files_bottom.append('%s' % "echo \"============ do patch ==============\"")
+			spec_files_bottom.append('%s' % "cat log.do_patch*")
+			spec_files_bottom.append('%s' % "echo \"============ do configure ==========\"")
+			spec_files_bottom.append('%s' % "cat log.do_configure*")
+			spec_files_bottom.append('')

The above will simply print the output of the do_patch and do_configure steps. It would probably be better to simply include the steps themselves... but with the python based steps I'm not sure that is possible. So returning the log entries is likely the next best thing.

Note, you don't need the wild cards in this, you should simply cat out the version log.do_patch instead of log.do_patch* -- bitbake ensures that the last log file is always the one with the symbolic link.

--Mark

Quoted 129 lines
meta/classes/package_rpm.bbclass +42 -10
+
  	# We need a simple way to remove the MLPREFIX from the package name,
  	# and dependency information...
  	def strip_multilib(name, d):
@@ -533,6 +547,13 @@ python write_specfile () {
  	srcmaintainer  = d.getVar('MAINTAINER', True)
  	srchomepage    = d.getVar('HOMEPAGE', True)
  	srcdescription = d.getVar('DESCRIPTION', True) or "."
+	
+	bb.build.exec_func('not_srpm', d)
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+		tpkg_name = d.getVar('PF',True)
+		srctargz  = tpkg_name + ".tar.gz"
+		logtargz = "log.tar.gz"
+
 
  	srcdepends     = strip_multilib(d.getVar('DEPENDS', True), d)
  	srcrdepends    = []
@@ -557,6 +578,11 @@ python write_specfile () {
  	spec_files_top = []
  	spec_files_bottom = []
 
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+		srcpatches = []	
+		bb.build.exec_func('get_patches', d)
+		srcpatches = d.getVar('PLIST',True)
+	
  	for pkg in packages.split():
  		localdata = bb.data.createCopy(d)
 
@@ -637,7 +663,7 @@ python write_specfile () {
  				else:
  					bb.note("Creating EMPTY RPM Package for %s" % splitname)
  				spec_files_top.append('')
-
+				
  			bb.utils.unlockfile(lf)
  			continue
 
@@ -714,7 +740,7 @@ python write_specfile () {
  			spec_scriptlets_bottom.append('# %s - %s' % (splitname, script))
  			spec_scriptlets_bottom.append(scriptvar)
  			spec_scriptlets_bottom.append('')
-
+		
  		# Now process files
  		file_list = []
  		walk_files(root, file_list, conffiles)
@@ -732,7 +758,8 @@ python write_specfile () {
 
  		del localdata
  		bb.utils.unlockfile(lf)
-
+	
+	add_prep(spec_files_bottom)
  	spec_preamble_top.append('Summary: %s' % srcsummary)
  	spec_preamble_top.append('Name: %s' % srcname)
  	spec_preamble_top.append('Version: %s' % srcversion)
@@ -743,6 +770,11 @@ python write_specfile () {
  	spec_preamble_top.append('Group: %s' % srcsection)
  	spec_preamble_top.append('Packager: %s' % srcmaintainer)
  	spec_preamble_top.append('URL: %s' % srchomepage)
+	
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+		spec_preamble_top.append('Source: %s' % srctargz)
+		spec_preamble_top.append('Source1: %s' % logtargz)
+
 
  	# Replaces == Obsoletes&&  Provides
  	if srcrreplaces and srcrreplaces.strip() != "":
@@ -764,6 +796,11 @@ python write_specfile () {
  	print_deps(srcrsuggests, 	"Recommends", spec_preamble_top, d)
  	print_deps(srcrprovides, 	"Provides", spec_preamble_top, d)
  	print_deps(srcrobsoletes, 	"Obsoletes", spec_preamble_top, d)
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+		numid = 1
+		for patch in srcpatches:
+			print_deps(patch, "Patch" + str(numid), spec_preamble_top, d)
+			numid += 1
 
  	# conflicts can not be in a provide!  We will need to filter it.
  	if srcrconflicts:
@@ -817,12 +854,6 @@ python write_specfile () {
  	except OSError:
  		raise bb.build.FuncFailed("unable to open spec file for writing.")
 
-	# RPMSPEC_PREAMBLE is a way to add arbitrary text to the top
-	# of the generated spec file
-	external_preamble = d.getVar("RPMSPEC_PREAMBLE", True)
-	if external_preamble:
-		specfile.write(external_preamble + "\n")
-
  	for line in spec_preamble_top:
  		specfile.write(line + "\n")
 
@@ -947,9 +978,14 @@ python do_package_rpm () {
  		d.setVar('PACKAGE_ARCH_EXTEND', package_arch)
  	pkgwritedir = bb.data.expand('${PKGWRITEDIRRPM}/${PACKAGE_ARCH_EXTEND}', d)
  	pkgarch = bb.data.expand('${PACKAGE_ARCH_EXTEND}${TARGET_VENDOR}-${TARGET_OS}', d)
-	magicfile = bb.data.expand('${STAGING_DIR_NATIVE}${datadir_native}/misc/magic.mgc', d)
+	magicfile = bb.data.expand('${STAGING_DIR_NATIVE}/usr/share/misc/magic.mgc', d)
  	bb.mkdirhier(pkgwritedir)
  	os.chmod(pkgwritedir, 0755)
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True):
+		pkgwritesrpmdir = bb.data.expand('${PKGWRITEDIRSRPM}/${PACKAGE_ARCH_EXTEND}', d)
+		bb.mkdirhier(pkgwritesrpmdir)
+		os.chmod(pkgwritesrpmdir, 0755)
+	
 
  	cmd = rpmbuild
  	cmd = cmd + " --nodeps --short-circuit --target " + pkgarch + " --buildroot " + pkgd
@@ -962,8 +998,17 @@ python do_package_rpm () {
  	cmd = cmd + " --define 'debug_package %{nil}'"
  	cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'"
  	cmd = cmd + " --define '_tmppath " + workdir + "'"
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+		cmdsrpm = cmd + " --define '_sourcedir " + workdir + "' --define '_srcrpmdir " + pkgwritesrpmdir + "'"
+		cmdsrpm = cmdsrpm + " -bs " + outspecfile
  	cmd = cmd + " -bb " + outspecfile
 
+	# Build the source rpm package !
+	if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+		d.setVar('SBUILDSPEC', cmdsrpm + "\n")
+		d.setVarFlag('SBUILDSPEC', 'func', '1')
+		bb.build.exec_func('SBUILDSPEC', d)
+
  	# Build the rpm package!
  	d.setVar('BUILDSPEC', cmd + "\n")
  	d.setVarFlag('BUILDSPEC', 'func', '1')
#3 lore raw

Re: [PATCH 1/2] package_rpm.bbclass: add srpm function in spec file

Quoted 47 lines · Mark Hatle
Quoted 46 lines · Xiaofeng Yan

From: Xiaofeng Yan<[email protected]>

For packaging source codes to source rpm package, adding Sources,\
Patches and prep stage in spec file.
"Sources" include source codes (type of tar.gz) and \
log files including log.do_patch and log.do_configure (type of tar.gz) "Patches" include all patches called in bb file.
"prep" is for user viewing the result in the stage of doing patch and configuration for example:
User can use the following command to run the stage of prep.
$rpmbuild -bp package.spec
<show the result of log.do_patch and log.configure>

[YOCTO #1655]

---
meta/classes/package_rpm.bbclass | 65
++++++++++++++++++++++++++++++++------

1 files changed, 55 insertions(+), 10 deletions(-)
meta/classes/package_rpm.bbclass +0 -0
index d03dc3f..3e0ca15 100644
@@ -6,6 +6,7 @@ RPM="rpm"

RPMBUILD="rpmbuild"

PKGWRITEDIRRPM = "${WORKDIR}/deploy-rpms"
+PKGWRITEDIRSRPM = "${WORKDIR}/deploy-srpm"

python package_rpm_fn () {
d.setVar('PKGFN', d.getVar('PKG'))

meta/classes/package_rpm.bbclass +0 -0
@@ -422,6 +423,19 @@ python write_specfile () {

import textwrap
import oe.packagedata

+ def add_prep(spec_files_bottom):
+ bb.build.exec_func('not_srpm', d)
+ if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+ spec_files_bottom.append('%%prep -n %s' % d.getVar('PN', True) )
+ spec_files_bottom.append('%s' % "set +x")
+ spec_files_bottom.append('%s' % "cd $RPM_SOURCE_BUILD")
+ spec_files_bottom.append('%s' % "tar zxvf $RPM_SOURCE_DIR/log.tar.gz")
+ spec_files_bottom.append('%s' % "echo \"============ do patch

Quoted 8 lines
Quoted 6 lines

==============\"")
+ spec_files_bottom.append('%s' % "cat log.do_patch*")
+ spec_files_bottom.append('%s' % "echo \"============ do configure ==========\"")
+ spec_files_bottom.append('%s' % "cat log.do_configure*")
+ spec_files_bottom.append('')

The above will simply print the output of the do_patch and do_configure steps. It would probably be better to simply include the steps themselves... but with the python based steps I'm not sure that is possible.

The stage of prep can work with command "rpmbuild -bp xxx.spec" on target platform. I have also a query. if I plus "%prep" between "%package" and "%file", then "prep" can't work but if plussing "%prep after "%file"", then "%prep" can work. I don't know why about that.

Quoted 2 lines

So returning the log entries is likely the next best thing.

I should modify codes like the following.

def add_prep(spec_files_bottom):
bb.build.exec_func('not_srpm', d)
if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
spec_files_bottom.append('%%prep -n %s' % d.getVar('PN', True) )
spec_files_bottom.append('%s' % "set +x")
spec_files_bottom.append('%s' % "echo \"include log.do_unpack and log.do_patch, Please check them in log.tar.gz from SOURCES\"") spec_files_bottom.append('')

only tell user to find log files in detailed place. right?

Quoted 146 lines

Note, you don't need the wild cards in this, you should simply cat out the version log.do_patch instead of log.do_patch* -- bitbake ensures that the last log file is always the one with the symbolic link.

--Mark

Quoted 140 lines

+
# We need a simple way to remove the MLPREFIX from the package name,

# and dependency information...
def strip_multilib(name, d):
meta/classes/package_rpm.bbclass +0 -0
@@ -533,6 +547,13 @@ python write_specfile () {
 srcmaintainer = d.getVar('MAINTAINER', True)
 srchomepage = d.getVar('HOMEPAGE', True)

srcdescription = d.getVar('DESCRIPTION', True) or "."
+
+ bb.build.exec_func('not_srpm', d)
+ if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+ tpkg_name = d.getVar('PF',True)
+ srctargz = tpkg_name + ".tar.gz"
+ logtargz = "log.tar.gz"
+

srcdepends = strip_multilib(d.getVar('DEPENDS', True), d) srcrdepends = []

meta/classes/package_rpm.bbclass +0 -0
@@ -557,6 +578,11 @@ python write_specfile () {

spec_files_top = []
spec_files_bottom = []

+ if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+ srcpatches = []
+ bb.build.exec_func('get_patches', d)
+ srcpatches = d.getVar('PLIST',True)
+
for pkg in packages.split():
localdata = bb.data.createCopy(d)

meta/classes/package_rpm.bbclass +0 -0
@@ -637,7 +663,7 @@ python write_specfile () {

else:
bb.note("Creating EMPTY RPM Package for %s" % splitname) spec_files_top.append('')

meta/classes/package_rpm.bbclass +1 -1
-
+

bb.utils.unlockfile(lf)
continue

meta/classes/package_rpm.bbclass +1 -1
@@ -714,7 +740,7 @@ python write_specfile () {
 spec_scriptlets_bottom.append('# %s - %s' % (splitname, script))
 spec_scriptlets_bottom.append(scriptvar)
 spec_scriptlets_bottom.append('')
-
+
 # Now process files

file_list = []
walk_files(root, file_list, conffiles)

meta/classes/package_rpm.bbclass +0 -0
@@ -732,7 +758,8 @@ python write_specfile () {
 

del localdata
bb.utils.unlockfile(lf)

meta/classes/package_rpm.bbclass +2 -1
-
+
+ add_prep(spec_files_bottom)

spec_preamble_top.append('Summary: %s' % srcsummary) spec_preamble_top.append('Name: %s' % srcname) spec_preamble_top.append('Version: %s' % srcversion)

meta/classes/package_rpm.bbclass +2 -0
@@ -743,6 +770,11 @@ python write_specfile () {
 spec_preamble_top.append('Group: %s' % srcsection)
 spec_preamble_top.append('Packager: %s' % srcmaintainer)
 spec_preamble_top.append('URL: %s' % srchomepage)
+
+ if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) 

== 'SRPM':
+ spec_preamble_top.append('Source: %s' % srctargz)
+ spec_preamble_top.append('Source1: %s' % logtargz) +

# Replaces == Obsoletes&& Provides
if srcrreplaces and srcrreplaces.strip() != "":

meta/classes/package_rpm.bbclass +1 -0
@@ -764,6 +796,11 @@ python write_specfile () {
 print_deps(srcrsuggests, "Recommends", spec_preamble_top, d)
 print_deps(srcrprovides, "Provides", spec_preamble_top, d)
 print_deps(srcrobsoletes, "Obsoletes", spec_preamble_top, d)
+ if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) 

== 'SRPM':
+ numid = 1
+ for patch in srcpatches:
+ print_deps(patch, "Patch" + str(numid), spec_preamble_top, d)
+ numid += 1

# conflicts can not be in a provide! We will need to filter it.
if srcrconflicts:
meta/classes/package_rpm.bbclass +0 -0
@@ -817,12 +854,6 @@ python write_specfile () {

except OSError:
raise bb.build.FuncFailed("unable to open spec file for writing.")

- # RPMSPEC_PREAMBLE is a way to add arbitrary text to the top
- # of the generated spec file
- external_preamble = d.getVar("RPMSPEC_PREAMBLE", True)
- if external_preamble:
- specfile.write(external_preamble + "\n")
-
for line in spec_preamble_top:
specfile.write(line + "\n")

meta/classes/package_rpm.bbclass +6 -1
@@ -947,9 +978,14 @@ python do_package_rpm () {
 d.setVar('PACKAGE_ARCH_EXTEND', package_arch)
 pkgwritedir = bb.data.expand('${PKGWRITEDIRRPM}/${PACKAGE_ARCH_EXTEND}', d)
 pkgarch = bb.data.expand('${PACKAGE_ARCH_EXTEND}${TARGET_VENDOR}-${TARGET_OS}', d)
- magicfile = 
 bb.data.expand('${STAGING_DIR_NATIVE}${datadir_native}/misc/magic.mgc', d)
+ magicfile = 
 bb.data.expand('${STAGING_DIR_NATIVE}/usr/share/misc/magic.mgc', d)
 bb.mkdirhier(pkgwritedir)
 os.chmod(pkgwritedir, 0755)
+ if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True):
+ pkgwritesrpmdir = 
 bb.data.expand('${PKGWRITEDIRSRPM}/${PACKAGE_ARCH_EXTEND}', d)
+ bb.mkdirhier(pkgwritesrpmdir)
+ os.chmod(pkgwritesrpmdir, 0755)
+

cmd = rpmbuild
cmd = cmd + " --nodeps --short-circuit --target " + pkgarch + " --buildroot " + pkgd

meta/classes/package_rpm.bbclass +0 -0
@@ -962,8 +998,17 @@ python do_package_rpm () {

cmd = cmd + " --define 'debug_package %{nil}'"
cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'" cmd = cmd + " --define '_tmppath " + workdir + "'"
+ if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+ cmdsrpm = cmd + " --define '_sourcedir " + workdir + "' --define '_srcrpmdir " + pkgwritesrpmdir + "'"
+ cmdsrpm = cmdsrpm + " -bs " + outspecfile
cmd = cmd + " -bb " + outspecfile

+ # Build the source rpm package !
+ if not d.getVar('NOTSRPM', True) and d.getVar('ARCHIVE_TYPE', True) == 'SRPM':
+ d.setVar('SBUILDSPEC', cmdsrpm + "\n")
+ d.setVarFlag('SBUILDSPEC', 'func', '1')
+ bb.build.exec_func('SBUILDSPEC', d)
+
# Build the rpm package!
d.setVar('BUILDSPEC', cmd + "\n") d.setVarFlag('BUILDSPEC', 'func', '1')

#4 lore raw

PATCH 2/2 tar_archive.bbclass: Package source codes and log files to tar package

In reply to Xiaofeng Yan

From: Xiaofeng Yan <[email protected]>

Source rpm package needs tar package as its source codes. log files \
are required as a part of source (description in bug 1655).
So log files need be packaged as tar package too.
User can select two types of package, the first is tar package and the second is src.rpm package. The option item is defined in conf/local.conf.(ARCHIVE_TYPE ?= "SRPM"(default) or ARCHIVE_TYPE ?= "TARGZ") if the option is the first type, then tar_archive.bbclass should be inherited in an suitable position. The tar packages(sources.tar.gz and log.tar.gz) will be created in workdir.
if the option is the second type, then tar_archive.bbclass shoud be inherited in package_rpm.bbclass. The sources rpm packages will be created in workdir/deploy-srpm when building.
The following command can ship all of source packages(src.rpm or tar.gz) to build/tmp/deploy/sources $bitbake core-image-sato -c copysources

[YOCTO #1655]

---
 meta/classes/tar_archive.bbclass |  216 ++++++++++++++++++++++++++++++++++++++
 1 files changed, 216 insertions(+), 0 deletions(-)
 create mode 100644 meta/classes/tar_archive.bbclass
meta/classes/tar_archive.bbclass new file +216 -0
new file mode 100644
index 0000000..2651cbc
@@ -0,0 +1,216 @@
+# This file is used for packaging source codes tree to tar and \
+# source rpm package.
+
+# Some patches are not in WORKDIR but in its sub-directory.
+# Rpmbuild uses workdir as source directoty.
+# Copy pathes in sub-directory to workdir. these patches could exist \
+# in gentoo, debian and fedora
+python move_patches_toworkdir(){	
+	import os
+
+	patches = d.getVar('PLIST', True)
+	workdir = d.getVar('WORKDIR',True)
+	s = d.getVar('S',True)
+	
+	# The source tree of gcc is different from others, it is \
+	# in work-shard, not in work. so this needs a special treatment.
+	if 'work-shared' in s:
+		for patch in patches:
+			os.system('cp ' + os.path.dirname(s) + '/' + patch + ' ' + workdir)
+		return
+	platforms = ['debian','gentoo','fedora']
+	os.chdir(workdir)
+	for patch in patches:
+		if patch  not in os.listdir('.'):
+			for platform in platforms:
+				if os.path.exists(platform):
+					for root, dirs, files in os.walk(platform):
+						for file in files:
+							os.system('cp ' + root + '/' + file + ' ' + workdir)
+			return
+}
+
+# Spec file needs patches' name to build source packages  
+# Get patches' name and set them to 'd'
+python get_patches () {
+	import os
+	import re
+    
+	plist=[]
+	pat = re.compile('NOTE(.+)\'(.+)\'(.+)$')
+	workdir = d.getVar('WORKDIR',True)
+	s = d.getVar('S',True)
+	file_log = workdir + "/temp/log.do_patch"
+	if 'work-shared' in s:
+		file_log = os.path.dirname(s) + "/temp/log.do_patch"
+      	
+	if os.path.exists(file_log):
+		f = open(file_log,'r')
+		for line in f.readlines():
+			m = pat.match(line)
+			if m:
+				plist.append(m.group(2))
+		f.close()
+        
+	d.setVar('PLIST',plist)
+	bb.build.exec_func('move_patches_toworkdir', d)
+}
+
+ 
+# The following pkgs don't have source rpm and tar packages
+# 1 The pkg do nothing when unpack
+# 2 The pkg includes 'task-' or 'native' in the workdir 
+# 3 The ${S} is empty 
+python not_srpm() {
+	import os
+
+	workdir = d.getVar('WORKDIR',True)
+	s = d.getVar('S',True)
+	# The source tree of gcc is different from others, it is \
+	#in work-shard, not in work. So it needs a special treatment.
+	if 'work-shared' in s:
+		return
+	# Identify an empty directory, if having file after \
+	#the stage of do_unpack, this will look as invalid source codes directoty.
+	if len(os.listdir(s)) == 0:
+		open("emptyflag", 'w')
+	try:
+		if not os.path.exists(workdir + '/temp/' + 'log.do_unpack') or 'task-' in workdir or 'native' in workdir or os.path.exists(s + '/' + 'emptyflag'):
+			raise IOError
+	except IOError:
+		d.setVar('NOTSRPM', '1')
+}
+
+# Spec file needs source package's name to build a source package
+# Package source code patched to ${PF}.tar.gz
+do_tararchive[dirs] = "${WORKDIR}"
+fakeroot python do_tararchive() {
+	import tarfile
+	import os
+	if not d.getVar('ARCHIVE_TYPE', True):
+		return
+	
+	s = d.getVar('S',True)
+	workdir=d.getVar('WORKDIR', True)
+	PF = d.getVar('PF',True)
+	bb.build.exec_func('not_srpm', d)	
+	if d.getVar('NOTSRPM', True):
+		return
+	if os.path.exists(s) and s is not workdir:
+		sourcedir = os.path.basename(s)
+		tarbase = os.path.dirname(s)
+		if not sourcedir or os.path.dirname(tarbase) == workdir:
+			sourcedir = os.path.basename(os.path.dirname(s))
+			tarbase = os.path.dirname(os.path.dirname(s))
+		os.chdir(tarbase)
+	else:
+		sourcedir = os.path.basename(s)
+		if not os.path.exists(sourcedir):
+			os.mkdir(sourcedir)
+		for file in os.listdir(s):
+			if file is not 'temp' and file is not sourcedir:
+				os.system('cp ' + file + ' ' + sourcedir)
+
+	if (len(os.listdir(sourcedir))) != 0:
+		tar = tarfile.open( PF + ".tar.gz", "w:gz")
+		tar.add(sourcedir)
+		tar.close()
+		if os.path.dirname(s) is not workdir:
+			os.system('mv ' + os.path.dirname(s) + '/' + PF + '.tar.gz ' + workdir)
+}
+
+addtask do_tararchive after do_patch before do_configure
+
+# "log.tar.gz" which inculdes do_unpack and do_configure is \
+# a part of source package
+# Package log files to "log.tar.gz"
+do_logarchive[dirs] = "${WORKDIR}"
+fakeroot python do_logarchive(){
+	import tarfile
+	import os
+	
+	if not d.getVar('ARCHIVE_TYPE', True):
+		return
+	
+	bb.build.exec_func('not_srpm', d)	
+	if d.getVar('NOTSRPM', True):
+		return 
+	
+	log_list = ['log.do_patch','log.do_configure']
+	workdir=d.getVar('WORKDIR', True)
+	temp = workdir + "/" + "temp"
+	os.chdir(temp)
+	logtar = tarfile.open("log.tar.gz", "w:gz")
+	if os.path.exists(temp):
+		for link_log in log_list:
+			if os.path.islink(link_log):
+				real_log = os.path.basename(os.readlink(link_log))
+				logtar.add(real_log)
+	logtar.close()
+	os.system('mv log.tar.gz ../')
+}
+addtask do_logarchive after do_install before do_package
+
+# This is used for fixing the "Bad owner/group: ..." 
+# Set owner and group for patches, log.tar.gz and ${PF}.tar.gz to "root"
+do_setowngroup[dirs] = "${WORKDIR}"
+fakeroot python do_setowngroup(){
+	import os
+	
+	if not d.getVar('ARCHIVE_TYPE', True):
+		return
+	bb.build.exec_func('not_srpm', d)	
+	if d.getVar('NOTSRPM', True):
+		return
+	bb.build.exec_func('get_patches', d)
+        srcpatches = d.getVar('PLIST',True)
+	for patch in srcpatches:
+		os.system('chown root.root' + ' ' + patch)
+	os.system('chown root.root' + ' ' + "log.tar.gz")
+	os.system('chown root.root' + ' ' + d.getVar('PF', True) + ".tar.gz")
+}
+addtask do_setowngroup after do_logarchive before do_package
+
+# Copy source package to build/tmp/deploy/sources
+do_copysources[dirs] = "${PWD}/tmp/work"
+python do_copysources (){
+	import os
+	
+	archive_type = d.getVar('ARCHIVE_TYPE', True)
+	pwd = d.getVar('PWD', True)
+	machine = d.getVar('MACHINE', True)
+	target_sys = d.getVar('TARGET_SYS', True)
+	target_os = d.getVar('TARGET_OS', True)
+	target_vendor = d.getVar('TARGET_VENDOR', True)
+	tune_pkgarch = d.getVar('TUNE_PKGARCH', True)
+	multimach_host_sys = d.getVar('MULTIMACH_HOST_SYS', True)
+	all = 'all' + target_vendor + '-' + 'linux'
+	target = tune_pkgarch + target_vendor + '-' + target_os
+	srpmdir=pwd + '/tmp/deploy/' + 'sources' + '/' + machine
+	
+	if not os.path.exists(srpmdir):
+		os.makedirs(srpmdir)
+	global_work = pwd + '/tmp' + '/work'
+	os.chdir(global_work)
+	for dirs in multimach_host_sys, all, target:
+		localdir = srpmdir + '/' + dirs
+		if not os.path.exists(localdir):
+			os.mkdir(localdir)
+		os.chdir(dirs)
+		if archive_type == 'SRPM': 
+			os.system('cp */deploy-srpm/*/*.src.rpm ' + localdir)
+		elif archive_type == 'TARGZ':
+			for dir in os.listdir('.'):
+				if os.path.isdir(dir):
+					os.chdir(dir)
+					if not os.path.exists(dir):
+						os.mkdir(localdir + '/' + dir)
+					os.system('cp *.gz ' + localdir + '/' + dir)
+					os.chdir('../')
+		else:
+			return
+		os.chdir(global_work)
+}
+addtask do_copysources  after do_rootfs
+
+EXPORT_FUNCTIONS do_archive do_logarchive do_setowngroup do_copysources
Signature · 1 line
1.7.7
#5 lore raw

Re: [PATCH 2/2] tar_archive.bbclass: Package source codes and log files to tar package

Quoted 22 lines · Xiaofeng Yan

From: Xiaofeng Yan<[email protected]>

Source rpm package needs tar package as its source codes. log files \
are required as a part of source (description in bug 1655).
So log files need be packaged as tar package too.
User can select two types of package, the first is tar package and the second is src.rpm package. The option item is defined in conf/local.conf.(ARCHIVE_TYPE ?= "SRPM"(default) or ARCHIVE_TYPE ?= "TARGZ") if the option is the first type, then tar_archive.bbclass should be inherited in an suitable position. The tar packages(sources.tar.gz and log.tar.gz) will be created in workdir.
if the option is the second type, then tar_archive.bbclass shoud be inherited in package_rpm.bbclass. The sources rpm packages will be created in workdir/deploy-srpm when building.
The following command can ship all of source packages(src.rpm or tar.gz) to build/tmp/deploy/sources $bitbake core-image-sato -c copysources

[YOCTO #1655]

---
  meta/classes/tar_archive.bbclass |  216 ++++++++++++++++++++++++++++++++++++++
  1 files changed, 216 insertions(+), 0 deletions(-)

create mode 100644 meta/classes/tar_archive.bbclass

...

Quoted 10 lines
meta/classes/tar_archive.bbclass new file +10 -0
+addtask do_logarchive after do_install before do_package
+
+# This is used for fixing the "Bad owner/group: ..."
+# Set owner and group for patches, log.tar.gz and ${PF}.tar.gz to "root"
+do_setowngroup[dirs] = "${WORKDIR}"
+fakeroot python do_setowngroup(){
+	import os
+	
+	if not d.getVar('ARCHIVE_TYPE', True):
+		return

meta/classes/tar_archive.bbclass line 171

Quoted 10 lines
meta/classes/tar_archive.bbclass new file +10 -0
+	bb.build.exec_func('not_srpm', d)	
+	if d.getVar('NOTSRPM', True):
+		return
+	bb.build.exec_func('get_patches', d)
+        srcpatches = d.getVar('PLIST',True)
+	for patch in srcpatches:
+		os.system('chown root.root' + ' ' + patch)
+	os.system('chown root.root' + ' ' + "log.tar.gz")
+	os.system('chown root.root' + ' ' + d.getVar('PF', True) + ".tar.gz")
+}

Instead of the above during the creation of the tar archive, you should be able to pass in --owner=root --group=root and tar will ignore the on-disk permissions and set it based on the arguments.

Quoted 45 lines
meta/classes/tar_archive.bbclass new file +45 -0
+addtask do_setowngroup after do_logarchive before do_package
+
+# Copy source package to build/tmp/deploy/sources
+do_copysources[dirs] = "${PWD}/tmp/work"
+python do_copysources (){
+	import os
+	
+	archive_type = d.getVar('ARCHIVE_TYPE', True)
+	pwd = d.getVar('PWD', True)
+	machine = d.getVar('MACHINE', True)
+	target_sys = d.getVar('TARGET_SYS', True)
+	target_os = d.getVar('TARGET_OS', True)
+	target_vendor = d.getVar('TARGET_VENDOR', True)
+	tune_pkgarch = d.getVar('TUNE_PKGARCH', True)
+	multimach_host_sys = d.getVar('MULTIMACH_HOST_SYS', True)
+	all = 'all' + target_vendor + '-' + 'linux'
+	target = tune_pkgarch + target_vendor + '-' + target_os
+	srpmdir=pwd + '/tmp/deploy/' + 'sources' + '/' + machine
+	
+	if not os.path.exists(srpmdir):
+		os.makedirs(srpmdir)
+	global_work = pwd + '/tmp' + '/work'
+	os.chdir(global_work)
+	for dirs in multimach_host_sys, all, target:
+		localdir = srpmdir + '/' + dirs
+		if not os.path.exists(localdir):
+			os.mkdir(localdir)
+		os.chdir(dirs)
+		if archive_type == 'SRPM':
+			os.system('cp */deploy-srpm/*/*.src.rpm ' + localdir)
+		elif archive_type == 'TARGZ':
+			for dir in os.listdir('.'):
+				if os.path.isdir(dir):
+					os.chdir(dir)
+					if not os.path.exists(dir):
+						os.mkdir(localdir + '/' + dir)
+					os.system('cp *.gz ' + localdir + '/' + dir)
+					os.chdir('../')
+		else:
+			return
+		os.chdir(global_work)
+}
+addtask do_copysources  after do_rootfs
+
+EXPORT_FUNCTIONS do_archive do_logarchive do_setowngroup do_copysources
#6 lore raw
In reply to Xiaofeng Yan
Quoted 86 lines · Xiaofeng Yan

From: Xiaofeng Yan<[email protected]>

Add file "tar_archive.bbclass" and modify file "package_rpm.bbclass" for packaging source codes tree to source rpm and tar packages. After adding srpm function in file "package_rpm.bbclass", user can get source rpm packages beside rpm package. User also get tar packages of source codes tree according to the requirement from bug 1655. The final result is as follow:
Take qemux86 for an example:
Get source rpm pakcages
1 Inherit tar_archive.bbclass in package_rpm.bbclass.
2 Select the type of packaging source code tree in conf/local.conf(ARCHIVE_TYPE ?= "SRPM")
3 Run the following command

   $ bitbake core-image-sato -c copysources
4 Get source rpm packages:
   $ tree build/tmp/deploy/sources
   build/tmp/deploy/sources/
   └── qemux86
     ├── all-poky-linux
     │   ├── encodings-1.0.4-r2.1.src.rpm
         ......
     ├── i586-poky-linux
     │   ├── acl-2.2.51-r2.src.rpm
         ......
     └── qemux86-poky-linux
         ├── base-files-3.0.14-r70.src.rpm
         ......
Get tar packages:
1 Inherit tar_archive.bbclass in an suitable position (for example, package_rpm.bbclass).
2 Select the type of packaging source code tree in conf/local.conf(ARCHIVE_TYPE ?= "TARGZ")
3 Run the following command
   $ bitbake core-image-sato -c copysources
4 Get tar packages:
   $ tree build/tmp/deploy/sources
   buildx86/tmp/deploy/sources
   └── qemux86
     ├── all-poky-linux
     │   ├── encodings-1_1.0.4-r2.1
     │   │   ├── encodings-1_1.0.4-r2.1.tar.gz
     │   │   └── log.tar.gz
             ......
     ├── i586-poky-linux
     │   ├── acl-2.2.51-r2
     │   │   ├── acl-2.2.51-r2.tar.gz
             └── log.tar.gz
             ......
     └── qemux86-poky-linux
         ├── core-image-sato-1.0-r0
         ├── libzypp-0.0-git1+15b6c52260bbc52b3d8e585e271b67e10cc7c433-r17
         │   ├── libzypp-0.0-git1+15b6c52260bbc52b3d8e585e271b67e10cc7c433-r17.tar.gz
         │   └── log.tar.gz
             ......

if inheriting tar_archive.bbclass in one bb file, then only package source codes tree of this file. Take zlib for an example:
Get source rpm pakcage of zlib
1 Inherit tar_archive.bbclass in zlib_1.2.5.bb.
2 Select the type of packaging source code tree in conf/local.conf(ARCHIVE_TYPE ?= "SRPM") 3 Run the following command

   $ bitbake zlib
4 Get source rpm package:
   $ ls build/tmp/work/i586-poky-linux/zlib-1.2.5-r3/deploy-srpm/i586/
     zlib-1.2.5-r3.src.rpm

Get tar package of zlib
1 Inherit tar_archive.bbclass in zlib_1.2.5.bb.
2 Select the type of packaging source code tree in conf/local.conf(ARCHIVE_TYPE ?= "TARGZ") 3 Run the following command

   $ bitbake zlib
4 Get tar package:
   $ ls build/tmp/work/i586-poky-linux/zlib-1.2.5-r3/
     zlib-1.2.5-r3.tar.gz log.tar.gz ......

Pull URL: git://git.pokylinux.org/poky-contrib.git
Branch: xiaofeng/1655
Browse: http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=xiaofeng/1655

Thanks,
Xiaofeng Yan<[email protected]>
---

Xiaofeng Yan (2):
package_rpm.bbclass: add srpm function in spec file tar_archive.bbclass: Package source codes and log files to tar
package

Quoted 6 lines
  meta/classes/package_rpm.bbclass |   65 ++++++++++--
  meta/classes/tar_archive.bbclass |  216 ++++++++++++++++++++++++++++++++++++++
  2 files changed, 271 insertions(+), 10 deletions(-)

create mode 100644 meta/classes/tar_archive.bbclass

Xiaofeng, Wenzong:

We are going to put a hold on both this patchset and Wenzong's patch set, due to the similarity of what is trying to be done. Both of these patches are creating tar archives of source and temp directories. While it is being done differently, we need to consolidate these changes.

The SRPM work can use the consolidated version. As I mentioned in a prior email to Wenzong, there are also other classes such as copyleft_complaince.bbclass and src_distrbute.bbclass that we should look at and determine if they can be modified or extended.

Wenzong pointed out that copyleft does license checking, it can work for all sources depending on the settings of the INCLUDE/EXCLUDE variables, so it can be reused, it creates a source + patchset directory.

The sourcepgk.bbclass seems to be doing something different in creating a diff file (among other) of a given package between the unpack and post-patch, including the python functions and environmnet variables.

I (with Mark's help) will craft and updated document to address what we are want to accomplish, which is simplifing what we currently have with the goal to meet the commercial vendor's needs of supplying the source either patched or with a patchset that can be applied along with the configuration and build scripts for various license compliance.

Thanks for your initial work in this area, but we need to find a better overall approach without duplicating code/effort.

Sau!

Quoted 6 lines

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

#7 lore raw
Quoted 102 lines · Saul Wold
Quoted 86 lines · Xiaofeng Yan

From: Xiaofeng Yan<[email protected]>

Add file "tar_archive.bbclass" and modify file "package_rpm.bbclass" for packaging source codes tree to source rpm and tar packages. After adding srpm function in file "package_rpm.bbclass", user can get source rpm packages beside rpm package. User also get tar packages of source codes tree according to the requirement from bug 1655. The final result is as follow:
Take qemux86 for an example:
Get source rpm pakcages
1 Inherit tar_archive.bbclass in package_rpm.bbclass.
2 Select the type of packaging source code tree in conf/local.conf(ARCHIVE_TYPE ?= "SRPM")
3 Run the following command

$ bitbake core-image-sato -c copysources
4 Get source rpm packages:
$ tree build/tmp/deploy/sources
build/tmp/deploy/sources/
└── qemux86
├── all-poky-linux
│  ├── encodings-1.0.4-r2.1.src.rpm
......
├── i586-poky-linux
│  ├── acl-2.2.51-r2.src.rpm
......
└── qemux86-poky-linux
├── base-files-3.0.14-r70.src.rpm
......
Get tar packages:
1 Inherit tar_archive.bbclass in an suitable position (for example, package_rpm.bbclass).
2 Select the type of packaging source code tree in conf/local.conf(ARCHIVE_TYPE ?= "TARGZ")
3 Run the following command
$ bitbake core-image-sato -c copysources
4 Get tar packages:
$ tree build/tmp/deploy/sources
buildx86/tmp/deploy/sources
└── qemux86
├── all-poky-linux
│  ├── encodings-1_1.0.4-r2.1
│  │  ├── encodings-1_1.0.4-r2.1.tar.gz
│  │  └── log.tar.gz
......
├── i586-poky-linux
│  ├── acl-2.2.51-r2
│  │  ├── acl-2.2.51-r2.tar.gz
└── log.tar.gz
......
└── qemux86-poky-linux
├── core-image-sato-1.0-r0
├── libzypp-0.0-git1+15b6c52260bbc52b3d8e585e271b67e10cc7c433-r17
│  ├── libzypp-0.0-git1+15b6c52260bbc52b3d8e585e271b67e10cc7c433-r17.tar.gz
│  └── log.tar.gz
......

if inheriting tar_archive.bbclass in one bb file, then only package source codes tree of this file. Take zlib for an example:
Get source rpm pakcage of zlib
1 Inherit tar_archive.bbclass in zlib_1.2.5.bb.
2 Select the type of packaging source code tree in conf/local.conf(ARCHIVE_TYPE ?= "SRPM") 3 Run the following command

$ bitbake zlib
4 Get source rpm package:
$ ls build/tmp/work/i586-poky-linux/zlib-1.2.5-r3/deploy-srpm/i586/
zlib-1.2.5-r3.src.rpm

Get tar package of zlib
1 Inherit tar_archive.bbclass in zlib_1.2.5.bb.
2 Select the type of packaging source code tree in conf/local.conf(ARCHIVE_TYPE ?= "TARGZ") 3 Run the following command

$ bitbake zlib
4 Get tar package:
$ ls build/tmp/work/i586-poky-linux/zlib-1.2.5-r3/
zlib-1.2.5-r3.tar.gz log.tar.gz ......

Pull URL: git://git.pokylinux.org/poky-contrib.git
Branch: xiaofeng/1655
Browse: http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=xiaofeng/1655

Thanks,
Xiaofeng Yan<[email protected]>
---

Xiaofeng Yan (2):
package_rpm.bbclass: add srpm function in spec file tar_archive.bbclass: Package source codes and log files to tar package

Quoted 7 lines

meta/classes/package_rpm.bbclass | 65 ++++++++++-- meta/classes/tar_archive.bbclass | 216
++++++++++++++++++++++++++++++++++++++

2 files changed, 271 insertions(+), 10 deletions(-)

create mode 100644 meta/classes/tar_archive.bbclass

Xiaofeng, Wenzong:

We are going to put a hold on both this patchset and Wenzong's patch set, due to the similarity of what is trying to be done. Both of these patches are creating tar archives of source and temp directories. While it is being done differently, we need to consolidate these changes.

The SRPM work can use the consolidated version. As I mentioned in a prior email to Wenzong, there are also other classes such as copyleft_complaince.bbclass and src_distrbute.bbclass that we should look at and determine if they can be modified or extended.

Wenzong pointed out that copyleft does license checking, it can work for all sources depending on the settings of the INCLUDE/EXCLUDE variables, so it can be reused, it creates a source + patchset directory.

Quoted 9 lines

The sourcepgk.bbclass seems to be doing something different in creating a diff file (among other) of a given package between the unpack and post-patch, including the python functions and environmnet variables.

I (with Mark's help) will craft and updated document to address what we are want to accomplish, which is simplifing what we currently have with the goal to meet the commercial vendor's needs of supplying the source either patched or with a patchset that can be applied along with the configuration and build scripts for various license compliance.

Thanks for your initial work in this area, but we need to find a better overall approach without duplicating code/effort.

Sau!

I reviewed sourcepkg.bbclass(some cases can't be considered and we need modify this file according to requirement). It is similar with tar_archive.bbclass in some functions. I agree with Saul's suggestion about combining two or more files into one file.

Yan
Thanks

Quoted 7 lines
Quoted 6 lines

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