]> code.ossystems Code Review - openembedded-core.git/commitdiff
archiver.bbclass: fix the fakeroot and other issues
authorRobert Yang <liezhi.yang@windriver.com>
Wed, 22 Aug 2012 07:34:34 +0000 (15:34 +0800)
committerSaul Wold <sgw@linux.intel.com>
Tue, 28 Aug 2012 15:03:40 +0000 (08:03 -0700)
* Fix the fakeroot issue
  The archiver.bbclass is used for archiving sources, patches, and logs,
  it uses the "rpmbuild -bs" from the package_rpm.bbclass to generate the
  .src.rpm, but it didn't work (it's not easy to explain it clearly):

  Reason:
  - It directly used the "fakeroot" command, we don't have such a
    command in native tools, so it would use the fakeroot from the host,
    and it would fail when there is no fakeroot on the host.

  - The "rpmbuild -bs" doesn't need to work under root, but it is in the
    function do_package_write_rpm which is running under fakeroot, and
    "rpmbuild" needs to know the source file's user/group name, the source
    file is the tarball which is created by the postfuncs of do_unpack
    or do_patch which doesn't use the fakeroot, so the created file's
    owner would be the real user, e.g.: robert, but there is no such a
    user under our native tools' fakeroot(pseudo), then the rpmbuild would
    fail. It worked when use the host's fakeroot in the past was because
    that the host's fakeroot knows the users on the host.

  Fix:
  - Remove the incorrect "fakeroot".

  - Change the source file's owner to root.root under fakeroot will fix the
    problem.

* Other fixes:
  - The typo: "do_remove_taball -> do_remove_tarball" which will cause the
    tarball is not removed.

  - Add the _sourcedir defination to the rpmbuild command since the the
    SOURCES would be added to the specfile when archiver.bbclass is
    inherited, otherwise there would be errors when "rpmbuild -bb", though
    the build is OK. It only added the defination to "rpmbuild -bs",
    didn't add to "rpmbuild -bb".

[YOCTO #2619]

Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
meta/classes/archiver.bbclass
meta/classes/package_rpm.bbclass

index b01b0784cdcbcb0862360948d2cd1f4e1d23b44e..7056714bd7eafe84f7ed8eeed82ce74b38688ef7 100644 (file)
@@ -573,7 +573,7 @@ python do_remove_tarball(){
         except (TypeError, OSError):
             pass
 }
-do_remove_taball[deptask] = "do_archive_scripts_logs"
+do_remove_tarball[deptask] = "do_archive_scripts_logs"
 do_package_write_rpm[postfuncs] += "do_remove_tarball "
 export get_licenses
 export get_package
index 58a9aac7790ad8179281a239a2ccb01db3904289..b999c28a9b88e5c045c4e574e74e8f746be2e753 100644 (file)
@@ -585,11 +585,17 @@ python write_specfile () {
         if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM':
             source_number = 0
             patch_number = 0
+            workdir = d.getVar('WORKDIR', True)
             for source in source_list:
+                # The rpmbuild doesn't need the root permission, but it needs
+                # to know the file's user and group name, the only user and
+                # group in fakeroot is "root" when working in fakeroot.
+                os.chown("%s/%s" % (workdir, source), 0, 0)
                 spec_preamble_top.append('Source' + str(source_number) + ': %s' % source)
                 source_number += 1
             if patch_list:
                 for patch in patch_list:
+                    os.chown("%s/%s" % (workdir, patch), 0, 0)
                     print_deps(patch, "Patch" + str(patch_number), spec_preamble_top, d)
                     patch_number += 1
     # We need a simple way to remove the MLPREFIX from the package name,
@@ -1142,8 +1148,9 @@ python do_package_rpm () {
     cmd = cmd + " --define '_rpmfc_magic_path " + magicfile + "'"
     cmd = cmd + " --define '_tmppath " + workdir + "'"
     if d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True) and d.getVar('SOURCE_ARCHIVE_PACKAGE_TYPE', True).upper() == 'SRPM':
-        cmdsrpm = cmd + " --define '_sourcedir " + workdir + "' --define '_srcrpmdir " + creat_srpm_dir(d) + "'"
-        cmdsrpm = 'fakeroot ' + cmdsrpm + " -bs " + outspecfile
+        cmd = cmd + " --define '_sourcedir " + workdir + "'"
+        cmdsrpm = cmd + " --define '_srcrpmdir " + creat_srpm_dir(d) + "'"
+        cmdsrpm = cmdsrpm + " -bs " + outspecfile
     cmd = cmd + " -bb " + outspecfile
 
     # Build the source rpm package !