Skip to content

Commit 8cd63f0

Browse files
igorpecovnikclaude
andcommitted
fix: remove conflicting pool files before publishing
When packages are rebuilt with the same version but different content, aptly fails to publish with "file already exists and is different" error. Fix: Before publishing, scan snapshots for packages and remove any existing pool files that match. This is safe because aptly will re-link the correct files during publish. This handles the case where: 1. Package v1 was built and published (pool has file A) 2. Package v1 was rebuilt with different content (isolated pool has file B) 3. Merge imports file B to main pool 4. Publish tries to link file B but file A already exists -> ERROR Now we remove file A before publishing, so file B can be linked cleanly. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent ea4a68a commit 8cd63f0

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

tools/repository/repo.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -935,6 +935,25 @@ merge_repos() {
935935

936936
# Publish with common component included
937937
log "Publishing $release with component list: $component_list"
938+
939+
# Before publishing, clean up any conflicting files in the pool
940+
# This can happen when packages are rebuilt with same version but different content
941+
local published_pool="${output_folder}/public/pool"
942+
if [[ -d "$published_pool" ]]; then
943+
log "Checking for conflicting pool files..."
944+
# Get list of packages that will be published and remove existing pool files
945+
# This is safe because aptly will re-link them during publish
946+
for snapshot in $snapshot_list; do
947+
aptly -config="$main_db_config" snapshot show "$snapshot" 2>/dev/null | grep -E "^\s+[a-z0-9]+:" | while read -r pkg_line; do
948+
# Parse package line: name_version_arch
949+
pkg_line=$(echo "$pkg_line" | xargs) # trim whitespace
950+
local pkg_name=$(echo "$pkg_line" | cut -d_ -f1)
951+
# Find and remove any existing pool files for this package
952+
find "$published_pool" -name "${pkg_name}_*.deb" -type f -delete 2>/dev/null || true
953+
done
954+
done
955+
fi
956+
938957
if ! run_aptly publish \
939958
-skip-signing \
940959
-skip-contents \

0 commit comments

Comments
 (0)