Skip to content

fix(release): drop the Moore Threads apt source before installing packages - #1117

Merged
ilopezluna merged 2 commits into
mainfrom
fix/musa-drop-mthreads-apt-source
Nov 23, 2026
Merged

ilopezluna merged 2 commits into
mainfrom
fix/musa-drop-mthreads-apt-source

Conversation

@ilopezluna

@ilopezluna ilopezluna commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Problem

The v1.2.10 Release run failed twice while building the MUSA image. apt-get update in scripts/apt-install.sh aborts because the Moore Threads repository, configured by the upstream server-musa base image, answers 403 Forbidden to the CI runners:

E: Failed to fetch https://dl.mthreads.com/repo/repository/ubuntu2204/dists/jammy/InRelease  403  Forbidden
E: The repository 'https://dl.mthreads.com/repo/repository/ubuntu2204 jammy InRelease' is not signed.

Because the MUSA image fails, the OpenVINO image, verify-docker-ce, and the GitHub release are skipped.

Change

Before running apt-get update, apt-install.sh deletes the lines that point at dl.mthreads.com from sources.list and sources.list.d/*.list. It edits the files in place, so other entries in the same file are kept and symlinked source files are followed. None of the packages it installs come from that repository, and the MUSA runtime libraries are already in the base image. Images that do not use the repository are unaffected.

Validation

  • ShellCheck passes.
  • Under set -eux -o pipefail, the function succeeds and changes nothing on clean ubuntu:22.04 and ubuntu:24.04 images. These are the non-MUSA cases.
  • In an ubuntu:22.04 container, the function removes mthreads entries from sources.list and from a symlinked .list file. It keeps the symlink, the other entry in that file, and a look-alike host (dlXmthreadsYcom.example).
  • On a copy of /etc/apt from ghcr.io/ggml-org/llama.cpp:server-musa-v1.0.0-b12359-b1b770d, the function removes the only entry in sources.list.d/musa-repo-manual-generic-main.list and keeps the 10 Ubuntu deb lines in sources.list. apt-get update itself was not run, because this environment cannot emulate amd64.

The MUSA image is built only by the Release workflow, so PR CI does not cover it. After this merges, rerunning the Release on main validates it end to end.

NONE

🤖 Generated with Claude Code

…kages

The MUSA base image configures dl.mthreads.com, which answers 403 to CI runners and makes apt-get update fail. No installed package comes from it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

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.

Hey - I've found 4 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="scripts/apt-install.sh" line_range="68-70" />
<code_context>
+remove_vendor_repos() {
+  local vendor_host="dl.mthreads.com"
+  local files
+  files=$(grep -rlF "$vendor_host" /etc/apt/sources.list.d/ 2>/dev/null || true)
+  if [ -n "$files" ]; then
+    echo "$files" | xargs rm -f
+  fi
+  if [ -f /etc/apt/sources.list ]; then
</code_context>
<issue_to_address>
**Base image can delete arbitrary files**

When the inherited image contains a matching file under `/etc/apt/sources.list.d/` whose pathname includes a newline followed by another absolute path, `echo` and `xargs` split that pathname into separate `rm -f` operands, so `rm` deletes the injected absolute-path target as root during the build.

Use NUL-delimited grep output with `xargs -0r rm -f --`.
</issue_to_address>

### Comment 2
<location path="scripts/apt-install.sh" line_range="68-70" />
<code_context>
+remove_vendor_repos() {
+  local vendor_host="dl.mthreads.com"
+  local files
+  files=$(grep -rlF "$vendor_host" /etc/apt/sources.list.d/ 2>/dev/null || true)
+  if [ -n "$files" ]; then
+    echo "$files" | xargs rm -f
+  fi
+  if [ -f /etc/apt/sources.list ]; then
</code_context>
<issue_to_address>
**Required repositories disappear**

When a matching source file also contains another active repository entry, `echo "$files" | xargs rm -f` removes the whole file, so apt loses the unrelated source and later package installs cannot obtain packages available only there.

Remove only the Moore Threads entries from matching files, preserving their other repository entries.
</issue_to_address>

### Comment 3
<location path="scripts/apt-install.sh" line_range="73" />
<code_context>
+    echo "$files" | xargs rm -f
+  fi
+  if [ -f /etc/apt/sources.list ]; then
+    sed -i "\|$vendor_host|d" /etc/apt/sources.list
+  fi
+}
</code_context>
<issue_to_address>
**Other repositories are deleted**

When `/etc/apt/sources.list` contains a non-vendor hostname matching the pattern with different characters in place of either dot, `sed` treats the dots in `vendor_host` as regex wildcards and deletes the non-vendor source line, so apt stops using that repository.

Escape regex metacharacters in the hostname before using it in the `sed` pattern.

Also at `scripts/apt-install.sh:74`.
</issue_to_address>

### Comment 4
<location path="scripts/apt-install.sh" line_range="68" />
<code_context>
+remove_vendor_repos() {
+  local vendor_host="dl.mthreads.com"
+  local files
+  files=$(grep -rlF "$vendor_host" /etc/apt/sources.list.d/ 2>/dev/null || true)
+  if [ -n "$files" ]; then
+    echo "$files" | xargs rm -f
</code_context>
<issue_to_address>
**Vendor source remains active**

When the vendor source file in `/etc/apt/sources.list.d/` is a symlink, `grep -r` skips symlinked files during traversal, so `remove_vendor_repos` misses the source and `apt-get update` still contacts the failing repository.

Search symlinked files as well, or explicitly inspect symlink targets.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread scripts/apt-install.sh Resolved
Comment thread scripts/apt-install.sh Resolved
Comment thread scripts/apt-install.sh Resolved
Comment thread scripts/apt-install.sh Resolved
Removing whole files dropped other entries in the same file and fed unquoted paths to rm. Editing lines in place with a literal pattern keeps other repositories and follows symlinked source files.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ilopezluna
ilopezluna merged commit 525253f into main Nov 23, 2026
14 checks passed
@ilopezluna
ilopezluna deleted the fix/musa-drop-mthreads-apt-source branch November 23, 2026 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants