Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Mark Hatle <mark.hatle@windriver.com>
To: Xiaofeng Yan <xiaofeng.yan@windriver.com>
Cc: openembedded-core@lists.openembedded.org
Subject: Re: [PATCH 1/2] package_rpm.bbclass: add srpm function in spec file
Date: Mon, 9 Jan 2012 10:17:06 -0600	[thread overview]
Message-ID: <4F0B1302.9020901@windriver.com> (raw)
In-Reply-To: <8e1e0bb2a8e876e37c2de9d84eb747c66d0ec750.1326003199.git.xiaofeng.yan@windriver.com>

On 1/8/12 1:11 AM, Xiaofeng Yan wrote:
> From: Xiaofeng Yan<xiaofeng.yan@windriver.com>
>
> 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]
>
> Signed-off-by: Xiaofeng Yan<xiaofeng.yan@windriver.com>
> ---
>   meta/classes/package_rpm.bbclass |   65 ++++++++++++++++++++++++++++++++------
>   1 files changed, 55 insertions(+), 10 deletions(-)
>
> diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
> index d03dc3f..3e0ca15 100644
> --- a/meta/classes/package_rpm.bbclass
> +++ b/meta/classes/package_rpm.bbclass
> @@ -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('')

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

> +
>   	# 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')




  reply	other threads:[~2012-01-09 16:24 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-08  7:11 [PATCH 0/2] Add function to package source codes tree to source rpm and tar packages Xiaofeng Yan
2012-01-08  7:11 ` [PATCH 1/2] package_rpm.bbclass: add srpm function in spec file Xiaofeng Yan
2012-01-09 16:17   ` Mark Hatle [this message]
2012-01-10  8:02     ` Xiaofeng Yan
2012-01-08  7:11 ` [PATCH 2/2] tar_archive.bbclass: Package source codes and log files to tar package Xiaofeng Yan
2012-01-09 16:20   ` Mark Hatle
2012-01-12 20:04 ` [PATCH 0/2] Add function to package source codes tree to source rpm and tar packages Saul Wold
2012-01-13 10:01   ` Xiaofeng Yan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F0B1302.9020901@windriver.com \
    --to=mark.hatle@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=xiaofeng.yan@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox