diff options
-rw-r--r-- | meta/classes/package_rpm.bbclass | 169 |
1 files changed, 104 insertions, 65 deletions
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass index 697bb365c5..3ac379d19a 100644 --- a/meta/classes/package_rpm.bbclass +++ b/meta/classes/package_rpm.bbclass | |||
@@ -8,6 +8,10 @@ RPMBUILD="rpmbuild" | |||
8 | PKGWRITEDIRRPM = "${WORKDIR}/deploy-rpms" | 8 | PKGWRITEDIRRPM = "${WORKDIR}/deploy-rpms" |
9 | PKGWRITEDIRSRPM = "${DEPLOY_DIR}/sources/deploy-srpm" | 9 | PKGWRITEDIRSRPM = "${DEPLOY_DIR}/sources/deploy-srpm" |
10 | 10 | ||
11 | # Maintaining the perfile dependencies has singificant overhead when writing the | ||
12 | # packages. When set, this value merges them for efficiency. | ||
13 | MERGEPERFILEDEPS = "1" | ||
14 | |||
11 | # | 15 | # |
12 | # Update the packages indexes ${DEPLOY_DIR_RPM} | 16 | # Update the packages indexes ${DEPLOY_DIR_RPM} |
13 | # | 17 | # |
@@ -460,6 +464,78 @@ EOF | |||
460 | fi | 464 | fi |
461 | } | 465 | } |
462 | 466 | ||
467 | # Construct per file dependencies file | ||
468 | def write_rpm_perfiledata(srcname, d): | ||
469 | workdir = d.getVar('WORKDIR', True) | ||
470 | packages = d.getVar('PACKAGES', True) | ||
471 | pkgd = d.getVar('PKGD', True) | ||
472 | |||
473 | def dump_filerdeps(varname, outfile, d): | ||
474 | outfile.write("#!/usr/bin/env python\n\n") | ||
475 | outfile.write("# Dependency table\n") | ||
476 | outfile.write('deps = {\n') | ||
477 | for pkg in packages.split(): | ||
478 | dependsflist_key = 'FILE' + varname + 'FLIST' + "_" + pkg | ||
479 | dependsflist = (d.getVar(dependsflist_key, True) or "") | ||
480 | for dfile in dependsflist.split(): | ||
481 | key = "FILE" + varname + "_" + dfile + "_" + pkg | ||
482 | depends_dict = bb.utils.explode_dep_versions(d.getVar(key, True) or "") | ||
483 | file = dfile.replace("@underscore@", "_") | ||
484 | file = file.replace("@closebrace@", "]") | ||
485 | file = file.replace("@openbrace@", "[") | ||
486 | file = file.replace("@tab@", "\t") | ||
487 | file = file.replace("@space@", " ") | ||
488 | file = file.replace("@at@", "@") | ||
489 | outfile.write('"' + pkgd + file + '" : "') | ||
490 | for dep in depends_dict: | ||
491 | ver = depends_dict[dep] | ||
492 | if dep and ver: | ||
493 | ver = ver.replace("(","") | ||
494 | ver = ver.replace(")","") | ||
495 | outfile.write(dep + " " + ver + " ") | ||
496 | else: | ||
497 | outfile.write(dep + " ") | ||
498 | outfile.write('",\n') | ||
499 | outfile.write('}\n\n') | ||
500 | outfile.write("import sys\n") | ||
501 | outfile.write("while 1:\n") | ||
502 | outfile.write("\tline = sys.stdin.readline().strip()\n") | ||
503 | outfile.write("\tif not line:\n") | ||
504 | outfile.write("\t\tsys.exit(0)\n") | ||
505 | outfile.write("\tif line in deps:\n") | ||
506 | outfile.write("\t\tprint(deps[line] + '\\n')\n") | ||
507 | |||
508 | # OE-core dependencies a.k.a. RPM requires | ||
509 | outdepends = workdir + "/" + srcname + ".requires" | ||
510 | |||
511 | try: | ||
512 | from __builtin__ import file | ||
513 | dependsfile = file(outdepends, 'w') | ||
514 | except OSError: | ||
515 | raise bb.build.FuncFailed("unable to open spec file for writing.") | ||
516 | |||
517 | dump_filerdeps('RDEPENDS', dependsfile, d) | ||
518 | |||
519 | dependsfile.close() | ||
520 | os.chmod(outdepends, 0755) | ||
521 | |||
522 | # OE-core / RPM Provides | ||
523 | outprovides = workdir + "/" + srcname + ".provides" | ||
524 | |||
525 | try: | ||
526 | from __builtin__ import file | ||
527 | providesfile = file(outprovides, 'w') | ||
528 | except OSError: | ||
529 | raise bb.build.FuncFailed("unable to open spec file for writing.") | ||
530 | |||
531 | dump_filerdeps('RPROVIDES', providesfile, d) | ||
532 | |||
533 | providesfile.close() | ||
534 | os.chmod(outprovides, 0755) | ||
535 | |||
536 | return (outdepends, outprovides) | ||
537 | |||
538 | |||
463 | python write_specfile () { | 539 | python write_specfile () { |
464 | import textwrap | 540 | import textwrap |
465 | import oe.packagedata | 541 | import oe.packagedata |
@@ -576,6 +652,17 @@ python write_specfile () { | |||
576 | scr = scr[:pos] + 'if [ "$1" = "0" ] ; then\n' + scr[pos:] + '\nfi' | 652 | scr = scr[:pos] + 'if [ "$1" = "0" ] ; then\n' + scr[pos:] + '\nfi' |
577 | return scr | 653 | return scr |
578 | 654 | ||
655 | def get_perfile(varname, pkg, d): | ||
656 | deps = [] | ||
657 | dependsflist_key = 'FILE' + varname + 'FLIST' + "_" + pkg | ||
658 | dependsflist = (d.getVar(dependsflist_key, True) or "") | ||
659 | for dfile in dependsflist.split(): | ||
660 | key = "FILE" + varname + "_" + dfile + "_" + pkg | ||
661 | depends = d.getVar(key, True) | ||
662 | if depends: | ||
663 | deps.append(depends) | ||
664 | return " ".join(deps) | ||
665 | |||
579 | packages = d.getVar('PACKAGES', True) | 666 | packages = d.getVar('PACKAGES', True) |
580 | if not packages or packages == '': | 667 | if not packages or packages == '': |
581 | bb.debug(1, "No packages; nothing to do") | 668 | bb.debug(1, "No packages; nothing to do") |
@@ -626,6 +713,8 @@ python write_specfile () { | |||
626 | spec_files_top = [] | 713 | spec_files_top = [] |
627 | spec_files_bottom = [] | 714 | spec_files_bottom = [] |
628 | 715 | ||
716 | perfiledeps = (d.getVar("MERGEPERFILEDEPS", True) or "0") == "0" | ||
717 | |||
629 | for pkg in packages.split(): | 718 | for pkg in packages.split(): |
630 | localdata = bb.data.createCopy(d) | 719 | localdata = bb.data.createCopy(d) |
631 | 720 | ||
@@ -679,6 +768,12 @@ python write_specfile () { | |||
679 | splitrprerm = localdata.getVar('pkg_prerm', True) | 768 | splitrprerm = localdata.getVar('pkg_prerm', True) |
680 | splitrpostrm = localdata.getVar('pkg_postrm', True) | 769 | splitrpostrm = localdata.getVar('pkg_postrm', True) |
681 | 770 | ||
771 | |||
772 | if not perfiledeps: | ||
773 | # Add in summary of per file dependencies | ||
774 | splitrdepends = splitrdepends + " " + get_perfile('RDEPENDS', pkg, d) | ||
775 | splitrprovides = splitrprovides + " " + get_perfile('RPROVIDES', pkg, d) | ||
776 | |||
682 | # Gather special src/first package data | 777 | # Gather special src/first package data |
683 | if srcname == splitname: | 778 | if srcname == splitname: |
684 | srcrdepends = splitrdepends | 779 | srcrdepends = splitrdepends |
@@ -977,69 +1072,9 @@ python do_package_rpm () { | |||
977 | d.setVar('OUTSPECFILE', outspecfile) | 1072 | d.setVar('OUTSPECFILE', outspecfile) |
978 | bb.build.exec_func('write_specfile', d) | 1073 | bb.build.exec_func('write_specfile', d) |
979 | 1074 | ||
980 | # Construct per file dependencies file | 1075 | perfiledeps = (d.getVar("MERGEPERFILEDEPS", True) or "0") == "0" |
981 | def dump_filerdeps(varname, outfile, d): | 1076 | if perfiledeps: |
982 | outfile.write("#!/usr/bin/env python\n\n") | 1077 | outdepends, outprovides = write_rpm_perfiledata(srcname, d) |
983 | outfile.write("# Dependency table\n") | ||
984 | outfile.write('deps = {\n') | ||
985 | for pkg in packages.split(): | ||
986 | dependsflist_key = 'FILE' + varname + 'FLIST' + "_" + pkg | ||
987 | dependsflist = (d.getVar(dependsflist_key, True) or "") | ||
988 | for dfile in dependsflist.split(): | ||
989 | key = "FILE" + varname + "_" + dfile + "_" + pkg | ||
990 | depends_dict = bb.utils.explode_dep_versions(d.getVar(key, True) or "") | ||
991 | file = dfile.replace("@underscore@", "_") | ||
992 | file = file.replace("@closebrace@", "]") | ||
993 | file = file.replace("@openbrace@", "[") | ||
994 | file = file.replace("@tab@", "\t") | ||
995 | file = file.replace("@space@", " ") | ||
996 | file = file.replace("@at@", "@") | ||
997 | outfile.write('"' + pkgd + file + '" : "') | ||
998 | for dep in depends_dict: | ||
999 | ver = depends_dict[dep] | ||
1000 | if dep and ver: | ||
1001 | ver = ver.replace("(","") | ||
1002 | ver = ver.replace(")","") | ||
1003 | outfile.write(dep + " " + ver + " ") | ||
1004 | else: | ||
1005 | outfile.write(dep + " ") | ||
1006 | outfile.write('",\n') | ||
1007 | outfile.write('}\n\n') | ||
1008 | outfile.write("import sys\n") | ||
1009 | outfile.write("while 1:\n") | ||
1010 | outfile.write("\tline = sys.stdin.readline().strip()\n") | ||
1011 | outfile.write("\tif not line:\n") | ||
1012 | outfile.write("\t\tsys.exit(0)\n") | ||
1013 | outfile.write("\tif line in deps:\n") | ||
1014 | outfile.write("\t\tprint(deps[line] + '\\n')\n") | ||
1015 | |||
1016 | # OE-core dependencies a.k.a. RPM requires | ||
1017 | outdepends = workdir + "/" + srcname + ".requires" | ||
1018 | |||
1019 | try: | ||
1020 | from __builtin__ import file | ||
1021 | dependsfile = file(outdepends, 'w') | ||
1022 | except OSError: | ||
1023 | raise bb.build.FuncFailed("unable to open spec file for writing.") | ||
1024 | |||
1025 | dump_filerdeps('RDEPENDS', dependsfile, d) | ||
1026 | |||
1027 | dependsfile.close() | ||
1028 | os.chmod(outdepends, 0755) | ||
1029 | |||
1030 | # OE-core / RPM Provides | ||
1031 | outprovides = workdir + "/" + srcname + ".provides" | ||
1032 | |||
1033 | try: | ||
1034 | from __builtin__ import file | ||
1035 | providesfile = file(outprovides, 'w') | ||
1036 | except OSError: | ||
1037 | raise bb.build.FuncFailed("unable to open spec file for writing.") | ||
1038 | |||
1039 | dump_filerdeps('RPROVIDES', providesfile, d) | ||
1040 | |||
1041 | providesfile.close() | ||
1042 | os.chmod(outprovides, 0755) | ||
1043 | 1078 | ||
1044 | # Setup the rpmbuild arguments... | 1079 | # Setup the rpmbuild arguments... |
1045 | rpmbuild = d.getVar('RPMBUILD', True) | 1080 | rpmbuild = d.getVar('RPMBUILD', True) |
@@ -1062,8 +1097,12 @@ python do_package_rpm () { | |||
1062 | cmd = cmd + " --define '_topdir " + workdir + "' --define '_rpmdir " + pkgwritedir + "'" | 1097 | cmd = cmd + " --define '_topdir " + workdir + "' --define '_rpmdir " + pkgwritedir + "'" |
1063 | cmd = cmd + " --define '_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'" | 1098 | cmd = cmd + " --define '_build_name_fmt %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm'" |
1064 | cmd = cmd + " --define '_use_internal_dependency_generator 0'" | 1099 | cmd = cmd + " --define '_use_internal_dependency_generator 0'" |
1065 | cmd = cmd + " --define '__find_requires " + outdepends + "'" | 1100 | if perfiledeps: |
1066 | cmd = cmd + " --define '__find_provides " + outprovides + "'" | 1101 | cmd = cmd + " --define '__find_requires " + outdepends + "'" |
1102 | cmd = cmd + " --define '__find_provides " + outprovides + "'" | ||
1103 | else: | ||
1104 | cmd = cmd + " --define '__find_requires %{nil}'" | ||
1105 | cmd = cmd + " --define '__find_provides %{nil}'" | ||
1067 | cmd = cmd + " --define '_unpackaged_files_terminate_build 0'" | 1106 | cmd = cmd + " --define '_unpackaged_files_terminate_build 0'" |
1068 | cmd = cmd + " --define 'debug_package %{nil}'" | 1107 | cmd = cmd + " --define 'debug_package %{nil}'" |
1069 | cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'" | 1108 | cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'" |