Module Name:    src
Committed By:   martin
Date:           Sat Oct  6 18:45:37 UTC 2018

Modified Files:
        src/usr.sbin/sysinst: Makefile.inc defs.h main.c net.c util.c

Log Message:
Support sets in .tar.xz format


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.sbin/sysinst/Makefile.inc
cvs rdiff -u -r1.19 -r1.20 src/usr.sbin/sysinst/defs.h
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/sysinst/main.c
cvs rdiff -u -r1.25 -r1.26 src/usr.sbin/sysinst/net.c
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/sysinst/util.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/sysinst/Makefile.inc
diff -u src/usr.sbin/sysinst/Makefile.inc:1.13 src/usr.sbin/sysinst/Makefile.inc:1.14
--- src/usr.sbin/sysinst/Makefile.inc:1.13	Thu Sep 20 12:27:42 2018
+++ src/usr.sbin/sysinst/Makefile.inc	Sat Oct  6 18:45:37 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.13 2018/09/20 12:27:42 rin Exp $
+#	$NetBSD: Makefile.inc,v 1.14 2018/10/06 18:45:37 martin Exp $
 #
 # Makefile for sysinst
 
@@ -47,9 +47,11 @@ LDADD=		-lcurses -ltermlib -lutil
 UNIF_AWK=	${.CURDIR}/../../unif.awk
 MSG_XLAT_SH=	${.CURDIR}/../../msg_xlat.sh
 
+SETS_TAR_SUFF=${"${USE_XZ_SETS:Uno}"!="no":?"tar.xz":"tgz"}
 
 CATALOGDIR=	/usr/share/sysinst/catalog
 CPPFLAGS+=	-I. -I${.CURDIR}/../.. -I${.CURDIR} \
+		-DSETS_TAR_SUFF=${SETS_TAR_SUFF:Q} \
 		-DREL=\"${DISTRIBVER}\" -DMACH=\"${MACHINE}\" \
 		-DMACH_${MACHINE} -DARCH_${MACHINE_ARCH} \
 		${NODISKLABEL:D-DNO_DISKLABEL} \

Index: src/usr.sbin/sysinst/defs.h
diff -u src/usr.sbin/sysinst/defs.h:1.19 src/usr.sbin/sysinst/defs.h:1.20
--- src/usr.sbin/sysinst/defs.h:1.19	Thu Sep 20 12:27:42 2018
+++ src/usr.sbin/sysinst/defs.h	Sat Oct  6 18:45:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.19 2018/09/20 12:27:42 rin Exp $	*/
+/*	$NetBSD: defs.h,v 1.20 2018/10/06 18:45:37 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -192,6 +192,7 @@ typedef struct arg_rv {
 typedef struct distinfo {
 	const char	*name;
 	uint		set;
+	bool		force_tgz;	/* this set is always in .tgz format */
 	const char	*desc;
 	const char	*marker_file;	/* set assumed installed if exists */
 } distinfo;
@@ -376,6 +377,10 @@ int  clean_xfer_dir;
 #define SYSINST_PKGSRC_HTTP_HOST	SYSINST_PKG_HTTP_HOST
 #endif
 
+#ifndef SETS_TAR_SUFF
+#define	SETS_TAR_SUFF	 "tgz"
+#endif
+
 /* Abs. path we extract binary sets from */
 char ext_dir_bin[STRSIZE];
 
@@ -433,6 +438,7 @@ char targetroot_mnt[SSTRSIZE];
 int  mnt2_mounted;
 
 char dist_postfix[SSTRSIZE];
+char dist_tgz_postfix[SSTRSIZE];
 
 /* needed prototypes */
 void set_menu_numopts(int, int);
@@ -579,6 +585,8 @@ int	extract_file(distinfo *, int);
 void	do_coloring (unsigned int, unsigned int);
 int set_menu_select(menudesc *, void *);
 const char *safectime(time_t *);
+bool	use_tgz_for_set(const char*);
+const char *set_postfix(const char*);
 
 /* from target.c */
 #if defined(DEBUG)  ||	defined(DEBUG_ROOT)

Index: src/usr.sbin/sysinst/main.c
diff -u src/usr.sbin/sysinst/main.c:1.10 src/usr.sbin/sysinst/main.c:1.11
--- src/usr.sbin/sysinst/main.c:1.10	Thu Sep 20 12:27:42 2018
+++ src/usr.sbin/sysinst/main.c	Sat Oct  6 18:45:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.10 2018/09/20 12:27:42 rin Exp $	*/
+/*	$NetBSD: main.c,v 1.11 2018/10/06 18:45:37 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -107,7 +107,8 @@ static const struct f_arg fflagopts[] = 
 	{"local fs", "ffs", localfs_fs, sizeof localfs_fs},
 	{"local dir", "release", localfs_dir, sizeof localfs_dir},
 	{"targetroot mount", "/targetroot", targetroot_mnt, sizeof targetroot_mnt},
-	{"dist postfix", ".tgz", dist_postfix, sizeof dist_postfix},
+	{"dist postfix", "." SETS_TAR_SUFF, dist_postfix, sizeof dist_postfix},
+	{"dist tgz postfix", ".tgz", dist_tgz_postfix, sizeof dist_tgz_postfix},
 	{"diskname", "mydisk", bsddiskname, sizeof bsddiskname},
 	{"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]},

Index: src/usr.sbin/sysinst/net.c
diff -u src/usr.sbin/sysinst/net.c:1.25 src/usr.sbin/sysinst/net.c:1.26
--- src/usr.sbin/sysinst/net.c:1.25	Tue Sep 11 08:05:18 2018
+++ src/usr.sbin/sysinst/net.c	Sat Oct  6 18:45:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: net.c,v 1.25 2018/09/11 08:05:18 martin Exp $	*/
+/*	$NetBSD: net.c,v 1.26 2018/10/06 18:45:37 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -909,23 +909,24 @@ make_url(char *urlbuffer, struct ftpinfo
 
 
 /* ftp_fetch() and pkgsrc_fetch() are essentially the same, with a different
- * ftpinfo var. */
-static int do_ftp_fetch(const char *, struct ftpinfo *);
+ * ftpinfo var and pkgsrc always using .tgz suffix, while for
+ * regular sets we only use .tgz for source sets on some architectures. */
+static int do_ftp_fetch(const char *, bool, struct ftpinfo *);
 
 static int
 ftp_fetch(const char *set_name)
 {
-	return do_ftp_fetch(set_name, &ftp);
+	return do_ftp_fetch(set_name, use_tgz_for_set(set_name), &ftp);
 }
 
 static int
 pkgsrc_fetch(const char *set_name)
 {
-	return do_ftp_fetch(set_name, &pkgsrc);
+	return do_ftp_fetch(set_name, true, &pkgsrc);
 }
 
 static int
-do_ftp_fetch(const char *set_name, struct ftpinfo *f)
+do_ftp_fetch(const char *set_name, bool force_tgz, struct ftpinfo *f)
 {
 	const char *ftp_opt;
 	char url[STRSIZE];
@@ -944,7 +945,8 @@ do_ftp_fetch(const char *set_name, struc
 	make_url(url, f, set_dir_for_set(set_name));
 	rval = run_program(RUN_DISPLAY | RUN_PROGRESS | RUN_XFER_DIR,
 		    "/usr/bin/ftp %s%s/%s%s",
-		    ftp_opt, url, set_name, dist_postfix);
+		    ftp_opt, url, set_name,
+		    force_tgz ? dist_tgz_postfix : dist_postfix);
 
 	return rval ? SET_RETRY : SET_OK;
 }

Index: src/usr.sbin/sysinst/util.c
diff -u src/usr.sbin/sysinst/util.c:1.11 src/usr.sbin/sysinst/util.c:1.12
--- src/usr.sbin/sysinst/util.c:1.11	Sun Jun 24 19:53:35 2018
+++ src/usr.sbin/sysinst/util.c	Sat Oct  6 18:45:37 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: util.c,v 1.11 2018/06/24 19:53:35 christos Exp $	*/
+/*	$NetBSD: util.c,v 1.12 2018/10/06 18:45:37 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -95,75 +95,75 @@ struct  tarstats {
 
 distinfo dist_list[] = {
 #ifdef SET_KERNEL_1_NAME
-	{SET_KERNEL_1_NAME,	SET_KERNEL_1,		MSG_set_kernel_1, NULL},
+	{SET_KERNEL_1_NAME,	SET_KERNEL_1,		false, MSG_set_kernel_1, NULL},
 #endif
 #ifdef SET_KERNEL_2_NAME
-	{SET_KERNEL_2_NAME,	SET_KERNEL_2,		MSG_set_kernel_2, NULL},
+	{SET_KERNEL_2_NAME,	SET_KERNEL_2,		false, MSG_set_kernel_2, NULL},
 #endif
 #ifdef SET_KERNEL_3_NAME
-	{SET_KERNEL_3_NAME,	SET_KERNEL_3,		MSG_set_kernel_3, NULL},
+	{SET_KERNEL_3_NAME,	SET_KERNEL_3,		false, MSG_set_kernel_3, NULL},
 #endif
 #ifdef SET_KERNEL_4_NAME
-	{SET_KERNEL_4_NAME,	SET_KERNEL_4,		MSG_set_kernel_4, NULL},
+	{SET_KERNEL_4_NAME,	SET_KERNEL_4,		false, MSG_set_kernel_4, NULL},
 #endif
 #ifdef SET_KERNEL_5_NAME
-	{SET_KERNEL_5_NAME,	SET_KERNEL_5,		MSG_set_kernel_5, NULL},
+	{SET_KERNEL_5_NAME,	SET_KERNEL_5,		false, MSG_set_kernel_5, NULL},
 #endif
 #ifdef SET_KERNEL_6_NAME
-	{SET_KERNEL_6_NAME,	SET_KERNEL_6,		MSG_set_kernel_6, NULL},
+	{SET_KERNEL_6_NAME,	SET_KERNEL_6,		false, MSG_set_kernel_6, NULL},
 #endif
 #ifdef SET_KERNEL_7_NAME
-	{SET_KERNEL_7_NAME,	SET_KERNEL_7,		MSG_set_kernel_7, NULL},
+	{SET_KERNEL_7_NAME,	SET_KERNEL_7,		false, MSG_set_kernel_7, NULL},
 #endif
 #ifdef SET_KERNEL_8_NAME
-	{SET_KERNEL_8_NAME,	SET_KERNEL_8,		MSG_set_kernel_8, NULL},
+	{SET_KERNEL_8_NAME,	SET_KERNEL_8,		false, MSG_set_kernel_8, NULL},
 #endif
 #ifdef SET_KERNEL_9_NAME
-	{SET_KERNEL_9_NAME,	SET_KERNEL_9,		MSG_set_kernel_9, NULL},
+	{SET_KERNEL_9_NAME,	SET_KERNEL_9,		false, MSG_set_kernel_9, NULL},
 #endif
 
-	{"modules",		SET_MODULES,		MSG_set_modules, NULL},
-	{"base",		SET_BASE,		MSG_set_base, NULL},
-	{"etc",			SET_ETC,		MSG_set_system, NULL},
-	{"comp",		SET_COMPILER,		MSG_set_compiler, NULL},
-	{"games",		SET_GAMES,		MSG_set_games, NULL},
-	{"man",			SET_MAN_PAGES,		MSG_set_man_pages, NULL},
-	{"misc",		SET_MISC,		MSG_set_misc, NULL},
-	{"tests",		SET_TESTS,		MSG_set_tests, NULL},
-	{"text",		SET_TEXT_TOOLS,		MSG_set_text_tools, NULL},
-
-	{NULL,			SET_GROUP,		MSG_set_X11, NULL},
-	{"xbase",		SET_X11_BASE,		MSG_set_X11_base, NULL},
-	{"xcomp",		SET_X11_PROG,		MSG_set_X11_prog, NULL},
-	{"xetc",		SET_X11_ETC,		MSG_set_X11_etc, NULL},
-	{"xfont",		SET_X11_FONTS,		MSG_set_X11_fonts, NULL},
-	{"xserver",		SET_X11_SERVERS,	MSG_set_X11_servers, NULL},
-	{NULL,			SET_GROUP_END,		NULL, NULL},
+	{"modules",		SET_MODULES,		false, MSG_set_modules, NULL},
+	{"base",		SET_BASE,		false, MSG_set_base, NULL},
+	{"etc",			SET_ETC,		false, MSG_set_system, NULL},
+	{"comp",		SET_COMPILER,		false, MSG_set_compiler, NULL},
+	{"games",		SET_GAMES,		false, MSG_set_games, NULL},
+	{"man",			SET_MAN_PAGES,		false, MSG_set_man_pages, NULL},
+	{"misc",		SET_MISC,		false, MSG_set_misc, NULL},
+	{"tests",		SET_TESTS,		false, MSG_set_tests, NULL},
+	{"text",		SET_TEXT_TOOLS,		false, MSG_set_text_tools, NULL},
+
+	{NULL,			SET_GROUP,		false, MSG_set_X11, NULL},
+	{"xbase",		SET_X11_BASE,		false, MSG_set_X11_base, NULL},
+	{"xcomp",		SET_X11_PROG,		false, MSG_set_X11_prog, NULL},
+	{"xetc",		SET_X11_ETC,		false, MSG_set_X11_etc, NULL},
+	{"xfont",		SET_X11_FONTS,		false, MSG_set_X11_fonts, NULL},
+	{"xserver",		SET_X11_SERVERS,	false, MSG_set_X11_servers, NULL},
+	{NULL,			SET_GROUP_END,		false, NULL, NULL},
 
 #ifdef SET_MD_1_NAME
-	{SET_MD_1_NAME,		SET_MD_1,		MSG_set_md_1, NULL},
+	{SET_MD_1_NAME,		SET_MD_1,		false, MSG_set_md_1, NULL},
 #endif
 #ifdef SET_MD_2_NAME
-	{SET_MD_2_NAME,		SET_MD_2,		MSG_set_md_2, NULL},
+	{SET_MD_2_NAME,		SET_MD_2,		false, MSG_set_md_2, NULL},
 #endif
 #ifdef SET_MD_3_NAME
-	{SET_MD_3_NAME,		SET_MD_3,		MSG_set_md_3, NULL},
+	{SET_MD_3_NAME,		SET_MD_3,		false, MSG_set_md_3, NULL},
 #endif
 #ifdef SET_MD_4_NAME
-	{SET_MD_4_NAME,		SET_MD_4,		MSG_set_md_4, NULL},
+	{SET_MD_4_NAME,		SET_MD_4,		false, MSG_set_md_4, NULL},
 #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},
-	{"debug",		SET_DEBUG,		MSG_set_debug, NULL},
-	{"xdebug",		SET_X11_DEBUG,		MSG_set_xdebug, NULL},
-	{NULL,			SET_GROUP_END,		NULL, NULL},
+	{NULL,			SET_GROUP,		true, MSG_set_source, NULL},
+	{"syssrc",		SET_SYSSRC,		true, MSG_set_syssrc, NULL},
+	{"src",			SET_SRC,		true, MSG_set_src, NULL},
+	{"sharesrc",		SET_SHARESRC,		true, MSG_set_sharesrc, NULL},
+	{"gnusrc",		SET_GNUSRC,		true, MSG_set_gnusrc, NULL},
+	{"xsrc",		SET_XSRC,		true, MSG_set_xsrc, NULL},
+	{"debug",		SET_DEBUG,		false, MSG_set_debug, NULL},
+	{"xdebug",		SET_X11_DEBUG,		false, MSG_set_xdebug, NULL},
+	{NULL,			SET_GROUP_END,		false, NULL, NULL},
 
-	{NULL,			SET_LAST,		NULL, NULL},
+	{NULL,			SET_LAST,		false, NULL, NULL},
 };
 
 #define MAX_CD_INFOS	16	/* how many media can be found? */
@@ -342,7 +342,8 @@ floppy_fetch(const char *set_name)
 		if (run_program(RUN_DISPLAY,
 			    "sh -c '/bin/cat /mnt2/%s.%s %s %s/%s/%s%s'",
 			    set_name, post, write_mode,
-			    target_prefix(), xfer_dir, set_name, dist_postfix))
+			    target_prefix(), xfer_dir, set_name,
+			    set_postfix(set_name)))
 			/* XXX: a read error will give a corrupt file! */
 			continue;
 
@@ -887,7 +888,7 @@ extract_file(distinfo *dist, int update)
 		make_target_dir(xfer_dir);
 
 	(void)snprintf(path, sizeof path, "%s/%s%s",
-	    ext_dir_for_set(dist->name), dist->name, dist_postfix);
+	    ext_dir_for_set(dist->name), dist->name, set_postfix(dist->name));
 
 	owd = getcwd(NULL, 0);
 
@@ -907,7 +908,7 @@ extract_file(distinfo *dist, int update)
 	 * characters and check again
 	 */
 	(void)snprintf(path, sizeof path, "%s/%.8s%.4s", /* 4 as includes '.' */
-	    ext_dir_for_set(dist->name), dist->name, dist_postfix);
+	    ext_dir_for_set(dist->name), dist->name, set_postfix(dist->name));
 		if (!file_exists_p(path)) {
 #endif /* SUPPORT_8_3_SOURCE_FILESYSTEM */
 
@@ -1743,3 +1744,25 @@ ask_noyes(const char *msgtxt)
 	process_menu(MENU_noyes, &p);
 	return p.rv;
 }
+
+bool
+use_tgz_for_set(const char *set_name)
+{
+	const struct distinfo *dist;
+	
+	for (dist = dist_list; dist->set != SET_LAST; dist++) {
+		if (dist->name == NULL)
+			continue;
+		if (strcmp(set_name, dist->name) == 0)
+			return dist->force_tgz;
+	}
+
+	return false;
+}
+
+/* Return the postfix used for a given set */
+const char *set_postfix(const char *set_name)
+{
+	return use_tgz_for_set(set_name) ? dist_tgz_postfix : dist_postfix;
+}
+

Reply via email to