diff options
Diffstat (limited to 'meta/classes-global/package_rpm.bbclass')
-rw-r--r-- | meta/classes-global/package_rpm.bbclass | 62 |
1 files changed, 27 insertions, 35 deletions
diff --git a/meta/classes-global/package_rpm.bbclass b/meta/classes-global/package_rpm.bbclass index 2e3e4e8c79..f383ed140e 100644 --- a/meta/classes-global/package_rpm.bbclass +++ b/meta/classes-global/package_rpm.bbclass | |||
@@ -10,7 +10,7 @@ IMAGE_PKGTYPE ?= "rpm" | |||
10 | 10 | ||
11 | RPM = "rpm" | 11 | RPM = "rpm" |
12 | RPMBUILD = "rpmbuild" | 12 | RPMBUILD = "rpmbuild" |
13 | RPMBUILD_COMPMODE ?= "${@'w19T%d.zstdio' % int(d.getVar('ZSTD_THREADS'))}" | 13 | RPMBUILD_COMPMODE ?= "${@'w%dT%d.zstdio' % (int(d.getVar('ZSTD_COMPRESSION_LEVEL')), int(d.getVar('ZSTD_THREADS')))}" |
14 | 14 | ||
15 | PKGWRITEDIRRPM = "${WORKDIR}/deploy-rpms" | 15 | PKGWRITEDIRRPM = "${WORKDIR}/deploy-rpms" |
16 | 16 | ||
@@ -38,6 +38,7 @@ def filter_nativesdk_deps(srcname, var): | |||
38 | 38 | ||
39 | # Construct per file dependencies file | 39 | # Construct per file dependencies file |
40 | def write_rpm_perfiledata(srcname, d): | 40 | def write_rpm_perfiledata(srcname, d): |
41 | import oe.package | ||
41 | workdir = d.getVar('WORKDIR') | 42 | workdir = d.getVar('WORKDIR') |
42 | packages = d.getVar('PACKAGES') | 43 | packages = d.getVar('PACKAGES') |
43 | pkgd = d.getVar('PKGD') | 44 | pkgd = d.getVar('PKGD') |
@@ -53,12 +54,7 @@ def write_rpm_perfiledata(srcname, d): | |||
53 | key = "FILE" + varname + ":" + dfile + ":" + pkg | 54 | key = "FILE" + varname + ":" + dfile + ":" + pkg |
54 | deps = filter_nativesdk_deps(srcname, d.getVar(key) or "") | 55 | deps = filter_nativesdk_deps(srcname, d.getVar(key) or "") |
55 | depends_dict = bb.utils.explode_dep_versions(deps) | 56 | depends_dict = bb.utils.explode_dep_versions(deps) |
56 | file = dfile.replace("@underscore@", "_") | 57 | file = oe.package.file_reverse_translate(dfile) |
57 | file = file.replace("@closebrace@", "]") | ||
58 | file = file.replace("@openbrace@", "[") | ||
59 | file = file.replace("@tab@", "\t") | ||
60 | file = file.replace("@space@", " ") | ||
61 | file = file.replace("@at@", "@") | ||
62 | outfile.write('"' + pkgd + file + '" : "') | 58 | outfile.write('"' + pkgd + file + '" : "') |
63 | for dep in depends_dict: | 59 | for dep in depends_dict: |
64 | ver = depends_dict[dep] | 60 | ver = depends_dict[dep] |
@@ -108,7 +104,7 @@ python write_specfile () { | |||
108 | # append information for logs and patches to %prep | 104 | # append information for logs and patches to %prep |
109 | def add_prep(d, spec_files_bottom): | 105 | def add_prep(d, spec_files_bottom): |
110 | if d.getVarFlag('ARCHIVER_MODE', 'srpm') == '1' and bb.data.inherits_class('archiver', d): | 106 | if d.getVarFlag('ARCHIVER_MODE', 'srpm') == '1' and bb.data.inherits_class('archiver', d): |
111 | spec_files_bottom.append('%%prep -n %s' % d.getVar('PN')) | 107 | spec_files_bottom.append('%%prep') |
112 | spec_files_bottom.append('%s' % "echo \"include logs and patches, Please check them in SOURCES\"") | 108 | spec_files_bottom.append('%s' % "echo \"include logs and patches, Please check them in SOURCES\"") |
113 | spec_files_bottom.append('') | 109 | spec_files_bottom.append('') |
114 | 110 | ||
@@ -191,7 +187,7 @@ python write_specfile () { | |||
191 | if not len(depends_dict[dep]): | 187 | if not len(depends_dict[dep]): |
192 | array.append("%s: %s" % (tag, dep)) | 188 | array.append("%s: %s" % (tag, dep)) |
193 | 189 | ||
194 | def walk_files(walkpath, target, conffiles, dirfiles): | 190 | def walk_files(walkpath, target, conffiles): |
195 | # We can race against the ipk/deb backends which create CONTROL or DEBIAN directories | 191 | # We can race against the ipk/deb backends which create CONTROL or DEBIAN directories |
196 | # when packaging. We just ignore these files which are created in | 192 | # when packaging. We just ignore these files which are created in |
197 | # packages-split/ and not package/ | 193 | # packages-split/ and not package/ |
@@ -205,14 +201,22 @@ python write_specfile () { | |||
205 | try: | 201 | try: |
206 | owner = pwd.getpwuid(stat_f.st_uid).pw_name | 202 | owner = pwd.getpwuid(stat_f.st_uid).pw_name |
207 | except Exception as e: | 203 | except Exception as e: |
208 | bb.error("Content of /etc/passwd in sysroot:\n{}".format( | 204 | filename = d.getVar('RECIPE_SYSROOT') + '/etc/passwd' |
209 | open(d.getVar("RECIPE_SYSROOT") +"/etc/passwd").read())) | 205 | if os.path.exists(filename): |
206 | bb.error("Content of /etc/passwd in sysroot:\n{}".format( | ||
207 | open(filename).read())) | ||
208 | else: | ||
209 | bb.error("File {} doesn't exist in sysroot!".format(filename)) | ||
210 | raise e | 210 | raise e |
211 | try: | 211 | try: |
212 | group = grp.getgrgid(stat_f.st_gid).gr_name | 212 | group = grp.getgrgid(stat_f.st_gid).gr_name |
213 | except Exception as e: | 213 | except Exception as e: |
214 | bb.error("Content of /etc/group in sysroot:\n{}".format( | 214 | filename = d.getVar("RECIPE_SYSROOT") +"/etc/group" |
215 | open(d.getVar("RECIPE_SYSROOT") +"/etc/group").read())) | 215 | if os.path.exists(filename): |
216 | bb.error("Content of /etc/group in sysroot:\n{}".format( | ||
217 | open(filename).read())) | ||
218 | else: | ||
219 | bb.error("File {} doesn't exists in sysroot!".format(filename)) | ||
216 | raise e | 220 | raise e |
217 | return "%attr({:o},{},{}) ".format(mode, owner, group) | 221 | return "%attr({:o},{},{}) ".format(mode, owner, group) |
218 | 222 | ||
@@ -233,22 +237,12 @@ python write_specfile () { | |||
233 | return False | 237 | return False |
234 | dirs[:] = [dir for dir in dirs if not move_to_files(dir)] | 238 | dirs[:] = [dir for dir in dirs if not move_to_files(dir)] |
235 | 239 | ||
236 | # Directory handling can happen in two ways, either DIRFILES is not set at all | 240 | for dir in dirs: |
237 | # in which case we fall back to the older behaviour of packages owning all their | 241 | if dir == "CONTROL" or dir == "DEBIAN": |
238 | # directories | 242 | continue |
239 | if dirfiles is None: | 243 | p = path + '/' + dir |
240 | for dir in dirs: | 244 | # All packages own the directories their files are in... |
241 | if dir == "CONTROL" or dir == "DEBIAN": | 245 | target.append(get_attr(dir) + '%dir "' + escape_chars(p) + '"') |
242 | continue | ||
243 | p = path + '/' + dir | ||
244 | # All packages own the directories their files are in... | ||
245 | target.append(get_attr(dir) + '%dir "' + escape_chars(p) + '"') | ||
246 | elif path: | ||
247 | # packages own only empty directories or explict directory. | ||
248 | # This will prevent the overlapping of security permission. | ||
249 | attr = get_attr(path) | ||
250 | if (not files and not dirs) or path in dirfiles: | ||
251 | target.append(attr + '%dir "' + escape_chars(path) + '"') | ||
252 | 246 | ||
253 | for file in files: | 247 | for file in files: |
254 | if file == "CONTROL" or file == "DEBIAN": | 248 | if file == "CONTROL" or file == "DEBIAN": |
@@ -363,9 +357,6 @@ python write_specfile () { | |||
363 | localdata.setVar('OVERRIDES', d.getVar("OVERRIDES", False) + ":" + pkg) | 357 | localdata.setVar('OVERRIDES', d.getVar("OVERRIDES", False) + ":" + pkg) |
364 | 358 | ||
365 | conffiles = oe.package.get_conffiles(pkg, d) | 359 | conffiles = oe.package.get_conffiles(pkg, d) |
366 | dirfiles = localdata.getVar('DIRFILES') | ||
367 | if dirfiles is not None: | ||
368 | dirfiles = dirfiles.split() | ||
369 | 360 | ||
370 | splitname = pkgname | 361 | splitname = pkgname |
371 | 362 | ||
@@ -430,7 +421,7 @@ python write_specfile () { | |||
430 | srcrpostrm = splitrpostrm | 421 | srcrpostrm = splitrpostrm |
431 | 422 | ||
432 | file_list = [] | 423 | file_list = [] |
433 | walk_files(root, file_list, conffiles, dirfiles) | 424 | walk_files(root, file_list, conffiles) |
434 | if not file_list and localdata.getVar('ALLOW_EMPTY', False) != "1": | 425 | if not file_list and localdata.getVar('ALLOW_EMPTY', False) != "1": |
435 | bb.note("Not creating empty RPM package for %s" % splitname) | 426 | bb.note("Not creating empty RPM package for %s" % splitname) |
436 | else: | 427 | else: |
@@ -522,7 +513,7 @@ python write_specfile () { | |||
522 | 513 | ||
523 | # Now process files | 514 | # Now process files |
524 | file_list = [] | 515 | file_list = [] |
525 | walk_files(root, file_list, conffiles, dirfiles) | 516 | walk_files(root, file_list, conffiles) |
526 | if not file_list and localdata.getVar('ALLOW_EMPTY', False) != "1": | 517 | if not file_list and localdata.getVar('ALLOW_EMPTY', False) != "1": |
527 | bb.note("Not creating empty RPM package for %s" % splitname) | 518 | bb.note("Not creating empty RPM package for %s" % splitname) |
528 | else: | 519 | else: |
@@ -705,9 +696,10 @@ python do_package_rpm () { | |||
705 | cmd = cmd + " --define '_use_internal_dependency_generator 0'" | 696 | cmd = cmd + " --define '_use_internal_dependency_generator 0'" |
706 | cmd = cmd + " --define '_binaries_in_noarch_packages_terminate_build 0'" | 697 | cmd = cmd + " --define '_binaries_in_noarch_packages_terminate_build 0'" |
707 | cmd = cmd + " --define '_build_id_links none'" | 698 | cmd = cmd + " --define '_build_id_links none'" |
699 | cmd = cmd + " --define '_smp_ncpus_max 4'" | ||
708 | cmd = cmd + " --define '_source_payload %s'" % rpmbuild_compmode | 700 | cmd = cmd + " --define '_source_payload %s'" % rpmbuild_compmode |
709 | cmd = cmd + " --define '_binary_payload %s'" % rpmbuild_compmode | 701 | cmd = cmd + " --define '_binary_payload %s'" % rpmbuild_compmode |
710 | cmd = cmd + " --define 'clamp_mtime_to_source_date_epoch 1'" | 702 | cmd = cmd + " --define 'build_mtime_policy clamp_to_source_date_epoch'" |
711 | cmd = cmd + " --define 'use_source_date_epoch_as_buildtime 1'" | 703 | cmd = cmd + " --define 'use_source_date_epoch_as_buildtime 1'" |
712 | cmd = cmd + " --define '_buildhost reproducible'" | 704 | cmd = cmd + " --define '_buildhost reproducible'" |
713 | cmd = cmd + " --define '__font_provides %{nil}'" | 705 | cmd = cmd + " --define '__font_provides %{nil}'" |