Skip to contentSkip to conversation

package_deb: Avoid chdir warnings and restore cwd after packaging

PATCH New Richard Purdie 1 participant 1 message Jun 16, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package_deb: Avoid chdir warnings and restore cwd after packaging

dpkg-build needs to be executed in the root of the package, so save and restore the current directory so this task doesn't modify the state.

meta/classes/package_deb.bbclass +3 -0
index e35f427..8f9b09a 100644
@@ -53,6 +53,8 @@ python do_package_deb () {
     import textwrap
     import subprocess
 
+    oldcwd = os.getcwd()
+
     workdir = d.getVar('WORKDIR', True)
     if not workdir:
         bb.error("WORKDIR not defined, unable to package")
@@ -311,6 +313,7 @@ python do_package_deb () {
 
         cleanupcontrol(root)
         bb.utils.unlockfile(lf)
+    os.chdir(oldcwd)
 }
 # Indirect references to these vars
 do_package_write_deb[vardeps] += "PKGV PKGR PKGV DESCRIPTION SECTION PRIORITY MAINTAINER DPKG_ARCH PN HOMEPAGE"