version 1.170, 2011/10/17 16:35:22 |
version 1.170.2.2, 2012/05/23 10:07:20 |
|
|
#define MD_SETS_SELECTED_NOX SET_KERNEL_1, SET_SYSTEM, SET_MD |
#define MD_SETS_SELECTED_NOX SET_KERNEL_1, SET_SYSTEM, SET_MD |
#endif |
#endif |
#ifndef MD_SETS_VALID |
#ifndef MD_SETS_VALID |
#define MD_SETS_VALID SET_KERNEL, SET_SYSTEM, SET_X11, SET_MD |
#define MD_SETS_VALID SET_KERNEL, SET_SYSTEM, SET_X11, SET_MD, SET_SOURCE |
#endif |
#endif |
|
|
#define MAX_CD_DEVS 256 /* how many cd drives do we expect to attach */ |
#define MAX_CD_DEVS 256 /* how many cd drives do we expect to attach */ |
Line 150 distinfo dist_list[] = { |
|
Line 150 distinfo dist_list[] = { |
|
{SET_MD_4_NAME, SET_MD_4, MSG_set_md_4, NULL}, |
{SET_MD_4_NAME, SET_MD_4, MSG_set_md_4, NULL}, |
#endif |
#endif |
|
|
|
{NULL, SET_GROUP, MSG_set_source, NULL}, |
|
{"syssrc", SET_SYSSRC, MSG_set_syssrc, NULL}, |
|
{"src", SET_SRC, MSG_set_src, NULL}, |
|
{"sharesrc", SET_SHARESRC, MSG_set_sharesrc, NULL}, |
|
{"gnusrc", SET_GNUSRC, MSG_set_gnusrc, NULL}, |
|
{"xsrc", SET_XSRC, MSG_set_xsrc, NULL}, |
|
{NULL, SET_GROUP_END, NULL, NULL}, |
|
|
{NULL, SET_LAST, NULL, NULL}, |
{NULL, SET_LAST, NULL, NULL}, |
}; |
}; |
|
|
Line 279 run_makedev(void) |
|
Line 287 run_makedev(void) |
|
* |
* |
* replace("/etc/some-file.conf", "s/prop1=NO/prop1=YES/;s/foo/bar/"); |
* replace("/etc/some-file.conf", "s/prop1=NO/prop1=YES/;s/foo/bar/"); |
*/ |
*/ |
static |
|
void |
void |
replace(const char *path, const char *patterns, ...) |
replace(const char *path, const char *patterns, ...) |
{ |
{ |
Line 357 get_via_floppy(void) |
|
Line 364 get_via_floppy(void) |
|
fetch_fn = floppy_fetch; |
fetch_fn = floppy_fetch; |
|
|
/* Set ext_dir for absolute path. */ |
/* Set ext_dir for absolute path. */ |
snprintf(ext_dir, sizeof ext_dir, "%s/%s", target_prefix(), xfer_dir); |
snprintf(ext_dir_bin, sizeof ext_dir_bin, "%s/%s", target_prefix(), xfer_dir); |
|
snprintf(ext_dir_src, sizeof ext_dir_src, "%s/%s", target_prefix(), xfer_dir); |
|
|
return SET_OK; |
return SET_OK; |
} |
} |
Line 400 get_iso9660_volname(int dev, int sess, c |
|
Line 408 get_iso9660_volname(int dev, int sess, c |
|
* the number of entries collected. |
* the number of entries collected. |
*/ |
*/ |
static int |
static int |
get_available_cds() |
get_available_cds(void) |
{ |
{ |
char dname[16], volname[80]; |
char dname[16], volname[80]; |
struct cd_info *info = cds; |
struct cd_info *info = cds; |
Line 423 get_available_cds() |
|
Line 431 get_available_cds() |
|
if (error == 0) { |
if (error == 0) { |
for (part = 0; part < label.d_npartitions; part++) { |
for (part = 0; part < label.d_npartitions; part++) { |
if (label.d_partitions[part].p_fstype |
if (label.d_partitions[part].p_fstype |
!= FS_ISO9660) |
== FS_UNUSED |
|
|| label.d_partitions[part].p_size == 0) |
continue; |
continue; |
if (label.d_partitions[part].p_fstype |
if (label.d_partitions[part].p_fstype |
== FS_ISO9660) { |
== FS_ISO9660) { |
Line 473 cd_has_sets(void) |
|
Line 482 cd_has_sets(void) |
|
|
|
mnt2_mounted = 1; |
mnt2_mounted = 1; |
|
|
snprintf(ext_dir, sizeof ext_dir, "%s/%s", "/mnt2", set_dir); |
snprintf(ext_dir_bin, sizeof ext_dir_bin, "%s/%s", "/mnt2", set_dir_bin); |
return dir_exists_p(ext_dir); |
snprintf(ext_dir_src, sizeof ext_dir_src, "%s/%s", "/mnt2", set_dir_src); |
|
return dir_exists_p(ext_dir_bin); |
} |
} |
|
|
|
|
Line 520 get_via_cdrom(void) |
|
Line 530 get_via_cdrom(void) |
|
bool silent = false; |
bool silent = false; |
|
|
/* If root is a CD-ROM and we have sets, skip this step. */ |
/* If root is a CD-ROM and we have sets, skip this step. */ |
if (statvfs(set_dir, &sb) == 0 && |
if (statvfs(set_dir_bin, &sb) == 0 && |
(strcmp(sb.f_fstypename, MOUNT_CD9660) == 0 |
(strcmp(sb.f_fstypename, MOUNT_CD9660) == 0 |
|| strcmp(sb.f_fstypename, MOUNT_UDF) == 0)) { |
|| strcmp(sb.f_fstypename, MOUNT_UDF) == 0)) { |
strlcpy(ext_dir, set_dir, sizeof ext_dir); |
strlcpy(ext_dir_bin, set_dir_bin, sizeof ext_dir_bin); |
|
strlcpy(ext_dir_src, set_dir_src, sizeof ext_dir_src); |
return SET_OK; |
return SET_OK; |
} |
} |
|
|
Line 562 get_via_cdrom(void) |
|
Line 573 get_via_cdrom(void) |
|
else { |
else { |
umount_mnt2(); |
umount_mnt2(); |
msg_display(MSG_cd_path_not_found); |
msg_display(MSG_cd_path_not_found); |
msg_display_add("\r\n\r\n"); |
process_menu(MENU_ok, NULL); |
} |
} |
|
|
/* ask for paths on the CD */ |
/* ask for paths on the CD */ |
Line 593 get_via_localfs(void) |
|
Line 604 get_via_localfs(void) |
|
|
|
mnt2_mounted = 1; |
mnt2_mounted = 1; |
|
|
snprintf(ext_dir, sizeof ext_dir, "%s/%s/%s", |
snprintf(ext_dir_bin, sizeof ext_dir_bin, "%s/%s/%s", |
"/mnt2", localfs_dir, set_dir); |
"/mnt2", localfs_dir, set_dir_bin); |
|
snprintf(ext_dir_src, sizeof ext_dir_src, "%s/%s/%s", |
|
"/mnt2", localfs_dir, set_dir_src); |
|
|
return SET_OK; |
return SET_OK; |
} |
} |
Line 614 get_via_localdir(void) |
|
Line 627 get_via_localdir(void) |
|
* We have to have an absolute path ('cos pax runs in a |
* We have to have an absolute path ('cos pax runs in a |
* different directory), make it so. |
* different directory), make it so. |
*/ |
*/ |
snprintf(ext_dir, sizeof ext_dir, "/%s/%s", localfs_dir, set_dir); |
snprintf(ext_dir_bin, sizeof ext_dir_bin, "/%s/%s", localfs_dir, set_dir_bin); |
|
snprintf(ext_dir_src, sizeof ext_dir_src, "/%s/%s", localfs_dir, set_dir_src); |
|
|
return SET_OK; |
return SET_OK; |
} |
} |
Line 844 customise_sets(void) |
|
Line 858 customise_sets(void) |
|
* full path name to the directory. |
* full path name to the directory. |
*/ |
*/ |
|
|
static int |
int |
extract_file(distinfo *dist, int update) |
extract_file(distinfo *dist, int update) |
{ |
{ |
char path[STRSIZE]; |
char path[STRSIZE]; |
Line 856 extract_file(distinfo *dist, int update) |
|
Line 870 extract_file(distinfo *dist, int update) |
|
make_target_dir(xfer_dir); |
make_target_dir(xfer_dir); |
|
|
(void)snprintf(path, sizeof path, "%s/%s%s", |
(void)snprintf(path, sizeof path, "%s/%s%s", |
ext_dir, dist->name, dist_postfix); |
ext_dir_for_set(dist->name), dist->name, dist_postfix); |
|
|
owd = getcwd(NULL, 0); |
owd = getcwd(NULL, 0); |
|
|
Line 872 extract_file(distinfo *dist, int update) |
|
Line 886 extract_file(distinfo *dist, int update) |
|
|
|
#ifdef SUPPORT_8_3_SOURCE_FILESYSTEM |
#ifdef SUPPORT_8_3_SOURCE_FILESYSTEM |
/* |
/* |
* Update path to use dist->name tuncated to the first eight |
* Update path to use dist->name truncated to the first eight |
* characters and check again |
* characters and check again |
*/ |
*/ |
(void)snprintf(path, sizeof path, "%s/%.8s%.4s", /* 4 as includes '.' */ |
(void)snprintf(path, sizeof path, "%s/%.8s%.4s", /* 4 as includes '.' */ |
ext_dir, dist->name, dist_postfix); |
ext_dir_for_set(dist->name), dist->name, dist_postfix); |
if (!file_exists_p(path)) { |
if (!file_exists_p(path)) { |
#endif /* SUPPORT_8_3_SOURCE_FILESYSTEM */ |
#endif /* SUPPORT_8_3_SOURCE_FILESYSTEM */ |
|
|
Line 895 extract_file(distinfo *dist, int update) |
|
Line 909 extract_file(distinfo *dist, int update) |
|
if (update && (dist->set == SET_ETC || dist->set == SET_X11_ETC)) { |
if (update && (dist->set == SET_ETC || dist->set == SET_X11_ETC)) { |
make_target_dir("/.sysinst"); |
make_target_dir("/.sysinst"); |
target_chdir_or_die("/.sysinst"); |
target_chdir_or_die("/.sysinst"); |
} else |
} else if (dist->set == SET_PKGSRC) |
|
target_chdir_or_die("/usr"); |
|
else |
target_chdir_or_die("/"); |
target_chdir_or_die("/"); |
|
|
/* |
/* |
Line 967 get_and_unpack_sets(int update, msg setu |
|
Line 983 get_and_unpack_sets(int update, msg setu |
|
|
|
/* Ensure mountpoint for distribution files exists in current root. */ |
/* Ensure mountpoint for distribution files exists in current root. */ |
(void)mkdir("/mnt2", S_IRWXU| S_IRGRP|S_IXGRP | S_IROTH|S_IXOTH); |
(void)mkdir("/mnt2", S_IRWXU| S_IRGRP|S_IXGRP | S_IROTH|S_IXOTH); |
if (scripting) |
if (script) |
(void)fprintf(script, "mkdir -m 755 /mnt2\n"); |
(void)fprintf(script, "mkdir -m 755 /mnt2\n"); |
|
|
/* reset failure/success counters */ |
/* reset failure/success counters */ |
Line 1068 get_and_unpack_sets(int update, msg setu |
|
Line 1084 get_and_unpack_sets(int update, msg setu |
|
if (set_status[SET_BASE] & SET_INSTALLED) |
if (set_status[SET_BASE] & SET_INSTALLED) |
run_makedev(); |
run_makedev(); |
|
|
/* Save keybard type */ |
if (!update) { |
save_kb_encoding(); |
/* Save keybard type */ |
|
save_kb_encoding(); |
|
|
/* Other configuration. */ |
/* Other configuration. */ |
mnt_net_config(); |
mnt_net_config(); |
|
} |
|
|
/* Mounted dist dir? */ |
/* Mounted dist dir? */ |
umount_mnt2(); |
umount_mnt2(); |
Line 1167 sanity_check(void) |
|
Line 1185 sanity_check(void) |
|
static char zoneinfo_dir[STRSIZE]; |
static char zoneinfo_dir[STRSIZE]; |
static int zonerootlen; |
static int zonerootlen; |
static char *tz_selected; /* timezonename (relative to share/zoneinfo */ |
static char *tz_selected; /* timezonename (relative to share/zoneinfo */ |
static const char *tz_default; /* UTC, or whatever /etc/localtime points to */ |
const char *tz_default; /* UTC, or whatever /etc/localtime points to */ |
static char tz_env[STRSIZE]; |
static char tz_env[STRSIZE]; |
static int save_cursel, save_topline; |
static int save_cursel, save_topline; |
|
|
Line 1318 tzm_set_names(menudesc *m, void *arg) |
|
Line 1336 tzm_set_names(menudesc *m, void *arg) |
|
qsort(tz_menu, nfiles, sizeof *tz_menu, tz_sort); |
qsort(tz_menu, nfiles, sizeof *tz_menu, tz_sort); |
} |
} |
|
|
/* |
void |
* Choose from the files in usr/share/zoneinfo and set etc/localtime |
get_tz_default(void) |
*/ |
|
int |
|
set_timezone(void) |
|
{ |
{ |
char localtime_link[STRSIZE]; |
char localtime_link[STRSIZE]; |
char localtime_target[STRSIZE]; |
static char localtime_target[STRSIZE]; |
int rc; |
int rc; |
time_t t; |
|
int menu_no; |
|
|
|
strlcpy(zoneinfo_dir, target_expand("/usr/share/zoneinfo/"), |
|
sizeof zoneinfo_dir - 1); |
|
zonerootlen = strlen(zoneinfo_dir); |
|
strlcpy(localtime_link, target_expand("/etc/localtime"), |
strlcpy(localtime_link, target_expand("/etc/localtime"), |
sizeof localtime_link); |
sizeof localtime_link); |
|
|
Line 1349 set_timezone(void) |
|
Line 1359 set_timezone(void) |
|
localtime_target[rc] = '\0'; |
localtime_target[rc] = '\0'; |
tz_default = strchr(strstr(localtime_target, "zoneinfo"), '/') + 1; |
tz_default = strchr(strstr(localtime_target, "zoneinfo"), '/') + 1; |
} |
} |
|
} |
|
|
|
/* |
|
* Choose from the files in usr/share/zoneinfo and set etc/localtime |
|
*/ |
|
int |
|
set_timezone(void) |
|
{ |
|
char localtime_link[STRSIZE]; |
|
char localtime_target[STRSIZE]; |
|
time_t t; |
|
int menu_no; |
|
|
|
strlcpy(zoneinfo_dir, target_expand("/usr/share/zoneinfo/"), |
|
sizeof zoneinfo_dir - 1); |
|
zonerootlen = strlen(zoneinfo_dir); |
|
|
|
get_tz_default(); |
|
|
tz_selected = strdup(tz_default); |
tz_selected = strdup(tz_default); |
snprintf(tz_env, sizeof(tz_env), "%s%s", zoneinfo_dir, tz_selected); |
snprintf(tz_env, sizeof(tz_env), "%s%s", zoneinfo_dir, tz_selected); |
Line 1375 set_timezone(void) |
|
Line 1403 set_timezone(void) |
|
|
|
snprintf(localtime_target, sizeof(localtime_target), |
snprintf(localtime_target, sizeof(localtime_target), |
"/usr/share/zoneinfo/%s", tz_selected); |
"/usr/share/zoneinfo/%s", tz_selected); |
|
strlcpy(localtime_link, target_expand("/etc/localtime"), |
|
sizeof localtime_link); |
unlink(localtime_link); |
unlink(localtime_link); |
symlink(localtime_target, localtime_link); |
symlink(localtime_target, localtime_link); |
|
|
|
|
return 1; |
return 1; |
} |
} |
|
|
int |
|
set_root_password(void) |
|
{ |
|
|
|
msg_display(MSG_rootpw); |
|
process_menu(MENU_yesno, NULL); |
|
if (yesno) |
|
run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_CHROOT, |
|
"passwd -l root"); |
|
return 0; |
|
} |
|
|
|
int |
|
set_root_shell(void) |
|
{ |
|
const char *shellpath; |
|
|
|
msg_display(MSG_rootsh); |
|
process_menu(MENU_rootsh, &shellpath); |
|
run_program(RUN_DISPLAY | RUN_CHROOT, "chpass -s %s root", shellpath); |
|
return 0; |
|
} |
|
|
|
void |
void |
scripting_vfprintf(FILE *f, const char *fmt, va_list ap) |
scripting_vfprintf(FILE *f, const char *fmt, va_list ap) |
{ |
{ |
|
|
if (f) |
if (f) |
(void)vfprintf(f, fmt, ap); |
(void)vfprintf(f, fmt, ap); |
if (scripting) |
if (script) |
(void)vfprintf(script, fmt, ap); |
(void)vfprintf(script, fmt, ap); |
} |
} |
|
|
Line 1443 add_rc_conf(const char *fmt, ...) |
|
Line 1450 add_rc_conf(const char *fmt, ...) |
|
va_end(ap); |
va_end(ap); |
} |
} |
|
|
|
int |
|
del_rc_conf(const char *value) |
|
{ |
|
FILE *fp, *nfp; |
|
char buf[4096]; /* Ridiculously high, but should be enough in any way */ |
|
char *rcconf, *tempname, *bakname; |
|
char *cp; |
|
int done = 0; |
|
int fd; |
|
int retval = 0; |
|
|
|
/* The paths might seem strange, but using /tmp would require copy instead |
|
* of rename operations. */ |
|
if (asprintf(&rcconf, "%s", target_expand("/etc/rc.conf")) < 0 |
|
|| asprintf(&tempname, "%s", target_expand("/etc/rc.conf.tmp.XXXXXX")) < 0 |
|
|| asprintf(&bakname, "%s", target_expand("/etc/rc.conf.bak.XXXXXX")) < 0) { |
|
if (rcconf) |
|
free(rcconf); |
|
if (tempname) |
|
free(tempname); |
|
msg_display(MSG_rcconf_delete_failed, value); |
|
process_menu(MENU_ok, NULL); |
|
return -1; |
|
} |
|
|
|
if ((fd = mkstemp(bakname)) < 0) { |
|
msg_display(MSG_rcconf_delete_failed, value); |
|
process_menu(MENU_ok, NULL); |
|
return -1; |
|
} |
|
close(fd); |
|
|
|
if (!(fp = fopen(rcconf, "r+")) || (fd = mkstemp(tempname)) < 0) { |
|
if (fp) |
|
fclose(fp); |
|
msg_display(MSG_rcconf_delete_failed, value); |
|
process_menu(MENU_ok, NULL); |
|
return -1; |
|
} |
|
|
|
nfp = fdopen(fd, "w"); |
|
if (!nfp) { |
|
fclose(fp); |
|
close(fd); |
|
msg_display(MSG_rcconf_delete_failed, value); |
|
process_menu(MENU_ok, NULL); |
|
return -1; |
|
} |
|
|
|
while (fgets(buf, sizeof buf, fp) != NULL) { |
|
|
|
cp = buf + strspn(buf, " \t"); /* Skip initial spaces */ |
|
if (strncmp(cp, value, strlen(value)) == 0) { |
|
cp += strlen(value); |
|
if (*cp != '=') |
|
scripting_fprintf(nfp, "%s", buf); |
|
else |
|
done = 1; |
|
} else { |
|
scripting_fprintf(nfp, "%s", buf); |
|
} |
|
} |
|
fclose(fp); |
|
fclose(nfp); |
|
|
|
if (done) { |
|
if (rename(rcconf, bakname)) { |
|
msg_display(MSG_rcconf_backup_failed); |
|
process_menu(MENU_noyes, NULL); |
|
if (!yesno) { |
|
retval = -1; |
|
goto done; |
|
} |
|
} |
|
|
|
if (rename(tempname, rcconf)) { |
|
if (rename(bakname, rcconf)) { |
|
msg_display(MSG_rcconf_restore_failed); |
|
process_menu(MENU_ok, NULL); |
|
} else { |
|
msg_display(MSG_rcconf_delete_failed, value); |
|
process_menu(MENU_ok, NULL); |
|
} |
|
} else { |
|
(void)unlink(bakname); |
|
} |
|
} |
|
|
|
done: |
|
(void)unlink(tempname); |
|
free(rcconf); |
|
free(tempname); |
|
free(bakname); |
|
return retval; |
|
} |
|
|
void |
void |
add_sysctl_conf(const char *fmt, ...) |
add_sysctl_conf(const char *fmt, ...) |
{ |
{ |
Line 1480 check_lfs_progs(void) |
|
Line 1583 check_lfs_progs(void) |
|
return 0; |
return 0; |
#endif |
#endif |
} |
} |
|
|
|
int |
|
set_is_source(const char *set_name) { |
|
int len = strlen(set_name); |
|
return len >= 3 && memcmp(set_name + len - 3, "src", 3) == 0; |
|
} |
|
|
|
const char * |
|
set_dir_for_set(const char *set_name) { |
|
if (strcmp(set_name, "pkgsrc") == 0) |
|
return pkgsrc_dir; |
|
return set_is_source(set_name) ? set_dir_src : set_dir_bin; |
|
} |
|
|
|
const char * |
|
ext_dir_for_set(const char *set_name) { |
|
if (strcmp(set_name, "pkgsrc") == 0) |
|
return ext_dir_pkgsrc; |
|
return set_is_source(set_name) ? ext_dir_src : ext_dir_bin; |
|
} |
|
|