1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-02 13:29:49 +00:00

package_rpm: Add optional improved directory handling

During spec generation, ideally directories should not be auto
packaged under the %file section of rpm packages but take ownership of
specific directories.

* packages only empty directories or explict directory.
   See:
       - http://www.rpm.org/max-rpm/s1-rpm-inside-files-list-directives.html
       - "The %dir Directive"

* This will prevent the overlapping of security permission.
   For example, in Tizen the directory /etc have smack label 'System::Shared'
   So Only one package should own and set the label of /etc to prevent
   the overwriting of the smack label.

Existing behaviour is maintained if DIRFILES is not set. If it is set,
the modified behaviour is used. If can be set to an empty value by
core recipes to trigger the modified behaviour.

[RP: Modified to allow optional usage of DIRFILES]
(From OE-Core rev: 0e33d232916125ba5305ced7200cc00f8b5f7b22)

Signed-off-by: Ronan Le Martret <ronan@fridu.net>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Ronan Le Martret
2014-08-29 18:39:12 +01:00
committed by Richard Purdie
parent 7b722c54e5
commit 2f42ef8d8f
+24 -8
View File
@@ -185,7 +185,7 @@ python write_specfile () {
if not len(depends_dict[dep]): if not len(depends_dict[dep]):
array.append("%s: %s" % (tag, dep)) array.append("%s: %s" % (tag, dep))
def walk_files(walkpath, target, conffiles): def walk_files(walkpath, target, conffiles, dirfiles):
# We can race against the ipk/deb backends which create CONTROL or DEBIAN directories # We can race against the ipk/deb backends which create CONTROL or DEBIAN directories
# when packaging. We just ignore these files which are created in # when packaging. We just ignore these files which are created in
# packages-split/ and not package/ # packages-split/ and not package/
@@ -196,11 +196,24 @@ python write_specfile () {
path = rootpath.replace(walkpath, "") path = rootpath.replace(walkpath, "")
if path.endswith("DEBIAN") or path.endswith("CONTROL"): if path.endswith("DEBIAN") or path.endswith("CONTROL"):
continue continue
for dir in dirs:
if dir == "CONTROL" or dir == "DEBIAN": # Directory handling can happen in two ways, either DIRFILES is not set at all
continue # in which case we fall back to the older behaviour of packages owning all their
# All packages own the directories their files are in... # directories
target.append('%dir "' + path + '/' + dir + '"') if dirfiles is None:
for dir in dirs:
if dir == "CONTROL" or dir == "DEBIAN":
continue
# All packages own the directories their files are in...
target.append('%dir "' + path + '/' + dir + '"')
else:
# packages own only empty directories or explict directory.
# This will prevent the overlapping of security permission.
if path and not files and not dirs:
target.append('%dir "' + path + '"')
elif path and path in dirfiles:
target.append('%dir "' + path + '"')
for file in files: for file in files:
if file == "CONTROL" or file == "DEBIAN": if file == "CONTROL" or file == "DEBIAN":
continue continue
@@ -312,6 +325,9 @@ python write_specfile () {
bb.data.update_data(localdata) bb.data.update_data(localdata)
conffiles = (localdata.getVar('CONFFILES', True) or "").split() conffiles = (localdata.getVar('CONFFILES', True) or "").split()
dirfiles = localdata.getVar('DIRFILES', True)
if dirfiles is not None:
dirfiles = dirfiles.split()
splitname = strip_multilib(pkgname, d) splitname = strip_multilib(pkgname, d)
@@ -368,7 +384,7 @@ python write_specfile () {
srcrpostrm = splitrpostrm srcrpostrm = splitrpostrm
file_list = [] file_list = []
walk_files(root, file_list, conffiles) walk_files(root, file_list, conffiles, dirfiles)
if not file_list and localdata.getVar('ALLOW_EMPTY') != "1": if not file_list and localdata.getVar('ALLOW_EMPTY') != "1":
bb.note("Not creating empty RPM package for %s" % splitname) bb.note("Not creating empty RPM package for %s" % splitname)
else: else:
@@ -477,7 +493,7 @@ python write_specfile () {
# Now process files # Now process files
file_list = [] file_list = []
walk_files(root, file_list, conffiles) walk_files(root, file_list, conffiles, dirfiles)
if not file_list and localdata.getVar('ALLOW_EMPTY') != "1": if not file_list and localdata.getVar('ALLOW_EMPTY') != "1":
bb.note("Not creating empty RPM package for %s" % splitname) bb.note("Not creating empty RPM package for %s" % splitname)
else: else: