Skip to content

Add Debian/Armbian support to Linux mirror configuration#2879

Draft
Copilot wants to merge 5 commits intodevelopfrom
copilot/fix-linux-package-source-url
Draft

Add Debian/Armbian support to Linux mirror configuration#2879
Copilot wants to merge 5 commits intodevelopfrom
copilot/fix-linux-package-source-url

Conversation

Copy link
Contributor

Copilot AI commented Dec 22, 2025

The Linux mirror update functionality only supported Alpine Linux (/etc/apk/repositories), causing Debian/Armbian systems to fail with malformed URLs containing repeated path segments: /armbian/dists/armbian/dists///armbian/armbian/armbian/debian.

Changes

  • Distribution detection: Check for both /etc/apt/sources.list and /etc/debian_version to identify Debian-based systems
  • Debian/Armbian handling:
    • Extract current mirror URL from sources.list via regex /^deb\s+(https?:\/\/[^\s]+)/m
    • Replace URLs in both /etc/apt/sources.list and /etc/apt/sources.list.d/ directory
    • Execute apt-get update after mirror changes
  • Security: Escape backslashes, forward slashes, and dots in URLs for sed commands to prevent injection
  • Backward compatibility: Alpine Linux logic unchanged

Implementation

// Detect Debian-based systems
const hasAptSourcesList = await fs.promises.access('/etc/apt/sources.list')
  .then(() => true).catch(() => false);
const hasDebianVersion = await fs.promises.access('/etc/debian_version')
  .then(() => true).catch(() => false);
const isDebianBased = hasAptSourcesList || hasDebianVersion;

if (isDebianBased) {
  // Extract and replace mirror URL with proper escaping
  const escapedDefault = defaultDomain
    .replace(/\\/g, '\\\\')
    .replace(/\//g, '\\/')
    .replace(/\./g, '\\.');
  
  command = `sed -i 's/${escapedDefault}/${escapedTarget}/g' /etc/apt/sources.list`;
  command += ` && find /etc/apt/sources.list.d -type f \\( -name "*.list" -o -name "*.sources" \\) -exec sed -i 's/${escapedDefault}/${escapedTarget}/g' {} \\;`;
  command += ` && apt-get update`;
}

Notes

  • Assumes all repositories use the same base mirror URL (replaces based on first detected mirror)
  • Supports both .list and .sources file formats in sources.list.d
Original prompt

This section details on the original issue you should resolve

<issue_title>Linux 软件包镜像源地址错误</issue_title>
<issue_description>### Qinglong version

v2.20.0

Steps to reproduce

无论是使用默认地址还是阿里云还是清华源,url都会都会重复好几遍armbian
Image
Image

于是查看源配置文件,发现里面也存在问题,手动修改sources.list文件后正常
Image

系统Armbian (24.11.0) aarch64,使用docker版青龙

What is expected?

正常更新软件源

What is actually happening?

无法更新软件源

System Info

Any additional comments?

No response</issue_description>

Comments on the Issue (you are @copilot in this section)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link

vercel bot commented Dec 22, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
qinglong Ready Ready Preview, Comment Dec 22, 2025 3:08pm
qinglong-back Ready Ready Preview, Comment Dec 22, 2025 3:08pm

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
Copilot AI and others added 2 commits December 22, 2025 14:47
…or handling

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
…ping

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
…n and Alpine

Co-authored-by: whyour <22700758+whyour@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Linux software package mirror source URL error Add Debian/Armbian support to Linux mirror configuration Dec 22, 2025
Copilot AI requested a review from whyour December 22, 2025 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.

Linux 软件包镜像源地址错误

2 participants