Skip to content

Commit f4812cd

Browse files
committed
Support openSUSE tumbleweed
1 parent 7011fc1 commit f4812cd

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

src/recipe/os/openSUSE.c

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,39 @@ os_opensuse_setsrc (char *option)
4242

4343
chsrc_yield_source_and_confirm (os_opensuse);
4444

45-
/* TODO: 实现 Tumbleweed 换源 */
46-
chsrc_run_as_bash_file (RAWSTR_os_openSUSE_leap_in_bash);
45+
while (1) {
46+
chsrc_note2 ("请选择你的操作系统为:");
47+
printf ("%s", R"(
48+
1. openSUSE Leap
49+
2. openSUSE Tumbleweed
50+
51+
==> )");
52+
53+
int choice = 0;
54+
55+
/* 接受到一个数字时返回1,非法为0,流结束为-1 */
56+
if (scanf("%d", &choice) != 1)
57+
{
58+
/* 清除输入缓冲区 */
59+
int ch;
60+
while ((ch = getchar()) != '\n' && ch != EOF);
61+
chsrc_error2 ("输入无效!请输入数字");
62+
continue;
63+
}
64+
if (choice == 1)
65+
{
66+
chsrc_run_as_bash_file (RAWSTR_os_openSUSE_leap_in_bash);
67+
}
68+
if (choice == 2)
69+
{
70+
chsrc_run_as_bash_file (RAWSTR_os_openSUSE_tumbleweed_in_bash);
71+
break;
72+
}
73+
else
74+
{
75+
chsrc_error2 ("无效的选择,请输入 1 或 2 ");
76+
}
77+
}
4778

4879
chsrc_determine_chgtype (ChgType_Untested);
4980
chsrc_conclude (&source);

0 commit comments

Comments
 (0)