From 855afdff1d13af186d37f47ed22389fbf6d9480f Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Sun, 16 Feb 2014 13:20:50 +0100 Subject: [PATCH] [entropy.client.package] Do not alter repository package file directory permissions It was observed that the new locking mechanism introduced a problem with the management of repository package files (.tbz2 files passed to "equo install", for instance). Try to avoid that by symlinking the package file to a safe location and using this one as pkgpath. This fixes bug 4604. --- .../interfaces/package/actions/install.py | 33 ++++++++++++------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/entropy/client/interfaces/package/actions/install.py b/lib/entropy/client/interfaces/package/actions/install.py index fbbfca0d5..c821914d0 100644 --- a/lib/entropy/client/interfaces/package/actions/install.py +++ b/lib/entropy/client/interfaces/package/actions/install.py @@ -170,6 +170,16 @@ class _PackageInstallAction(_PackageInstallRemoveAction): metadata['affected_directories'] = set() metadata['affected_infofiles'] = set() + # craete an atomically safe unpack directory path + unpack_dir = os.path.join( + etpConst['entropyunpackdir'], + self._escape_path(metadata['atom']).lstrip(os.path.sep)) + try: + os.makedirs(unpack_dir, 0o755) + except OSError as err: + if err.errno != errno.EEXIST: + raise + metadata['smartpackage'] = False # set unpack dir and image dir if is_package_repo: @@ -187,22 +197,23 @@ class _PackageInstallAction(_PackageInstallRemoveAction): repo_data = self._settings['repositories'] repo_meta = repo_data['available'][self._repository_id] metadata['smartpackage'] = repo_meta['smartpackage'] - metadata['pkgpath'] = repo_meta['pkgpath'] + + # create a symlink into a generic entropy temp directory + # and reference the file from there. This will avoid + # Entropy locking code to change ownership and permissions + # of the directory containing the package file. + pkg_dir = const_mkdtemp(dir=unpack_dir, prefix="repository_pkgdir") + pkgpath = os.path.join( + pkg_dir, os.path.basename(repo_meta['pkgpath'])) + + os.symlink(repo_meta['pkgpath'], pkgpath) + + metadata['pkgpath'] = pkgpath else: metadata['pkgpath'] = self.get_standard_fetch_disk_path( metadata['download']) - # craete an atomically safe unpack directory path - unpack_dir = os.path.join( - etpConst['entropyunpackdir'], - self._escape_path(metadata['atom']).lstrip(os.path.sep)) - try: - os.makedirs(unpack_dir, 0o755) - except OSError as err: - if err.errno != errno.EEXIST: - raise - metadata['unpackdir'] = const_mkdtemp(dir=unpack_dir) metadata['imagedir'] = os.path.join(