diff options
author | Xiaofeng Yan <xiaofeng.yan@windriver.com> | 2012-03-26 18:49:23 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-03-26 23:13:20 +0100 |
commit | 6a99e0f8fbb5c7a411da2e4b724c43f28e6fa0c1 (patch) | |
tree | e2593bcddfd9b156f54131684f98eda5f55d4abc /meta/classes/package_rpm.bbclass | |
parent | b711d7b631accaac238b68cfd5bd44995382fc72 (diff) | |
download | poky-6a99e0f8fbb5c7a411da2e4b724c43f28e6fa0c1.tar.gz |
package_rpm: Add srpm function to this bbclass
Add a new function to archive source, patches and logs to a source rpm
package. Every source rpm package will be deployed to
${DEPLOY_DIR}/sources/deploy-srpm
[YOCTO #1977]
(From OE-Core rev: be2db850fbe516b92a3991a5eaf646c4a2b8a1b9)
Signed-off-by: Xiaofeng Yan <xiaofeng.yan@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package_rpm.bbclass')
-rw-r--r-- | meta/classes/package_rpm.bbclass | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass index 8c8d967741..0ccf574850 100644 --- a/meta/classes/package_rpm.bbclass +++ b/meta/classes/package_rpm.bbclass | |||
@@ -6,6 +6,7 @@ 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" | ||
9 | 10 | ||
10 | python package_rpm_fn () { | 11 | python package_rpm_fn () { |
11 | d.setVar('PKGFN', d.getVar('PKG')) | 12 | d.setVar('PKGFN', d.getVar('PKG')) |
@@ -481,6 +482,30 @@ python write_specfile () { | |||
481 | import textwrap | 482 | import textwrap |
482 | import oe.packagedata | 483 | import oe.packagedata |
483 | 484 | ||
485 | # append information for logs and patches to %prep | ||
486 | def add_prep(d,spec_files_bottom): | ||
487 | if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': | ||
488 | spec_files_bottom.append('%%prep -n %s' % d.getVar('PN', True) ) | ||
489 | spec_files_bottom.append('%s' % "echo \"include logs and patches, Please check them in SOURCES\"") | ||
490 | spec_files_bottom.append('') | ||
491 | |||
492 | # get the name of tarball for sources, patches and logs | ||
493 | def get_tarballs(d): | ||
494 | if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': | ||
495 | return get_package(d) | ||
496 | |||
497 | # append the name of tarball to key word 'SOURCE' in xxx.spec. | ||
498 | def tail_source(d,source_list=[],patch_list=None): | ||
499 | if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': | ||
500 | source_number = 0 | ||
501 | patch_number = 0 | ||
502 | for source in source_list: | ||
503 | spec_preamble_top.append('Source' + str(source_number) + ': %s' % source) | ||
504 | source_number += 1 | ||
505 | if patch_list: | ||
506 | for patch in patch_list: | ||
507 | print_deps(patch, "Patch" + str(patch_number), spec_preamble_top, d) | ||
508 | patch_number += 1 | ||
484 | # We need a simple way to remove the MLPREFIX from the package name, | 509 | # We need a simple way to remove the MLPREFIX from the package name, |
485 | # and dependency information... | 510 | # and dependency information... |
486 | def strip_multilib(name, d): | 511 | def strip_multilib(name, d): |
@@ -791,7 +816,8 @@ python write_specfile () { | |||
791 | 816 | ||
792 | del localdata | 817 | del localdata |
793 | bb.utils.unlockfile(lf) | 818 | bb.utils.unlockfile(lf) |
794 | 819 | ||
820 | add_prep(d,spec_files_bottom) | ||
795 | spec_preamble_top.append('Summary: %s' % srcsummary) | 821 | spec_preamble_top.append('Summary: %s' % srcsummary) |
796 | spec_preamble_top.append('Name: %s' % srcname) | 822 | spec_preamble_top.append('Name: %s' % srcname) |
797 | spec_preamble_top.append('Version: %s' % srcversion) | 823 | spec_preamble_top.append('Version: %s' % srcversion) |
@@ -802,6 +828,8 @@ python write_specfile () { | |||
802 | spec_preamble_top.append('Group: %s' % srcsection) | 828 | spec_preamble_top.append('Group: %s' % srcsection) |
803 | spec_preamble_top.append('Packager: %s' % srcmaintainer) | 829 | spec_preamble_top.append('Packager: %s' % srcmaintainer) |
804 | spec_preamble_top.append('URL: %s' % srchomepage) | 830 | spec_preamble_top.append('URL: %s' % srchomepage) |
831 | source_list = get_tarballs(d) | ||
832 | tail_source(d,source_list,None) | ||
805 | 833 | ||
806 | # Replaces == Obsoletes && Provides | 834 | # Replaces == Obsoletes && Provides |
807 | if srcrreplaces and srcrreplaces.strip() != "": | 835 | if srcrreplaces and srcrreplaces.strip() != "": |
@@ -823,7 +851,7 @@ python write_specfile () { | |||
823 | print_deps(srcrsuggests, "Recommends", spec_preamble_top, d) | 851 | print_deps(srcrsuggests, "Recommends", spec_preamble_top, d) |
824 | print_deps(srcrprovides, "Provides", spec_preamble_top, d) | 852 | print_deps(srcrprovides, "Provides", spec_preamble_top, d) |
825 | print_deps(srcrobsoletes, "Obsoletes", spec_preamble_top, d) | 853 | print_deps(srcrobsoletes, "Obsoletes", spec_preamble_top, d) |
826 | 854 | ||
827 | # conflicts can not be in a provide! We will need to filter it. | 855 | # conflicts can not be in a provide! We will need to filter it. |
828 | if srcrconflicts: | 856 | if srcrconflicts: |
829 | depends_dict = bb.utils.explode_dep_versions(srcrconflicts) | 857 | depends_dict = bb.utils.explode_dep_versions(srcrconflicts) |
@@ -905,7 +933,16 @@ python write_specfile () { | |||
905 | 933 | ||
906 | python do_package_rpm () { | 934 | python do_package_rpm () { |
907 | import os | 935 | import os |
908 | 936 | ||
937 | def creat_srpm_dir(d): | ||
938 | if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': | ||
939 | clean_licenses = get_licenses(d) | ||
940 | pkgwritesrpmdir = bb.data.expand('${PKGWRITEDIRSRPM}/${PACKAGE_ARCH_EXTEND}', d) | ||
941 | pkgwritesrpmdir = pkgwritesrpmdir + '/' + clean_licenses | ||
942 | bb.mkdirhier(pkgwritesrpmdir) | ||
943 | os.chmod(pkgwritesrpmdir, 0755) | ||
944 | return pkgwritesrpmdir | ||
945 | |||
909 | # We need a simple way to remove the MLPREFIX from the package name, | 946 | # We need a simple way to remove the MLPREFIX from the package name, |
910 | # and dependency information... | 947 | # and dependency information... |
911 | def strip_multilib(name, d): | 948 | def strip_multilib(name, d): |
@@ -1021,8 +1058,18 @@ python do_package_rpm () { | |||
1021 | cmd = cmd + " --define 'debug_package %{nil}'" | 1058 | cmd = cmd + " --define 'debug_package %{nil}'" |
1022 | cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'" | 1059 | cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'" |
1023 | cmd = cmd + " --define '_tmppath " + workdir + "'" | 1060 | cmd = cmd + " --define '_tmppath " + workdir + "'" |
1061 | if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': | ||
1062 | cmdsrpm = cmd + " --define '_sourcedir " + workdir + "' --define '_srcrpmdir " + creat_srpm_dir(d) + "'" | ||
1063 | cmdsrpm = 'fakeroot ' + cmdsrpm + " -bs " + outspecfile | ||
1024 | cmd = cmd + " -bb " + outspecfile | 1064 | cmd = cmd + " -bb " + outspecfile |
1025 | 1065 | ||
1066 | # Build the source rpm package ! | ||
1067 | if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM': | ||
1068 | d.setVar('SBUILDSPEC', cmdsrpm + "\n") | ||
1069 | d.setVarFlag('SBUILDSPEC', 'func', '1') | ||
1070 | bb.build.exec_func('SBUILDSPEC', d) | ||
1071 | |||
1072 | |||
1026 | # Build the rpm package! | 1073 | # Build the rpm package! |
1027 | d.setVar('BUILDSPEC', cmd + "\n") | 1074 | d.setVar('BUILDSPEC', cmd + "\n") |
1028 | d.setVarFlag('BUILDSPEC', 'func', '1') | 1075 | d.setVarFlag('BUILDSPEC', 'func', '1') |