Fix pisi delta's not carrying file permission changes
This commit is contained in:
@@ -358,6 +358,13 @@ class Install(AtomicOperation):
|
|||||||
|
|
||||||
os.rename(oldconfig, path)
|
os.rename(oldconfig, path)
|
||||||
|
|
||||||
|
# Package file's path may not be relocated or content may not be changed but
|
||||||
|
# permission may be changed
|
||||||
|
def update_permissions():
|
||||||
|
permissions = pisi.operations.delta.find_permission_changes(self.old_files, self.files)
|
||||||
|
for path, mode in permissions:
|
||||||
|
os.chmod(path, mode)
|
||||||
|
|
||||||
# Delta package does not contain the files that have the same hash as in
|
# Delta package does not contain the files that have the same hash as in
|
||||||
# the old package's. Because it means the file has not changed. But some
|
# the old package's. Because it means the file has not changed. But some
|
||||||
# of these files may be relocated to some other directory in the new package.
|
# of these files may be relocated to some other directory in the new package.
|
||||||
@@ -411,6 +418,7 @@ class Install(AtomicOperation):
|
|||||||
|
|
||||||
if self.package_fname.endswith(ctx.const.delta_package_suffix):
|
if self.package_fname.endswith(ctx.const.delta_package_suffix):
|
||||||
relocate_files()
|
relocate_files()
|
||||||
|
update_permissions()
|
||||||
|
|
||||||
self.package.extract_install(ctx.config.dest_dir())
|
self.package.extract_install(ctx.config.dest_dir())
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
# Please read the COPYING file.
|
# Please read the COPYING file.
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
import stat
|
||||||
|
|
||||||
import gettext
|
import gettext
|
||||||
__trans = gettext.translation("pisi", fallback=True)
|
__trans = gettext.translation("pisi", fallback=True)
|
||||||
@@ -137,3 +138,22 @@ def find_relocations(oldfiles, newfiles):
|
|||||||
relocations.append((files_old[h][0], files_new[h][i]))
|
relocations.append((files_old[h][0], files_new[h][i]))
|
||||||
|
|
||||||
return relocations
|
return relocations
|
||||||
|
|
||||||
|
def find_permission_changes(oldfiles, newfiles):
|
||||||
|
|
||||||
|
files_new = {}
|
||||||
|
for f in newfiles.list:
|
||||||
|
files_new.setdefault(f.hash, []).append(f)
|
||||||
|
|
||||||
|
hashes_new = set(map(lambda f:f.hash, newfiles.list))
|
||||||
|
hashes_old = set(map(lambda f:f.hash, oldfiles.list))
|
||||||
|
unchanged = hashes_new.intersection(hashes_old)
|
||||||
|
|
||||||
|
permissions = []
|
||||||
|
for h in unchanged:
|
||||||
|
for _file in files_new[h]:
|
||||||
|
path = "/%s" % _file.path
|
||||||
|
if oct(stat.S_IMODE(os.stat(path)[stat.ST_MODE])) != _file.mode:
|
||||||
|
permissions.append((path, int(_file.mode, 8)))
|
||||||
|
|
||||||
|
return permissions
|
||||||
|
|||||||
Reference in New Issue
Block a user