Split the host name used for ftp transfers from the one used for http

transfers. This is slightly inconsistent, as directories are still
shared - but this allows us to default to cdn/nycdn for http (which don't
support ftp).
This commit is contained in:
martin 2018-09-11 08:05:18 +00:00
parent 3bdbd8da34
commit 9ce05eeee9
9 changed files with 69 additions and 31 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: defs.h,v 1.15 2018/09/08 20:01:19 martin Exp $ */
/* $NetBSD: defs.h,v 1.16 2018/09/11 08:05:18 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -340,6 +340,10 @@ int clean_xfer_dir;
#define SYSINST_FTP_HOST "ftp.NetBSD.org"
#endif
#if !defined(SYSINST_HTTP_HOST)
#define SYSINST_HTTP_HOST "cdn.NetBSD.org"
#endif
#if !defined(SYSINST_FTP_DIR)
#if defined(NETBSD_OFFICIAL_RELEASE)
#define SYSINST_FTP_DIR "pub/NetBSD/NetBSD-" REL
@ -355,6 +359,9 @@ int clean_xfer_dir;
#if !defined(SYSINST_PKG_HOST)
#define SYSINST_PKG_HOST "ftp.NetBSD.org"
#endif
#if !defined(SYSINST_PKG_HTTP_HOST)
#define SYSINST_PKG_HTTP_HOST "cdn.NetBSD.org"
#endif
#if !defined(SYSINST_PKG_DIR)
#define SYSINST_PKG_DIR "pub/pkgsrc/packages/NetBSD"
@ -363,6 +370,9 @@ int clean_xfer_dir;
#if !defined(SYSINST_PKGSRC_HOST)
#define SYSINST_PKGSRC_HOST SYSINST_PKG_HOST
#endif
#if !defined(SYSINST_PKGSRC_HTTP_HOST)
#define SYSINST_PKGSRC_HTTP_HOST SYSINST_PKG_HTTP_HOST
#endif
/* Abs. path we extract binary sets from */
char ext_dir_bin[STRSIZE];
@ -388,13 +398,17 @@ char pkgsrc_dir[STRSIZE];
/* User shell */
const char *ushell;
#define XFER_FTP 0
#define XFER_HTTP 1
#define XFER_MAX XFER_HTTP
struct ftpinfo {
char host[STRSIZE];
char xfer_host[XFER_MAX+1][STRSIZE];
char dir[STRSIZE] ;
char user[SSTRSIZE];
char pass[STRSIZE];
char proxy[STRSIZE];
const char *xfer_type; /* "ftp" or "http" */
unsigned int xfer; /* XFER_FTP for "ftp" or XFER_HTTP for "http" */
};
/* use the same struct for sets ftp and to build pkgpath */
@ -500,12 +514,13 @@ int get_real_geom(const char *, struct disklabel *);
/* from net.c */
extern int network_up;
extern char net_namesvr[STRSIZE];
int get_via_ftp(const char *);
int get_via_ftp(unsigned int);
int get_via_nfs(void);
int config_network(void);
void mnt_net_config(void);
void make_url(char *, struct ftpinfo *, const char *);
int get_pkgsrc(void);
const char *url_proto(unsigned int);
/* From run.c */
int collect(int, char **, const char *, ...) __printflike(3, 4);

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.7 2017/05/04 16:26:10 sevan Exp $ */
/* $NetBSD: main.c,v 1.8 2018/09/11 08:05:18 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -91,7 +91,8 @@ static const struct f_arg fflagopts[] = {
{"xfer dir", "/usr/INSTALL", xfer_dir, sizeof xfer_dir},
{"ext dir", "", ext_dir_bin, sizeof ext_dir_bin},
{"ext src dir", "", ext_dir_src, sizeof ext_dir_src},
{"ftp host", SYSINST_FTP_HOST, ftp.host, sizeof ftp.host},
{"ftp host", SYSINST_FTP_HOST, ftp.xfer_host[XFER_FTP], sizeof ftp.xfer_host[XFER_FTP]},
{"http host", SYSINST_HTTP_HOST, ftp.xfer_host[XFER_HTTP], sizeof ftp.xfer_host[XFER_HTTP]},
{"ftp dir", SYSINST_FTP_DIR, ftp.dir, sizeof ftp.dir},
{"ftp prefix", "/" MACH "/binary/sets", set_dir_bin, sizeof set_dir_bin},
{"ftp src prefix", "/source/sets", set_dir_src, sizeof set_dir_src},
@ -108,13 +109,15 @@ static const struct f_arg fflagopts[] = {
{"targetroot mount", "/targetroot", targetroot_mnt, sizeof targetroot_mnt},
{"dist postfix", ".tgz", dist_postfix, sizeof dist_postfix},
{"diskname", "mydisk", bsddiskname, sizeof bsddiskname},
{"pkg host", SYSINST_PKG_HOST, pkg.host, sizeof pkg.host},
{"pkg host", SYSINST_PKG_HOST, pkg.xfer_host[XFER_FTP], sizeof pkg.xfer_host[XFER_FTP]},
{"pkg http host", SYSINST_PKG_HTTP_HOST, pkg.xfer_host[XFER_HTTP], sizeof pkg.xfer_host[XFER_HTTP]},
{"pkg dir", SYSINST_PKG_DIR, pkg.dir, sizeof pkg.dir},
{"pkg prefix", "/" MACH "/" REL "/All", pkg_dir, sizeof pkg_dir},
{"pkg user", "ftp", pkg.user, sizeof pkg.user},
{"pkg pass", "", pkg.pass, sizeof pkg.pass},
{"pkg proxy", "", pkg.proxy, sizeof pkg.proxy},
{"pkgsrc host", SYSINST_PKGSRC_HOST, pkgsrc.host, sizeof pkgsrc.host},
{"pkgsrc host", SYSINST_PKGSRC_HOST, pkgsrc.xfer_host[XFER_FTP], sizeof pkgsrc.xfer_host[XFER_FTP]},
{"pkgsrc http host", SYSINST_PKGSRC_HTTP_HOST, pkgsrc.xfer_host[XFER_HTTP], sizeof pkgsrc.xfer_host[XFER_HTTP]},
{"pkgsrc dir", "", pkgsrc.dir, sizeof pkgsrc.dir},
{"pkgsrc prefix", "pub/pkgsrc/stable", pkgsrc_dir, sizeof pkgsrc_dir},
{"pkgsrc user", "ftp", pkgsrc.user, sizeof pkgsrc.user},
@ -149,7 +152,7 @@ init(void)
strlcpy(arg->var, arg->dflt, arg->size);
}
strlcpy(pm_new->bsddiskname, bsddiskname, sizeof pm_new->bsddiskname);
pkg.xfer_type = pkgsrc.xfer_type = "http";
pkg.xfer = pkgsrc.xfer = XFER_HTTP;
clr_arg.bg=COLOR_BLUE;
clr_arg.fg=COLOR_WHITE;

View File

@ -1,4 +1,4 @@
/* $NetBSD: menus.mi,v 1.13 2018/06/03 13:23:58 martin Exp $ */
/* $NetBSD: menus.mi,v 1.14 2018/09/11 08:05:18 martin Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -327,8 +327,8 @@ menu sizechoice, sub menu, y=0, title MSG_Choose_your_size_specifier;
menu distmedium, title MSG_Select_medium, y=-5;
option MSG_cdrom, exit, action { *(int *)arg = get_via_cdrom(); };
option MSG_http, exit, action { *(int *)arg = get_via_ftp("http"); };
option MSG_ftp, exit, action { *(int *)arg = get_via_ftp("ftp"); };
option MSG_http, exit, action { *(int *)arg = get_via_ftp(XFER_HTTP); };
option MSG_ftp, exit, action { *(int *)arg = get_via_ftp(XFER_FTP); };
option MSG_nfs, exit, action { *(int *)arg = get_via_nfs(); };
option MSG_floppy, exit, action { *(int *)arg = get_via_floppy(); };
option MSG_local_fs, exit, action { *(int *)arg = get_via_localfs(); };
@ -347,9 +347,9 @@ menu distset, title MSG_Select_your_distribution, exit,
menu ftpsource, y=-4, x=0, w=70, no box, no clear,
exitstring MSG_Get_Distribution;
display action { msg_display(MSG_ftpsource, ((arg_rv*)arg)->arg); };
option {src_legend(menu, MSG_Host, ftp.host);},
action { src_prompt(MSG_Host, ftp.host, sizeof ftp.host); };
display action { msg_display(MSG_ftpsource, url_proto((uintptr_t)((arg_rv*)arg)->arg)); };
option {src_legend(menu, MSG_Host, ftp.xfer_host[(uintptr_t)((arg_rv*)arg)->arg]);},
action { src_prompt(MSG_Host, ftp.xfer_host[(uintptr_t)((arg_rv*)arg)->arg], sizeof ftp.xfer_host[(uintptr_t)((arg_rv*)arg)->arg]); };
option {src_legend(menu, MSG_Base_dir, ftp.dir);},
action { src_prompt(MSG_Base_dir, ftp.dir, sizeof ftp.dir); };
option {src_legend(menu, MSG_Set_dir_bin, set_dir_bin);},
@ -533,8 +533,8 @@ menu zeroconf, title "Zeroconf", no clear;
menu binpkg, y=-4, x=0, w=70, no box, no clear,
exitstring MSG_Install_pkgin;
display action { msg_display(MSG_pkgpath); };
option {src_legend(menu, MSG_Host, pkg.host);},
action { src_prompt(MSG_Host, pkg.host, sizeof pkg.host); };
option {src_legend(menu, MSG_Host, pkg.xfer_host[pkg.xfer]);},
action { src_prompt(MSG_Host, pkg.xfer_host[pkg.xfer], sizeof pkg.xfer_host[pkg.xfer]); };
option {src_legend(menu, MSG_Base_dir, pkg.dir);},
action { src_prompt(MSG_Base_dir, pkg.dir, sizeof pkg.dir); };
option {src_legend(menu, MSG_Pkg_dir, pkg_dir);},
@ -573,14 +573,16 @@ menu binpkg, y=-4, x=0, w=70, no box, no clear,
config_network();
mnt_net_config();
};
option {src_legend(menu, MSG_transfer_method, url_proto(pkg.xfer));},
action { pkg.xfer = (pkg.xfer+1) % (XFER_MAX+1); };
option MSG_quit_pkgs_install, exit, action { ((arg_rv*)arg)->rv = SET_SKIP; };
menu pkgsrc, y=-4, x=0, w=70, no box, no clear,
exit, exitstring MSG_Install_pkgsrc;
display action { msg_display(MSG_pkgsrc); };
option {src_legend(menu, MSG_Host, pkgsrc.host);},
action { src_prompt(MSG_Host, pkgsrc.host,
sizeof pkgsrc.host); };
option {src_legend(menu, MSG_Host, pkgsrc.xfer_host[pkgsrc.xfer]);},
action { src_prompt(MSG_Host, pkgsrc.xfer_host[pkgsrc.xfer],
sizeof pkgsrc.xfer_host[pkgsrc.xfer]); };
option {src_legend(menu, MSG_Pkgsrc_dir, pkgsrc_dir);},
action { src_prompt(MSG_Pkgsrc_dir, pkgsrc_dir, sizeof pkgsrc_dir); };
option {src_legend(menu, MSG_User, pkgsrc.user);},
@ -612,6 +614,8 @@ menu pkgsrc, y=-4, x=0, w=70, no box, no clear,
option {src_legend(menu, MSG_delete_xfer_file,
clean_xfer_dir ? MSG_Yes : MSG_No);},
action {clean_xfer_dir = ask_yesno(MSG_delete_xfer_file); };
option {src_legend(menu, MSG_transfer_method, url_proto(pkgsrc.xfer));},
action { pkgsrc.xfer = (pkgsrc.xfer+1) % (XFER_MAX+1); };
option MSG_quit_pkgsrc, exit, action { *((int*)arg) = SET_SKIP;};
menu usersh, title MSG_User_shell, no clear;

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.de,v 1.7 2018/06/03 13:16:30 martin Exp $ */
/* $NetBSD: msg.mi.de,v 1.8 2018/09/11 08:05:18 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -988,6 +988,7 @@ message Base_dir {Basispfad}
message Set_dir_bin {Binärpaket-Verzeichnis}
message Set_dir_src {Quelltext-Verzeichnis}
message Xfer_dir {Zwischenspeicher}
message transfer_method {Download via}
message User {Benutzer}
message Password {Passwort}
message Proxy {Proxy}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.en,v 1.11 2018/06/03 13:16:30 martin Exp $ */
/* $NetBSD: msg.mi.en,v 1.12 2018/09/11 08:05:18 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -923,6 +923,7 @@ message Base_dir {Base directory}
message Set_dir_bin {Binary set directory}
message Set_dir_src {Source set directory}
message Xfer_dir {Transfer directory}
message transfer_method {Download via}
message User {User}
message Password {Password}
message Proxy {Proxy}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.es,v 1.7 2018/06/03 13:16:30 martin Exp $ */
/* $NetBSD: msg.mi.es,v 1.8 2018/09/11 08:05:18 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -954,6 +954,7 @@ message Base_dir {Directorio base}
message Set_dir_src {Directorio de conjuntos binary} /* fix XLAT */
message Set_dir_bin {Directorio de conjuntos source} /* fix XLAT */
message Xfer_dir {Directorio a transferir a}
message transfer_method {Download via}
message User {Usuario}
message Password {Contraseña}
message Proxy {Proxy}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.fr,v 1.10 2018/06/03 13:16:30 martin Exp $ */
/* $NetBSD: msg.mi.fr,v 1.11 2018/09/11 08:05:18 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -1023,6 +1023,7 @@ message Base_dir {R
message Set_dir_bin {Répertoire des composants binaire}
message Set_dir_src {Répertoire des composants source}
message Xfer_dir {Répertoire de transfert}
message transfer_method {Download via}
message User {Utilisateur}
message Password {Mot de passe}
message Proxy {Proxy}

View File

@ -1,4 +1,4 @@
/* $NetBSD: msg.mi.pl,v 1.9 2018/06/03 13:16:30 martin Exp $ */
/* $NetBSD: msg.mi.pl,v 1.10 2018/09/11 08:05:18 martin Exp $ */
/* Based on english version: */
/* NetBSD: msg.mi.pl,v 1.36 2004/04/17 18:55:35 atatat Exp */
@ -926,6 +926,7 @@ message Base_dir {Katalog}
message Set_dir_src {Katalog pakiet binary} /* fix XLAT */
message Set_dir_bin {Katalog pakiet source} /* fix XLAT */
message Xfer_dir {Transfer Katalog} /* fix XLAT */
message transfer_method {Download via}
message User {Uzytkownik}
message Password {Haslo}
message Proxy {Proxy}

View File

@ -1,4 +1,4 @@
/* $NetBSD: net.c,v 1.24 2018/05/18 12:23:22 joerg Exp $ */
/* $NetBSD: net.c,v 1.25 2018/09/11 08:05:18 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@ -849,6 +849,17 @@ done:
return network_up;
}
const char *
url_proto(unsigned int xfer)
{
switch (xfer) {
case XFER_FTP: return "ftp";
case XFER_HTTP: return "http";
}
return "";
}
void
make_url(char *urlbuffer, struct ftpinfo *f, const char *dir)
{
@ -892,8 +903,8 @@ make_url(char *urlbuffer, struct ftpinfo *f, const char *dir)
ftp_dir_encoded + sizeof ftp_dir_encoded,
RFC1738_SAFE_LESS_SHELL_PLUS_SLASH, 0);
snprintf(urlbuffer, STRSIZE, "%s://%s%s/%s", f->xfer_type,
ftp_user_encoded, f->host, ftp_dir_encoded);
snprintf(urlbuffer, STRSIZE, "%s://%s%s/%s", url_proto(f->xfer),
ftp_user_encoded, f->xfer_host[f->xfer], ftp_dir_encoded);
}
@ -959,12 +970,12 @@ get_pkgsrc(void)
}
int
get_via_ftp(const char *xfer_type)
get_via_ftp(unsigned int xfer)
{
arg_rv arg;
arg.rv = -1;
arg.arg = __UNCONST(xfer_type);
arg.arg = (void*)(uintptr_t)(xfer);
process_menu(MENU_ftpsource, &arg);
if (arg.rv == SET_RETRY)
@ -972,7 +983,7 @@ get_via_ftp(const char *xfer_type)
/* We'll fetch each file just before installing it */
fetch_fn = ftp_fetch;
ftp.xfer_type = xfer_type;
ftp.xfer = xfer;
snprintf(ext_dir_bin, sizeof ext_dir_bin, "%s/%s", target_prefix(),
xfer_dir + (*xfer_dir == '/'));
snprintf(ext_dir_src, sizeof ext_dir_src, "%s/%s", target_prefix(),