Skip to content

Commit e6dd832

Browse files
committed
container support
1 parent aa0cd98 commit e6dd832

File tree

2 files changed

+32
-15
lines changed

2 files changed

+32
-15
lines changed

bin/ejudge-setup.c

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3213,7 +3213,6 @@ generate_contest_xml(FILE *f)
32133213
} else {
32143214
fprintf(f, "<?xml version=\"1.0\" ?>\n");
32153215
}
3216-
fprintf(f, "<!-- %cId%c -->\n", '$', '$');
32173216
fprintf(f, "<!-- Generated by ejudge-setup, version %s -->\n",
32183217
compile_version);
32193218
fprintf(f, "<!-- Generation date: %s -->\n", date_buf);
@@ -3276,7 +3275,7 @@ generate_userlist_xml(FILE *f)
32763275
}
32773276

32783277
static void
3279-
generate_ejudge_xml(FILE *f)
3278+
generate_ejudge_xml(FILE *f, int container_mode)
32803279
{
32813280
const struct path_edit_item *cur;
32823281
unsigned char date_buf[64];
@@ -3293,11 +3292,14 @@ generate_ejudge_xml(FILE *f)
32933292
compile_version);
32943293
fprintf(f, "<!-- Generation date: %s -->\n", date_buf);
32953294

3295+
fprintf(f, "<config");
32963296
#if CONF_HAS_LIBINTL - 0 == 1
3297-
fprintf(f, "<config l10n=\"yes\">\n");
3298-
#else
3299-
fprintf(f, "<config>\n");
3297+
fprintf(f, " l10n=\"yes\"");
33003298
#endif /* CONF_HAS_LIBINTL */
3299+
if (container_mode > 0) {
3300+
fprintf(f, " enable_compile_container=\"yes\" force_container=\"yes\"");
3301+
}
3302+
fprintf(f, ">\n");
33013303

33023304
cur = &path_edit_items[PATH_LINE_SOCKET_PATH];
33033305
if (cur->default_value && !strcmp(cur->default_value, cur->buf)) {
@@ -3745,7 +3747,7 @@ do_preview_menu(void)
37453747
case 1:
37463748
snprintf(preview_header, sizeof(preview_header),
37473749
"To be installed to %s", config_ejudge_xml_path);
3748-
generate_ejudge_xml(f);
3750+
generate_ejudge_xml(f, 0);
37493751
break;
37503752
case 2:
37513753
snprintf(preview_header, sizeof(preview_header),
@@ -3907,7 +3909,7 @@ const unsigned char b64_contest1_tgz[] =
39073909
;
39083910

39093911
static void
3910-
generate_install_script(FILE *f, int batch_install_script)
3912+
generate_install_script(FILE *f, int batch_install_script, int container_mode)
39113913
{
39123914
FILE *floc = 0, *ff = 0;
39133915
char *txt_ptr = 0;
@@ -4104,7 +4106,7 @@ generate_install_script(FILE *f, int batch_install_script)
41044106
"echo \"%s already exists, not overwriting\" 1>&2\n"
41054107
"else\n", config_ejudge_xml_path, config_ejudge_xml_path);
41064108
floc = open_memstream(&txt_ptr, &txt_len);
4107-
generate_ejudge_xml(floc);
4109+
generate_ejudge_xml(floc, container_mode);
41084110
close_memstream(floc); floc = 0;
41094111
snprintf(fpath, sizeof(fpath), "%s", config_ejudge_xml_path);
41104112
fprintf(f, "# copy ejudge.xml to its location\n");
@@ -4430,15 +4432,18 @@ preview_install_script(void)
44304432
if (check_install_script_validity() < 0) return;
44314433

44324434
f = open_memstream(&txt_ptr, &txt_len);
4433-
generate_install_script(f, 0);
4435+
generate_install_script(f, 0, 0);
44344436
close_memstream(f); f = 0;
44354437
ncurses_view_text("Setup script preview", txt_ptr);
44364438
free(txt_ptr); txt_ptr = 0; txt_len = 0;
44374439
}
44384440

44394441
static void
4440-
save_install_script(int batch_mode, const unsigned char *output_name,
4441-
int batch_install_script)
4442+
save_install_script(
4443+
int batch_mode,
4444+
const unsigned char *output_name,
4445+
int batch_install_script,
4446+
int container_mode)
44424447
{
44434448
FILE *f = 0;
44444449
char *txt_ptr = 0, *p;
@@ -4463,7 +4468,7 @@ save_install_script(int batch_mode, const unsigned char *output_name,
44634468
if (check_install_script_validity() < 0) return;
44644469

44654470
f = open_memstream(&txt_ptr, &txt_len);
4466-
generate_install_script(f, batch_install_script);
4471+
generate_install_script(f, batch_install_script, container_mode);
44674472
close_memstream(f); f = 0;
44684473

44694474
if (output_name && *output_name) {
@@ -4596,7 +4601,7 @@ do_main_menu(void)
45964601
preview_install_script();
45974602
break;
45984603
case 7:
4599-
save_install_script(0, NULL, 0);
4604+
save_install_script(0, NULL, 0, 0);
46004605
break;
46014606
}
46024607
}
@@ -4723,6 +4728,7 @@ main(int argc, char **argv)
47234728
const unsigned char *user = 0, *group = 0, *workdir = 0;
47244729
int batch_mode = 0;
47254730
int batch_install_script = 0;
4731+
int container_mode = 0;
47264732

47274733
while (cur_arg < argc) {
47284734
if (!strcmp(argv[cur_arg], "-u")) {
@@ -4743,6 +4749,9 @@ main(int argc, char **argv)
47434749
} else if (!strcmp(argv[cur_arg], "-B")) {
47444750
batch_install_script = 1;
47454751
cur_arg += 1;
4752+
} else if (!strcmp(argv[cur_arg], "-s")) {
4753+
container_mode = 1;
4754+
cur_arg += 1;
47464755
} else if (!strcmp(argv[cur_arg], "-i")) {
47474756
if (cur_arg + 1 >= argc) arg_expected(argv[0]);
47484757
lang_ids_file = argv[cur_arg + 1];
@@ -4784,7 +4793,8 @@ main(int argc, char **argv)
47844793
snprintf(config_email, sizeof(config_email), "%s", "ejudge@localhost");
47854794
snprintf(config_name, sizeof(config_name), "%s", "ejudge administrator");
47864795
make_sha1_passwd(config_password_sha1, "ejudge");
4787-
save_install_script(1, "ejudge-install.sh", batch_install_script);
4796+
save_install_script(1, "ejudge-install.sh", batch_install_script,
4797+
container_mode);
47884798
} else {
47894799
//answer = ncurses_yesno(0, initial_warning);
47904800
make_sha1_passwd(config_password_sha1, "ejudge");

docker/build.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ RELEASE='RELEASE=1'
2424
> ejudge-install.sh
2525
chmod 755 ejudge-install.sh
2626
chown ejudge:ejudge ejudge-install.sh
27-
./ejudge-setup -u ejudge -g ejudge -b -B
27+
./ejudge-setup -u ejudge -g ejudge -b -B -s
2828
cp -p ejudge-install.sh /opt/ejudge/bin
2929
cp docker/httpd.conf /etc/httpd/conf
30+
31+
wget https://ejudge.ru/download/ejudge-container-fedora-36.tbz
32+
mv ejudge-container-fedora-36.tbz /opt/ejudge/share/ejudge
33+
tar -C /opt/ejudge/share/ejudge xf /opt/ejudge/share/ejudge/ejudge-container-fedora-36.tbz
34+
rm /opt/ejudge/share/ejudge/ejudge-container-fedora-36.tbz
35+
cp -p /etc/passwd /opt/ejudge/share/ejudge/container/etc
36+
cp -p /etc/group /opt/ejudge/share/ejudge/container/etc

0 commit comments

Comments
 (0)