Skip to content

fix(deb): avoid duplicate apt source entries when .sources exists (#10011)#10019

Open
lonexreb wants to merge 2 commits intowarpdotdev:masterfrom
lonexreb:fix/10011-apt-duplicate-sources
Open

fix(deb): avoid duplicate apt source entries when .sources exists (#10011)#10019
lonexreb wants to merge 2 commits intowarpdotdev:masterfrom
lonexreb:fix/10011-apt-duplicate-sources

Conversation

@lonexreb
Copy link
Copy Markdown
Contributor

@lonexreb lonexreb commented May 4, 2026

Fixes #10011.

The bug

Ubuntu 26.04's apt modernize-sources converts legacy one-line .list apt source-list files to the RFC 822-style .sources (DEB822) format. The existing resources/linux/debian/common/postinst.repo.template only checked for @@REPO_NAME@@.list before writing, so a post-modernization Warp upgrade created a fresh .list alongside the existing .sources. Result: duplicate-source warnings on every apt update, exactly as the issue reports.

The fix

Two-part change to the postinst template:

  1. Check both filenames (@@REPO_NAME@@.list and @@REPO_NAME@@.sources) before deciding to write a fresh source-list. If either exists, we leave the existing setup alone.
  2. Prefer .sources for new installs, per the reporter's explicit recommendation ("preferably .sources, as it's the modern format"). DEB822 is supported by every apt version Warp's packages target. The new .sources content is byte-equivalent to what apt modernize-sources would produce when migrating from the old .list template.

Behavior matrix

Existing state Postinst action
Neither file present Write .sources (modern format)
.list exists, .sources does not Leave alone (existing setup works)
.sources exists (post-modernize) Leave alone (modern setup)
Both exist (the broken state today) Leave both alone — the bug stops producing additional duplicates; user's apt modernize-sources cleanup remains the recovery path

Why not auto-migrate .list.sources here?

Considered and rejected. apt modernize-sources is the canonical migration tool, runs interactively, and respects user edits. Migrating from a postinst hook would overwrite potentially-hand-edited source files (the postinst even acknowledges this risk in the existing comment: "You may comment out this entry, but other modifications to the file may be lost."). The simpler, safer behavior is: don't double-write, prefer modern format for fresh installs, leave migration to the user's tooling.

Test plan

  • Fresh Ubuntu 26.04 install (no prior Warp) → postinst writes warp.sources only; apt update shows zero duplicate warnings.
  • Ubuntu 24.04 user with existing warp.list → upgrades Warp; postinst sees .list, no-ops; apt update continues to read .list; no duplicates introduced.
  • Ubuntu 26.04 user who ran apt modernize-sources (now has warp.sources, no warp.list) → upgrades Warp; postinst sees .sources, no-ops; the bug: previously this is the case where the duplicate .list would have been created. Now it is not.
  • User in the broken state (both .list and .sources present from a prior buggy upgrade) → upgrades Warp again; postinst sees both, no-ops; user's pre-existing duplicate is preserved (not made worse) and they can clean up manually with rm /etc/apt/sources.list.d/warp.list.

Scope

  • Single file (resources/linux/debian/common/postinst.repo.template), 27 insertions, 5 deletions.
  • macOS and Windows package paths are unaffected.
  • Signing-key install path is unaffected.

…rpdotdev#10011)

Ubuntu 26.04's `apt modernize-sources` converts legacy `.list` apt
source-list files to the RFC 822-style `.sources` (DEB822) format. The
existing postinst.repo.template only checked for `.list` before writing,
so a post-modernization Warp upgrade created a fresh `.list` alongside
the existing `.sources`. The result: duplicate-source warnings on every
`apt update`.

Fix:

- Check for both filenames (`@@REPO_NAME@@.list` legacy and
  `@@REPO_NAME@@.sources` DEB822) before deciding to write.
- For new installs, write `.sources` (the format the issue reporter
  recommended; supported by every apt version Warp's packages target).
- For existing installs that already have either format, do nothing.
  Don't migrate `.list` to `.sources` from here — `apt modernize-sources`
  is the canonical migration tool and overwriting a user's potentially
  hand-edited source file would be hostile.

Behavior summary:

| Existing state                   | Action                                      |
|----------------------------------|---------------------------------------------|
| Neither file present             | Write `.sources` (modern format)            |
| `.list` exists, `.sources` does not | Leave `.list` alone (existing setup works) |
| `.sources` exists                | Leave `.sources` alone (post-modernize)     |
| Both exist (broken state today)  | Leave both alone (the bug is no longer
                                       producing additional duplicates;
                                       user's `apt modernize-sources`
                                       cleanup remains the recovery path)|

The new `.sources` format is otherwise byte-equivalent to what apt would
produce when modernizing the legacy `.list` from this template.
@cla-bot cla-bot Bot added the cla-signed label May 4, 2026
@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 4, 2026

@lonexreb

I'm starting a first review of this pull request.

You can view the conversation on Warp.

I completed the review and no human review was requested for this pull request.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@github-actions github-actions Bot added the external-contributor Indicates that a PR has been opened by someone outside the Warp team. label May 4, 2026
oz-for-oss[bot]
oz-for-oss Bot previously requested changes May 4, 2026
Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This change prevents post-modernization upgrades from creating a duplicate legacy .list entry and switches fresh apt installs to the DEB822 .sources format.

Concerns

  • Fresh installs now create @@REPO_NAME@@.sources, but purge cleanup still removes only @@REPO_NAME@@.list, leaving the repository configuration behind after package purge.
  • Security pass found no additional issues.

Verdict

Found: 0 critical, 1 important, 0 suggestions

Request changes

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

# configured within it, install our repo.
cat > "$APT_SOURCE_LIST" <<EOF
# configured in either format, install our repo.
cat > "$APT_SOURCE_LIST_DEB822" <<EOF
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ [IMPORTANT] New installs now write @@REPO_NAME@@.sources, but resources/linux/debian/common/postrm.repo.template still purges only @@REPO_NAME@@.list, so purging Warp would leave this apt source entry behind; update the purge script to remove the .sources file too.

Per oz-for-oss review on PR warpdotdev#10019: the postinst now writes the modern
`.sources` (DEB822) file for new installs, but postrm.repo.template
still purges only the legacy `.list` file. So purging Warp on a system
where the postinst wrote .sources would leave the apt source entry
behind.

Add a second `rm -f` for the .sources filename. `rm -f` is silent on
missing files, so older installs that have only .list are unaffected
(and conversely, brand-new installs that have only .sources are also
cleaned correctly).
@lonexreb
Copy link
Copy Markdown
Contributor Author

lonexreb commented May 4, 2026

/oz-review

@oz-for-oss
Copy link
Copy Markdown
Contributor

oz-for-oss Bot commented May 4, 2026

@lonexreb

I'm re-reviewing this pull request in response to a review request.

You can view the conversation on Warp.

I reviewed this pull request and requested human review from: @acarl005.

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot dismissed their stale review May 4, 2026 09:35

Oz no longer requests changes for this pull request after the latest automated review.

Copy link
Copy Markdown
Contributor

@oz-for-oss oz-for-oss Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overview

This PR updates the Debian post-install repository setup to recognize both legacy .list and modern DEB822 .sources apt source files, writes .sources for fresh installs, and purges both possible source-list filenames.

Concerns

No blocking correctness or security concerns identified in the changed lines.

Verdict

Found: 0 critical, 0 important, 0 suggestions

Approve

Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).

Powered by Oz

@oz-for-oss oz-for-oss Bot requested a review from acarl005 May 4, 2026 09:35
@acarl005
Copy link
Copy Markdown
Contributor

acarl005 commented May 5, 2026

This makes sense to me. I'm going to test this on the latest Debian and will approve once I verify that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed external-contributor Indicates that a PR has been opened by someone outside the Warp team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate APT source entries created (.list and .sources) causing warnings on apt update

2 participants