Skip to content

Commit 78e863a

Browse files
committed
Rewrite openSUSE Leap recipe
1 parent a3a8127 commit 78e863a

File tree

3 files changed

+72
-45
lines changed

3 files changed

+72
-45
lines changed

src/recipe/os/openSUSE.c

Lines changed: 11 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
/** ------------------------------------------------------------
22
* SPDX-License-Identifier: GPL-3.0-or-later
33
* -------------------------------------------------------------
4-
* File Authors : Heng Guo <[email protected]>
5-
* Contributors : Aoran Zeng <[email protected]>
6-
* Created On : <2023-09-17>
7-
* Last Modified : <2025-07-21>
4+
* File Authors : Heng Guo <[email protected]>
5+
* Contributors : Aoran Zeng <[email protected]>
6+
* Created On : <2023-09-17>
7+
* Major Revision : 1
8+
* Last Modified : <2025-07-21>
89
* ------------------------------------------------------------*/
910

11+
#include "rawstr4c.h"
12+
1013
/**
1114
* @update 2025-06-20
1215
*/
@@ -30,54 +33,17 @@ def_sources_n(os_opensuse);
3033

3134

3235
/**
33-
* HELP: 未经测试
36+
* @consult https://mirrors.tuna.tsinghua.edu.cn/help/opensuse/
3437
*/
3538
void
3639
os_opensuse_setsrc (char *option)
3740
{
38-
chsrc_ensure_root (); // HELP: 不知道是否需要确保root权限
41+
chsrc_ensure_root ();
3942

4043
chsrc_yield_source_and_confirm (os_opensuse);
4144

42-
char *source_nselect = "zypper mr -da";
43-
chsrc_run (source_nselect, RunOpt_Default);
44-
45-
char *cmd1 = xy_strjoin (3,
46-
"zypper ar -cfg '",
47-
source.url,
48-
"/opensuse/distribution/leap/$releasever/repo/oss/' mirror-oss");
49-
char *cmd2 = xy_strjoin (3,
50-
"zypper ar -cfg '",
51-
source.url,
52-
"/opensuse/distribution/leap/$releasever/repo/non-oss/' mirror-non-oss");
53-
char *cmd3 = xy_strjoin (3,
54-
"zypper ar -cfg '",
55-
source.url,
56-
"/opensuse/distribution/leap/$releasever/oss/' mirror-update");
57-
char *cmd4 = xy_strjoin (3,
58-
"zypper ar -cfg '",
59-
source.url,
60-
"/opensuse/distribution/leap/$releasever/non-oss/' mirror-update-non-oss");
61-
char *cmd5 = xy_strjoin (3,
62-
"zypper ar -cfg '",
63-
source.url,
64-
"/opensuse/distribution/leap/$releasever/sle/' mirror-sle-update");
65-
char *cmd6 = xy_strjoin (3,
66-
"zypper ar -cfg '",
67-
source.url,
68-
"/opensuse/distribution/leap/$releasever/backports/' mirror-backports-update");
69-
70-
chsrc_run (cmd1, RunOpt_Default);
71-
chsrc_run (cmd2, RunOpt_Default);
72-
chsrc_run (cmd3, RunOpt_Default);
73-
chsrc_run (cmd4, RunOpt_Default);
74-
75-
chsrc_note2 ("leap 15.3用户还需要添加sle和backports源");
76-
chsrc_note2 ("另外请确保系统在更新后仅启用了六个软件源,可以使用 zypper lr 检查软件源状态");
77-
chsrc_note2 ("并使用 zypper mr -d 禁用多余的软件源");
78-
79-
chsrc_run (cmd5, RunOpt_Default);
80-
chsrc_run (cmd6, RunOpt_Default);
45+
/* TODO: 实现 Tumbleweed 换源 */
46+
chsrc_run_as_bash_file (RAWSTR_os_openSUSE_leap_in_bash);
8147

8248
chsrc_determine_chgtype (ChgType_Untested);
8349
chsrc_conclude (&source);

src/recipe/os/rawstr4c.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#pragma once
2+
3+
/**
4+
* Generated by rawstr4c v0.2.2-2025/07/21
5+
*/
6+
7+
char RAWSTR_os_openSUSE_leap_in_bash[] = "\x23\x20\xe9\xa6\x96\xe5\x85\x88\xe7\xa6\x81\xe7\x94\xa8\xe5\xae\x98\xe6\x96\xb9\xe8\xbd\xaf\xe4\xbb\xb6\xe6\xba\x90\x0a\x7a\x79\x70\x70\x65\x72\x20\x6d\x72\x20\x2d\x64\x61\x0a\x0a\x7a\x79\x70\x70\x65\x72\x20\x61\x72\x20\x2d\x63\x66\x67\x20\x27\x40\x75\x72\x6c\x40\x2f\x64\x69\x73\x74\x72\x69\x62\x75\x74\x69\x6f\x6e\x2f\x6c\x65\x61\x70\x2f\x24\x72\x65\x6c\x65\x61\x73\x65\x76\x65\x72\x2f\x72\x65\x70\x6f\x2f\x6f\x73\x73\x2f\x27\x20\x6d\x69\x72\x72\x6f\x72\x2d\x6f\x73\x73\x0a\x7a\x79\x70\x70\x65\x72\x20\x61\x72\x20\x2d\x63\x66\x67\x20\x27\x40\x75\x72\x6c\x40\x2f\x64\x69\x73\x74\x72\x69\x62\x75\x74\x69\x6f\x6e\x2f\x6c\x65\x61\x70\x2f\x24\x72\x65\x6c\x65\x61\x73\x65\x76\x65\x72\x2f\x72\x65\x70\x6f\x2f\x6e\x6f\x6e\x2d\x6f\x73\x73\x2f\x27\x20\x6d\x69\x72\x72\x6f\x72\x2d\x6e\x6f\x6e\x2d\x6f\x73\x73\x0a\x7a\x79\x70\x70\x65\x72\x20\x61\x72\x20\x2d\x63\x66\x67\x20\x27\x40\x75\x72\x6c\x40\x2f\x75\x70\x64\x61\x74\x65\x2f\x6c\x65\x61\x70\x2f\x24\x72\x65\x6c\x65\x61\x73\x65\x76\x65\x72\x2f\x6f\x73\x73\x2f\x27\x20\x6d\x69\x72\x72\x6f\x72\x2d\x75\x70\x64\x61\x74\x65\x0a\x7a\x79\x70\x70\x65\x72\x20\x61\x72\x20\x2d\x63\x66\x67\x20\x27\x40\x75\x72\x6c\x40\x2f\x75\x70\x64\x61\x74\x65\x2f\x6c\x65\x61\x70\x2f\x24\x72\x65\x6c\x65\x61\x73\x65\x76\x65\x72\x2f\x6e\x6f\x6e\x2d\x6f\x73\x73\x2f\x27\x20\x6d\x69\x72\x72\x6f\x72\x2d\x75\x70\x64\x61\x74\x65\x2d\x6e\x6f\x6e\x2d\x6f\x73\x73\x0a\x0a\x7a\x79\x70\x70\x65\x72\x20\x61\x72\x20\x2d\x63\x66\x67\x20\x27\x40\x75\x72\x6c\x40\x2f\x75\x70\x64\x61\x74\x65\x2f\x6c\x65\x61\x70\x2f\x24\x72\x65\x6c\x65\x61\x73\x65\x76\x65\x72\x2f\x73\x6c\x65\x2f\x27\x20\x6d\x69\x72\x72\x6f\x72\x2d\x73\x6c\x65\x2d\x75\x70\x64\x61\x74\x65\x0a\x7a\x79\x70\x70\x65\x72\x20\x61\x72\x20\x2d\x63\x66\x67\x20\x27\x40\x75\x72\x6c\x40\x2f\x75\x70\x64\x61\x74\x65\x2f\x6c\x65\x61\x70\x2f\x24\x72\x65\x6c\x65\x61\x73\x65\x76\x65\x72\x2f\x62\x61\x63\x6b\x70\x6f\x72\x74\x73\x2f\x27\x20\x6d\x69\x72\x72\x6f\x72\x2d\x62\x61\x63\x6b\x70\x6f\x72\x74\x73\x2d\x75\x70\x64\x61\x74\x65\x0a";
8+
9+
char RAWSTR_os_openSUSE_tumbleweed_in_bash[] = "\x23\x20\xe9\xa6\x96\xe5\x85\x88\xe7\xa6\x81\xe7\x94\xa8\xe5\xae\x98\xe6\x96\xb9\xe8\xbd\xaf\xe4\xbb\xb6\xe6\xba\x90\x0a\x7a\x79\x70\x70\x65\x72\x20\x6d\x72\x20\x2d\x64\x61\x0a\x0a\x7a\x79\x70\x70\x65\x72\x20\x61\x72\x20\x2d\x63\x66\x67\x20\x27\x68\x74\x74\x70\x73\x3a\x2f\x2f\x6d\x69\x72\x72\x6f\x72\x73\x2e\x74\x75\x6e\x61\x2e\x74\x73\x69\x6e\x67\x68\x75\x61\x2e\x65\x64\x75\x2e\x63\x6e\x2f\x6f\x70\x65\x6e\x73\x75\x73\x65\x2f\x74\x75\x6d\x62\x6c\x65\x77\x65\x65\x64\x2f\x72\x65\x70\x6f\x2f\x6f\x73\x73\x2f\x27\x20\x6d\x69\x72\x72\x6f\x72\x2d\x6f\x73\x73\x0a\x7a\x79\x70\x70\x65\x72\x20\x61\x72\x20\x2d\x63\x66\x67\x20\x27\x68\x74\x74\x70\x73\x3a\x2f\x2f\x6d\x69\x72\x72\x6f\x72\x73\x2e\x74\x75\x6e\x61\x2e\x74\x73\x69\x6e\x67\x68\x75\x61\x2e\x65\x64\x75\x2e\x63\x6e\x2f\x6f\x70\x65\x6e\x73\x75\x73\x65\x2f\x74\x75\x6d\x62\x6c\x65\x77\x65\x65\x64\x2f\x72\x65\x70\x6f\x2f\x6e\x6f\x6e\x2d\x6f\x73\x73\x2f\x27\x20\x6d\x69\x72\x72\x6f\x72\x2d\x6e\x6f\x6e\x2d\x6f\x73\x73\x0a\x0a\x23\x20\xe5\x88\xb7\xe6\x96\xb0\xe8\xbd\xaf\xe4\xbb\xb6\xe6\xba\x90\x0a\x7a\x79\x70\x70\x65\x72\x20\x72\x65\x66\x0a";
10+

src/recipe/os/rawstr4c.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<!-- -----------------------------------------------------------
2+
! SPDX-License-Identifier: GPL-3.0-or-later
3+
! -------------------------------------------------------------
4+
! Config Type : rawstr4c (Markdown)
5+
! Config Authors: Aoran Zeng <[email protected]>
6+
! Contributors : Nil Null <[email protected]>
7+
! Created On : <2025-07-21>
8+
! Last Modified : <2025-07-21>
9+
! ---------------------------------------------------------- -->
10+
11+
# rawstr4c input for OS
12+
13+
- prefix = `RAWSTR_os`
14+
- output = `:global-variable-only-header`
15+
- translate = `:hex`
16+
17+
## openSUSE
18+
19+
- namespace = `openSUSE`
20+
21+
### Leap
22+
23+
`openSUSE Leap` 换源脚本
24+
25+
```bash
26+
# 首先禁用官方软件源
27+
zypper mr -da
28+
29+
zypper ar -cfg '@url@/distribution/leap/$releasever/repo/oss/' mirror-oss
30+
zypper ar -cfg '@url@/distribution/leap/$releasever/repo/non-oss/' mirror-non-oss
31+
zypper ar -cfg '@url@/update/leap/$releasever/oss/' mirror-update
32+
zypper ar -cfg '@url@/update/leap/$releasever/non-oss/' mirror-update-non-oss
33+
34+
zypper ar -cfg '@url@/update/leap/$releasever/sle/' mirror-sle-update
35+
zypper ar -cfg '@url@/update/leap/$releasever/backports/' mirror-backports-update
36+
```
37+
38+
### Tumbleweed
39+
40+
`openSUSE Tumbleweed` 换源脚本
41+
42+
```bash
43+
# 首先禁用官方软件源
44+
zypper mr -da
45+
46+
zypper ar -cfg 'https://mirrors.tuna.tsinghua.edu.cn/opensuse/tumbleweed/repo/oss/' mirror-oss
47+
zypper ar -cfg 'https://mirrors.tuna.tsinghua.edu.cn/opensuse/tumbleweed/repo/non-oss/' mirror-non-oss
48+
49+
# 刷新软件源
50+
zypper ref
51+
```

0 commit comments

Comments
 (0)