Skip to content

Commit

Permalink
fix(debian): fix multiple files for quick-lint-js-vim package
Browse files Browse the repository at this point in the history
Since adding arm64 builds to our Debian repository, we have two files
containing the quick-lint-js-vim package. For example:

* https://c.quick-lint-js.com/debian/pool/2.15.0/amd64/quick-lint-js-vim_2.15.0-1_all.deb
* https://c.quick-lint-js.com/debian/pool/2.15.0/arm64/quick-lint-js-vim_2.15.0-1_all.deb

These two files are logically equivalent, but there are differences in
their bit patterns (specifically different timestamps). (In the future
there might be other differences too, but I hope not.)

Refactor the pool to avoid having two different copies of the same
logical package.

Prior to this patch, the pool looks like this:

    debian/pool/
      $(VERSION)/
        # quick-lint-js versions since 2.14.0:
        $(ARCH)/
          quick-lint-js_$(VERSION).orig.tar.gz    # source package
          quick-lint-js_$(VERSION)-1.dsc          # source package
          quick-lint-js_$(VERSION)-1_$(ARCH).deb  # arch-dependent package
          quick-lint-js-vim_$(VERSION)-1_all.deb  # arch-independent package
        # quick-lint-js versions prior to 2.14.0 (no $(ARCH) directory):
        quick-lint-js_$(VERSION).orig.tar.gz      # source package
        quick-lint-js_$(VERSION)-1.dsc            # source package
        quick-lint-js_$(VERSION)-1_$(ARCH).deb    # arch-dependent package
        quick-lint-js-vim_$(VERSION)-1_all.deb    # arch-independent package

After the patch, the pool looks like this:

    debian/pool/
      $(VERSION)/
        $(ARCH)/
          quick-lint-js_$(VERSION)-1_$(ARCH).deb  # arch-dependent package
        source/
          quick-lint-js_$(VERSION).orig.tar.gz    # source package
          quick-lint-js_$(VERSION)-1.dsc          # source package
        all/
          quick-lint-js-vim_$(VERSION)-1_all.deb  # arch-independent package
  • Loading branch information
strager committed Aug 12, 2023
1 parent 570eaa0 commit 226e84b
Showing 1 changed file with 50 additions and 3 deletions.
53 changes: 50 additions & 3 deletions dist/debian/sync-releases-to-apt
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,62 @@ copy_releases_to_debian_pool() {
shift 4
extra_builds=("${@}")
archs=(all amd64 arm64)
copy_build_to_pool() {
local release_path="${1}"
local release="$(basename "${release_path}")"
if [ -d "${release_path}/debian/amd64" ]; then
for arch_path in "${release_path}/debian/"*; do
# NOTE(strager): Later architectures might overwrite files from
# earlier architectures. This is fine. Unfortunately, some files (such
# as {amd64,arm64}/quick-lint-js-vim_2.15.0-1_all.deb) are logically
# identical but not bit-identical, so we choose an arbitrary version
# of the file.
#
# FIXME(strager): There is a race condition. If someone downloads a
# release while we copy, they might get the amd64 version of a file
# before the arm64 version is written. (The amd64 and arm64 versions
# might have different file hashes.)
copy_build_bins_to_pool "${arch_path}/" "${release}"
done
else
# Releases prior to 2.14.0 were only amd64 and did not have
# architecture-specific directories.
copy_build_bins_to_pool "${release_path}/debian/" "${release}"
fi
}
copy_build_bins_to_pool() {
local bin_path="${1}"
local release="${2}"
for file in "${bin_path}"/*; do
local file_arch="$(classify_file "${file}")"
mkdir -p "${debian_root}/pool/${release}/${file_arch}/"
rsync -a "${file}" "${debian_root}/pool/${release}/${file_arch}/"
done
}
classify_file() {
local file="${1}"
for arch in "${archs[@]}"; do
if [[ "${file}" = *"_${arch}."* ]]; then
echo "${arch}"
return
fi
done
echo source
}
mkdir -p "${debian_root}/pool/"
if [ "${sync_releases}" -ne 0 ]; then
for release_path in "${releases_root}"/[0-9]*; do
release="$(basename "${release_path}")"
rsync -a "${release_path}/debian/" "${debian_root}/pool/${release}/"
copy_build_to_pool "${release_path}"
done
fi
for extra_build in "${extra_builds[@]:+${extra_builds[@]}}"; do
rsync -a "${builds_root}/${extra_build}/debian/" "${debian_root}/pool/${extra_build}/"
copy_build_to_pool "${builds_root}/${extra_build}"
done
EOF
}
Expand Down

0 comments on commit 226e84b

Please sign in to comment.