Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/pycpio/cpio/archive.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,23 +55,31 @@ def _update_inodes(self, entry):
if it's a hardlink, remove the data in the copy.
"""
if entry.header.ino in self.inodes:
self.logger.log(5, "[%s] Inode already exists: %s" % (entry.header.name, entry.header.ino))
# For regular files, check if the existing entry has the same data, if so, clear it before making a hardlink
if isinstance(entry, CPIO_File) and self[self.inodes[entry.header.ino][0]].data == entry.data:
self.logger.info("[%s] New hardlink detected, removing data." % entry.header.name)
# Remove the data from the current entry
entry.data = b""
# If it's a file, but has no data, it's already a hardlink
elif isinstance(entry, CPIO_File) and entry.data == b"":
self.logger.debug("[%s] Hardlink detected." % entry.header.name)
else:
from .common import get_new_inode

if entry.header.ino == 0 and not self.reproducible:
if entry.header.ino == 0 and not self.reproducible: # Warn for another inode of 0 for non-reproducible archives
self.logger.warning("[%s] Inode already exists: %s" % (entry.header.name, entry.header.ino))

old_inode = entry.header.ino
entry.header.ino = get_new_inode(self.inodes)
if self.reproducible:
self.logger.debug("[%s] Inode recalculated: %s" % (entry.header.name, entry.header.ino))
else:
self.logger.info("[%s] New inode: %s" % (entry.header.name, entry.header.ino))
# Create a new inode entry, clear the old one if it's empty
self.inodes[entry.header.ino] = []
if len(self.inodes[old_inode]) == 0:
del self.inodes[old_inode]
else:
self.inodes[entry.header.ino] = []
self.inodes[entry.header.ino].append(entry.header.name)
Expand Down