Skip to contentSkip to conversation

package_manager: Create variable for install_dir_name

PATCH Superseded Saul Wold 2 participants 2 messages Mar 16, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Saul Wold

author
#0 lore raw

PATCH 1/1 package_manager: Create variable for install_dir_name

This patch creates a variable for the install_dir name so it can be something other than /install, also by doing this we can correctly clean up the empty directories (/install/tmp) during the clean-up phase. The new default is /oe_install so as to not conflict with other possible packages that might use /install to place files.

[YOCTO #7353]

---
 meta/lib/oe/package_manager.py | 15 ++++++++-------
 meta/lib/oe/rootfs.py          |  5 ++++-
 2 files changed, 12 insertions(+), 8 deletions(-)
meta/lib/oe/package_manager.py +8 -7
index 69bef1d..63bce27 100644
@@ -578,7 +578,8 @@ class RpmPM(PackageManager):
         self.fullpkglist = list()
         self.deploy_dir = self.d.getVar('DEPLOY_DIR_RPM', True)
         self.etcrpm_dir = os.path.join(self.target_rootfs, "etc/rpm")
-        self.install_dir = os.path.join(self.target_rootfs, "install")
+        self.install_dir_name = os.path.join("oe_install")
+        self.install_dir_path = os.path.join(self.target_rootfs, self.install_dir_name)
         self.rpm_cmd = bb.utils.which(os.getenv('PATH'), "rpm")
         self.smart_cmd = bb.utils.which(os.getenv('PATH'), "smart")
         self.smart_opt = "--quiet --data-dir=" + os.path.join(target_rootfs,
@@ -749,9 +750,9 @@ class RpmPM(PackageManager):
         bb.utils.mkdirhier(self.etcrpm_dir)
 
         # Setup temporary directory -- install...
-        if os.path.exists(self.install_dir):
-            bb.utils.remove(self.install_dir, True)
-        bb.utils.mkdirhier(os.path.join(self.install_dir, 'tmp'))
+        if os.path.exists(self.install_dir_path):
+            bb.utils.remove(self.install_dir_path, True)
+        bb.utils.mkdirhier(os.path.join(self.install_dir_path, 'tmp'))
 
         channel_priority = 5
         platform_dir = os.path.join(self.etcrpm_dir, "platform")
@@ -838,7 +839,7 @@ class RpmPM(PackageManager):
         self._invoke_smart('config --set rpm-dbpath=/var/lib/rpm')
         self._invoke_smart('config --set rpm-extra-macros._var=%s' %
                            self.d.getVar('localstatedir', True))
-        cmd = 'config --set rpm-extra-macros._tmppath=/install/tmp'
+        cmd = "config --set rpm-extra-macros._tmppath=/%s/tmp" % (self.install_dir_name)
 
         prefer_color = self.d.getVar('RPM_PREFER_ELF_ARCH', True)
         if prefer_color:
@@ -992,7 +993,7 @@ class RpmPM(PackageManager):
             cmd += "--dbpath=/var/lib/rpm "
             cmd += "--define='_cross_scriptlet_wrapper %s' " % \
                    self.scriptlet_wrapper
-            cmd += "--define='_tmppath /install/tmp' %s" % ' '.join(pkgs)
+            cmd += "--define='_tmppath /%s/tmp' %s" % (self.install_dir_name, ' '.join(pkgs))
         else:
             # for pkg in pkgs:
             #   bb.note('Debug: What required: %s' % pkg)
@@ -1027,7 +1028,7 @@ class RpmPM(PackageManager):
         bb.utils.remove(os.path.join(self.target_rootfs, 'var/lib/opkg'), True)
 
         # remove temp directory
-        bb.utils.remove(self.d.expand('${IMAGE_ROOTFS}/install'), True)
+        bb.utils.remove(self.d.expand('${IMAGE_ROOTFS}/%s' % (self.install_dir_name)), True)
 
     def backup_packaging_data(self):
         # Save the rpmlib for increment rpm image generation
meta/lib/oe/rootfs.py +4 -1
index dd7aa44..9493d22b 100644
@@ -409,7 +409,10 @@ class RpmRootfs(Rootfs):
         # __db.00* (Berkeley DB files that hold locks, rpm specific environment
         # settings, etc.), that should not get into the final rootfs
         self.pm.unlock_rpm_db()
-        bb.utils.remove(self.image_rootfs + "/install", True)
+        if os.path.isdir(self.pm.install_dir_path + "/tmp") and not os.listdir(self.pm.install_dir_path + "/tmp"):
+           bb.utils.remove(self.pm.install_dir_path + "/tmp", True)
+        if os.path.isdir(self.pm.install_dir_path) and not os.listdir(self.pm.install_dir_path):
+           bb.utils.remove(self.pm.install_dir_path, True)
 
 
 class DpkgRootfs(Rootfs):
Signature · 1 line
2.1.0
#1 lore raw

Hi Saul,

A couple of minor things:

Quoted 19 lines · On Sunday 15 March 2015 22:32:57 Saul Wold wrote:

This patch creates a variable for the install_dir name so it can be something other than /install, also by doing this we can correctly clean up the empty directories (/install/tmp) during the clean-up phase. The new default is /oe_install so as to not conflict with other possible packages that might use /install to place files.

[YOCTO #7353]

---
 meta/lib/oe/package_manager.py | 15 ++++++++-------
 meta/lib/oe/rootfs.py          |  5 ++++-
 2 files changed, 12 insertions(+), 8 deletions(-)
meta/lib/oe/package_manager.py +0 -0
index 69bef1d..63bce27 100644

meta/lib/oe/package_manager.py class RpmPM(PackageManager): · line 581

Quoted 5 lines
meta/lib/oe/package_manager.py +1 -1
@@ -578,7 +578,8 @@ class RpmPM(PackageManager):
         self.fullpkglist = list()
         self.deploy_dir = self.d.getVar('DEPLOY_DIR_RPM', True)
         self.etcrpm_dir = os.path.join(self.target_rootfs, "etc/rpm")
-        self.install_dir = os.path.join(self.target_rootfs, "install")
+        self.install_dir_name = os.path.join("oe_install")

You aren't joining anything, best to just set the variable outright surely?

Quoted 39 lines
meta/lib/oe/package_manager.py +1 -0
+        self.install_dir_path = os.path.join(self.target_rootfs,
 self.install_dir_name) self.rpm_cmd = bb.utils.which(os.getenv('PATH'),
 "rpm")
         self.smart_cmd = bb.utils.which(os.getenv('PATH'), "smart")
         self.smart_opt = "--quiet --data-dir=" +

os.path.join(target_rootfs, @@ -749,9 +750,9 @@ class RpmPM(PackageManager):
bb.utils.mkdirhier(self.etcrpm_dir)

# Setup temporary directory -- install...

meta/lib/oe/package_manager.py +4 -4
-        if os.path.exists(self.install_dir):
-            bb.utils.remove(self.install_dir, True)
-        bb.utils.mkdirhier(os.path.join(self.install_dir, 'tmp'))
+        if os.path.exists(self.install_dir_path):
+            bb.utils.remove(self.install_dir_path, True)
+        bb.utils.mkdirhier(os.path.join(self.install_dir_path, 'tmp'))
 
         channel_priority = 5
         platform_dir = os.path.join(self.etcrpm_dir, "platform")
@@ -838,7 +839,7 @@ class RpmPM(PackageManager):
         self._invoke_smart('config --set rpm-dbpath=/var/lib/rpm')
         self._invoke_smart('config --set rpm-extra-macros._var=%s' %
                            self.d.getVar('localstatedir', True))
-        cmd = 'config --set rpm-extra-macros._tmppath=/install/tmp'
+        cmd = "config --set rpm-extra-macros._tmppath=/%s/tmp" %
 (self.install_dir_name)
 
         prefer_color = self.d.getVar('RPM_PREFER_ELF_ARCH', True)

if prefer_color:

meta/lib/oe/package_manager.py +1 -1
@@ -992,7 +993,7 @@ class RpmPM(PackageManager):
             cmd += "--dbpath=/var/lib/rpm "
             cmd += "--define='_cross_scriptlet_wrapper %s' " % \
                    self.scriptlet_wrapper
-            cmd += "--define='_tmppath /install/tmp' %s" % ' '.join(pkgs)
+            cmd += "--define='_tmppath /%s/tmp' %s" %

(self.install_dir_name, ' '.join(pkgs)) else:

             # for pkg in pkgs:
             #   bb.note('Debug: What required: %s' % pkg)

meta/lib/oe/package_manager.py class RpmPM(PackageManager): · line 1033

Quoted 7 lines
meta/lib/oe/package_manager.py +1 -1
@@ -1027,7 +1028,7 @@ class RpmPM(PackageManager):
         bb.utils.remove(os.path.join(self.target_rootfs, 'var/lib/opkg'),
 True)
 
         # remove temp directory
-        bb.utils.remove(self.d.expand('${IMAGE_ROOTFS}/install'), True)
+        bb.utils.remove(self.d.expand('${IMAGE_ROOTFS}/%s' %
 (self.install_dir_name)), True)

Obviously you're just following existing code, but shouldn't we just use self.install_dir_path here?

Quoted 20 lines
meta/lib/oe/package_manager.py +0 -0
     def backup_packaging_data(self):

# Save the rpmlib for increment rpm image generation

meta/lib/oe/rootfs.py +0 -0
index dd7aa44..9493d22b 100644
@@ -409,7 +409,10 @@ class RpmRootfs(Rootfs):
         # __db.00* (Berkeley DB files that hold locks, rpm specific

environment # settings, etc.), that should not get into the final rootfs self.pm.unlock_rpm_db()

meta/lib/oe/rootfs.py +1 -1
-        bb.utils.remove(self.image_rootfs + "/install", True)
+        if os.path.isdir(self.pm.install_dir_path + "/tmp") and not

os.listdir(self.pm.install_dir_path + "/tmp"): +
bb.utils.remove(self.pm.install_dir_path + "/tmp", True) + if
os.path.isdir(self.pm.install_dir_path) and not
os.listdir(self.pm.install_dir_path): +
bb.utils.remove(self.pm.install_dir_path, True)

Quoted 1 line

class DpkgRootfs(Rootfs):

Cheers,
Paul

Signature · 2 lines
Paul Eggleton
Intel Open Source Technology Centre