Add openSUSE platform support and tests

Added openSUSE to the supported platforms in the documentation and configuration. Updated README with openSUSE usage instructions and examples. Introduced tests to verify openSUSE path transformation logic.
This commit is contained in:
xixu-me committed 2025-07-31 14:40:48 +08:00
1 parent 3872b063c2
commit 1e18fce3b0
3 files changed
+88

No files matched your search

+26
View File
@@ -26,6 +26,7 @@
[![Ubuntu](https://img.shields.io/badge/Ubuntu-E95420?logo=ubuntu&logoColor=white)](#linux-发行版加速)
[![Fedora](https://img.shields.io/badge/Fedora-294172?logo=fedora&logoColor=white)](#linux-发行版加速)
[![Rocky Linux](https://img.shields.io/badge/Rocky%20Linux-10B981?logo=rockylinux&logoColor=white)](#linux-发行版加速)
[![openSUSE](https://img.shields.io/badge/openSUSE-73BA25?logo=opensuse&logoColor=white)](#linux-发行版加速)
[![Arch Linux](https://img.shields.io/badge/Arch%20Linux-1793D1?logo=archlinux&logoColor=white)](#linux-发行版加速)
[![arXiv](https://img.shields.io/badge/arXiv-B31B1B?logo=arxiv&logoColor=white)](#学术资源加速)
[![容器注册表](https://img.shields.io/badge/容器注册表-%23007EC6.svg?logo=docker&logoColor=white)](#容器注册表)
@@ -139,6 +140,7 @@
| Ubuntu | `ubuntu` | `https://archive.ubuntu.com/...` | `https://xget.xi-xu.me/ubuntu/...` |
| Fedora | `fedora` | `https://dl.fedoraproject.org/...` | `https://xget.xi-xu.me/fedora/...` |
| Rocky Linux | `rocky` | `https://download.rockylinux.org/...` | `https://xget.xi-xu.me/rocky/...` |
| openSUSE | `opensuse` | `https://download.opensuse.org/...` | `https://xget.xi-xu.me/opensuse/...` |
| Arch Linux | `arch` | `https://geo.mirror.pkgbuild.com/...` | `https://xget.xi-xu.me/arch/...` |
| arXiv | `arxiv` | `https://arxiv.org/...` | `https://xget.xi-xu.me/arxiv/...` |
| 容器注册表 | `cr` | 见[容器注册表](#容器注册表) | 见[容器注册表](#容器注册表) |
@@ -420,6 +422,12 @@ https://download.rockylinux.org/pub/rocky/9/BaseOS/x86_64/os/Packages/b/bash-5.1
# 转换后(添加 rocky 前缀)
https://xget.xi-xu.me/rocky/pub/rocky/9/BaseOS/x86_64/os/Packages/b/bash-5.1.8-6.el9.x86_64.rpm
# openSUSE 包原始链接
https://download.opensuse.org/distribution/leap/15.5/repo/oss/x86_64/vim-9.0.1572-150500.20.8.1.x86_64.rpm
# 转换后(添加 opensuse 前缀)
https://xget.xi-xu.me/opensuse/distribution/leap/15.5/repo/oss/x86_64/vim-9.0.1572-150500.20.8.1.x86_64.rpm
# Arch Linux 包原始链接
https://geo.mirror.pkgbuild.com/core/os/x86_64/linux-6.6.10.arch1-1-x86_64.pkg.tar.zst
@@ -1125,6 +1133,24 @@ sudo sed -i 's|^#baseurl=http://dl.rockylinux.org|baseurl=https://xget.xi-xu.me/
sudo dnf makecache
```
#### openSUSE Zypper 配置
```bash
# 配置 openSUSE Leap 镜像
sudo zypper mr -d repo-oss
sudo zypper ar -f https://xget.xi-xu.me/opensuse/distribution/leap/15.5/repo/oss/ repo-oss-xget
# 配置 openSUSE Tumbleweed 镜像
sudo zypper mr -d repo-oss
sudo zypper ar -f https://xget.xi-xu.me/opensuse/tumbleweed/repo/oss/ repo-oss-xget
# 刷新软件源
sudo zypper refresh
# 验证配置
sudo zypper lr -u
```
#### Arch Linux Pacman 配置
```bash
+1
View File
@@ -26,6 +26,7 @@ export const PLATFORMS = {
ubuntu: 'https://archive.ubuntu.com',
fedora: 'https://dl.fedoraproject.org',
rocky: 'https://download.rockylinux.org',
opensuse: 'https://download.opensuse.org',
arch: 'https://geo.mirror.pkgbuild.com',
arxiv: 'https://arxiv.org',
+61
View File
@@ -0,0 +1,61 @@
import { describe, expect, it } from 'vitest';
import { PLATFORMS, transformPath } from '../src/config/platforms.js';
describe('openSUSE Platform Configuration', () => {
it('should have openSUSE platform configured', () => {
expect(PLATFORMS.opensuse).toBe('https://download.opensuse.org');
});
it('should transform openSUSE paths correctly', () => {
const testCases = [
{
input:
'/opensuse/distribution/leap/15.5/repo/oss/x86_64/vim-9.0.1572-150500.20.8.1.x86_64.rpm',
expected: '/distribution/leap/15.5/repo/oss/x86_64/vim-9.0.1572-150500.20.8.1.x86_64.rpm',
description: 'Leap package file'
},
{
input: '/opensuse/tumbleweed/repo/oss/x86_64/firefox-121.0-1.1.x86_64.rpm',
expected: '/tumbleweed/repo/oss/x86_64/firefox-121.0-1.1.x86_64.rpm',
description: 'Tumbleweed package file'
},
{
input: '/opensuse/distribution/leap/15.5/repo/oss/repodata/repomd.xml',
expected: '/distribution/leap/15.5/repo/oss/repodata/repomd.xml',
description: 'repository metadata'
},
{
input:
'/opensuse/source/distribution/leap/15.5/repo/oss/src/kernel-default-5.14.21-150500.55.44.1.src.rpm',
expected:
'/source/distribution/leap/15.5/repo/oss/src/kernel-default-5.14.21-150500.55.44.1.src.rpm',
description: 'source package'
},
{
input: '/opensuse/update/leap/15.5/oss/x86_64/systemd-249.17-150400.8.35.1.x86_64.rpm',
expected: '/update/leap/15.5/oss/x86_64/systemd-249.17-150400.8.35.1.x86_64.rpm',
description: 'update package'
}
];
testCases.forEach(({ input, expected, description }) => {
const result = transformPath(input, 'opensuse');
expect(result).toBe(expected, `Failed for ${description}: ${input}`);
});
});
it('should handle root path correctly', () => {
const result = transformPath('/opensuse/', 'opensuse');
expect(result).toBe('/');
});
it('should handle paths without platform prefix', () => {
const result = transformPath(
'/distribution/leap/15.5/repo/oss/x86_64/vim-9.0.1572-150500.20.8.1.x86_64.rpm',
'opensuse'
);
expect(result).toBe(
'/distribution/leap/15.5/repo/oss/x86_64/vim-9.0.1572-150500.20.8.1.x86_64.rpm'
);
});
});