mirror of
https://github.com/RubyMetric/chsrc
synced 2025-07-16 04:07:27 +08:00
Rewrite old source list for Ubuntu
and Debian
This commit is contained in:
parent
ec8f57dc98
commit
0dba3904cf
@ -5,10 +5,12 @@
|
|||||||
* Contributors : happy game <happygame1024@gmail.com>
|
* Contributors : happy game <happygame1024@gmail.com>
|
||||||
* |
|
* |
|
||||||
* Created On : <2024-06-14>
|
* Created On : <2024-06-14>
|
||||||
* Major Revision : 2
|
* Major Revision : 3
|
||||||
* Last Modified : <2025-03-25>
|
* Last Modified : <2025-07-14>
|
||||||
* ------------------------------------------------------------*/
|
* ------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "rawstr4c.h"
|
||||||
|
|
||||||
#define OS_Apt_SourceList "/etc/apt/sources.list"
|
#define OS_Apt_SourceList "/etc/apt/sources.list"
|
||||||
#define OS_Apt_SourceList_D "/etc/apt/sources.list.d/"
|
#define OS_Apt_SourceList_D "/etc/apt/sources.list.d/"
|
||||||
|
|
||||||
@ -63,7 +65,7 @@ ensure_debian_or_ubuntu_old_sourcelist (int debian_type)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *msg = ENGLISH ? "Will generate a new source list file"
|
char *msg = ENGLISH ? "Will generate a new source list file"
|
||||||
: "将生成新的源配置文件";
|
: "将生成新的源配置文件";
|
||||||
chsrc_note2 (msg);
|
chsrc_note2 (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -78,53 +80,34 @@ ensure_debian_or_ubuntu_old_sourcelist (int debian_type)
|
|||||||
|
|
||||||
if (debian_type == OS_Is_Ubuntu)
|
if (debian_type == OS_Is_Ubuntu)
|
||||||
{
|
{
|
||||||
makeup = xy_strjoin (9,
|
makeup = xy_str_gsub (RAWSTR_os_apt_based_ubuntu_old_source_list, "@v@", Chsrc_Version);
|
||||||
"# Generated by chsrc " Chsrc_Version "\n\n"
|
makeup = xy_str_gsub (makeup, "@1@", Chsrc_Maintain_URL);
|
||||||
"deb " Chsrc_Maintain_URL "/ubuntu ", codename, " main restricted universe multiverse\n"
|
makeup = xy_str_gsub (makeup, "@2@", codename);
|
||||||
"deb " Chsrc_Maintain_URL "/ubuntu ", codename, "-updates main restricted universe multiverse\n"
|
|
||||||
"deb " Chsrc_Maintain_URL "/ubuntu ", codename, "-backports main restricted universe multiverse\n"
|
|
||||||
"deb " Chsrc_Maintain_URL "/ubuntu ", codename, "-security main restricted universe multiverse\n");
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (version >= 12) /* bookworm */
|
if (version >= 12) /* bookworm */
|
||||||
{
|
{
|
||||||
/**
|
makeup = xy_str_gsub (RAWSTR_os_apt_based_debian_12_source_list, "@v@", Chsrc_Version);
|
||||||
* https://wiki.debian.org/SourcesList
|
makeup = xy_str_gsub (makeup, "@1@", Chsrc_Maintain_URL);
|
||||||
* https://mirrors.tuna.tsinghua.edu.cn/help/debian/
|
makeup = xy_str_gsub (makeup, "@2@", codename);
|
||||||
* 从 Debian 12 开始,开始有一项 non-free-firmware
|
|
||||||
*/
|
|
||||||
makeup = xy_strjoin (9,
|
|
||||||
"# Generated by chsrc " Chsrc_Version "\n\n"
|
|
||||||
"deb " Chsrc_Maintain_URL "/debian ", codename, " main contrib non-free non-free-firmware\n"
|
|
||||||
"deb " Chsrc_Maintain_URL "/debian ", codename, "-updates main contrib non-free non-free-firmware\n"
|
|
||||||
"deb " Chsrc_Maintain_URL "/debian ", codename, "-backports main contrib non-free non-free-firmware\n"
|
|
||||||
"deb " Chsrc_Maintain_URL "/debian-security ", codename, "-security main contrib non-free non-free-firmware\n");
|
|
||||||
/* 上述 debian-security 这种写法是和 Debian 10不同的,所以我们只能支持 Debian 11+ */
|
|
||||||
}
|
}
|
||||||
else if (version >= 11) /* bullseye */
|
else if (version >= 11) /* bullseye */
|
||||||
{
|
{
|
||||||
makeup = xy_strjoin (9,
|
makeup = xy_str_gsub (RAWSTR_os_apt_based_debian_11_source_list, "@v@", Chsrc_Version);
|
||||||
"# Generated by chsrc " Chsrc_Version "(" Chsrc_Maintain_URL ")\n\n"
|
makeup = xy_str_gsub (makeup, "@1@", Chsrc_Maintain_URL);
|
||||||
"deb " Chsrc_Maintain_URL "/debian ", codename, " main contrib non-free\n"
|
makeup = xy_str_gsub (makeup, "@2@", codename);
|
||||||
"deb " Chsrc_Maintain_URL "/debian ", codename, "-updates main contrib non-free\n"
|
|
||||||
"deb " Chsrc_Maintain_URL "/debian ", codename, "-backports main contrib non-free\n"
|
|
||||||
"deb " Chsrc_Maintain_URL "/debian-security ", codename, "-security main contrib non-free\n");
|
|
||||||
}
|
}
|
||||||
else if (version >= 10) /* buster */
|
else if (version >= 10) /* buster */
|
||||||
{
|
{
|
||||||
makeup = xy_strjoin (9,
|
makeup = xy_str_gsub (RAWSTR_os_apt_based_debian_10_source_list, "@v@", Chsrc_Version);
|
||||||
"# Generated by chsrc " Chsrc_Version "(" Chsrc_Maintain_URL ")\n\n"
|
makeup = xy_str_gsub (makeup, "@1@", Chsrc_Maintain_URL);
|
||||||
"deb " Chsrc_Maintain_URL "/debian ", codename, " main contrib non-free\n"
|
makeup = xy_str_gsub (makeup, "@2@", codename);
|
||||||
"deb " Chsrc_Maintain_URL "/debian ", codename, "-updates main contrib non-free\n"
|
|
||||||
"deb " Chsrc_Maintain_URL "/debian ", codename, "-backports main contrib non-free\n"
|
|
||||||
"deb " Chsrc_Maintain_URL "/debian-security ", codename, "/updates main contrib non-free\n");
|
|
||||||
/* 上述 debian-security 这种写法是和 Debian 11 不同的 */
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *msg = ENGLISH ? "Your Debian version is too low (<10) for chsrc to support"
|
char *msg = ENGLISH ? "Your Debian version is too low (<10) for chsrc to support"
|
||||||
: "你的 Debian 版本过低 (<10),暂不支持换源";
|
: "你的 Debian 版本过低 (<10),暂不支持换源";
|
||||||
chsrc_error (msg);
|
chsrc_error (msg);
|
||||||
exit (Exit_Unsupported);
|
exit (Exit_Unsupported);
|
||||||
}
|
}
|
||||||
|
16
src/recipe/os/APT/rawstr4c.h
Normal file
16
src/recipe/os/APT/rawstr4c.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generated by rawstr4c v0.1.0.1-2025/07/14
|
||||||
|
*
|
||||||
|
* Date: 2025-07-14T17:01:22.816708+08:00
|
||||||
|
*/
|
||||||
|
|
||||||
|
char RAWSTR_os_apt_based_ubuntu_old_source_list[] = "\x23\x20\x47\x65\x6e\x65\x72\x61\x74\x65\x64\x20\x62\x79\x20\x63\x68\x73\x72\x63\x20\x40\x76\x40\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x75\x62\x75\x6e\x74\x75\x20\x40\x32\x40\x20\x6d\x61\x69\x6e\x20\x72\x65\x73\x74\x72\x69\x63\x74\x65\x64\x20\x75\x6e\x69\x76\x65\x72\x73\x65\x20\x6d\x75\x6c\x74\x69\x76\x65\x72\x73\x65\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x75\x62\x75\x6e\x74\x75\x20\x40\x32\x40\x2d\x75\x70\x64\x61\x74\x65\x73\x20\x6d\x61\x69\x6e\x20\x72\x65\x73\x74\x72\x69\x63\x74\x65\x64\x20\x75\x6e\x69\x76\x65\x72\x73\x65\x20\x6d\x75\x6c\x74\x69\x76\x65\x72\x73\x65\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x75\x62\x75\x6e\x74\x75\x20\x40\x32\x40\x2d\x62\x61\x63\x6b\x70\x6f\x72\x74\x73\x20\x6d\x61\x69\x6e\x20\x72\x65\x73\x74\x72\x69\x63\x74\x65\x64\x20\x75\x6e\x69\x76\x65\x72\x73\x65\x20\x6d\x75\x6c\x74\x69\x76\x65\x72\x73\x65\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x75\x62\x75\x6e\x74\x75\x20\x40\x32\x40\x2d\x73\x65\x63\x75\x72\x69\x74\x79\x20\x6d\x61\x69\x6e\x20\x72\x65\x73\x74\x72\x69\x63\x74\x65\x64\x20\x75\x6e\x69\x76\x65\x72\x73\x65\x20\x6d\x75\x6c\x74\x69\x76\x65\x72\x73\x65\x0a";
|
||||||
|
|
||||||
|
char RAWSTR_os_apt_based_debian_12_source_list[] = "\x23\x20\x47\x65\x6e\x65\x72\x61\x74\x65\x64\x20\x62\x79\x20\x63\x68\x73\x72\x63\x20\x40\x76\x40\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x64\x65\x62\x69\x61\x6e\x20\x40\x32\x40\x20\x6d\x61\x69\x6e\x20\x63\x6f\x6e\x74\x72\x69\x62\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x2d\x66\x69\x72\x6d\x77\x61\x72\x65\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x64\x65\x62\x69\x61\x6e\x20\x40\x32\x40\x2d\x75\x70\x64\x61\x74\x65\x73\x20\x6d\x61\x69\x6e\x20\x63\x6f\x6e\x74\x72\x69\x62\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x2d\x66\x69\x72\x6d\x77\x61\x72\x65\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x64\x65\x62\x69\x61\x6e\x20\x40\x32\x40\x2d\x62\x61\x63\x6b\x70\x6f\x72\x74\x73\x20\x6d\x61\x69\x6e\x20\x63\x6f\x6e\x74\x72\x69\x62\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x2d\x66\x69\x72\x6d\x77\x61\x72\x65\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x64\x65\x62\x69\x61\x6e\x2d\x73\x65\x63\x75\x72\x69\x74\x79\x20\x40\x32\x40\x2d\x73\x65\x63\x75\x72\x69\x74\x79\x20\x6d\x61\x69\x6e\x20\x63\x6f\x6e\x74\x72\x69\x62\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x2d\x66\x69\x72\x6d\x77\x61\x72\x65\x0a";
|
||||||
|
|
||||||
|
char RAWSTR_os_apt_based_debian_11_source_list[] = "\x23\x20\x47\x65\x6e\x65\x72\x61\x74\x65\x64\x20\x62\x79\x20\x63\x68\x73\x72\x63\x20\x40\x76\x40\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x64\x65\x62\x69\x61\x6e\x20\x40\x32\x40\x20\x6d\x61\x69\x6e\x20\x63\x6f\x6e\x74\x72\x69\x62\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x64\x65\x62\x69\x61\x6e\x20\x40\x32\x40\x2d\x75\x70\x64\x61\x74\x65\x73\x20\x6d\x61\x69\x6e\x20\x63\x6f\x6e\x74\x72\x69\x62\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x64\x65\x62\x69\x61\x6e\x20\x40\x32\x40\x2d\x62\x61\x63\x6b\x70\x6f\x72\x74\x73\x20\x6d\x61\x69\x6e\x20\x63\x6f\x6e\x74\x72\x69\x62\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x64\x65\x62\x69\x61\x6e\x2d\x73\x65\x63\x75\x72\x69\x74\x79\x20\x40\x32\x40\x2d\x73\x65\x63\x75\x72\x69\x74\x79\x20\x6d\x61\x69\x6e\x20\x63\x6f\x6e\x74\x72\x69\x62\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x0a";
|
||||||
|
|
||||||
|
char RAWSTR_os_apt_based_debian_10_source_list[] = "\x23\x20\x47\x65\x6e\x65\x72\x61\x74\x65\x64\x20\x62\x79\x20\x63\x68\x73\x72\x63\x20\x40\x76\x40\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x64\x65\x62\x69\x61\x6e\x20\x40\x32\x40\x20\x6d\x61\x69\x6e\x20\x63\x6f\x6e\x74\x72\x69\x62\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x64\x65\x62\x69\x61\x6e\x20\x40\x32\x40\x2d\x75\x70\x64\x61\x74\x65\x73\x20\x6d\x61\x69\x6e\x20\x63\x6f\x6e\x74\x72\x69\x62\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x64\x65\x62\x69\x61\x6e\x20\x40\x32\x40\x2d\x62\x61\x63\x6b\x70\x6f\x72\x74\x73\x20\x6d\x61\x69\x6e\x20\x63\x6f\x6e\x74\x72\x69\x62\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x0a\x64\x65\x62\x20\x40\x31\x40\x2f\x64\x65\x62\x69\x61\x6e\x2d\x73\x65\x63\x75\x72\x69\x74\x79\x20\x40\x32\x40\x2f\x75\x70\x64\x61\x74\x65\x73\x20\x6d\x61\x69\x6e\x20\x63\x6f\x6e\x74\x72\x69\x62\x20\x6e\x6f\x6e\x2d\x66\x72\x65\x65\x0a";
|
||||||
|
|
70
src/recipe/os/APT/rawstr4c.md
Normal file
70
src/recipe/os/APT/rawstr4c.md
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<!-- -----------------------------------------------------------
|
||||||
|
! SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
! -------------------------------------------------------------
|
||||||
|
! Config Type : rawstr4c (Markdown)
|
||||||
|
! Config Authors: Aoran Zeng <ccmywish@qq.com>
|
||||||
|
! Contributors : Nil Null <nil@null.org>
|
||||||
|
! Created On : <2025-07-14>
|
||||||
|
! Last Modified : <2025-07-14>
|
||||||
|
! ---------------------------------------------------------- -->
|
||||||
|
|
||||||
|
# rawstr4c input
|
||||||
|
|
||||||
|
- prefix = `RAWSTR_os_apt_based`
|
||||||
|
- output = `:global-variable-only-header`
|
||||||
|
- translate = `:hex`
|
||||||
|
- keep-postfix = `false`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Ubuntu old source list
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Generated by chsrc @v@
|
||||||
|
deb @1@/ubuntu @2@ main restricted universe multiverse
|
||||||
|
deb @1@/ubuntu @2@-updates main restricted universe multiverse
|
||||||
|
deb @1@/ubuntu @2@-backports main restricted universe multiverse
|
||||||
|
deb @1@/ubuntu @2@-security main restricted universe multiverse
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Debian 12 source list
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Generated by chsrc @v@
|
||||||
|
deb @1@/debian @2@ main contrib non-free non-free-firmware
|
||||||
|
deb @1@/debian @2@-updates main contrib non-free non-free-firmware
|
||||||
|
deb @1@/debian @2@-backports main contrib non-free non-free-firmware
|
||||||
|
deb @1@/debian-security @2@-security main contrib non-free non-free-firmware
|
||||||
|
```
|
||||||
|
|
||||||
|
从 Debian 12 开始,开始有一项 `non-free-firmware`
|
||||||
|
|
||||||
|
- https://wiki.debian.org/SourcesList
|
||||||
|
- https://mirrors.tuna.tsinghua.edu.cn/help/debian/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
## Debian 11 source list
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Generated by chsrc @v@
|
||||||
|
deb @1@/debian @2@ main contrib non-free
|
||||||
|
deb @1@/debian @2@-updates main contrib non-free
|
||||||
|
deb @1@/debian @2@-backports main contrib non-free
|
||||||
|
deb @1@/debian-security @2@-security main contrib non-free
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Debian 10 source list
|
||||||
|
|
||||||
|
```sh
|
||||||
|
# Generated by chsrc @v@
|
||||||
|
deb @1@/debian @2@ main contrib non-free
|
||||||
|
deb @1@/debian @2@-updates main contrib non-free
|
||||||
|
deb @1@/debian @2@-backports main contrib non-free
|
||||||
|
deb @1@/debian-security @2@/updates main contrib non-free
|
||||||
|
```
|
||||||
|
|
||||||
|
上述 debian-security 这种写法是和 Debian 11 不同的,我们只支持到这里
|
@ -7,7 +7,7 @@
|
|||||||
! Contributors : Nul None <nul@none.org>
|
! Contributors : Nul None <nul@none.org>
|
||||||
! |
|
! |
|
||||||
! Created On : <2025-07-12>
|
! Created On : <2025-07-12>
|
||||||
! Last Modified : <2025-07-13>
|
! Last Modified : <2025-07-14>
|
||||||
! ---------------------------------------------------------- -->
|
! ---------------------------------------------------------- -->
|
||||||
|
|
||||||
# rawstr4c
|
# rawstr4c
|
||||||
@ -73,7 +73,7 @@ just rawstr4c ./src/recipe/ware
|
|||||||
|
|
||||||
- name =
|
- name =
|
||||||
|
|
||||||
生成的变量名,默认将会包含前缀和后缀
|
生成的变量名,默认将会包含前缀和后缀。如果没有给该配置项,将会使用该节标题
|
||||||
|
|
||||||
- name-literally = `false` | `true`
|
- name-literally = `false` | `true`
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user