Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: openembedded-core <openembedded-core@lists.openembedded.org>
Cc: ronan <ronan.lemartret@open.eurogiciel.org>,
	Ed Bartosh <eduard.bartosh@intel.com>
Subject: [PATCH] package_rpm: Add optional improved directory handling
Date: Fri, 29 Aug 2014 18:39:12 +0100	[thread overview]
Message-ID: <1409333952.29296.195.camel@ted> (raw)

From: Ronan Le Martret <ronan@fridu.net>

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.

[RP: Modified to allow optional usage of DIRFILES]
Signed-off-by: Ronan Le Martret <ronan@fridu.net>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>

diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index 0a32b3e..eecfcb2 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -185,7 +185,7 @@ python write_specfile () {
                 if not len(depends_dict[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
         # when packaging. We just ignore these files which are created in 
         # packages-split/ and not package/
@@ -196,11 +196,24 @@ python write_specfile () {
             path = rootpath.replace(walkpath, "")
             if path.endswith("DEBIAN") or path.endswith("CONTROL"):
                 continue
-            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 + '"')
+
+            # Directory handling can happen in two ways, either DIRFILES is not set at all
+            # in which case we fall back to the older behaviour of packages owning all their
+            # directories
+            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:
                 if file == "CONTROL" or file == "DEBIAN":
                     continue
@@ -311,6 +324,9 @@ python write_specfile () {
         bb.data.update_data(localdata)
 
         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)
 
@@ -367,7 +383,7 @@ python write_specfile () {
             srcrpostrm     = splitrpostrm
 
             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":
                 bb.note("Not creating empty RPM package for %s" % splitname)
             else:
@@ -474,7 +490,7 @@ python write_specfile () {
 
         # Now process files
         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":
             bb.note("Not creating empty RPM package for %s" % splitname)
         else:




             reply	other threads:[~2014-08-29 17:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-29 17:39 Richard Purdie [this message]
2014-08-29 18:36 ` [PATCH] package_rpm: Add optional improved directory handling Mark Hatle
2014-08-29 22:02   ` Richard Purdie
2014-08-29 22:13     ` Mark Hatle
2014-08-29 22:32       ` Richard Purdie
2014-08-30 13:35         ` Mark Hatle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1409333952.29296.195.camel@ted \
    --to=richard.purdie@linuxfoundation.org \
    --cc=eduard.bartosh@intel.com \
    --cc=openembedded-core@lists.openembedded.org \
    --cc=ronan.lemartret@open.eurogiciel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox