You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2026/09/17 09:13:31 UTC

(skywalking-ai-sessionizer) 01/02: Ship Debian packages with each release, and an apt repository on the website

This is an automated email from the ASF dual-hosted git repository.

wu-sheng pushed a commit to branch apt-packages
in repository https://gitbox.apache.org/repos/asf/skywalking-ai-sessionizer.git

commit 76b58a6ecd046bbcc23d2a19547ff0ed8e917a45
Author: Wu Sheng <wu...@foxmail.com>
AuthorDate: Thu Sep 17 17:06:30 2026 +0800

    Ship Debian packages with each release, and an apt repository on the website
    
    Each release gets a .deb of asz and of asz-claude-code for amd64 and arm64,
    voted and signed with the other packages. tools/debpackage writes them in
    make binaries from the same staged files, with Go's tar and gzip, so a
    rebuild gives the same bytes on macOS and on Linux. make binaries also
    removes .DS_Store, ._ and __MACOSX files from what it packages, and
    package-check refuses a package, a .deb too, that holds one.
    
    https://skywalking.apache.org/apt is static/apt in apache/skywalking-website.
    It holds the signed index of every released version and a .htaccess that
    redirects apt to each .deb: the newest version through the mirrors, every
    older one on archive.apache.org. tools/aptindex writes both, and
    tools/apt-repository.sh holds the released packages to their .sha512 and
    KEYS, adds them and signs the index. tools/apt-check.sh serves such an
    index with Apache httpd and installs, downgrades, upgrades and removes two
    versions with apt in Debian and Ubuntu; CI's apt job runs it on amd64 and
    arm64.
    
    release.sh candidate checks each .deb's files and control file, CI attaches
    the .deb files to the prerelease, publish lists them on the website, and the
    binary-distribution skill now does apt beside Homebrew.
---
 .claude/skills/binary-distribution/SKILL.md | 116 +++++--
 .github/workflows/ci.yaml                   |  45 ++-
 Makefile                                    |  28 +-
 docs/en/changes/changes.md                  |  13 +
 docs/en/guides/how-to-release.md            |  72 +++-
 docs/en/setup/install.md                    |  22 ++
 tools/apt-check.sh                          | 220 ++++++++++++
 tools/apt-repository.sh                     | 147 ++++++++
 tools/aptindex/main.go                      | 497 ++++++++++++++++++++++++++++
 tools/aptindex/main_test.go                 | 139 ++++++++
 tools/ci-binaries.sh                        |  20 +-
 tools/ci-upload-binaries.sh                 |  15 +-
 tools/cibinaries/cibinaries_test.go         |  50 ++-
 tools/ciupload/ciupload_test.go             |  38 ++-
 tools/deb-list.sh                           |  74 +++++
 tools/debfixture/debfixture.go              |  82 +++++
 tools/debpackage/main.go                    | 327 ++++++++++++++++++
 tools/debpackage/main_test.go               |  96 ++++++
 tools/package-check.sh                      |   1 +
 tools/packagecheck/packagecheck_test.go     |  17 +-
 tools/release.sh                            | 110 ++++--
 tools/releasecandidate/candidate_test.go    |  87 ++++-
 tools/releasepublish/publish_test.go        |   7 +-
 23 files changed, 2126 insertions(+), 97 deletions(-)

diff --git a/.claude/skills/binary-distribution/SKILL.md b/.claude/skills/binary-distribution/SKILL.md
index 7188fad..8b4b297 100644
--- a/.claude/skills/binary-distribution/SKILL.md
+++ b/.claude/skills/binary-distribution/SKILL.md
@@ -1,14 +1,19 @@
 ---
 name: binary-distribution
-description: Put released versions of Apache SkyWalking AI Sessionizer into Homebrew by updating Formula/ on main in apache/skywalking-ai-sessionizer, the tap. Writes asz@VERSION and asz-claude-code@VERSION for each version, moves asz and asz-claude-code to the newest, checks the formulae with Homebrew, and opens the pull request. Use after a version is published, or to add older released versions.
+description: Put released versions of Apache SkyWalking AI Sessionizer into Homebrew and apt. Homebrew is Formula/ on main in apache/skywalking-ai-sessionizer, the tap; apt is static/apt in apache/skywalking-website, served at https://skywalking.apache.org/apt. Writes and checks the formulae and the signed apt index for each version, and opens the two pull requests. Use after a version is published, or to add older released versions.
 user-invocable: true
 ---
 
-# Binary distribution: Homebrew
+# Binary distribution: Homebrew and apt
 
-`Formula/` on main is the Homebrew tap. It holds, for every released version,
-`asz@VERSION.rb` and `asz-claude-code@VERSION.rb`, and `asz.rb` and
-`asz-claude-code.rb` for the newest version. Users install with:
+The user names one version or several. A version must be released: voted,
+moved to the download site, and its GitHub release promoted. Do both parts
+unless the user names one.
+
+**Homebrew.** `Formula/` on main in this repository is the tap. It holds, for
+every released version, `asz@VERSION.rb` and `asz-claude-code@VERSION.rb`, and
+`asz.rb` and `asz-claude-code.rb` for the newest version. The formulae download
+the packages from the GitHub release.
 
 ```sh
 brew tap apache/skywalking-ai-sessionizer https://github.com/apache/skywalking-ai-sessionizer
@@ -16,15 +21,24 @@ brew install apache/skywalking-ai-sessionizer/asz
 brew install apache/skywalking-ai-sessionizer/asz-claude-code@0.4.0
 ```
 
-The user names one version or several. A version must be released: voted,
-moved to the download site, and its GitHub release promoted, because the
-formulae download the packages from that GitHub release.
+**apt.** `static/apt` in apache/skywalking-website is the repository at
+`https://skywalking.apache.org/apt`. It holds the signed index of every released
+version and a `.htaccess` that redirects apt to each `.deb`: the newest version
+through the mirrors, every older one on archive.apache.org. It holds no package.
+0.4.0 is the first version with Debian packages.
+
+```sh
+sudo apt install asz asz-claude-code
+sudo apt install asz=0.4.0 asz-claude-code=0.4.0
+```
+
+A local proxy can break HTTPS to Apache hosts, so every command below that
+reaches them goes around it.
 
 ## 1. Check the versions are released
 
 Each version must answer 200 on one of the two Apache sites, and its GitHub
-release must carry the packages. A local proxy can break HTTPS to Apache hosts,
-so these commands go around it:
+release must carry the packages:
 
 ```sh
 for v in <versions>; do
@@ -37,27 +51,29 @@ done
 ```
 
 Stop and tell the user about any version that is not released, or whose release
-is still a prerelease.
+is still a prerelease. A version before 0.4.0 goes to Homebrew only.
 
-## 2. Branch from main
+## 2. Branch
 
-Work in a worktree so another session's changes in the main clone are left
+Work in worktrees, so another session's changes in the main clones are left
 alone:
 
 ```sh
 git fetch origin
-git worktree add -b brew-<versions> <scratch dir> origin/main
-cd <scratch dir>
+git worktree add -b dist-<versions> <scratch dir>/asz origin/main
+git -C ~/github/skywalking-website fetch origin
+git -C ~/github/skywalking-website worktree add -b apt-<versions> <scratch dir>/website origin/master
+cd <scratch dir>/asz
 ```
 
-## 3. Write and check the formulae, on macOS
+## 3. Homebrew: write and check the formulae, on macOS
 
 ```sh
 env -u http_proxy -u https_proxy -u all_proxy tools/homebrew-formula.sh --check <versions>
 ```
 
-For each version it downloads the six packages and their `.sha512` from the
-Apache sites, holds each package to its `.sha512`, and runs the formulae
+For each version it downloads the six binary packages and their `.sha512` from
+the Apache sites, holds each package to its `.sha512`, and runs the formulae
 through `brew style`, `brew audit --strict`, `brew install` and `brew test`,
 removing what it installed. Only then does it write `Formula/asz@VERSION.rb`
 and `Formula/asz-claude-code@VERSION.rb`, and move `Formula/asz.rb` and
@@ -69,26 +85,68 @@ If `asz` or `asz-claude-code` is already installed on this machine, the check
 refuses to run rather than replace it. Say so and stop; do not uninstall the
 user's own install.
 
-## 4. Look at the change
+## 4. apt: write, check and sign the index
+
+The index is signed with the user's own key, which must be in
+https://downloads.apache.org/skywalking/KEYS. Ask the user which key to use if
+they have not said, and never sign with a key they did not name. gpg may ask for
+the passphrase in a window of its own; tell the user to expect it.
 
-Read what it printed, and `git status --short`. Only files under `Formula/` may
-change.
+```sh
+env -u http_proxy -u https_proxy -u all_proxy GPG_USER=<key> \
+  tools/apt-repository.sh --check <scratch dir>/website/static/apt <versions>
+```
+
+For each version it downloads the four `.deb` packages with their `.sha512` and
+`.asc`, holds each to its `.sha512` and its signature to KEYS, and, with
+`--check`, installs them with apt in Debian and Ubuntu in docker, through Apache
+httpd serving the same kind of index and redirects. Only then does it add them to
+the index, write the redirects, sign `dists/stable/Release` into `InRelease` and
+`Release.gpg`, and check both signatures against KEYS as apt would read it.
+Adding an older version keeps the newest version on the mirrors. A version
+already in the index with the same bytes changes nothing, and one with other
+bytes is refused.
+
+`--check` needs docker. If docker is not running, say so and ask the user
+whether to start it or to go on without `--check`. CI's `apt` job runs the same
+check on every change.
 
-## 5. Commit and open the pull request
+## 5. Look at the changes
+
+Read what both scripts printed. In the asz worktree, `git status --short` may
+show changes under `Formula/` only. In the website worktree, only under
+`static/apt/`: `.htaccess`, `dists/stable/Release`, `InRelease`, `Release.gpg`,
+and `Packages` and `Packages.gz` for amd64 and arm64. Read `.htaccess`: the
+newest version goes to `closer.lua`, and every other to archive.apache.org.
+
+## 6. Commit and open the pull requests
 
 ```sh
 git add Formula
 git commit -m "Homebrew formulae for <versions>"
-git push -u origin brew-<versions>
+git push -u origin dist-<versions>
 gh pr create --repo apache/skywalking-ai-sessionizer --base main --title "Homebrew formulae for <versions>"
+
+cd <scratch dir>/website
+git add static/apt
+git commit -m "AI Sessionizer apt repository: add <versions>"
+git push -u origin apt-<versions>
+gh pr create --repo apache/skywalking-website --base master --title "AI Sessionizer apt repository: add <versions>"
 ```
 
-The commit message and the pull request carry no AI attribution: no
-Co-Authored-By line and no "Generated with" line. Say in the pull request which
-versions were added, which version `asz` and `asz-claude-code` now install, and
-that the check passed.
+The commit messages and the pull requests carry no AI attribution: no
+Co-Authored-By line and no "Generated with" line. Say in each pull request which
+versions were added and that the check passed. In the Homebrew one, say which
+version `asz` and `asz-claude-code` now install. In the apt one, say which
+version apt installs by default, and which key signed the index.
 
-## 6. After the merge
+## 7. After the merges
 
 Anyone who tapped runs `brew update`, then `brew upgrade asz asz-claude-code`.
-Tell the user the pull request link, and remove the worktree once it is merged.
+apt users run `sudo apt update && sudo apt upgrade` once the website has been
+built, which its CI does on every merge to master.
+
+`tools/release.sh publish VERSION --remove-old` removes older versions from the
+download site. It must wait for the apt pull request, because until it merges
+apt downloads the previous version through the mirrors. Tell the user the pull
+request links, and remove both worktrees once they are merged.
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index da69a1c..80084d7 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -251,6 +251,7 @@ jobs:
           path: |
             dist/*.tgz
             dist/*.zip
+            dist/*.deb
             dist/*.sha512
           if-no-files-found: error
 
@@ -414,6 +415,43 @@ jobs:
           make binaries checksums VERSION=0.0.0
           tools/homebrew-check.sh 0.0.0 dist
 
+  # The Debian packages, through the apt repository the SkyWalking website
+  # serves: tools/aptindex writes the index for two versions, Apache httpd
+  # serves it with its redirects, and apt in Debian and in Ubuntu installs,
+  # downgrades, upgrades and removes them. The packages are built here with
+  # two versions of a release's form, which the index requires, for the
+  # Linux platforms only. Each runner installs its own architecture.
+  apt:
+    name: apt ${{ matrix.arch }}
+    if: github.event_name != 'release'
+    runs-on: ${{ matrix.runner }}
+    timeout-minutes: 30
+    strategy:
+      fail-fast: false
+      matrix:
+        include:
+          - { arch: amd64, runner: ubuntu-latest }
+          - { arch: arm64, runner: ubuntu-24.04-arm }
+    steps:
+      - uses: actions/checkout@v4
+        with:
+          ref: ${{ github.sha }}
+      - uses: actions/setup-go@v5
+        with:
+          go-version: '1.27'
+          cache: true
+      # Run by hand for a tag older than this job, the tag has no check.
+      - name: Build two versions and install them with apt
+        run: |
+          if [ ! -f tools/apt-check.sh ]; then
+            echo "::notice::this tag has no tools/apt-check.sh, so apt is not run"
+            exit 0
+          fi
+          for v in 0.0.1 0.0.2; do
+            make binaries checksums VERSION=$v PLATFORMS="linux/amd64 linux/arm64" DIST=apt/$v
+          done
+          tools/apt-check.sh apt 0.0.1 0.0.2
+
   lint:
     name: Lint
     if: github.event_name != 'release'
@@ -431,7 +469,7 @@ jobs:
   candidate-assets:
     name: Prerelease binaries
     if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
-    needs: [license, build, source-package, lint, binaries, packages, claude-code, homebrew, collector, conversation-view]
+    needs: [license, build, source-package, lint, binaries, packages, claude-code, homebrew, apt, collector, conversation-view]
     runs-on: ubuntu-latest
     permissions:
       contents: write
@@ -449,7 +487,8 @@ jobs:
           VERSION: ${{ needs.binaries.outputs.version }}
         run: |
           platforms=$(sed -nE 's/^PLATFORMS[[:space:]]*:?=[[:space:]]*//p' Makefile)
-          bash tools/ci-upload-binaries.sh "$VERSION" "$GITHUB_SHA" "$GITHUB_RUN_ID" "$GITHUB_RUN_ATTEMPT" dist "$platforms"
+          debs=$(sed -nE 's/^DEB_PACKAGES[[:space:]]*:?=[[:space:]]*//p' Makefile)
+          bash tools/ci-upload-binaries.sh "$VERSION" "$GITHUB_SHA" "$GITHUB_RUN_ID" "$GITHUB_RUN_ATTEMPT" dist "$platforms" "$debs"
 
   # Candidate tags build and test their packages without publishing an image.
   # A manual image retry requires an existing public GitHub release.
@@ -548,7 +587,7 @@ jobs:
   result:
     name: Required
     if: always()
-    needs: [license, build, source-package, lint, docker, binaries, packages, claude-code, homebrew, collector, conversation-view, candidate-assets]
+    needs: [license, build, source-package, lint, docker, binaries, packages, claude-code, homebrew, apt, collector, conversation-view, candidate-assets]
     runs-on: ubuntu-latest
     steps:
       - name: Fail if any job failed
diff --git a/Makefile b/Makefile
index 5bc831c..65f4b9a 100644
--- a/Makefile
+++ b/Makefile
@@ -42,6 +42,13 @@ PLATFORMS := darwin/arm64 darwin/amd64 linux/amd64 linux/arm64 windows/amd64 win
 DIST      := dist
 PKG_BASE  := apache-skywalking-ai-sessionizer-$(VERSION)-bin
 
+# The Debian packages a release ships for each Linux platform in PLATFORMS,
+# written by tools/debpackage. apt installs them from the repository the
+# SkyWalking website serves, which tools/aptindex writes. tools/release.sh
+# reads this line from the tag's Makefile, so a version from before it has
+# none.
+DEB_PACKAGES := asz asz-claude-code
+
 # The GPG key that signs a release, by id, fingerprint or email. Empty means
 # gpg's default key. The key must be in the SkyWalking KEYS file.
 GPG_USER  ?=
@@ -189,7 +196,7 @@ tidy:
 docker: ## Build the container image, as CI builds and publishes it
 	docker build --build-arg VERSION=$(VERSION) -t skywalking-ai-sessionizer:dev .
 
-## binaries: cross-compile every platform in PLATFORMS and package each, with the Claude Code plugin's binary, the LICENSE, the NOTICE and the dependency licenses, into dist/
+## binaries: cross-compile every platform in PLATFORMS and package each, with the Claude Code plugin's binary, the LICENSE, the NOTICE and the dependency licenses, into dist/, and every package in DEB_PACKAGES for each Linux platform
 .PHONY: binaries
 # Two builds of one tag give the same bytes when they use the same Go, the
 # same tar and the same gzip. Go records the tag in each binary as the
@@ -207,8 +214,14 @@ docker: ## Build the container image, as CI builds and publishes it
 # CI build, with GNU tar and GNU gzip, and a macOS build, with bsdtar and
 # Apple gzip, differ.
 # COPYFILE_DISABLE keeps Apple's tar from adding AppleDouble ._ entries
-# for extended attributes. The archive check also catches metadata files
-# that were present in a copied directory before tar or zip ran.
+# for extended attributes. Finder writes .DS_Store and ._ files into a
+# directory it has shown, such as dist-material/licenses, and cp copies
+# them. So they are removed from the staged files before any package is
+# written, and tools/package-check.sh still refuses a package, a .deb too,
+# that holds one.
+# A Debian package holds the same staged binaries. tools/debpackage writes it
+# with the same time, owner and modes, and with Go's own tar and gzip, so it
+# does not depend on the tar or the gzip of the machine.
 # The build ignores a go.work and the GOFLAGS of the environment. A
 # workspace changes the code a dependency is compiled from, and git does not
 # show a go.work, because it is ignored. Ignoring workspace settings also
@@ -223,6 +236,7 @@ binaries:
 	  if [ "$$os" = windows ]; then ext=.exe; fi; \
 	  rm -rf $$out && mkdir -p $$out && \
 	  cp dist-material/LICENSE dist-material/NOTICE $$out/ && cp -R dist-material/licenses $$out/licenses && \
+	  find $$out \( -name '._*' -o -name .DS_Store -o -name __MACOSX \) -prune -exec rm -rf {} + && \
 	  echo "building $$os/$$arch" && \
 	  CGO_ENABLED=0 GOWORK=off GOFLAGS=-mod=readonly GOOS=$$os GOARCH=$$arch $(GO) build -trimpath -ldflags "-s -w $(LDFLAGS)" -o $$out/$(BINARY)$$ext ./cmd/$(BINARY) || exit 1; \
 	  CGO_ENABLED=0 GOWORK=off GOFLAGS=-mod=readonly GOOS=$$os GOARCH=$$arch $(GO) build -trimpath -ldflags "-s -w $(LDFLAGS)" -o $$out/$(PLUGIN_BINARY)$$ext ./$(PLUGIN_DIR) || exit 1; \
@@ -236,6 +250,12 @@ binaries:
 	    (cd $$out && COPYFILE_DISABLE=1 tar --format=ustar $$owner --no-recursion -cf ../$$os-$$arch.tar -T ../$$os-$$arch.list) && \
 	    gzip -n -c $(DIST)/build/$$os-$$arch.tar > $(DIST)/$(PKG_BASE)-$$os-$$arch.tgz || exit 1; \
 	  fi; \
+	  if [ "$$os" = linux ]; then \
+	    for p in $(DEB_PACKAGES); do \
+	      GOWORK=off GOFLAGS=-mod=readonly $(GO) run ./tools/debpackage -package $$p -version $(VERSION) -arch $$arch \
+	        -from $$out -time $${epoch:-$$(date +%s)} -out $(DIST)/$(PKG_BASE)-$$p-$$arch.deb || exit 1; \
+	    done; \
+	  fi; \
 	done
 	@sh tools/package-check.sh $(DIST)/$(PKG_BASE)-*
 	@ls -la $(DIST)/$(PKG_BASE)-*
@@ -248,7 +268,7 @@ binaries:
 # .sha512, and make went on to sign every package. Each file is checked
 # right after it is written.
 checksums:
-	@cd $(DIST) && for f in *.tgz *.zip; do \
+	@cd $(DIST) && for f in *.tgz *.zip *.deb; do \
 	  [ -f "$$f" ] || continue; \
 	  { shasum -a 512 "$$f" > "$$f.sha512" && shasum -a 512 --status -c "$$f.sha512"; } \
 	    || { rm -f "$$f.sha512"; echo "cannot write the sha512 of $$f, so this stops here"; exit 1; }; \
diff --git a/docs/en/changes/changes.md b/docs/en/changes/changes.md
index 8115545..3d0d631 100644
--- a/docs/en/changes/changes.md
+++ b/docs/en/changes/changes.md
@@ -105,6 +105,19 @@
   writes them into `Formula/` from the released packages, checks them with Homebrew first, and
   moves `asz` and `asz-claude-code` only forward. The `binary-distribution` skill runs it and opens
   the pull request.
+- **Debian packages, and an apt repository on the website.** Each release ships
+  `apache-skywalking-ai-sessionizer-VERSION-bin-asz-ARCH.deb` and `...-bin-asz-claude-code-ARCH.deb`
+  for amd64 and arm64, voted and signed with the other packages. `tools/debpackage` writes them in
+  `make binaries` from the same staged files, with the same time, owner and modes, so a rebuild
+  gives the same bytes on any machine. `https://skywalking.apache.org/apt` serves an index of every
+  released version, signed with a key in KEYS, and `.htaccess` redirects that send apt to the newest
+  version on the mirrors and to every older one on archive.apache.org. `tools/aptindex` writes the
+  index and the redirects, and `tools/apt-repository.sh` checks the released packages against their
+  `.sha512` and KEYS, adds them and signs the index; the `binary-distribution` skill runs it with the
+  Homebrew formulae. CI's `apt` job installs two versions through Apache httpd with the same
+  redirects, in Debian and Ubuntu, on amd64 and arm64. [Install](../setup/install.md) gives the
+  commands. `candidate` checks each `.deb`'s contents and control file, and `make binaries` removes
+  `.DS_Store`, `._` and `__MACOSX` files from what it packages.
 - **Two install scripts, one for each install.** asz, the collector, and the Claude Code plugin are
   installed apart. `install/asz.sh` and `install/asz.ps1` install `asz`, and
   [Install](../setup/install.md#install-script) runs them from the version's tag in one command. The
diff --git a/docs/en/guides/how-to-release.md b/docs/en/guides/how-to-release.md
index 667f4b9..b87e76b 100644
--- a/docs/en/guides/how-to-release.md
+++ b/docs/en/guides/how-to-release.md
@@ -29,7 +29,8 @@ A GitHub release alone cannot provide that approval. See the
   to a full GitHub release.
 - **The container image** is a convenience. The promotion of the GitHub release starts CI's image
   job. A tag push and a default manual CI run publish no image.
-- **The Homebrew, Scoop and winget manifests** are conveniences, submitted after the release.
+- **The Homebrew, Scoop and winget manifests** and **the apt repository** are conveniences,
+  written after the release.
 
 0.3.0 is the first version to go through this process. 0.1.0 and 0.2.0 were published on GitHub
 before it, as full GitHub releases carrying binary packages that CI built. No vote was held for
@@ -47,6 +48,7 @@ GitHub releases as pre-releases, or to remove their packages, is for the PMC to
 | [The website](#the-website) | the release manager | the downloads entry and the documentation of the version |
 | [The announcement](#the-announcement) | the release manager | the mail to the dev and announce lists |
 | [Install manifests](#install-manifests) | the release manager, once the PMC agrees to each channel | the Homebrew, Scoop and winget manifests, each submitted |
+| [The apt repository](#the-apt-repository) | the release manager | the version in the apt repository on the website |
 | [Later: remove old versions](#later-remove-old-versions) | a PMC member | the release directory without the versions the new one replaces |
 
 Between step 1 and step 2, the release manager waits for CI by hand. Nothing in the script waits.
@@ -382,6 +384,13 @@ writes nothing into `dist/$VERSION/`. The plan does not claim that prerelease as
   Code plugin, and the binary distribution's `LICENSE`, `NOTICE` and `licenses/`. Both binaries
   end in `.exe` on Windows. These packages include the renderer's two OFL fonts and their license
   texts.
+- Each Debian package is `apache-skywalking-ai-sessionizer-$VERSION-bin-<package>-<arch>.deb`, one
+  for each package in `DEB_PACKAGES` in the tag's Makefile and each Linux platform. `asz` installs
+  `/usr/bin/asz`, and `asz-claude-code` installs `/usr/bin/asz-claude-plugin`. Each holds the same
+  binary as the Linux binary package, with the same `LICENSE`, `NOTICE` and `licenses/` under
+  `/usr/share/doc/<package>/`. `tools/debpackage` writes them, so a build on macOS gives the same
+  bytes as one on Linux. `candidate` checks that each installs its binary and the licenses, and
+  that its control file names the package, `$VERSION` and the architecture of its file name.
 - Every archive has a `.sha512` checksum and an ASCII-armored detached `.asc` signature.
 
 No package carries the Claude Code plugin's manifest and hooks. Users install them from the
@@ -394,8 +403,9 @@ without cgo on Linux with its configured Go toolchain and packages with GNU tar,
 It uses `GOWORK=off` and `GOFLAGS=-mod=readonly`. Both binaries report `$VERSION` and the Go
 version used to build them. The run must pass the whole CI workflow, including package smoke
 tests on all six platforms, and on the same six the Claude Code check, which installs each package
-and the plugin as the install pages say and runs a session the plugin must record. Only then are
-its archives eligible for the candidate.
+and the plugin as the install pages say and runs a session the plugin must record. The `apt` job
+installs Debian packages with apt, in Debian and Ubuntu, on x86-64 and ARM 64. Only then are its
+archives eligible for the candidate.
 
 `make binaries` remains useful for local build checks. Those archives are not the release
 candidate. GNU and macOS archive tools can produce different bytes even from the same files, so
@@ -475,11 +485,12 @@ svn export https://dist.apache.org/repos/dist/dev/skywalking/ai-sessionizer/$VER
 cd candidate
 curl -fsSLO https://dist.apache.org/repos/dist/release/skywalking/KEYS
 gpg --import KEYS
-for f in *.tgz *.zip; do shasum -a 512 -c "$f.sha512" && gpg --verify "$f.asc" "$f"; done
+for f in *.tgz *.zip *.deb; do shasum -a 512 -c "$f.sha512" && gpg --verify "$f.asc" "$f"; done
 ```
 
-1. The source package and one binary package for each platform are there, each with its `.asc`
-   and `.sha512`. The platforms are the `PLATFORMS` list in the Makefile of the tag.
+1. The source package, one binary package for each platform, and one Debian package for each
+   package in `DEB_PACKAGES` and each Linux platform are there, each with its `.asc` and `.sha512`.
+   The lists are in the Makefile of the tag.
 2. `shasum -a 512 -c` passes for each package.
 3. `gpg --verify` passes for each package, with a key from KEYS. gpg prints `Good signature`,
    and nothing about an expired or revoked key: no `[expired]` after the name, no
@@ -583,6 +594,19 @@ for f in *.tgz *.zip; do shasum -a 512 -c "$f.sha512" && gpg --verify "$f.asc" "
    CI's `packages` job runs the same script on all six packages, each on a GitHub runner of its
    own platform, on every CI run. If you use Claude Code, the unpacked `asz` can also be tried on
    your own conversations: `asz sources`, `asz collect -once`, `asz parse`, `asz verify`.
+10. On Debian or Ubuntu, a Debian package installs, and holds the binary of the Linux package:
+
+    ```sh
+    sudo apt install ./apache-skywalking-ai-sessionizer-$VERSION-bin-asz-amd64.deb
+    asz version
+    dpkg -L asz
+    sudo apt remove asz
+    ```
+
+    `asz version` must report `$VERSION`, and `dpkg -L` must list `/usr/bin/asz`, and `LICENSE`,
+    `NOTICE` and `licenses/` under `/usr/share/doc/asz/`. On any machine,
+    `tools/deb-list.sh` from the source package lists what a `.deb` installs, and
+    `tools/deb-list.sh --control` prints its control file.
 
 ### The result
 
@@ -977,8 +1001,37 @@ that `.sha512`, so the manifests describe the voted bytes. It also refuses a mac
 that lacks a file the formula installs, or that holds `asz` or the plugin's binary without its
 executable bit, because such a formula would fail for everyone on that platform.
 
-[Install](../setup/install.md) marks each package manager as not published yet. When a manifest is
-accepted for the first time, update that page with the command that installs from it.
+When a manifest is accepted for the first time, add the command that installs from it to
+[Install](../setup/install.md).
+
+## The apt repository
+
+`https://skywalking.apache.org/apt` is an apt repository: `static/apt` in apache/skywalking-website.
+It holds no package. It holds the index, which lists every released version of `asz` and
+`asz-claude-code`, signed with a key in KEYS, and a `.htaccess` that redirects each package's
+address to the voted `.deb` on the Apache download sites: the newest version through the mirrors,
+and every older one from archive.apache.org, which keeps every version. apt follows the redirect
+and checks the file against the index. The index is written after the vote from the voted packages,
+and is not voted on.
+
+After Publish, and at least one hour after the move, in a checkout of apache/skywalking-website on a
+branch from master:
+
+```sh
+GPG_USER=<your key in KEYS> tools/apt-repository.sh --from dist --check <skywalking-website>/static/apt $VERSION
+```
+
+It holds each `.deb` to its `.sha512` and its `.asc` to KEYS, installs them with apt in Debian and
+Ubuntu in docker, adds them to the index, and writes the redirects. It then signs the index with
+your key, and checks that apt would accept the signature with the keys from KEYS. Without `--from`
+it downloads released packages from the Apache sites, which is how older versions are added. Open
+a pull request on apache/skywalking-website with the change to `static/apt`. The
+`binary-distribution` skill in `.claude/skills/` does this with Claude Code, with the Homebrew
+formulae.
+
+CI's `apt` job runs `tools/apt-check.sh` on every change: it builds two versions, writes and signs
+their index, serves it with Apache httpd as the website does, and installs, downgrades, upgrades and
+removes both packages with apt.
 
 ## Later: remove old versions
 
@@ -998,6 +1051,9 @@ these:
    downloads page links the files that would be removed.
 2. The Scoop bucket names the new version. Its manifest downloads the version it names from the
    download site, and that URL stops working when the version is removed.
+3. The website pull request that adds the new version to [the apt repository](#the-apt-repository)
+   has merged. Until then, apt downloads the older version through the mirrors, from the files that
+   would be removed.
 
 The move is not repeated, and the steps after it run again. For each version older than
 `$VERSION`, it runs:
diff --git a/docs/en/setup/install.md b/docs/en/setup/install.md
index 4a00834..64be319 100644
--- a/docs/en/setup/install.md
+++ b/docs/en/setup/install.md
@@ -41,6 +41,20 @@ For an exact version, install `apache/skywalking-ai-sessionizer/asz@<version>` a
 `apache/skywalking-ai-sessionizer/asz-claude-code@<version>`. Homebrew keeps them off your `PATH`;
 `brew info` shows where they are.
 
+## apt, on Debian and Ubuntu
+
+```sh
+curl -fsSL https://downloads.apache.org/skywalking/KEYS | gpg --dearmor | sudo tee /usr/share/keyrings/apache-skywalking.gpg > /dev/null
+echo "deb [signed-by=/usr/share/keyrings/apache-skywalking.gpg] https://skywalking.apache.org/apt stable main" | sudo tee /etc/apt/sources.list.d/apache-skywalking.list
+sudo apt update
+sudo apt install asz asz-claude-code
+```
+
+`asz-claude-code` installs `asz-claude-plugin`, the Claude Code plugin's binary. Then install the
+plugin into Claude Code as [Claude Code Plugin](claude-code-plugin.md) says. Upgrade with
+`sudo apt update && sudo apt upgrade`. For an exact version, run
+`sudo apt install asz=<version> asz-claude-code=<version>`.
+
 ## Binary package
 
 The [downloads page](https://skywalking.apache.org/downloads/) links one package per platform:
@@ -53,6 +67,14 @@ apache-skywalking-ai-sessionizer-<version>-bin-windows-<arch>.zip  arch: amd64,
 Each holds `asz`, `asz-claude-plugin` (the Claude Code plugin's binary), `LICENSE`, `NOTICE` and
 `licenses/`.
 
+For Debian and Ubuntu, the same page links two `.deb` packages per architecture, which
+`sudo apt install ./<file>.deb` installs:
+
+```text
+apache-skywalking-ai-sessionizer-<version>-bin-asz-<arch>.deb              arch: amd64, arm64
+apache-skywalking-ai-sessionizer-<version>-bin-asz-claude-code-<arch>.deb  arch: amd64, arm64
+```
+
 On macOS or Linux:
 
 ```sh
diff --git a/tools/apt-check.sh b/tools/apt-check.sh
new file mode 100755
index 0000000..132255c
--- /dev/null
+++ b/tools/apt-check.sh
@@ -0,0 +1,220 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Installs the Debian packages of some versions with apt, from an apt
+# repository served the way the SkyWalking website serves it. CI runs it on
+# amd64 and on arm64, and tools/apt-repository.sh runs it on released
+# packages before it changes the website.
+#
+#   tools/apt-check.sh DIR VERSION...
+#
+# DIR/VERSION holds the Debian packages of each VERSION, as make binaries
+# writes them with DIST=DIR/VERSION. The versions are digits and dots.
+#
+# tools/aptindex writes the index one version at a time, oldest first, and a
+# second run with every package must change nothing. The index is signed
+# with a key made for the run. Apache httpd serves it with the .htaccess
+# aptindex wrote, as the website does, and serves the packages as the
+# Apache download sites do: the newest version behind a redirect, like the
+# mirror selector, and every version in the archive. In Debian and in Ubuntu,
+# apt then installs the newest version, each older one by its version, and
+# the newest again, and each must report its version. The server's log must
+# show the newest downloaded from the mirrors and every older one from the
+# archive. Needs docker, go and gpg.
+
+set -euo pipefail
+
+me=apt-check
+fail() { printf '%s: %s\n' "$me" "$*" >&2; exit 1; }
+step() { printf '\n== %s\n' "$*"; }
+
+[ "$#" -ge 2 ] || { echo "usage: tools/apt-check.sh DIR VERSION..." >&2; exit 2; }
+[ -d "$1" ] || fail "$1 is not a directory"
+dir=$(cd "$1" && pwd)
+shift
+for v in "$@"; do
+  printf '%s' "$v" | grep -Eq '^[0-9]+(\.[0-9]+)*$' || fail "$v is not digits and dots, which a release version is"
+  [ -d "$dir/$v" ] || fail "$dir/$v does not exist"
+done
+for t in docker go gpg; do command -v "$t" >/dev/null 2>&1 || fail "$t is not on PATH"; done
+tree=$(cd "$(dirname "$0")/.." && pwd)
+versions=$(printf '%s\n' "$@" | sort -V | uniq)
+newest=$(printf '%s\n' "$versions" | tail -1)
+packages="asz asz-claude-code"
+arches="amd64 arm64"
+images="debian:stable ubuntu:24.04"
+
+work=$(mktemp -d)
+id=asz-apt-check-$$
+cleanup() {
+  docker rm -f "$id-site" >/dev/null 2>&1 || true
+  docker network rm "$id" >/dev/null 2>&1 || true
+  if command -v gpgconf >/dev/null 2>&1; then gpgconf --homedir "$work/gnupg" --kill all >/dev/null 2>&1 || true; fi
+  rm -rf "$work"
+}
+trap cleanup EXIT
+
+step "Write the repository, one version at a time"
+(cd "$tree" && go build -o "$work/aptindex" ./tools/aptindex)
+site=$work/site
+mkdir -p "$site/apt" "$site/closer"
+# The mirror selector answers with a redirect to a mirror, which has no
+# query. So does this.
+printf 'RewriteEngine On\nRewriteRule ^(.*)$ /downloads/$1 [R=302,L,QSD]\n' > "$site/closer/.htaccess"
+all=()
+for v in $versions; do
+  debs=()
+  for p in $packages; do
+    for a in $arches; do
+      f=$dir/$v/apache-skywalking-ai-sessionizer-$v-bin-$p-$a.deb
+      [ -f "$f" ] || fail "$f is missing"
+      debs+=("$f")
+    done
+  done
+  mkdir -p "$site/archive/$v"
+  cp "${debs[@]}" "$site/archive/$v/"
+  if [ "$v" = "$newest" ]; then
+    mkdir -p "$site/downloads/$v"
+    cp "${debs[@]}" "$site/downloads/$v/"
+  fi
+  "$work/aptindex" -dir "$site/apt" \
+    -current 'http://site/closer/{version}/{file}?action=download' \
+    -archive 'http://site/archive/{version}/{file}' "${debs[@]}"
+  all+=("${debs[@]}")
+done
+before=$(cd "$site/apt" && find . -type f -exec shasum -a 256 {} + | sort)
+out=$("$work/aptindex" -dir "$site/apt" \
+  -current 'http://site/closer/{version}/{file}?action=download' \
+  -archive 'http://site/archive/{version}/{file}' "${all[@]}")
+printf '%s\n' "$out"
+[ "$(cd "$site/apt" && find . -type f -exec shasum -a 256 {} + | sort)" = "$before" ] ||
+  fail "a second run with the same packages changed the repository"
+printf '%s\n' "$out" | grep -q 'the index did not change' || fail "a second run with the same packages did not say the index is unchanged"
+for v in $versions; do
+  n=$(grep -c "^RewriteRule \^pool/[a-z-]*_${v//./\\\\.}_" "$site/apt/.htaccess" || true)
+  want=4
+  [ "$n" = "$want" ] || fail ".htaccess has $n rules for $v, not $want"
+done
+echo "every version is in the index, and a second run changed nothing"
+
+step "Sign the index"
+gnupg=$work/gnupg
+mkdir -m 700 "$gnupg"
+g() { gpg --homedir "$gnupg" --batch --pinentry-mode loopback --passphrase '' "$@"; }
+# KEYS holds many keys. apt must find the one that signed among them.
+g --quiet --quick-gen-key 'Another committer <an...@example.invalid>' rsa2048 sign never
+g --quiet --quick-gen-key 'Release manager <re...@example.invalid>' rsa2048 sign never
+{
+  echo "This file contains the PGP keys of the developers."
+  g --armor --export another@example.invalid
+  echo
+  g --armor --export release@example.invalid
+} > "$work/KEYS"
+g --yes --local-user release@example.invalid --clearsign -o "$site/apt/dists/stable/InRelease" "$site/apt/dists/stable/Release"
+g --yes --local-user release@example.invalid --armor --detach-sign -o "$site/apt/dists/stable/Release.gpg" "$site/apt/dists/stable/Release"
+mkdir "$work/keyring"
+# What the install page has a person run on KEYS.
+gpg --dearmor < "$work/KEYS" > "$work/keyring/apache-skywalking.gpg"
+echo "signed with a key that is second in KEYS"
+
+step "Serve it as the website and the download sites do"
+docker network create "$id" >/dev/null
+docker run --rm httpd:2.4 cat /usr/local/apache2/conf/httpd.conf > "$work/httpd.conf"
+# The website's server reads .htaccess files, with mod_rewrite.
+perl -0pi -e 's/^#(LoadModule rewrite_module )/$1/m; s/(<Directory "\/usr\/local\/apache2\/htdocs">.*?)AllowOverride None/$1AllowOverride All/s' "$work/httpd.conf"
+grep -q '^LoadModule rewrite_module' "$work/httpd.conf" || fail "cannot turn on mod_rewrite in httpd.conf"
+chmod -R a+rX "$site"
+docker run -d --name "$id-site" --network "$id" --network-alias site \
+  -v "$site:/usr/local/apache2/htdocs:ro" -v "$work/httpd.conf:/usr/local/apache2/conf/httpd.conf:ro" httpd:2.4 >/dev/null
+echo "httpd serves the repository at http://site/apt"
+
+cat > "$work/keyring/install.sh" <<'SH'
+set -euo pipefail
+for i in $(seq 100); do
+  if (exec 3<>/dev/tcp/site/80) 2>/dev/null; then break; fi
+  sleep 0.1
+done
+# Only this repository, so apt reaches nothing else.
+rm -f /etc/apt/sources.list /etc/apt/sources.list.d/*
+install -m 644 /check/apache-skywalking.gpg /usr/share/keyrings/apache-skywalking.gpg
+echo "deb [signed-by=/usr/share/keyrings/apache-skywalking.gpg] http://site/apt stable main" > /etc/apt/sources.list.d/apache-skywalking.list
+export DEBIAN_FRONTEND=noninteractive
+apt-get update
+listed=$(apt list -a asz 2>/dev/null)
+printf '%s\n' "$listed"
+for v in $VERSIONS; do
+  printf '%s\n' "$listed" | grep -q " $v " || { echo "apt list does not show asz $v"; exit 1; }
+done
+expect() { # expect VERSION
+  asz version | grep -qF "$1" || { echo "asz reports $(asz version), not $1"; exit 1; }
+  asz-claude-plugin version | grep -qF "$1" || { echo "asz-claude-plugin reports $(asz-claude-plugin version), not $1"; exit 1; }
+  [ "$(command -v asz)" = /usr/bin/asz ] || { echo "asz is at $(command -v asz), not /usr/bin/asz"; exit 1; }
+  # A minimal image leaves out /usr/share/doc, and dpkg --verify reports
+  # those files as missing. Anything else it reports is a failure.
+  differ=$(dpkg --verify asz asz-claude-code 2>&1 | grep -v "^missing  *$DOCS_LEFT_OUT" || true)
+  [ -z "$differ" ] || { printf '%s\n' "$differ"; echo "dpkg --verify found installed files that differ from the packages"; exit 1; }
+  echo "ok  asz and asz-claude-plugin $1"
+}
+DOCS_LEFT_OUT='/usr/share/doc/'
+if ! grep -rqs 'path-exclude.*/usr/share/doc' /etc/dpkg/dpkg.cfg.d/; then DOCS_LEFT_OUT='^$'; fi
+apt-get install -y asz asz-claude-code
+expect "$NEWEST"
+if [ "$DOCS_LEFT_OUT" = '^$' ]; then
+  for p in asz asz-claude-code; do
+    for f in LICENSE NOTICE; do [ -f "/usr/share/doc/$p/$f" ] || { echo "/usr/share/doc/$p/$f is missing"; exit 1; }; done
+    [ -n "$(ls -A "/usr/share/doc/$p/licenses")" ] || { echo "/usr/share/doc/$p/licenses is empty"; exit 1; }
+  done
+  echo "ok  LICENSE, NOTICE and licenses/ under /usr/share/doc"
+fi
+for v in $VERSIONS; do
+  [ "$v" != "$NEWEST" ] || continue
+  apt-get install -y --allow-downgrades "asz=$v" "asz-claude-code=$v"
+  expect "$v"
+done
+apt-get install -y asz asz-claude-code
+expect "$NEWEST"
+apt-get remove -y asz asz-claude-code
+[ ! -e /usr/bin/asz ] && [ ! -e /usr/bin/asz-claude-plugin ] || { echo "apt-get remove left a binary"; exit 1; }
+echo "ok  removed"
+SH
+
+for image in $images; do
+  step "apt in $image"
+  docker run --rm --network "$id" -v "$work/keyring:/check:ro" \
+    -e VERSIONS="$versions" -e NEWEST="$newest" "$image" bash /check/install.sh ||
+    fail "apt in $image did not install the packages as it should. Its output is above"
+done
+
+step "Where apt downloaded from"
+log=$(docker logs "$id-site" 2>&1)
+arch=$(docker run --rm debian:stable dpkg --print-architecture)
+for v in $versions; do
+  for p in $packages; do
+    f=apache-skywalking-ai-sessionizer-$v-bin-$p-$arch.deb
+    if [ "$v" = "$newest" ]; then where=downloads; else where=archive; fi
+    printf '%s\n' "$log" | grep -q "\"GET /$where/$v/$f HTTP/1.1\" 200 " ||
+      { printf '%s\n' "$log" | grep 'GET /' >&2; fail "apt did not download $f from /$where/"; }
+  done
+done
+if printf '%s\n' "$log" | grep -E '" (4|5)[0-9][0-9] ' >&2; then fail "the server answered a request with an error, above"; fi
+echo "the newest version came from the mirrors, and every older one from the archive"
+
+step "Done"
+echo "apt installs $(printf '%s\n' "$versions" | paste -sd ' ' -) in $images"
diff --git a/tools/apt-repository.sh b/tools/apt-repository.sh
new file mode 100755
index 0000000..3f84f9c
--- /dev/null
+++ b/tools/apt-repository.sh
@@ -0,0 +1,147 @@
+#!/usr/bin/env bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Adds released versions to the apt repository the SkyWalking website serves
+# at https://skywalking.apache.org/apt, from static/apt in a checkout of
+# apache/skywalking-website.
+#
+#   tools/apt-repository.sh [--from DIR] [--check] APT_DIR VERSION...
+#
+# For each VERSION it takes the four Debian packages with their .sha512 and
+# .asc from DIR/VERSION, or else downloads them from downloads.apache.org, or
+# from archive.apache.org for a version the download site no longer holds.
+# Each package must match its .sha512, and its .asc must be a good signature
+# by a key in KEYS. With --check, tools/apt-check.sh installs them with apt
+# before anything is written, which needs docker.
+#
+# tools/aptindex then adds them to the index in APT_DIR, and writes the
+# redirects: the newest version to the download mirrors, every older one to
+# archive.apache.org. When the index changed, Release is signed into InRelease
+# and Release.gpg with the key GPG_USER names, or gpg's default key. apt checks
+# them against the keys a person took from KEYS, so both signatures must verify
+# against KEYS read the same way. The script changes APT_DIR only, and leaves
+# the commit and the pull request to the person who runs it.
+
+set -euo pipefail
+
+me=apt-repository
+fail() { printf '%s: %s\n' "$me" "$*" >&2; exit 1; }
+say() { printf '%s: %s\n' "$me" "$*"; }
+
+from=""
+check=false
+while [ "$#" -gt 0 ]; do
+  case "$1" in
+    --from)
+      [ -n "${2:-}" ] || fail "--from needs a directory"
+      from=$(cd "$2" && pwd) || fail "$2 is not a directory"
+      shift 2 ;;
+    --check) check=true; shift ;;
+    --*) fail "unknown option $1" ;;
+    *) break ;;
+  esac
+done
+[ "$#" -ge 2 ] || { echo "usage: tools/apt-repository.sh [--from DIR] [--check] APT_DIR VERSION..." >&2; exit 2; }
+apt_parent=$(dirname "$1")
+[ -d "$apt_parent" ] || fail "$apt_parent does not exist. APT_DIR is static/apt in a checkout of apache/skywalking-website"
+apt=$(cd "$apt_parent" && pwd)/$(basename "$1")
+shift
+for v in "$@"; do
+  printf '%s' "$v" | grep -Eq '^[0-9]+(\.[0-9]+)*$' || fail "$v is not a released version: digits and dots"
+done
+for t in go gpg gpgv curl shasum; do command -v "$t" >/dev/null 2>&1 || fail "$t is not on PATH"; done
+
+tree=$(cd "$(dirname "$0")/.." && pwd)
+work=$(mktemp -d)
+trap 'rm -rf "$work"' EXIT
+packages="asz asz-claude-code"
+arches="amd64 arm64"
+
+# fetch FILE VERSION DEST downloads one file of a released version.
+fetch() {
+  local site=https://downloads.apache.org/skywalking/ai-sessionizer/$2/$1
+  local archive=https://archive.apache.org/dist/skywalking/ai-sessionizer/$2/$1
+  local code
+  code=$(curl -sSL -o "$3/$1" -w '%{http_code}' "$site") || fail "cannot reach downloads.apache.org for $1"
+  case "$code" in
+    200) ;;
+    404) curl -fsSL -o "$3/$1" "$archive" || fail "neither downloads.apache.org nor archive.apache.org has $1. Is $2 released, with Debian packages? 0.4.0 is the first version that has them" ;;
+    *) fail "downloads.apache.org answered $code for $1" ;;
+  esac
+}
+
+say "reading KEYS the way the install page has a person read it"
+# A test gives a KEYS file of its own keys in APT_REPOSITORY_KEYS.
+if [ -n "${APT_REPOSITORY_KEYS:-}" ]; then
+  cp "$APT_REPOSITORY_KEYS" "$work/KEYS"
+else
+  curl -fsSL -o "$work/KEYS" https://downloads.apache.org/skywalking/KEYS || fail "cannot download https://downloads.apache.org/skywalking/KEYS"
+fi
+gpg --dearmor < "$work/KEYS" > "$work/keys.gpg" || fail "gpg cannot read KEYS"
+
+debs=()
+for v in "$@"; do
+  dir=$work/packages/$v
+  mkdir -p "$dir"
+  for p in $packages; do
+    for a in $arches; do
+      f=apache-skywalking-ai-sessionizer-$v-bin-$p-$a.deb
+      for g in "$f" "$f.sha512" "$f.asc"; do
+        if [ -n "$from" ]; then
+          [ -f "$from/$v/$g" ] || fail "$from/$v/$g does not exist"
+          cp "$from/$v/$g" "$dir/"
+        else
+          fetch "$g" "$v" "$dir"
+        fi
+      done
+      (cd "$dir" && shasum -a 512 --status -c "$f.sha512") || fail "$f does not match its .sha512"
+      gpgv --keyring "$work/keys.gpg" "$dir/$f.asc" "$dir/$f" 2>"$work/gpgv.txt" ||
+        { cat "$work/gpgv.txt" >&2; fail "$f.asc is not a good signature by a key in KEYS"; }
+      debs+=("$dir/$f")
+    done
+  done
+  say "$v: four Debian packages, each matching its .sha512 and signed by a key in KEYS"
+done
+
+if [ "$check" = true ]; then
+  say "installing them with apt in Debian and Ubuntu"
+  bash "$tree/tools/apt-check.sh" "$work/packages" "$@" || fail "tools/apt-check.sh failed, so $apt was not changed"
+fi
+
+(cd "$tree" && go build -o "$work/aptindex" ./tools/aptindex)
+"$work/aptindex" -dir "$apt" "${debs[@]}"
+
+release=$apt/dists/stable
+if [ ! -f "$release/InRelease" ] || [ ! -f "$release/Release.gpg" ]; then
+  signer=()
+  if [ -n "${GPG_USER:-}" ]; then signer=(--local-user "$GPG_USER"); fi
+  if [ -z "${GPG_TTY:-}" ] && [ -t 0 ]; then GPG_TTY=$(tty); export GPG_TTY; fi
+  gpg --yes ${signer[@]+"${signer[@]}"} --clearsign -o "$release/InRelease" "$release/Release" ||
+    fail "gpg could not sign Release. The index in $apt is written and not signed: run this again once gpg can sign"
+  gpg --yes ${signer[@]+"${signer[@]}"} --armor --detach-sign -o "$release/Release.gpg" "$release/Release" ||
+    fail "gpg could not sign Release. The index in $apt is written and not signed: run this again once gpg can sign"
+  say "signed dists/stable/Release into InRelease and Release.gpg"
+fi
+gpgv --keyring "$work/keys.gpg" "$release/InRelease" 2>"$work/gpgv.txt" ||
+  { cat "$work/gpgv.txt" >&2; fail "InRelease is not a good signature by a key in KEYS, so apt would refuse the repository. Remove $release/InRelease and $release/Release.gpg, and run this again with GPG_USER set to your key in KEYS"; }
+gpgv --keyring "$work/keys.gpg" "$release/Release.gpg" "$release/Release" 2>"$work/gpgv.txt" ||
+  { cat "$work/gpgv.txt" >&2; fail "Release.gpg is not a good signature by a key in KEYS. Remove $release/InRelease and $release/Release.gpg, and run this again with GPG_USER set to your key in KEYS"; }
+listed=$(cat "$release"/main/binary-*/Packages | sed -n 's/^Version: //p' | sort -uV | paste -sd ' ' -)
+say "the index is signed by a key in KEYS, and lists $listed"
diff --git a/tools/aptindex/main.go b/tools/aptindex/main.go
new file mode 100644
index 0000000..f3d83a3
--- /dev/null
+++ b/tools/aptindex/main.go
@@ -0,0 +1,497 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Command aptindex adds released Debian packages to the apt repository that
+// the SkyWalking website serves at https://skywalking.apache.org/apt, from
+// static/apt in apache/skywalking-website.
+//
+//	go run ./tools/aptindex -dir APT_DIR PACKAGE.deb...
+//
+// The repository holds no package. It holds the index, which lists every
+// version of every package, and a .htaccess that redirects each package's
+// address in the index to the file on the Apache download sites. apt follows
+// the redirect and checks the file against the index. The newest version is
+// on the download mirrors, and archive.apache.org keeps every version, so the
+// newest redirects to the mirrors and every older one to the archive.
+//
+// It writes, under APT_DIR:
+//
+//	dists/stable/main/binary-ARCH/Packages and Packages.gz, for amd64 and arm64
+//	dists/stable/Release, which names the size and hashes of each of them
+//	.htaccess, the redirects
+//
+// A package already in the index stays as it is. The same package given again
+// changes nothing, and a package of the same name, version and architecture
+// with other bytes is refused, because apt would reject the published file.
+// When an index changes, Release is written with a new date, and InRelease and
+// Release.gpg, its signatures, are removed. The release manager signs Release
+// again: tools/apt-repository.sh does both.
+package main
+
+import (
+	"archive/tar"
+	"bufio"
+	"bytes"
+	"compress/gzip"
+	"crypto/sha256"
+	"crypto/sha512"
+	"encoding/hex"
+	"errors"
+	"flag"
+	"fmt"
+	"io"
+	"os"
+	"path/filepath"
+	"regexp"
+	"sort"
+	"strconv"
+	"strings"
+	"time"
+)
+
+const (
+	suite     = "stable"
+	component = "main"
+	// The name make binaries gives a Debian package in the release.
+	fileTemplate = "apache-skywalking-ai-sessionizer-{version}-bin-{package}-{arch}.deb"
+)
+
+var arches = []string{"amd64", "arm64"}
+
+func main() {
+	dir := flag.String("dir", "", "the apt directory: static/apt in apache/skywalking-website")
+	current := flag.String("current", "https://www.apache.org/dyn/closer.lua/skywalking/ai-sessionizer/{version}/{file}?action=download",
+		"where the newest version's packages are")
+	archive := flag.String("archive", "https://archive.apache.org/dist/skywalking/ai-sessionizer/{version}/{file}",
+		"where every other version's packages are")
+	date := flag.String("date", "", "the date of Release, in RFC 3339; now when empty")
+	flag.Parse()
+	if err := run(*dir, *current, *archive, *date, flag.Args()); err != nil {
+		fmt.Fprintln(os.Stderr, "aptindex:", err)
+		os.Exit(1)
+	}
+}
+
+// A field of a stanza, in the order it is written.
+type field struct{ name, value string }
+
+type stanza []field
+
+func (s stanza) get(name string) string {
+	for _, f := range s {
+		if strings.EqualFold(f.name, name) {
+			return f.value
+		}
+	}
+	return ""
+}
+
+func (s stanza) key() string {
+	return s.get("Package") + " " + s.get("Version") + " " + s.get("Architecture")
+}
+
+var releaseVersion = regexp.MustCompile(`^[0-9]+(\.[0-9]+)*$`)
+
+func run(dir, current, archive, date string, debs []string) error {
+	if dir == "" {
+		return errors.New("-dir is needed")
+	}
+	for _, t := range []string{current, archive} {
+		if !strings.Contains(t, "{version}") || !strings.Contains(t, "{file}") {
+			return fmt.Errorf("%q must hold {version} and {file}", t)
+		}
+	}
+	stamp := time.Now().UTC()
+	if date != "" {
+		var err error
+		if stamp, err = time.Parse(time.RFC3339, date); err != nil {
+			return fmt.Errorf("-date: %w", err)
+		}
+		stamp = stamp.UTC()
+	}
+	index := map[string][]stanza{}
+	for _, arch := range arches {
+		entries, err := readPackages(filepath.Join(dir, packagesPath(arch)))
+		if err != nil {
+			return err
+		}
+		index[arch] = entries
+	}
+	for _, deb := range debs {
+		entry, err := describe(deb)
+		if err != nil {
+			return fmt.Errorf("%s: %w", deb, err)
+		}
+		arch := entry.get("Architecture")
+		added := true
+		for _, known := range index[arch] {
+			if known.key() != entry.key() {
+				continue
+			}
+			if known.get("SHA256") != entry.get("SHA256") || known.get("Size") != entry.get("Size") {
+				return fmt.Errorf("%s: the index lists %s already, with other bytes. A published package never changes", deb, entry.key())
+			}
+			added = false
+		}
+		if added {
+			index[arch] = append(index[arch], entry)
+			fmt.Printf("aptindex: added %s\n", entry.key())
+		} else {
+			fmt.Printf("aptindex: %s is in the index already\n", entry.key())
+		}
+	}
+
+	changed := false
+	newest := ""
+	for _, arch := range arches {
+		entries := index[arch]
+		sort.SliceStable(entries, func(i, j int) bool {
+			if a, b := entries[i].get("Package"), entries[j].get("Package"); a != b {
+				return a < b
+			}
+			return compareVersions(entries[i].get("Version"), entries[j].get("Version")) < 0
+		})
+		for _, e := range entries {
+			if newest == "" || compareVersions(e.get("Version"), newest) > 0 {
+				newest = e.get("Version")
+			}
+		}
+		text := writeStanzas(entries)
+		wrote, err := update(filepath.Join(dir, packagesPath(arch)), text)
+		if err != nil {
+			return err
+		}
+		changed = changed || wrote
+		packed, err := gzipped(text)
+		if err != nil {
+			return err
+		}
+		// A Packages.gz from another gzip differs in bytes and not in what
+		// it holds, so it is written again only when Packages changed or it
+		// is missing.
+		gzPath := filepath.Join(dir, packagesPath(arch)+".gz")
+		if _, err := os.Stat(gzPath); wrote || errors.Is(err, os.ErrNotExist) {
+			if err := write(gzPath, packed); err != nil {
+				return err
+			}
+			changed = true
+		}
+	}
+
+	releasePath := filepath.Join(dir, "dists", suite, "Release")
+	if _, err := os.Stat(releasePath); changed || errors.Is(err, os.ErrNotExist) {
+		release, err := releaseFile(dir, stamp)
+		if err != nil {
+			return err
+		}
+		if err := write(releasePath, release); err != nil {
+			return err
+		}
+		for _, signature := range []string{"InRelease", "Release.gpg"} {
+			if err := os.Remove(filepath.Join(dir, "dists", suite, signature)); err != nil && !errors.Is(err, os.ErrNotExist) {
+				return err
+			}
+		}
+		fmt.Println("aptindex: wrote dists/stable/Release, which needs to be signed again")
+	} else {
+		fmt.Println("aptindex: the index did not change")
+	}
+
+	wrote, err := update(filepath.Join(dir, ".htaccess"), redirects(index, newest, current, archive))
+	if err != nil {
+		return err
+	}
+	if wrote {
+		fmt.Printf("aptindex: wrote .htaccess: %s from the download mirrors, every older version from the archive\n", newest)
+	}
+	return nil
+}
+
+func packagesPath(arch string) string {
+	return filepath.Join("dists", suite, component, "binary-"+arch, "Packages")
+}
+
+// describe reads a package's control file and returns its index entry.
+func describe(deb string) (stanza, error) {
+	body, err := os.ReadFile(deb)
+	if err != nil {
+		return nil, err
+	}
+	control, err := controlOf(body)
+	if err != nil {
+		return nil, err
+	}
+	fields, err := parseStanzas(control)
+	if err != nil || len(fields) != 1 {
+		return nil, fmt.Errorf("the control file is not one stanza")
+	}
+	entry := fields[0]
+	pkg, version, arch := entry.get("Package"), entry.get("Version"), entry.get("Architecture")
+	if !releaseVersion.MatchString(version) {
+		return nil, fmt.Errorf("version %q is not a release version: digits and dots", version)
+	}
+	known := false
+	for _, a := range arches {
+		known = known || a == arch
+	}
+	if !known {
+		return nil, fmt.Errorf("architecture %q is not one of %s", arch, strings.Join(arches, " "))
+	}
+	if want := distName(pkg, version, arch); filepath.Base(deb) != want {
+		return nil, fmt.Errorf("the release names this package %s", want)
+	}
+	s256 := sha256.Sum256(body)
+	s512 := sha512.Sum512(body)
+	var out stanza
+	for _, f := range entry {
+		if f.name != "Description" {
+			out = append(out, f)
+		}
+	}
+	out = append(out,
+		field{"Filename", "pool/" + pkg + "_" + version + "_" + arch + ".deb"},
+		field{"Size", strconv.Itoa(len(body))},
+		field{"SHA256", hex.EncodeToString(s256[:])},
+		field{"SHA512", hex.EncodeToString(s512[:])},
+		field{"Description", entry.get("Description")},
+	)
+	return out, nil
+}
+
+// distName is the name of a package on the download sites.
+func distName(pkg, version, arch string) string {
+	return strings.NewReplacer("{version}", version, "{package}", pkg, "{arch}", arch).Replace(fileTemplate)
+}
+
+// controlOf takes the control file out of a .deb: an ar archive whose second
+// member is control.tar.gz.
+func controlOf(deb []byte) ([]byte, error) {
+	const magic = "!<arch>\n"
+	if !bytes.HasPrefix(deb, []byte(magic)) {
+		return nil, errors.New("not a Debian package: no ar header")
+	}
+	rest := deb[len(magic):]
+	for len(rest) >= 60 {
+		header := rest[:60]
+		name := strings.TrimRight(strings.TrimSpace(string(header[:16])), "/")
+		size, err := strconv.Atoi(strings.TrimSpace(string(header[48:58])))
+		if err != nil || size < 0 || 60+size > len(rest) {
+			return nil, errors.New("a damaged ar member header")
+		}
+		body := rest[60 : 60+size]
+		if name == "control.tar.gz" {
+			gz, err := gzip.NewReader(bytes.NewReader(body))
+			if err != nil {
+				return nil, err
+			}
+			tr := tar.NewReader(gz)
+			for {
+				h, err := tr.Next()
+				if err == io.EOF {
+					break
+				}
+				if err != nil {
+					return nil, err
+				}
+				if strings.TrimPrefix(h.Name, "./") == "control" {
+					return io.ReadAll(tr)
+				}
+			}
+			return nil, errors.New("control.tar.gz holds no control file")
+		}
+		rest = rest[60+size+size%2:]
+	}
+	return nil, errors.New("no control.tar.gz member")
+}
+
+func readPackages(path string) ([]stanza, error) {
+	body, err := os.ReadFile(path)
+	if errors.Is(err, os.ErrNotExist) {
+		return nil, nil
+	}
+	if err != nil {
+		return nil, err
+	}
+	entries, err := parseStanzas(body)
+	if err != nil {
+		return nil, fmt.Errorf("%s: %w", path, err)
+	}
+	return entries, nil
+}
+
+func parseStanzas(body []byte) ([]stanza, error) {
+	var out []stanza
+	var cur stanza
+	sc := bufio.NewScanner(bytes.NewReader(body))
+	for sc.Scan() {
+		line := sc.Text()
+		switch {
+		case strings.TrimSpace(line) == "":
+			if len(cur) > 0 {
+				out = append(out, cur)
+				cur = nil
+			}
+		case line[0] == ' ' || line[0] == '\t':
+			if len(cur) == 0 {
+				return nil, fmt.Errorf("a continuation line with no field: %q", line)
+			}
+			cur[len(cur)-1].value += "\n" + line
+		default:
+			name, value, ok := strings.Cut(line, ":")
+			if !ok {
+				return nil, fmt.Errorf("a line with no field name: %q", line)
+			}
+			cur = append(cur, field{name, strings.TrimSpace(value)})
+		}
+	}
+	if err := sc.Err(); err != nil {
+		return nil, err
+	}
+	if len(cur) > 0 {
+		out = append(out, cur)
+	}
+	return out, nil
+}
+
+func writeStanzas(entries []stanza) []byte {
+	var b bytes.Buffer
+	for i, e := range entries {
+		if i > 0 {
+			b.WriteString("\n")
+		}
+		for _, f := range e {
+			fmt.Fprintf(&b, "%s: %s\n", f.name, f.value)
+		}
+	}
+	return b.Bytes()
+}
+
+func gzipped(body []byte) ([]byte, error) {
+	var out bytes.Buffer
+	gz, _ := gzip.NewWriterLevel(&out, gzip.BestCompression)
+	if _, err := gz.Write(body); err != nil {
+		return nil, err
+	}
+	if err := gz.Close(); err != nil {
+		return nil, err
+	}
+	return out.Bytes(), nil
+}
+
+func releaseFile(dir string, stamp time.Time) ([]byte, error) {
+	var b bytes.Buffer
+	b.WriteString("Origin: Apache SkyWalking\n")
+	b.WriteString("Label: Apache SkyWalking AI Sessionizer\n")
+	fmt.Fprintf(&b, "Suite: %s\nCodename: %s\n", suite, suite)
+	fmt.Fprintf(&b, "Date: %s\n", stamp.Format("Mon, 02 Jan 2006 15:04:05 UTC"))
+	fmt.Fprintf(&b, "Architectures: %s\n", strings.Join(arches, " "))
+	fmt.Fprintf(&b, "Components: %s\n", component)
+	b.WriteString("Description: Apache SkyWalking AI Sessionizer, the released Debian packages\n")
+	type sums struct{ s256, s512 string }
+	var names []string
+	hashes := map[string]sums{}
+	sizes := map[string]int{}
+	for _, arch := range arches {
+		for _, suffix := range []string{"", ".gz"} {
+			name := component + "/binary-" + arch + "/Packages" + suffix
+			body, err := os.ReadFile(filepath.Join(dir, "dists", suite, filepath.FromSlash(name)))
+			if err != nil {
+				return nil, err
+			}
+			a, c := sha256.Sum256(body), sha512.Sum512(body)
+			names = append(names, name)
+			hashes[name] = sums{hex.EncodeToString(a[:]), hex.EncodeToString(c[:])}
+			sizes[name] = len(body)
+		}
+	}
+	b.WriteString("SHA256:\n")
+	for _, n := range names {
+		fmt.Fprintf(&b, " %s %d %s\n", hashes[n].s256, sizes[n], n)
+	}
+	b.WriteString("SHA512:\n")
+	for _, n := range names {
+		fmt.Fprintf(&b, " %s %d %s\n", hashes[n].s512, sizes[n], n)
+	}
+	return b.Bytes(), nil
+}
+
+func redirects(index map[string][]stanza, newest, current, archive string) []byte {
+	var b bytes.Buffer
+	b.WriteString(`# Written by tools/aptindex in apache/skywalking-ai-sessionizer. Do not edit it
+# by hand: run tools/apt-repository.sh there.
+#
+# apt reads the index under dists/ and asks for each package under pool/.
+# These rules send it to the file on the Apache download sites. The newest
+# version is on the download mirrors, and archive.apache.org keeps every
+# version.
+RewriteEngine On
+`)
+	for _, arch := range arches {
+		for _, e := range index[arch] {
+			pkg, version := e.get("Package"), e.get("Version")
+			target := archive
+			if version == newest {
+				target = current
+			}
+			url := strings.NewReplacer("{version}", version, "{file}", distName(pkg, version, arch)).Replace(target)
+			fmt.Fprintf(&b, "RewriteRule ^%s$ %s [R=302,L]\n", regexp.QuoteMeta(e.get("Filename")), url)
+		}
+	}
+	return b.Bytes()
+}
+
+// compareVersions orders release versions, digits and dots, by number.
+func compareVersions(a, b string) int {
+	as, bs := strings.Split(a, "."), strings.Split(b, ".")
+	for i := 0; i < len(as) || i < len(bs); i++ {
+		var x, y int
+		if i < len(as) {
+			x, _ = strconv.Atoi(as[i])
+		}
+		if i < len(bs) {
+			y, _ = strconv.Atoi(bs[i])
+		}
+		if x != y {
+			if x < y {
+				return -1
+			}
+			return 1
+		}
+	}
+	return 0
+}
+
+// update writes body to path when the file does not hold it already, and
+// says whether it wrote.
+func update(path string, body []byte) (bool, error) {
+	old, err := os.ReadFile(path)
+	if err == nil && bytes.Equal(old, body) {
+		return false, nil
+	}
+	return true, write(path, body)
+}
+
+func write(path string, body []byte) error {
+	if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
+		return err
+	}
+	tmp := path + ".tmp"
+	if err := os.WriteFile(tmp, body, 0o644); err != nil {
+		return err
+	}
+	return os.Rename(tmp, path)
+}
diff --git a/tools/aptindex/main_test.go b/tools/aptindex/main_test.go
new file mode 100644
index 0000000..895b1a7
--- /dev/null
+++ b/tools/aptindex/main_test.go
@@ -0,0 +1,139 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package main
+
+import (
+	"os"
+	"path/filepath"
+	"strings"
+	"testing"
+
+	"github.com/apache/skywalking-ai-sessionizer/tools/debfixture"
+)
+
+const (
+	current = "https://mirrors/{version}/{file}"
+	archive = "https://archive/{version}/{file}"
+)
+
+func deb(t *testing.T, dir, pkg, version, arch, body string) string {
+	t.Helper()
+	control := "Package: " + pkg + "\nVersion: " + version + "\nArchitecture: " + arch + "\nDescription: fixture\n more text\n"
+	data, err := debfixture.Bytes(control, map[string]string{"usr/bin/" + pkg: body})
+	if err != nil {
+		t.Fatal(err)
+	}
+	path := filepath.Join(dir, distName(pkg, version, arch))
+	if err := os.WriteFile(path, data, 0o644); err != nil {
+		t.Fatal(err)
+	}
+	return path
+}
+
+func read(t *testing.T, path string) string {
+	t.Helper()
+	body, err := os.ReadFile(path)
+	if err != nil {
+		t.Fatal(err)
+	}
+	return string(body)
+}
+
+// Each version is added in its own run. The index keeps every version, the
+// newest goes to the mirrors and every older one to the archive, and a run
+// that adds nothing new leaves Release and its signatures alone.
+func TestVersionsAreAddedOneRunAtATime(t *testing.T) {
+	apt, debs := t.TempDir(), t.TempDir()
+	older := deb(t, debs, "asz", "0.4.0", "amd64", "old")
+	if err := run(apt, current, archive, "2026-09-17T00:00:00Z", []string{older}); err != nil {
+		t.Fatal(err)
+	}
+	newer := deb(t, debs, "asz", "0.10.0", "amd64", "new")
+	if err := run(apt, current, archive, "2026-09-18T00:00:00Z", []string{newer}); err != nil {
+		t.Fatal(err)
+	}
+	packages := read(t, filepath.Join(apt, "dists/stable/main/binary-amd64/Packages"))
+	for _, want := range []string{"Filename: pool/asz_0.4.0_amd64.deb", "Filename: pool/asz_0.10.0_amd64.deb", "Description: fixture\n more text\n"} {
+		if !strings.Contains(packages, want) {
+			t.Fatalf("Packages has no %q:\n%s", want, packages)
+		}
+	}
+	redirects := read(t, filepath.Join(apt, ".htaccess"))
+	for _, want := range []string{
+		"RewriteRule ^pool/asz_0\\.10\\.0_amd64\\.deb$ https://mirrors/0.10.0/apache-skywalking-ai-sessionizer-0.10.0-bin-asz-amd64.deb [R=302,L]\n",
+		"RewriteRule ^pool/asz_0\\.4\\.0_amd64\\.deb$ https://archive/0.4.0/apache-skywalking-ai-sessionizer-0.4.0-bin-asz-amd64.deb [R=302,L]\n",
+	} {
+		if !strings.Contains(redirects, want) {
+			t.Fatalf(".htaccess has no %q:\n%s", want, redirects)
+		}
+	}
+	release := filepath.Join(apt, "dists/stable/Release")
+	if !strings.Contains(read(t, release), "Date: Fri, 18 Sep 2026 00:00:00 UTC\n") {
+		t.Fatalf("Release does not carry the date of the run that changed the index:\n%s", read(t, release))
+	}
+	for _, signature := range []string{"InRelease", "Release.gpg"} {
+		if err := os.WriteFile(filepath.Join(apt, "dists/stable", signature), []byte("signed"), 0o644); err != nil {
+			t.Fatal(err)
+		}
+	}
+	before := read(t, release)
+	if err := run(apt, current, archive, "2026-09-19T00:00:00Z", []string{older, newer}); err != nil {
+		t.Fatal(err)
+	}
+	if read(t, release) != before {
+		t.Fatal("a run that added nothing wrote Release again")
+	}
+	if _, err := os.Stat(filepath.Join(apt, "dists/stable/InRelease")); err != nil {
+		t.Fatal("a run that added nothing removed the signature")
+	}
+	third := deb(t, debs, "asz-claude-code", "0.10.0", "arm64", "plugin")
+	if err := run(apt, current, archive, "2026-09-19T00:00:00Z", []string{third}); err != nil {
+		t.Fatal(err)
+	}
+	if _, err := os.Stat(filepath.Join(apt, "dists/stable/InRelease")); !os.IsNotExist(err) {
+		t.Fatal("a changed index kept the signature of the old Release")
+	}
+}
+
+// A published package never changes. apt would refuse the file the
+// redirect sends it to, so the index refuses other bytes under the same name.
+func TestOtherBytesUnderAPublishedVersionAreRefused(t *testing.T) {
+	apt := t.TempDir()
+	if err := run(apt, current, archive, "", []string{deb(t, t.TempDir(), "asz", "0.4.0", "amd64", "voted")}); err != nil {
+		t.Fatal(err)
+	}
+	err := run(apt, current, archive, "", []string{deb(t, t.TempDir(), "asz", "0.4.0", "amd64", "rebuilt")})
+	if err == nil || !strings.Contains(err.Error(), "never changes") {
+		t.Fatalf("other bytes were accepted: %v", err)
+	}
+}
+
+func TestAPackageMustBeAReleasedOneByItsName(t *testing.T) {
+	debs := t.TempDir()
+	renamed := filepath.Join(debs, "asz_0.4.0_amd64.deb")
+	if err := os.Rename(deb(t, debs, "asz", "0.4.0", "amd64", "x"), renamed); err != nil {
+		t.Fatal(err)
+	}
+	if err := run(t.TempDir(), current, archive, "", []string{renamed}); err == nil || !strings.Contains(err.Error(), "the release names this package") {
+		t.Fatalf("a package under another name was accepted: %v", err)
+	}
+	build := deb(t, debs, "asz", "0~e55c406", "amd64", "x")
+	if err := run(t.TempDir(), current, archive, "", []string{build}); err == nil || !strings.Contains(err.Error(), "not a release version") {
+		t.Fatalf("a build of a commit was accepted: %v", err)
+	}
+}
diff --git a/tools/ci-binaries.sh b/tools/ci-binaries.sh
index 117cf3e..0324492 100755
--- a/tools/ci-binaries.sh
+++ b/tools/ci-binaries.sh
@@ -17,13 +17,15 @@
 # under the License.
 
 # Download the CI-built binary packages from the tag's GitHub prerelease.
-# Usage: tools/ci-binaries.sh VERSION COMMIT RUN_ID OUT_DIR "OS/ARCH ..."
-# OUT_DIR must be new or empty. PLATFORMS comes from the release tag's Makefile.
+# Usage: tools/ci-binaries.sh VERSION COMMIT RUN_ID OUT_DIR "OS/ARCH ..." ["DEB_PACKAGES"]
+# OUT_DIR must be new or empty. PLATFORMS and DEB_PACKAGES come from the
+# release tag's Makefile.
 # An empty RUN_ID or auto uses the run recorded by CI after uploading its files.
 # Only GitHub API reads are made. No package is installed before its run,
 # release identity, asset digests, checksums and archive checks have passed.
 set -euo pipefail
-[ "$#" -eq 5 ] || { echo 'usage: tools/ci-binaries.sh VERSION COMMIT RUN_ID OUT_DIR "OS/ARCH ..."' >&2; exit 2; }
+[ "$#" -eq 5 ] || [ "$#" -eq 6 ] || { echo 'usage: tools/ci-binaries.sh VERSION COMMIT RUN_ID OUT_DIR "OS/ARCH ..." ["DEB_PACKAGES"]' >&2; exit 2; }
+[ "$#" -eq 6 ] || set -- "$@" ""
 command -v python3 >/dev/null || { echo 'ci-binaries: python3 is required' >&2; exit 1; }
 command -v gh >/dev/null || { echo 'ci-binaries: gh is required' >&2; exit 1; }
 script_dir=$(cd "$(dirname "$0")" && pwd)
@@ -139,7 +141,7 @@ def release_assets(base, release_id, expected, signed, run=None):
 
 
 def main():
-    version, commit, run_id, directory, platform_text, package_check = sys.argv[1:]
+    version, commit, run_id, directory, platform_text, deb_text, package_check = sys.argv[1:]
     require(re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?", version), "invalid release version")
     require(re.fullmatch(r"[0-9a-f]{40}", commit), "COMMIT must be the complete commit SHA")
     automatic = run_id in ("", "auto")
@@ -153,6 +155,16 @@ def main():
         os_name, arch = platform.split("/")
         extension = "zip" if os_name == "windows" else "tgz"
         packages.append(f"apache-skywalking-ai-sessionizer-{version}-bin-{os_name}-{arch}.{extension}")
+    # DEB_PACKAGES in the tag's Makefile names the Debian packages, one for
+    # each Linux platform. A tag from before them passes none.
+    debs = deb_text.split()
+    require(len(debs) == len(set(debs)) and set(debs) <= {"asz", "asz-claude-code"},
+            "DEB_PACKAGES must name distinct packages among asz and asz-claude-code")
+    for name in debs:
+        for platform in platforms:
+            os_name, arch = platform.split("/")
+            if os_name == "linux":
+                packages.append(f"apache-skywalking-ai-sessionizer-{version}-bin-{name}-{arch}.deb")
     expected = set(packages + [name + ".sha512" for name in packages])
     source = f"apache-skywalking-ai-sessionizer-{version}-src.tgz"
     signed = {source, source + ".sha512"} | {name + ".asc" for name in packages + [source]}
diff --git a/tools/ci-upload-binaries.sh b/tools/ci-upload-binaries.sh
index e8d48d1..7b29edb 100644
--- a/tools/ci-upload-binaries.sh
+++ b/tools/ci-upload-binaries.sh
@@ -23,7 +23,8 @@
 # failed or rejected candidate must be removed explicitly before its
 # replacement is prepared.
 set -euo pipefail
-[ "$#" -eq 6 ] || { echo 'usage: ci-upload-binaries.sh VERSION COMMIT RUN_ID RUN_ATTEMPT PKG_DIR "OS/ARCH ..."' >&2; exit 2; }
+[ "$#" -eq 6 ] || [ "$#" -eq 7 ] || { echo 'usage: ci-upload-binaries.sh VERSION COMMIT RUN_ID RUN_ATTEMPT PKG_DIR "OS/ARCH ..." ["DEB_PACKAGES"]' >&2; exit 2; }
+[ "$#" -eq 7 ] || set -- "$@" ""
 script_dir=$(cd "$(dirname "$0")" && pwd)
 python3 - "$@" "$script_dir/package-check.sh" <<'PY'
 import hashlib
@@ -60,7 +61,7 @@ def digest(path, algorithm="sha512"):
     return result.hexdigest()
 
 def main():
-    version, commit, run_id, attempt, directory, platforms, checker = sys.argv[1:]
+    version, commit, run_id, attempt, directory, platforms, deb_text, checker = sys.argv[1:]
     require(re.fullmatch(r"[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.]+)?", version), "invalid version")
     require(re.fullmatch(r"[0-9a-f]{40}", commit), "invalid commit")
     for identifier in (run_id, attempt):
@@ -77,6 +78,16 @@ def main():
         os_name, arch = platform.split("/")
         extension = "zip" if os_name == "windows" else "tgz"
         packages.append(f"apache-skywalking-ai-sessionizer-{version}-bin-{os_name}-{arch}.{extension}")
+    # DEB_PACKAGES in the tag's Makefile names the Debian packages, one for
+    # each Linux platform. A tag from before them passes none.
+    debs = deb_text.split()
+    require(len(debs) == len(set(debs)) and set(debs) <= {"asz", "asz-claude-code"},
+            "DEB_PACKAGES must name distinct packages among asz and asz-claude-code")
+    for name in debs:
+        for platform in pairs:
+            os_name, arch = platform.split("/")
+            if os_name == "linux":
+                packages.append(f"apache-skywalking-ai-sessionizer-{version}-bin-{name}-{arch}.deb")
     names = sorted(packages + [name + ".sha512" for name in packages])
     require({entry.name for entry in package_dir.iterdir()} == set(names), "the CI package directory has missing or extra files")
     for name in names:
diff --git a/tools/cibinaries/cibinaries_test.go b/tools/cibinaries/cibinaries_test.go
index 59b092e..974ce93 100644
--- a/tools/cibinaries/cibinaries_test.go
+++ b/tools/cibinaries/cibinaries_test.go
@@ -33,6 +33,8 @@ import (
 	"sort"
 	"strings"
 	"testing"
+
+	"github.com/apache/skywalking-ai-sessionizer/tools/debfixture"
 )
 
 const (
@@ -226,6 +228,26 @@ func (f *fixture) write() {
 }
 
 func (f *fixture) execute(selected ...string) (string, error) {
+	f.t.Helper()
+	return f.executeWith("", selected...)
+}
+
+// addDebs adds the Debian packages CI builds for DEB_PACKAGES to the release.
+func (f *fixture) addDebs(debs string) {
+	f.t.Helper()
+	for _, p := range strings.Fields(debs) {
+		for _, arch := range []string{"amd64", "arm64"} {
+			name := "apache-skywalking-ai-sessionizer-" + version + "-bin-" + p + "-" + arch + ".deb"
+			data, err := debfixture.Bytes("Package: "+p+"\n", map[string]string{"usr/bin/" + p: "fixture\n"})
+			if err != nil {
+				f.t.Fatal(err)
+			}
+			f.members = append(f.members, member{name: name, data: data}, member{name: name + ".sha512", data: []byte(fmt.Sprintf("%x  %s\n", sha512.Sum512(data), name))})
+		}
+	}
+}
+
+func (f *fixture) executeWith(debs string, selected ...string) (string, error) {
 	f.t.Helper()
 	f.write()
 	script, err := filepath.Abs(filepath.Join("..", "ci-binaries.sh"))
@@ -236,7 +258,11 @@ func (f *fixture) execute(selected ...string) (string, error) {
 	if len(selected) > 0 {
 		runID = selected[0]
 	}
-	command := exec.Command("bash", script, version, commit, runID, filepath.Join(f.dir, "output"), platforms)
+	args := []string{script, version, commit, runID, filepath.Join(f.dir, "output"), platforms}
+	if debs != "" {
+		args = append(args, debs)
+	}
+	command := exec.Command("bash", args...)
 	command.Env = append(os.Environ(), "PATH="+filepath.Join(f.dir, "bin")+string(os.PathListSeparator)+os.Getenv("PATH"), "CI_BINARY_FIXTURE="+f.dir)
 	output, err := command.CombinedOutput()
 	return string(output), err
@@ -259,6 +285,28 @@ func TestCIBinariesUsePrereleaseBuildRun(t *testing.T) {
 	}
 }
 
+// A tag whose Makefile names Debian packages has one of each for every Linux
+// platform, and the prerelease must hold them too.
+func TestCIBinariesExpectTheDebianPackages(t *testing.T) {
+	f := newFixture(t)
+	f.addDebs("asz asz-claude-code")
+	output, err := f.executeWith("asz asz-claude-code")
+	if err != nil || !strings.Contains(output, "verified 10 packages") {
+		t.Fatalf("prerelease with Debian packages rejected: %v\n%s", err, output)
+	}
+	f = newFixture(t)
+	output, err = f.executeWith("asz asz-claude-code")
+	if err == nil || !strings.Contains(output, "exactly the expected") {
+		t.Fatalf("prerelease without the Debian packages accepted: %v\n%s", err, output)
+	}
+	f = newFixture(t)
+	f.addDebs("asz")
+	output, err = f.executeWith("asz")
+	if err != nil || !strings.Contains(output, "verified 8 packages") {
+		t.Fatalf("prerelease with the asz Debian packages rejected: %v\n%s", err, output)
+	}
+}
+
 // A candidate that stopped after attaching its signatures is run again. The
 // prerelease then holds the source package and the signatures too, uploaded
 // by the release manager, and only CI's files are downloaded and checked.
diff --git a/tools/ciupload/ciupload_test.go b/tools/ciupload/ciupload_test.go
index bfbf2c8..bfac022 100644
--- a/tools/ciupload/ciupload_test.go
+++ b/tools/ciupload/ciupload_test.go
@@ -32,6 +32,8 @@ import (
 	"sort"
 	"strings"
 	"testing"
+
+	"github.com/apache/skywalking-ai-sessionizer/tools/debfixture"
 )
 
 func TestPrereleaseIsReadyOnlyAfterEveryUploadedByteIsVerified(t *testing.T) {
@@ -43,7 +45,7 @@ func TestPrereleaseIsReadyOnlyAfterEveryUploadedByteIsVerified(t *testing.T) {
 			t.Skipf("CI upload fixture needs %s", name)
 		}
 	}
-	for _, mode := range []string{"complete", "reuse-empty", "existing", "official", "api-failure", "corrupt-download", "moved-tag", "swapped-assets"} {
+	for _, mode := range []string{"complete", "complete-debs", "missing-deb", "reuse-empty", "existing", "official", "api-failure", "corrupt-download", "moved-tag", "swapped-assets"} {
 		t.Run(mode, func(t *testing.T) {
 			dir := t.TempDir()
 			bin := filepath.Join(dir, "bin")
@@ -78,6 +80,25 @@ func TestPrereleaseIsReadyOnlyAfterEveryUploadedByteIsVerified(t *testing.T) {
 			if err := os.WriteFile(filepath.Join(packages, name+".sha512"), []byte(sum), 0o644); err != nil {
 				t.Fatal(err)
 			}
+			// DEB_PACKAGES names a Debian package for the Linux platform.
+			debs := ""
+			deb := "apache-skywalking-ai-sessionizer-0.3.0-bin-asz-amd64.deb"
+			if mode == "complete-debs" || mode == "missing-deb" {
+				debs = "asz"
+			}
+			if mode == "complete-debs" {
+				body, err := debfixture.Bytes("Package: asz\n", map[string]string{"usr/bin/asz": "CI binary bytes"})
+				if err != nil {
+					t.Fatal(err)
+				}
+				if err := os.WriteFile(filepath.Join(packages, deb), body, 0o644); err != nil {
+					t.Fatal(err)
+				}
+				sum := fmt.Sprintf("%x  %s\n", sha512.Sum512(body), deb)
+				if err := os.WriteFile(filepath.Join(packages, deb+".sha512"), []byte(sum), 0o644); err != nil {
+					t.Fatal(err)
+				}
+			}
 			// CI creates the prerelease on the tag push. An empty one left by an
 			// earlier attempt of the run is reused; any other is refused.
 			release := map[string]any{"id": 789, "tag_name": "v0.3.0", "name": "0.3.0", "draft": false, "prerelease": true, "body": "Developer review only. Not an Apache release.", "assets": []any{}}
@@ -87,7 +108,7 @@ func TestPrereleaseIsReadyOnlyAfterEveryUploadedByteIsVerified(t *testing.T) {
 			case "official":
 				release["prerelease"] = false
 			}
-			if mode != "complete" && mode != "api-failure" {
+			if mode != "complete" && mode != "complete-debs" && mode != "missing-deb" && mode != "api-failure" {
 				state, _ := json.Marshal(release)
 				if err := os.WriteFile(filepath.Join(dir, "release.json"), state, 0o644); err != nil {
 					t.Fatal(err)
@@ -148,7 +169,7 @@ else: sys.exit(8)
 			if err := os.WriteFile(filepath.Join(bin, "gh"), []byte(stub), 0o755); err != nil {
 				t.Fatal(err)
 			}
-			cmd := exec.Command("bash", "../ci-upload-binaries.sh", "0.3.0", strings.Repeat("a", 40), "123", "2", packages, "linux/amd64")
+			cmd := exec.Command("bash", "../ci-upload-binaries.sh", "0.3.0", strings.Repeat("a", 40), "123", "2", packages, "linux/amd64", debs)
 			cmd.Env = append(os.Environ(), "PATH="+bin+string(os.PathListSeparator)+os.Getenv("PATH"), "CI_UPLOAD_FIXTURE="+dir, "CI_UPLOAD_MODE="+mode)
 			output, err := cmd.CombinedOutput()
 			if state, readErr := os.ReadFile(filepath.Join(dir, "release.json")); readErr == nil {
@@ -171,12 +192,17 @@ else: sys.exit(8)
 			fingerprint := sha256.Sum256([]byte(strings.Join(lines, "\n") + "\n"))
 			ready := strings.Contains(release["body"].(string), fmt.Sprintf("<!-- asz-ci-binaries run_id=123 run_attempt=2 commit=%s assets=%x -->", strings.Repeat("a", 40), fingerprint))
 			writes, _ := os.ReadFile(filepath.Join(dir, "writes"))
-			if mode == "complete" || mode == "reuse-empty" {
+			if mode == "complete" || mode == "complete-debs" || mode == "reuse-empty" {
 				if err != nil || !ready {
 					t.Fatalf("upload: %s\n%v; ready=%v", output, err, ready)
 				}
+				if mode == "complete-debs" {
+					if _, err := os.Stat(filepath.Join(remote, deb)); err != nil {
+						t.Fatalf("the Debian package was not attached: %v", err)
+					}
+				}
 				order := "upload\ndownload\nready\n"
-				if mode == "complete" {
+				if mode != "reuse-empty" {
 					order = "create\n" + order
 				}
 				if string(writes) != order {
@@ -193,7 +219,7 @@ else: sys.exit(8)
 				if err == nil || ready {
 					t.Fatalf("unsafe upload accepted: %s\n%v; ready=%v", output, err, ready)
 				}
-				if (mode == "existing" || mode == "official" || mode == "api-failure") && len(writes) > 0 {
+				if (mode == "existing" || mode == "official" || mode == "api-failure" || mode == "missing-deb") && len(writes) > 0 {
 					t.Fatalf("%s release was modified: %s", mode, writes)
 				}
 				if strings.Contains(string(writes), "ready") {
diff --git a/tools/deb-list.sh b/tools/deb-list.sh
new file mode 100755
index 0000000..084d7bf
--- /dev/null
+++ b/tools/deb-list.sh
@@ -0,0 +1,74 @@
+#!/bin/sh
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# Lists what a Debian package installs, one path per line with no leading
+# ./ or /, and a directory with a trailing slash. With --control, it prints
+# the package's control file instead, which names the package, its version
+# and its architecture.
+#
+#   tools/deb-list.sh [--control] PACKAGE.deb
+#
+# A .deb is an ar archive that holds a tar archive of the files. macOS has no
+# dpkg-deb, and GNU tar cannot read ar, so Python reads both, as it is
+# already needed by the release scripts.
+set -eu
+part=data
+if [ "${1:-}" = --control ]; then part=control; shift; fi
+[ "$#" -eq 1 ] || { echo "usage: tools/deb-list.sh [--control] PACKAGE.deb" >&2; exit 2; }
+command -v python3 >/dev/null 2>&1 || { echo "deb-list: python3 is required" >&2; exit 1; }
+exec python3 - "$part" "$1" <<'PY'
+import io, sys, tarfile
+
+part, path = sys.argv[1:]
+
+def fail(message):
+    print("deb-list: %s: %s" % (path, message), file=sys.stderr)
+    sys.exit(1)
+
+with open(path, "rb") as source:
+    data = source.read()
+if not data.startswith(b"!<arch>\n"):
+    fail("not a Debian package")
+offset, members = 8, {}
+while offset + 60 <= len(data):
+    header = data[offset:offset + 60]
+    name = header[:16].decode("ascii", "replace").strip().rstrip("/")
+    try:
+        size = int(header[48:58].decode("ascii").strip())
+    except ValueError:
+        fail("a damaged ar member header")
+    members[name] = data[offset + 60:offset + 60 + size]
+    offset += 60 + size + size % 2
+if members.get("debian-binary") != b"2.0\n":
+    fail("its debian-binary member is not 2.0")
+names = [n for n in members if n.startswith(part + ".tar")]
+if len(names) != 1:
+    fail("it has no single %s.tar member" % part)
+with tarfile.open(fileobj=io.BytesIO(members[names[0]])) as archive:
+    if part == "control":
+        for entry in archive.getmembers():
+            if entry.name in ("./control", "control"):
+                sys.stdout.write(archive.extractfile(entry).read().decode("utf-8"))
+                sys.exit(0)
+        fail("it has no control file")
+    for entry in archive.getmembers():
+        path = entry.name[2:] if entry.name.startswith("./") else entry.name.lstrip("/")
+        if path in ("", "."):
+            continue
+        print(path + "/" if entry.isdir() else path)
+PY
diff --git a/tools/debfixture/debfixture.go b/tools/debfixture/debfixture.go
new file mode 100644
index 0000000..662542a
--- /dev/null
+++ b/tools/debfixture/debfixture.go
@@ -0,0 +1,82 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Package debfixture writes small Debian packages for the tests of the
+// release scripts. tools/debpackage refuses what a test needs to hold, such
+// as macOS metadata, so the tests write their own.
+package debfixture
+
+import (
+	"archive/tar"
+	"bytes"
+	"compress/gzip"
+	"fmt"
+	"sort"
+)
+
+// Bytes returns a Debian package whose control file is control and whose
+// data archive holds files, by path with no leading ./.
+func Bytes(control string, files map[string]string) ([]byte, error) {
+	var names []string
+	for name := range files {
+		names = append(names, name)
+	}
+	sort.Strings(names)
+	data, err := tarGz(names, files)
+	if err != nil {
+		return nil, err
+	}
+	meta, err := tarGz([]string{"control"}, map[string]string{"control": control})
+	if err != nil {
+		return nil, err
+	}
+	var out bytes.Buffer
+	out.WriteString("!<arch>\n")
+	for _, m := range []struct {
+		name string
+		body []byte
+	}{{"debian-binary", []byte("2.0\n")}, {"control.tar.gz", meta}, {"data.tar.gz", data}} {
+		fmt.Fprintf(&out, "%-16s%-12d%-6d%-6d%-8s%-10d`\n", m.name, 0, 0, 0, "100644", len(m.body))
+		out.Write(m.body)
+		if len(m.body)%2 == 1 {
+			out.WriteByte('\n')
+		}
+	}
+	return out.Bytes(), nil
+}
+
+func tarGz(names []string, files map[string]string) ([]byte, error) {
+	var out bytes.Buffer
+	gz := gzip.NewWriter(&out)
+	tw := tar.NewWriter(gz)
+	for _, name := range names {
+		body := files[name]
+		if err := tw.WriteHeader(&tar.Header{Name: "./" + name, Mode: 0o644, Size: int64(len(body))}); err != nil {
+			return nil, err
+		}
+		if _, err := tw.Write([]byte(body)); err != nil {
+			return nil, err
+		}
+	}
+	if err := tw.Close(); err != nil {
+		return nil, err
+	}
+	if err := gz.Close(); err != nil {
+		return nil, err
+	}
+	return out.Bytes(), nil
+}
diff --git a/tools/debpackage/main.go b/tools/debpackage/main.go
new file mode 100644
index 0000000..bf08919
--- /dev/null
+++ b/tools/debpackage/main.go
@@ -0,0 +1,327 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// Command debpackage writes one Debian package from the files make binaries
+// staged for a Linux platform. make binaries runs it for every package in
+// DEB_PACKAGES and every Linux platform in PLATFORMS.
+//
+//	go run ./tools/debpackage -package asz -version 0.4.0 -arch amd64 \
+//	  -from dist/build/linux-amd64 -time 1757000000 -out FILE.deb
+//
+// A package holds its binary in /usr/bin, and the LICENSE, the NOTICE and the
+// dependency licenses under /usr/share/doc/PACKAGE, as the other binary
+// packages hold them beside the binary.
+//
+// The tool writes the archive itself rather than run dpkg-deb, which macOS
+// does not have. Two runs with the same files, version and time write the
+// same bytes: every entry gets the time given, owner and group 0, a fixed
+// mode, and one sorted order, and gzip records no name and no time.
+package main
+
+import (
+	"archive/tar"
+	"bytes"
+	"compress/gzip"
+	"crypto/md5" //nolint:gosec // dpkg --verify reads md5sums; it is not a security check
+	"encoding/hex"
+	"errors"
+	"flag"
+	"fmt"
+	"io"
+	"io/fs"
+	"os"
+	"path"
+	"path/filepath"
+	"regexp"
+	"sort"
+	"strconv"
+	"strings"
+	"time"
+)
+
+// A package of this project: the binary it installs, and what apt shows.
+type definition struct {
+	binary      string
+	summary     string
+	description []string
+}
+
+var definitions = map[string]definition{
+	"asz": {
+		binary:  "asz",
+		summary: "Conversation-level observability for long-lived AI agents",
+		description: []string{
+			"Apache SkyWalking AI Sessionizer assembles fragmented agent telemetry,",
+			"such as transcripts, subagent streams and workflow journals, into one",
+			"durable conversation structure.",
+		},
+	},
+	"asz-claude-code": {
+		binary:  "asz-claude-plugin",
+		summary: "Claude Code plugin that records which files each tool call changed",
+		description: []string{
+			"The binary the hooks of the asz-changes plugin run. The plugin itself is",
+			"installed into Claude Code with the claude plugin commands.",
+		},
+	},
+}
+
+var arches = map[string]bool{"amd64": true, "arm64": true}
+
+func main() {
+	pkg := flag.String("package", "", "the package: "+strings.Join(names(), " or "))
+	version := flag.String("version", "", "the version the binaries report")
+	arch := flag.String("arch", "", "the Debian architecture: amd64 or arm64")
+	from := flag.String("from", "", "the directory make binaries staged the platform's files in")
+	epoch := flag.Int64("time", -1, "the time of every entry, in seconds since 1970")
+	out := flag.String("out", "", "the package file to write")
+	flag.Parse()
+	if err := run(*pkg, *version, *arch, *from, *epoch, *out); err != nil {
+		fmt.Fprintln(os.Stderr, "debpackage:", err)
+		os.Exit(1)
+	}
+}
+
+func names() []string {
+	var list []string
+	for name := range definitions {
+		list = append(list, name)
+	}
+	sort.Strings(list)
+	return list
+}
+
+func run(pkg, version, arch, from string, epoch int64, out string) error {
+	def, ok := definitions[pkg]
+	if !ok {
+		return fmt.Errorf("unknown package %q: the packages are %s", pkg, strings.Join(names(), ", "))
+	}
+	if !arches[arch] {
+		return fmt.Errorf("unknown architecture %q: amd64 or arm64", arch)
+	}
+	if version == "" || from == "" || out == "" || epoch < 0 {
+		return errors.New("-version, -from, -time and -out are all needed")
+	}
+	stamp := time.Unix(epoch, 0).UTC()
+	files, err := stage(def, pkg, from)
+	if err != nil {
+		return err
+	}
+	data, installed, sums, err := dataArchive(files, stamp)
+	if err != nil {
+		return err
+	}
+	control := controlFile(pkg, def, DebianVersion(version), arch, installed)
+	meta, err := controlArchive(control, sums, stamp)
+	if err != nil {
+		return err
+	}
+	var deb bytes.Buffer
+	deb.WriteString("!<arch>\n")
+	for _, m := range []struct {
+		name string
+		body []byte
+	}{{"debian-binary", []byte("2.0\n")}, {"control.tar.gz", meta}, {"data.tar.gz", data}} {
+		arMember(&deb, m.name, m.body, epoch)
+	}
+	tmp := out + ".tmp"
+	if err := os.WriteFile(tmp, deb.Bytes(), 0o644); err != nil {
+		return err
+	}
+	return os.Rename(tmp, out)
+}
+
+// debianVersionPattern is what dpkg accepts as a version with no epoch: it
+// starts with a digit, and holds letters, digits and . + ~ -.
+var debianVersionPattern = regexp.MustCompile(`^[0-9][A-Za-z0-9.+~-]*$`)
+
+// DebianVersion is the version the package states. A release version is
+// used as it is. A build of a commit that is not tagged reports the commit,
+// which can start with a letter, and dpkg refuses such a version. It becomes
+// 0~COMMIT, which dpkg accepts and orders before every release.
+func DebianVersion(version string) string {
+	if debianVersionPattern.MatchString(version) {
+		return version
+	}
+	cleaned := regexp.MustCompile(`[^A-Za-z0-9.+~]`).ReplaceAllString(version, ".")
+	return "0~" + cleaned
+}
+
+// A file of the package: where it goes, and where it comes from.
+type file struct {
+	target string // relative to /, with no leading slash
+	source string
+	mode   int64
+}
+
+func stage(def definition, pkg, from string) ([]file, error) {
+	bin := filepath.Join(from, def.binary)
+	if info, err := os.Stat(bin); err != nil || !info.Mode().IsRegular() {
+		return nil, fmt.Errorf("%s is not a file that make binaries staged", bin)
+	}
+	files := []file{{target: "usr/bin/" + def.binary, source: bin, mode: 0o755}}
+	doc := "usr/share/doc/" + pkg
+	for _, name := range []string{"LICENSE", "NOTICE"} {
+		source := filepath.Join(from, name)
+		if _, err := os.Stat(source); err != nil {
+			return nil, fmt.Errorf("%s is missing: every binary package carries it", source)
+		}
+		files = append(files, file{target: doc + "/" + name, source: source, mode: 0o644})
+	}
+	licenses := filepath.Join(from, "licenses")
+	err := filepath.WalkDir(licenses, func(p string, d fs.DirEntry, err error) error {
+		if err != nil {
+			return err
+		}
+		// make binaries removes macOS metadata from the staged files. One
+		// that is still there is refused, not packaged.
+		if name := d.Name(); name == ".DS_Store" || name == "__MACOSX" || strings.HasPrefix(name, "._") {
+			return fmt.Errorf("%s is macOS metadata, which no package may hold", p)
+		}
+		if d.IsDir() {
+			return nil
+		}
+		if !d.Type().IsRegular() {
+			return fmt.Errorf("%s is not a regular file", p)
+		}
+		rel, err := filepath.Rel(licenses, p)
+		if err != nil {
+			return err
+		}
+		files = append(files, file{target: doc + "/licenses/" + filepath.ToSlash(rel), source: p, mode: 0o644})
+		return nil
+	})
+	if err != nil {
+		return nil, fmt.Errorf("the dependency licenses in %s: %w", licenses, err)
+	}
+	sort.Slice(files, func(i, j int) bool { return files[i].target < files[j].target })
+	return files, nil
+}
+
+// dataArchive returns data.tar.gz, the installed size in KiB as dpkg counts
+// it, and the md5sums file.
+func dataArchive(files []file, stamp time.Time) ([]byte, int64, []byte, error) {
+	var out bytes.Buffer
+	gz, _ := gzip.NewWriterLevel(&out, gzip.BestCompression)
+	tw := tar.NewWriter(gz)
+	dirs := map[string]bool{}
+	var entries []string
+	for _, f := range files {
+		for d := path.Dir(f.target); d != "."; d = path.Dir(d) {
+			if !dirs[d] {
+				dirs[d] = true
+				entries = append(entries, d+"/")
+			}
+		}
+	}
+	sort.Strings(entries)
+	header := func(name string, mode, size int64, kind byte) *tar.Header {
+		return &tar.Header{Name: "./" + name, Mode: mode, Size: size, Typeflag: kind, ModTime: stamp,
+			Uname: "root", Gname: "root", Format: tar.FormatGNU}
+	}
+	if err := tw.WriteHeader(header("", 0o755, 0, tar.TypeDir)); err != nil {
+		return nil, 0, nil, err
+	}
+	for _, d := range entries {
+		if err := tw.WriteHeader(header(d, 0o755, 0, tar.TypeDir)); err != nil {
+			return nil, 0, nil, err
+		}
+	}
+	var installed int64
+	var sums bytes.Buffer
+	for _, f := range files {
+		body, err := os.ReadFile(f.source)
+		if err != nil {
+			return nil, 0, nil, err
+		}
+		if err := tw.WriteHeader(header(f.target, f.mode, int64(len(body)), tar.TypeReg)); err != nil {
+			return nil, 0, nil, err
+		}
+		if _, err := tw.Write(body); err != nil {
+			return nil, 0, nil, err
+		}
+		installed += (int64(len(body)) + 1023) / 1024
+		sum := md5.Sum(body) //nolint:gosec // see the import
+		fmt.Fprintf(&sums, "%s  %s\n", hex.EncodeToString(sum[:]), f.target)
+	}
+	// dpkg-gencontrol counts each directory as 1 KiB too.
+	installed += int64(len(entries))
+	if err := tw.Close(); err != nil {
+		return nil, 0, nil, err
+	}
+	if err := gz.Close(); err != nil {
+		return nil, 0, nil, err
+	}
+	return out.Bytes(), installed, sums.Bytes(), nil
+}
+
+func controlFile(pkg string, def definition, version, arch string, installed int64) []byte {
+	var b strings.Builder
+	fmt.Fprintf(&b, "Package: %s\n", pkg)
+	fmt.Fprintf(&b, "Version: %s\n", version)
+	fmt.Fprintf(&b, "Architecture: %s\n", arch)
+	b.WriteString("Maintainer: Apache SkyWalking <de...@skywalking.apache.org>\n")
+	fmt.Fprintf(&b, "Installed-Size: %s\n", strconv.FormatInt(installed, 10))
+	b.WriteString("Section: devel\n")
+	b.WriteString("Priority: optional\n")
+	b.WriteString("Homepage: https://skywalking.apache.org/\n")
+	fmt.Fprintf(&b, "Description: %s\n", def.summary)
+	for _, line := range def.description {
+		fmt.Fprintf(&b, " %s\n", line)
+	}
+	return []byte(b.String())
+}
+
+func controlArchive(control, sums []byte, stamp time.Time) ([]byte, error) {
+	var out bytes.Buffer
+	gz, _ := gzip.NewWriterLevel(&out, gzip.BestCompression)
+	tw := tar.NewWriter(gz)
+	if err := tw.WriteHeader(&tar.Header{Name: "./", Mode: 0o755, Typeflag: tar.TypeDir, ModTime: stamp,
+		Uname: "root", Gname: "root", Format: tar.FormatGNU}); err != nil {
+		return nil, err
+	}
+	for _, m := range []struct {
+		name string
+		body []byte
+	}{{"control", control}, {"md5sums", sums}} {
+		if err := tw.WriteHeader(&tar.Header{Name: "./" + m.name, Mode: 0o644, Size: int64(len(m.body)),
+			Typeflag: tar.TypeReg, ModTime: stamp, Uname: "root", Gname: "root", Format: tar.FormatGNU}); err != nil {
+			return nil, err
+		}
+		if _, err := tw.Write(m.body); err != nil {
+			return nil, err
+		}
+	}
+	if err := tw.Close(); err != nil {
+		return nil, err
+	}
+	if err := gz.Close(); err != nil {
+		return nil, err
+	}
+	return out.Bytes(), nil
+}
+
+// arMember writes one member the way dpkg-deb does: the name with no
+// trailing slash, owner and group 0, mode 100644, and a newline after an odd
+// size.
+func arMember(w io.Writer, name string, body []byte, epoch int64) {
+	fmt.Fprintf(w, "%-16s%-12d%-6d%-6d%-8s%-10d`\n", name, epoch, 0, 0, "100644", len(body))
+	_, _ = w.Write(body)
+	if len(body)%2 == 1 {
+		_, _ = w.Write([]byte("\n"))
+	}
+}
diff --git a/tools/debpackage/main_test.go b/tools/debpackage/main_test.go
new file mode 100644
index 0000000..3bf05e5
--- /dev/null
+++ b/tools/debpackage/main_test.go
@@ -0,0 +1,96 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package main
+
+import (
+	"bytes"
+	"os"
+	"path/filepath"
+	"strings"
+	"testing"
+)
+
+func staged(t *testing.T) string {
+	t.Helper()
+	dir := t.TempDir()
+	for name, body := range map[string]string{"asz": "binary", "asz-claude-plugin": "plugin", "LICENSE": "license", "NOTICE": "notice", "licenses/license-a.txt": "a"} {
+		path := filepath.Join(dir, filepath.FromSlash(name))
+		if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
+			t.Fatal(err)
+		}
+		if err := os.WriteFile(path, []byte(body), 0o644); err != nil {
+			t.Fatal(err)
+		}
+	}
+	return dir
+}
+
+// A rebuild is held against the voted package, so the same files, version
+// and time must give the same bytes.
+func TestTheSameFilesGiveTheSameBytes(t *testing.T) {
+	from := staged(t)
+	out := t.TempDir()
+	var packages [][]byte
+	for _, name := range []string{"one.deb", "two.deb"} {
+		if err := run("asz-claude-code", "0.4.0", "arm64", from, 1757000000, filepath.Join(out, name)); err != nil {
+			t.Fatal(err)
+		}
+		body, err := os.ReadFile(filepath.Join(out, name))
+		if err != nil {
+			t.Fatal(err)
+		}
+		packages = append(packages, body)
+	}
+	if !bytes.Equal(packages[0], packages[1]) {
+		t.Fatal("two builds of the same files differ")
+	}
+	if !bytes.HasPrefix(packages[0], []byte("!<arch>\ndebian-binary   ")) {
+		t.Fatalf("not an ar archive that starts with debian-binary: %q", packages[0][:40])
+	}
+}
+
+// make binaries removes macOS metadata before it packages. One that is
+// still in the staged files stops the build rather than being packaged.
+func TestMacOSMetadataIsRefused(t *testing.T) {
+	for _, name := range []string{".DS_Store", "._license-a.txt", "__MACOSX"} {
+		t.Run(name, func(t *testing.T) {
+			from := staged(t)
+			if err := os.WriteFile(filepath.Join(from, "licenses", name), []byte("metadata"), 0o644); err != nil {
+				t.Fatal(err)
+			}
+			err := run("asz", "0.4.0", "amd64", from, 1757000000, filepath.Join(t.TempDir(), "asz.deb"))
+			if err == nil || !strings.Contains(err.Error(), "macOS metadata") {
+				t.Fatalf("metadata was not refused: %v", err)
+			}
+		})
+	}
+}
+
+func TestDebianVersion(t *testing.T) {
+	for version, want := range map[string]string{
+		"0.4.0":                  "0.4.0",
+		"0.3.0-12-gabcdef-dirty": "0.3.0-12-gabcdef-dirty",
+		"3321751abc":             "3321751abc",
+		"e55c406abc":             "0~e55c406abc",
+		"dev":                    "0~dev",
+	} {
+		if got := DebianVersion(version); got != want {
+			t.Errorf("DebianVersion(%q) = %q, want %q", version, got, want)
+		}
+	}
+}
diff --git a/tools/package-check.sh b/tools/package-check.sh
index 1fc7f10..1588ef7 100644
--- a/tools/package-check.sh
+++ b/tools/package-check.sh
@@ -36,6 +36,7 @@ for package in "$@"; do
         listing=$(tar -tzf "$package")
       fi ;;
     *.zip) listing=$(unzip -Z1 "$package") ;;
+    *.deb) listing=$(sh "$(dirname "$0")/deb-list.sh" "$package") ;;
     *) echo "package-check: unsupported archive $package" >&2; exit 2 ;;
   esac
   bad=$(printf '%s\n' "$listing" | grep -E '(^|/)(\._[^/]*|\.DS_Store|__MACOSX)(/|$)' || true)
diff --git a/tools/packagecheck/packagecheck_test.go b/tools/packagecheck/packagecheck_test.go
index 7c44980..1ef2e6d 100644
--- a/tools/packagecheck/packagecheck_test.go
+++ b/tools/packagecheck/packagecheck_test.go
@@ -28,6 +28,8 @@ import (
 	"path/filepath"
 	"strings"
 	"testing"
+
+	"github.com/apache/skywalking-ai-sessionizer/tools/debfixture"
 )
 
 func TestSourceArchiveOmitsMetadata(t *testing.T) {
@@ -94,7 +96,7 @@ func TestArchiveMetadataIsRejected(t *testing.T) {
 	if err != nil {
 		t.Skip("archive checks need the release shell")
 	}
-	for _, ext := range []string{"tgz", "zip"} {
+	for _, ext := range []string{"tgz", "zip", "deb"} {
 		for _, name := range []string{"LICENSE", "._asz", "licenses/._LICENSE", ".DS_Store", "__MACOSX/asz"} {
 			t.Run(ext+"/"+name, func(t *testing.T) {
 				path := filepath.Join(t.TempDir(), "package."+ext)
@@ -102,7 +104,16 @@ func TestArchiveMetadataIsRejected(t *testing.T) {
 				if err != nil {
 					t.Fatal(err)
 				}
-				if ext == "zip" {
+				switch ext {
+				case "deb":
+					body, err := debfixture.Bytes("Package: asz\n", map[string]string{"usr/share/doc/asz/" + name: "x"})
+					if err != nil {
+						t.Fatal(err)
+					}
+					if _, err := f.Write(body); err != nil {
+						t.Fatal(err)
+					}
+				case "zip":
 					w := zip.NewWriter(f)
 					entry, err := w.Create(name)
 					if err != nil {
@@ -114,7 +125,7 @@ func TestArchiveMetadataIsRejected(t *testing.T) {
 					if err := w.Close(); err != nil {
 						t.Fatal(err)
 					}
-				} else {
+				default:
 					gz := gzip.NewWriter(f)
 					w := tar.NewWriter(gz)
 					if err := w.WriteHeader(&tar.Header{Name: name, Mode: 0o644, Size: 1}); err != nil {
diff --git a/tools/release.sh b/tools/release.sh
index 9f57631..abd3a99 100755
--- a/tools/release.sh
+++ b/tools/release.sh
@@ -349,6 +349,31 @@ binary_package() { # binary_package OS/ARCH
   printf '%s' "$pkg-$version-bin-$os-$arch.$ext"
 }
 
+# The Debian packages of a version are the ones DEB_PACKAGES in its tag's
+# Makefile names, one for each Linux platform. A tag from before them has no
+# such line and no Debian package.
+tag_debs() {
+  git show "$tag:Makefile" | sed -nE 's/^DEB_PACKAGES[[:space:]]*:?=[[:space:]]*//p'
+}
+
+# deb_packages prints "FILE PACKAGE ARCH" for each Debian package.
+deb_packages() {
+  local p t
+  for p in $debs; do
+    for t in $platforms; do
+      case "$t" in linux/*) printf '%s %s %s\n' "$pkg-$version-bin-$p-${t#linux/}.deb" "$p" "${t#linux/}" ;; esac
+    done
+  done
+}
+
+# ci_packages prints every package CI builds and attaches: one binary
+# package per platform, and the Debian packages.
+ci_packages() {
+  local t
+  for t in $platforms; do printf '%s\n' "$(binary_package "$t")"; done
+  deb_packages | awk '{print $1}'
+}
+
 # host_platform prints the PLATFORMS entry of the machine running this, such
 # as darwin/arm64. It prints nothing for a system or a processor that no
 # package is built for. Git Bash on Windows names the system MINGW64_NT-10.0
@@ -370,9 +395,8 @@ host_platform() {
 }
 
 expected_packages() {
-  local t
   printf '%s\n' "$pkg-$version-src.tgz"
-  for t in $platforms; do printf '%s\n' "$(binary_package "$t")"; done
+  ci_packages
 }
 
 pick_version() { # pick_version PROMPT
@@ -387,11 +411,8 @@ release_repo=apache/skywalking-ai-sessionizer
 # ci_names prints the files CI attaches to the prerelease: each binary
 # package and its .sha512. The release stages never upload these.
 ci_names() {
-  local t b
-  for t in $platforms; do
-    b=$(binary_package "$t")
-    printf '%s\n%s\n' "$b" "$b.sha512"
-  done
+  local b
+  for b in $(ci_packages); do printf '%s\n%s\n' "$b" "$b.sha512"; done
 }
 
 # release_names prints every file the GitHub release holds once candidate
@@ -468,10 +489,13 @@ if [ "$cmd" = candidate ]; then
   need_tools $tools
   ci_helper=tools/ci-binaries.sh
   package_check=tools/package-check.sh
+  deb_list=tools/deb-list.sh
   [ -f "$ci_helper" ] || fail "$ci_helper is missing"
   [ -f "$package_check" ] || fail "$package_check is missing"
+  [ -f "$deb_list" ] || fail "$deb_list is missing"
   fetch_tag
   platforms=$(tag_platforms)
+  debs=$(tag_debs)
   packages=$(expected_packages)
   origin_url=$(git remote get-url origin)
   dev_dir="$dist_dev/ai-sessionizer/$version"
@@ -493,6 +517,7 @@ if [ "$cmd" = candidate ]; then
   say "tag      : $tag, on origin, at commit $commit"
   say "origin   : $origin_url"
   say "packages : the source package and one binary package for each of $(printf '%s\n' "$platforms" | awk 'NR>1{printf " "} {printf "%s", $0}')"
+  if [ -n "$debs" ]; then say "debian   : $debs, for each Linux platform"; fi
   if [ -n "$host_pkg" ]; then say "machine  : $host, so $host_pkg is run before the upload"
   else say "machine  : $(uname -s) $(uname -m), which no package is built for, so none is run here"; fi
 
@@ -582,15 +607,14 @@ Fonts are under licenses such as the SIL Open Font License, which the ASF puts i
   mkdir -m 700 "$keyring"
   step "The CI binary packages"
   if [ "$dry_run" = true ]; then
-    say "- $ci_helper $version $commit $ci_run <temporary directory> <platforms from $tag>"
+    say "- $ci_helper $version $commit $ci_run <temporary directory> <platforms from $tag> <Debian packages from $tag>"
     say "- read the prerelease's readiness marker, require its successful uploader run for $tag at $commit, and verify asset digests, package checksums and archive contents"
     say "dry run: no GitHub prerelease asset was downloaded or verified"
   else
-    bash "$ci_helper" "$version" "$commit" "$ci_run" "$work/ci" "$platforms" | tee "$work/ci-check.txt" \
+    bash "$ci_helper" "$version" "$commit" "$ci_run" "$work/ci" "$platforms" "$debs" | tee "$work/ci-check.txt" \
       || fail "no verified CI binary packages are available. Wait for the CI run of the $tag push to create the prerelease and attach the binaries. If a job failed, rerun it; if the prerelease is incomplete or was rejected, remove it explicitly first, as the release guide describes. --ci-run must match its successful uploader run"
     if [ "$resume" = true ]; then
-      for t in $platforms; do
-        p=$(binary_package "$t")
+      for p in $(ci_packages); do
         for f in "$p" "$p.sha512"; do
           cmp -s "$work/ci/$f" "$out/$f" || fail "$out/$f is not the file CI attached to the prerelease, so the uploaded candidate is not the one CI built. Remove $dev_dir and run candidate again"
         done
@@ -730,8 +754,7 @@ Fonts are under licenses such as the SIL Open Font License, which the ASF puts i
     rm -f "$out/vote.txt" "$out/vote-preview.txt"
     for p in $packages; do rm -f "$out/$p" "$out/$p.asc" "$out/$p.sha512"; done
     mkdir -p "$out"
-    for t in $platforms; do
-      p=$(binary_package "$t")
+    for p in $(ci_packages); do
       cp "$work/ci/$p" "$work/ci/$p.sha512" "$out/"
     done
     grep '^ci-binaries:' "$work/ci-check.txt" > "$out/ci-provenance.txt"
@@ -746,7 +769,7 @@ Fonts are under licenses such as the SIL Open Font License, which the ASF puts i
       sh "$package_check" "$out/$p" || fail "$p has forbidden archive metadata"
     done
     extra=""
-    for f in "$out"/*.tgz "$out"/*.zip; do
+    for f in "$out"/*.tgz "$out"/*.zip "$out"/*.deb; do
       [ -f "$f" ] || continue
       has_line "$packages" "${f##*/}" || extra="$extra ${f##*/}"
     done
@@ -791,6 +814,25 @@ $found"
       done
       say "ok  $b: asz$exe, asz-claude-plugin$exe, LICENSE, NOTICE and licenses/"
     done
+    # A Debian package installs one binary, and the same licenses under
+    # /usr/share/doc. Its control file must name the package, the version and
+    # the architecture its file name gives, because the apt index is made
+    # from the control file after the vote.
+    while read -r b p arch; do
+      [ -n "$b" ] || continue
+      bin=asz
+      [ "$p" = asz ] || bin=asz-claude-plugin
+      listing=$(sh "$deb_list" "$out/$b" </dev/null) || fail "cannot list $b"
+      for f in "usr/bin/$bin" "usr/share/doc/$p/LICENSE" "usr/share/doc/$p/NOTICE"; do
+        has_line "$listing" "$f" || fail "$b has no /$f"
+      done
+      has_prefix "$listing" "usr/share/doc/$p/licenses/" || fail "$b has no /usr/share/doc/$p/licenses/"
+      control=$(sh "$deb_list" --control "$out/$b" </dev/null) || fail "cannot read the control file of $b"
+      for f in "Package: $p" "Version: $version" "Architecture: $arch"; do
+        has_line "$control" "$f" || fail "the control file of $b does not say $f"
+      done
+      say "ok  $b: $p $version $arch, /usr/bin/$bin, and LICENSE, NOTICE and licenses/ in /usr/share/doc/$p"
+    done <<< "$(deb_packages)"
 
     step "Sign the verified archives"
     for p in $packages; do
@@ -871,7 +913,7 @@ Notes for voters:
  * The binary archives are the unchanged packages CI attached to the GitHub prerelease after all its checks passed on the tag push, verified below. Only the source archive was created locally. The release manager signed every archive after checking its contents and checksums, and attached the source archive and every signature to the same prerelease.
 $(sed 's/^ci-binaries:/ */' "$out/ci-provenance.txt")
  * internal/view/conversation-view/ in the source package is the build output of Horizon's conversation renderer, from apache/skywalking-horizon-ui at the commit its HORIZON_COMMIT file names. It is Apache-2.0 code of the ASF with no third-party code in it. The source package builds and runs with it as it is. \`make conversation-view-check\`, which needs Node.js 24 and pnpm, rebuilds it from that commit and compares. In the unpacked source package it compares every file except the two fo [...]
- * The two fonts the page draws with are under the SIL Open Font License, a Category B license, so they are in the binary packages only. A build from the source package draws the page with system fonts.
+ * The two fonts the page draws with are under the SIL Open Font License, a Category B license, so they are in the binary packages only. A build from the source package draws the page with system fonts.$(if [ -n "$debs" ]; then printf '\n * The .deb files are Debian packages of the same Linux binaries, one for asz and one for asz-claude-plugin, with the same LICENSE, NOTICE and licenses/ under /usr/share/doc. apt installs them from the index on the SkyWalking website, which lists release [...]
 
 Voting will start now and will remain open for at least 72 hours. All PMC members are requested to give their votes.
 
@@ -916,6 +958,7 @@ if [ "$cmd" = publish ]; then
   [ -f "$manifests" ] || fail "$manifests is missing. publish runs it after the move, to write the install manifests from the voted packages. Add it and run publish again; nothing has changed."
   fetch_tag
   platforms=$(tag_platforms)
+  debs=$(tag_debs)
   packages=$(expected_packages)
   dev_dir="$dist_dev/ai-sessionizer/$version"
   rel_parent="$dist_release/ai-sessionizer"
@@ -1013,11 +1056,13 @@ if [ "$cmd" = publish ]; then
     files="$dev_files"
   fi
   # The downloads page links the older versions in the release directory
-  # until the website pull request points them at the archive, and the
-  # Scoop bucket names the previous version until it moves on. Removing them
-  # in the run that moves would break both, so removal is a later run.
+  # until the website pull request points them at the archive, the apt
+  # repository on the website sends apt to the mirrors for the previous
+  # version until it lists this one, and the Scoop bucket names the previous
+  # version until it moves on. Removing them in the run that moves would
+  # break all three, so removal is a later run.
   if [ "$remove_old" = true ] && [ "$moved" = false ]; then
-    fail "--remove-old runs only after the move, in a later run. Run publish without it now. Once the website pull request that points the older versions at archive.apache.org has merged, and the Scoop bucket names $version, run: tools/release.sh publish $version --remove-old"
+    fail "--remove-old runs only after the move, in a later run. Run publish without it now. Once the website pull requests that point the older versions at archive.apache.org and add $version to the apt repository have merged, and the Scoop bucket names $version, run: tools/release.sh publish $version --remove-old"
   fi
   for p in $packages; do
     for f in "$p" "$p.asc" "$p.sha512"; do has_line "$files" "$f" || fail "$from has no $f"; done
@@ -1126,7 +1171,7 @@ if [ "$cmd" = publish ]; then
 
 #### Where to get it
 
-- The Apache release of $version is the source package. The binary packages for macOS, Linux and Windows are conveniences built from it. The [SkyWalking downloads page](https://skywalking.apache.org/downloads/) links each package with its signature and checksum.
+- The Apache release of $version is the source package. The binary packages for macOS, Linux and Windows$(if [ -n "$debs" ]; then printf ', and the Debian packages,'; fi) are conveniences built from it. The [SkyWalking downloads page](https://skywalking.apache.org/downloads/) links each package with its signature and checksum.
 - The files attached to this GitHub release are the same signed packages, each with its \`.asc\` signature and \`.sha512\` checksum. Verify them against https://downloads.apache.org/skywalking/KEYS, as [Install]($github/blob/$tag/docs/en/setup/install.md#verify-a-package) describes.
 - To build from the source package, see [Install]($github/blob/$tag/docs/en/setup/install.md#build-from-the-source-package).
 - Documentation: $github/blob/$tag/docs/README.md
@@ -1259,6 +1304,13 @@ YAML
       printf '                asc: %s\n' "$downloads/$version/$b.asc"
       printf '                sha512: %s\n' "$downloads/$version/$b.sha512"
     done
+    while read -r b p arch; do
+      [ -n "$b" ] || continue
+      printf '              - name: Debian package %s, %s\n                type: binary\n' "$p" "$(printf '%s' "$arch" | tr '[:lower:]' '[:upper:]')"
+      printf '                link: %s\n' "$closer/$version/$b"
+      printf '                asc: %s\n' "$downloads/$version/$b.asc"
+      printf '                sha512: %s\n' "$downloads/$version/$b.sha512"
+    done <<< "$(deb_packages)"
     printf '            date: %s\n' "$(site_date "$published_on")"
   }
 
@@ -1288,14 +1340,20 @@ YAML
   say "     $out/announce.txt to dev@skywalking.apache.org and announce@apache.org, as plain"
   say "     text from your apache.org address. Sign it with your release key if your mail"
   say "     program can; the ASF recommends it."
-  say "  3. Submit the install manifests in $out/install, once the PMC has agreed on"
+  say "  3. Put $version into Homebrew and apt, with the binary-distribution skill of this"
+  say "     repository, or by hand:"
+  say "       tools/homebrew-formula.sh --from dist --check $version, in a pull request to main"
+  if [ -n "$debs" ]; then
+    say "       tools/apt-repository.sh --from dist --check <skywalking-website>/static/apt $version,"
+    say "       in a pull request to apache/skywalking-website"
+  fi
+  say "     Submit the Scoop and winget manifests in $out/install, once the PMC has agreed on"
   say "     dev@skywalking.apache.org to each channel. $out/install/README.md says where each"
-  say "     one goes. The Homebrew formulae go to Formula/ on main in this repository, by a pull"
-  say "     request. They and the winget files download from the GitHub release, which is"
-  say "     promoted now."
+  say "     one goes. The winget files download from the GitHub release, which is promoted now."
   if [ -n "$old" ] && [ "$remove_old" = false ]; then
-    say "  4. Later, once the website pull request that points$old at archive.apache.org"
-    say "     has merged, and the Scoop bucket names $version:"
+    say "  4. Later, once the website pull requests that point$old at archive.apache.org"
+    say "     and add $version to the apt repository have merged, and the Scoop bucket names"
+    say "     $version:"
     say "     tools/release.sh publish $version --remove-old"
   fi
   exit 0
diff --git a/tools/releasecandidate/candidate_test.go b/tools/releasecandidate/candidate_test.go
index 743cbbb..13f45d4 100644
--- a/tools/releasecandidate/candidate_test.go
+++ b/tools/releasecandidate/candidate_test.go
@@ -35,7 +35,9 @@ import (
 
 type candidateFixture struct {
 	dir, binaries, commands, archive, state string
-	env                                     []string
+	// debs are the Debian packages CI attached beside the archive.
+	debs []string
+	env  []string
 }
 
 func candidateFixtureFor(t *testing.T) *candidateFixture {
@@ -63,19 +65,24 @@ func candidateFixtureFor(t *testing.T) *candidateFixture {
 			t.Fatal(err)
 		}
 	}
-	for _, name := range []string{"release.sh", "package-check.sh"} {
+	for _, name := range []string{"release.sh", "package-check.sh", "deb-list.sh"} {
 		body, err := os.ReadFile(filepath.Join("..", name))
 		if err != nil {
 			t.Fatal(err)
 		}
 		write(filepath.Join(f.dir, "tools", name), string(body), 0o755)
 	}
-	platform := "linux/amd64"
-	if runtime.GOOS == "linux" {
-		platform = "darwin/arm64"
+	// A Linux platform, so the tag has Debian packages, and never this
+	// machine's, so candidate runs no package here.
+	platform, arch := "linux/amd64", "amd64"
+	if runtime.GOOS == "linux" && runtime.GOARCH == "amd64" {
+		platform, arch = "linux/arm64", "arm64"
 	}
 	f.archive = "apache-skywalking-ai-sessionizer-0.3.0-bin-" + strings.ReplaceAll(platform, "/", "-") + ".tgz"
-	write(filepath.Join(f.dir, "Makefile"), "PLATFORMS := "+platform+"\nCOMPILED_TYPES := application/x-executable\nCOMPILED_FILES := \\.(exe|o)\n", 0o644)
+	for _, p := range []string{"asz", "asz-claude-code"} {
+		f.debs = append(f.debs, "apache-skywalking-ai-sessionizer-0.3.0-bin-"+p+"-"+arch+".deb")
+	}
+	write(filepath.Join(f.dir, "Makefile"), "PLATFORMS := "+platform+"\nDEB_PACKAGES := asz asz-claude-code\nCOMPILED_TYPES := application/x-executable\nCOMPILED_FILES := \\.(exe|o)\n", 0o644)
 	write(filepath.Join(f.dir, "LICENSE"), "Apache License fixture\n", 0o644)
 	write(filepath.Join(f.dir, "NOTICE"), "ASF fixture\n", 0o644)
 	write(filepath.Join(f.dir, "docs/en/changes/changes.md"), "# Changes in 0.3.0\n\nFixture release.\n", 0o644)
@@ -180,8 +187,20 @@ echo 'ci-binaries: artifact 456, sha256:fixture, commit fixture'
 	}
 	write(filepath.Join(f.binaries, f.archive), packed.String(), 0o644)
 	write(filepath.Join(f.binaries, f.archive+".sha512"), fmt.Sprintf("%x  %s\n", sha512.Sum512(packed.Bytes()), f.archive), 0o644)
+	// The Debian packages come from the tool make binaries runs.
+	staged := filepath.Join(base, "staged")
+	for _, name := range []string{"asz", "asz-claude-plugin", "LICENSE", "NOTICE", "licenses/license.txt"} {
+		write(filepath.Join(staged, name), "CI bytes for "+name+"\n", 0o755)
+	}
+	for i, p := range []string{"asz", "asz-claude-code"} {
+		f.writeDeb(t, p, "0.3.0", arch, staged, filepath.Join(f.binaries, f.debs[i]))
+	}
 	// The prerelease holds what CI attached on the tag push.
-	for _, name := range []string{f.archive, f.archive + ".sha512"} {
+	ci := []string{f.archive, f.archive + ".sha512"}
+	for _, d := range f.debs {
+		ci = append(ci, d, d+".sha512")
+	}
+	for _, name := range ci {
 		body, err := os.ReadFile(filepath.Join(f.binaries, name))
 		if err != nil {
 			t.Fatal(err)
@@ -200,6 +219,24 @@ echo 'ci-binaries: artifact 456, sha256:fixture, commit fixture'
 	return f
 }
 
+// writeDeb writes a Debian package with tools/debpackage, and its .sha512.
+func (f *candidateFixture) writeDeb(t *testing.T, pkg, version, arch, staged, out string) {
+	t.Helper()
+	cmd := exec.Command("go", "run", "../debpackage", "-package", pkg, "-version", version, "-arch", arch,
+		"-from", staged, "-time", "1757000000", "-out", out)
+	if output, err := cmd.CombinedOutput(); err != nil {
+		t.Fatalf("debpackage: %s\n%v", output, err)
+	}
+	body, err := os.ReadFile(out)
+	if err != nil {
+		t.Fatal(err)
+	}
+	sum := fmt.Sprintf("%x  %s\n", sha512.Sum512(body), filepath.Base(out))
+	if err := os.WriteFile(out+".sha512", []byte(sum), 0o644); err != nil {
+		t.Fatal(err)
+	}
+}
+
 func (f *candidateFixture) run(t *testing.T, args ...string) ([]byte, error) {
 	t.Helper()
 	return f.stage(t, append([]string{"--no-upload"}, args...)...)
@@ -231,7 +268,7 @@ func names(t *testing.T, dir string) []string {
 
 func (f *candidateFixture) voted() []string {
 	var out []string
-	for _, p := range []string{"apache-skywalking-ai-sessionizer-0.3.0-src.tgz", f.archive} {
+	for _, p := range append([]string{"apache-skywalking-ai-sessionizer-0.3.0-src.tgz", f.archive}, f.debs...) {
 		out = append(out, p, p+".asc", p+".sha512")
 	}
 	sort.Strings(out)
@@ -283,6 +320,38 @@ func TestCandidateUploadsToSVNAndAttachesToThePrerelease(t *testing.T) {
 	if err != nil || !strings.Contains(string(vote), "releases/tag/v0.3.0") {
 		t.Fatalf("vote mail does not link the prerelease: %v\n%s", err, vote)
 	}
+	for _, d := range f.debs {
+		if !strings.Contains(string(vote), d) {
+			t.Fatalf("vote mail does not give the checksum of %s:\n%s", d, vote)
+		}
+	}
+	if !strings.Contains(string(vote), "The .deb files are Debian packages") {
+		t.Fatalf("vote mail does not say what the .deb files are:\n%s", vote)
+	}
+}
+
+// The apt index is made from a Debian package's control file after the
+// vote. A package whose control file names another version than its file
+// name is refused before anything is signed.
+func TestCandidateRefusesADebianPackageOfAnotherVersion(t *testing.T) {
+	f := candidateFixtureFor(t)
+	staged := filepath.Join(filepath.Dir(f.dir), "staged")
+	arch := strings.TrimSuffix(strings.TrimPrefix(f.debs[0], "apache-skywalking-ai-sessionizer-0.3.0-bin-asz-"), ".deb")
+	for _, dir := range []string{f.binaries, filepath.Join(f.state, "gh")} {
+		for _, name := range []string{f.debs[0], f.debs[0] + ".sha512"} {
+			if err := os.Remove(filepath.Join(dir, name)); err != nil {
+				t.Fatal(err)
+			}
+		}
+	}
+	f.writeDeb(t, "asz", "0.2.0", arch, staged, filepath.Join(f.binaries, f.debs[0]))
+	output, err := f.run(t)
+	if err == nil || !strings.Contains(string(output), "does not say Version: 0.3.0") {
+		t.Fatalf("a Debian package of another version passed: %v\n%s", err, output)
+	}
+	if n := f.packageSignatures(t); n != 0 {
+		t.Fatalf("candidate signed %d packages before refusing", n)
+	}
 }
 
 // The prerelease must hold the very binaries candidate signed. One replaced
@@ -358,7 +427,7 @@ func TestCandidateRefusesAnUploadedCandidateItDidNotSign(t *testing.T) {
 	if err == nil || !strings.Contains(string(output), "does not hold the same files") {
 		t.Fatalf("foreign candidate accepted: %v\n%s", err, output)
 	}
-	if got := names(t, filepath.Join(f.state, "gh")); len(got) != 2 {
+	if got := names(t, filepath.Join(f.state, "gh")); len(got) != 2+2*len(f.debs) {
 		t.Fatalf("prerelease changed to %v", got)
 	}
 }
diff --git a/tools/releasepublish/publish_test.go b/tools/releasepublish/publish_test.go
index 166204b..fcf5c68 100644
--- a/tools/releasepublish/publish_test.go
+++ b/tools/releasepublish/publish_test.go
@@ -87,7 +87,7 @@ func newFixture(t *testing.T) *fixture {
 			t.Fatal(err)
 		}
 	}
-	for _, kind := range []string{"src.tgz", "bin-linux-amd64.tgz"} {
+	for _, kind := range []string{"src.tgz", "bin-linux-amd64.tgz", "bin-asz-amd64.deb"} {
 		name := "apache-skywalking-ai-sessionizer-" + version + "-" + kind
 		data := []byte("voted package: " + name + "\n")
 		files := map[string][]byte{
@@ -502,6 +502,9 @@ func (f *fixture) requireWebsiteLatest(latest bool) {
 			"                sha512: https://downloads.apache.org/skywalking/ai-sessionizer/" + version + "/" + pkg + "-src.tgz.sha512\n",
 		"              - name: Linux AMD64\n                type: binary\n" +
 			"                link: https://www.apache.org/dyn/closer.lua/skywalking/ai-sessionizer/" + version + "/" + pkg + "-bin-linux-amd64.tgz\n",
+		"              - name: Debian package asz, AMD64\n                type: binary\n" +
+			"                link: https://www.apache.org/dyn/closer.lua/skywalking/ai-sessionizer/" + version + "/" + pkg + "-bin-asz-amd64.deb\n" +
+			"                asc: https://downloads.apache.org/skywalking/ai-sessionizer/" + version + "/" + pkg + "-bin-asz-amd64.deb.asc\n",
 		"            date: Sep. 15th, 2026\n",
 	} {
 		if !strings.Contains(text, want) {
@@ -619,7 +622,7 @@ if tool == "git":
     elif args in [["rev-parse", "-q", "--verify", "refs/tags/" + tag], ["rev-parse", tag + "^{commit}"]]:
         print(sha)
     elif args == ["show", tag + ":Makefile"]:
-        print("PLATFORMS := linux/amd64")
+        print("PLATFORMS := linux/amd64\nDEB_PACKAGES := asz")
     elif args == ["show", tag + ":docs/en/changes/changes.md"]:
         print("# Changes in 0.3.0\n\nFixture release.")
     else: