diff options
author | Robert Yang <liezhi.yang@windriver.com> | 2014-01-13 18:46:43 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-03-21 17:15:27 +0000 |
commit | 2c7d20ce3849aba84e0552f0fc4bde649d96faa9 (patch) | |
tree | dfa93bc6b9f443d8929d7f258901f50bd2a5af40 | |
parent | cbcf5b219858b58c4429ee87444eaacc5a7cfa3e (diff) | |
download | poky-2c7d20ce3849aba84e0552f0fc4bde649d96faa9.tar.gz |
package_rpm.bbclass: archive the source to srpm package
The archiver.bbclass will put the sources to ARCHIVER_OUTDIR according
to configuration, then the rpmbuild -bs will create the srpm.
[YOCTO #4986]
[YOCTO #5113]
(From OE-Core rev: f9ba047afb8780c8bd7cb1ba45470d30abf92e92)
Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | meta/classes/package_rpm.bbclass | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass index bce564808f..9e638785fd 100644 --- a/meta/classes/package_rpm.bbclass +++ b/meta/classes/package_rpm.bbclass | |||
@@ -6,7 +6,6 @@ RPM="rpm" | |||
6 | RPMBUILD="rpmbuild" | 6 | RPMBUILD="rpmbuild" |
7 | 7 | ||
8 | PKGWRITEDIRRPM = "${WORKDIR}/deploy-rpms" | 8 | PKGWRITEDIRRPM = "${WORKDIR}/deploy-rpms" |
9 | PKGWRITEDIRSRPM = "${DEPLOY_DIR}/sources/deploy-srpm" | ||
10 | 9 | ||
11 | # Maintaining the perfile dependencies has singificant overhead when writing the | 10 | # Maintaining the perfile dependencies has singificant overhead when writing the |
12 | # packages. When set, this value merges them for efficiency. | 11 | # packages. When set, this value merges them for efficiency. |
@@ -87,23 +86,26 @@ python write_specfile () { | |||
87 | 86 | ||
88 | # append information for logs and patches to %prep | 87 | # append information for logs and patches to %prep |
89 | def add_prep(d,spec_files_bottom): | 88 | def add_prep(d,spec_files_bottom): |
90 | if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm': | 89 | if d.getVarFlag('ARCHIVER_MODE', 'srpm', True) == '1' and bb.data.inherits_class('archiver', d): |
91 | spec_files_bottom.append('%%prep -n %s' % d.getVar('PN', True) ) | 90 | spec_files_bottom.append('%%prep -n %s' % d.getVar('PN', True) ) |
92 | spec_files_bottom.append('%s' % "echo \"include logs and patches, Please check them in SOURCES\"") | 91 | spec_files_bottom.append('%s' % "echo \"include logs and patches, Please check them in SOURCES\"") |
93 | spec_files_bottom.append('') | 92 | spec_files_bottom.append('') |
94 | 93 | ||
95 | # append the name of tarball to key word 'SOURCE' in xxx.spec. | 94 | # append the name of tarball to key word 'SOURCE' in xxx.spec. |
96 | def tail_source(d): | 95 | def tail_source(d): |
97 | if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm': | 96 | if d.getVarFlag('ARCHIVER_MODE', 'srpm', True) == '1' and bb.data.inherits_class('archiver', d): |
98 | source_list = get_package(d) | 97 | ar_outdir = d.getVar('ARCHIVER_OUTDIR', True) |
98 | if not os.path.exists(ar_outdir): | ||
99 | return | ||
100 | source_list = os.listdir(ar_outdir) | ||
99 | source_number = 0 | 101 | source_number = 0 |
100 | workdir = d.getVar('WORKDIR', True) | ||
101 | for source in source_list: | 102 | for source in source_list: |
102 | # The rpmbuild doesn't need the root permission, but it needs | 103 | # The rpmbuild doesn't need the root permission, but it needs |
103 | # to know the file's user and group name, the only user and | 104 | # to know the file's user and group name, the only user and |
104 | # group in fakeroot is "root" when working in fakeroot. | 105 | # group in fakeroot is "root" when working in fakeroot. |
105 | os.chown("%s/%s" % (workdir, source), 0, 0) | 106 | f = os.path.join(ar_outdir, source) |
106 | spec_preamble_top.append('Source' + str(source_number) + ': %s' % source) | 107 | os.chown(f, 0, 0) |
108 | spec_preamble_top.append('Source%s: %s' % (source_number, source)) | ||
107 | source_number += 1 | 109 | source_number += 1 |
108 | # We need a simple way to remove the MLPREFIX from the package name, | 110 | # We need a simple way to remove the MLPREFIX from the package name, |
109 | # and dependency information... | 111 | # and dependency information... |
@@ -611,15 +613,6 @@ python write_specfile () { | |||
611 | } | 613 | } |
612 | 614 | ||
613 | python do_package_rpm () { | 615 | python do_package_rpm () { |
614 | def creat_srpm_dir(d): | ||
615 | if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm': | ||
616 | clean_licenses = get_licenses(d) | ||
617 | pkgwritesrpmdir = bb.data.expand('${PKGWRITEDIRSRPM}/${PACKAGE_ARCH_EXTEND}', d) | ||
618 | pkgwritesrpmdir = pkgwritesrpmdir + '/' + clean_licenses | ||
619 | bb.utils.mkdirhier(pkgwritesrpmdir) | ||
620 | os.chmod(pkgwritesrpmdir, 0755) | ||
621 | return pkgwritesrpmdir | ||
622 | |||
623 | # We need a simple way to remove the MLPREFIX from the package name, | 616 | # We need a simple way to remove the MLPREFIX from the package name, |
624 | # and dependency information... | 617 | # and dependency information... |
625 | def strip_multilib(name, d): | 618 | def strip_multilib(name, d): |
@@ -687,16 +680,14 @@ python do_package_rpm () { | |||
687 | cmd = cmd + " --define 'debug_package %{nil}'" | 680 | cmd = cmd + " --define 'debug_package %{nil}'" |
688 | cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'" | 681 | cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'" |
689 | cmd = cmd + " --define '_tmppath " + workdir + "'" | 682 | cmd = cmd + " --define '_tmppath " + workdir + "'" |
690 | if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) == 'srpm': | 683 | if d.getVarFlag('ARCHIVER_MODE', 'srpm', True) == '1' and bb.data.inherits_class('archiver', d): |
691 | cmd = cmd + " --define '_sourcedir " + workdir + "'" | 684 | cmd = cmd + " --define '_sourcedir " + d.getVar('ARCHIVER_OUTDIR', True) + "'" |
692 | cmdsrpm = cmd + " --define '_srcrpmdir " + creat_srpm_dir(d) + "'" | 685 | cmdsrpm = cmd + " --define '_srcrpmdir " + d.getVar('ARCHIVER_OUTDIR', True) + "'" |
693 | cmdsrpm = cmdsrpm + " -bs " + outspecfile | 686 | cmdsrpm = cmdsrpm + " -bs " + outspecfile |
694 | # Build the .src.rpm | 687 | # Build the .src.rpm |
695 | d.setVar('SBUILDSPEC', cmdsrpm + "\n") | 688 | d.setVar('SBUILDSPEC', cmdsrpm + "\n") |
696 | d.setVarFlag('SBUILDSPEC', 'func', '1') | 689 | d.setVarFlag('SBUILDSPEC', 'func', '1') |
697 | bb.build.exec_func('SBUILDSPEC', d) | 690 | bb.build.exec_func('SBUILDSPEC', d) |
698 | # Remove the source (SOURCE0, SOURCE1 ...) | ||
699 | cmd = cmd + " --rmsource " | ||
700 | cmd = cmd + " -bb " + outspecfile | 691 | cmd = cmd + " -bb " + outspecfile |
701 | 692 | ||
702 | # Build the rpm package! | 693 | # Build the rpm package! |