summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/cvs/Makefile8
-rw-r--r--usr.bin/cvs/checkout.c17
-rw-r--r--usr.bin/cvs/config.h20
-rw-r--r--usr.bin/cvs/cvs.c6
-rw-r--r--usr.bin/cvs/modules.c111
5 files changed, 147 insertions, 15 deletions
diff --git a/usr.bin/cvs/Makefile b/usr.bin/cvs/Makefile
index 48c8989ac20..37a08b7b403 100644
--- a/usr.bin/cvs/Makefile
+++ b/usr.bin/cvs/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.41 2007/09/17 10:07:21 tobias Exp $
+# $OpenBSD: Makefile,v 1.42 2008/02/02 19:32:28 joris Exp $
PROG= opencvs
MAN= cvs.1 cvs.5 cvsintro.7
@@ -7,9 +7,9 @@ CPPFLAGS+=-I${.CURDIR}
SRCS= cvs.c add.c admin.c annotate.c atomicio.c commit.c config.c \
checkout.c client.c buf.c cmd.c date.y diff.c diff3.c \
diff_internals.c edit.c entries.c fatal.c file.c getlog.c history.c \
- log.c logmsg.c import.c init.c release.c remove.c repository.c \
- rcs.c rcsnum.c remote.c root.c server.c status.c tag.c worklist.c \
- util.c update.c version.c watch.c xmalloc.c
+ log.c logmsg.c modules.c import.c init.c release.c remove.c \
+ repository.c rcs.c rcsnum.c remote.c root.c server.c status.c tag.c \
+ worklist.c util.c update.c version.c watch.c xmalloc.c
CFLAGS+=-Wall
CFLAGS+=-Wstrict-prototypes -Wmissing-prototypes
diff --git a/usr.bin/cvs/checkout.c b/usr.bin/cvs/checkout.c
index 238649e017b..7e259821b93 100644
--- a/usr.bin/cvs/checkout.c
+++ b/usr.bin/cvs/checkout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: checkout.c,v 1.115 2008/01/31 19:51:40 xsa Exp $ */
+/* $OpenBSD: checkout.c,v 1.116 2008/02/02 19:32:28 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -146,6 +146,7 @@ static void
checkout_check_repository(int argc, char **argv)
{
int i;
+ char *module;
char repo[MAXPATHLEN];
struct cvs_recursion cr;
@@ -196,22 +197,24 @@ checkout_check_repository(int argc, char **argv)
cvs_directory_tag = cvs_specified_tag;
for (i = 0; i < argc; i++) {
+ module = cvs_module_lookup(argv[i]);
+
(void)xsnprintf(repo, sizeof(repo), "%s/%s",
- current_cvsroot->cr_dir, argv[i]);
+ current_cvsroot->cr_dir, module);
- switch (checkout_classify(repo, argv[i])) {
+ switch (checkout_classify(repo, module)) {
case CVS_FILE:
cr.fileproc = cvs_update_local;
cr.flags = flags;
if (build_dirs == 1)
- cvs_mkpath(dirname(argv[i]), cvs_specified_tag);
- cvs_file_run(1, &(argv[i]), &cr);
+ cvs_mkpath(dirname(module), cvs_specified_tag);
+ cvs_file_run(1, &(module), &cr);
break;
case CVS_DIR:
if (build_dirs == 1)
- cvs_mkpath(argv[i], cvs_specified_tag);
- checkout_repository(repo, argv[i]);
+ cvs_mkpath(module, cvs_specified_tag);
+ checkout_repository(repo, module);
break;
default:
break;
diff --git a/usr.bin/cvs/config.h b/usr.bin/cvs/config.h
index 04b5cede216..17e22a56902 100644
--- a/usr.bin/cvs/config.h
+++ b/usr.bin/cvs/config.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.h,v 1.2 2008/02/01 18:10:26 joris Exp $ */
+/* $OpenBSD: config.h,v 1.3 2008/02/02 19:32:28 joris Exp $ */
/*
* Copyright (c) 2006 Joris Vink <joris@openbsd.org>
*
@@ -18,9 +18,25 @@
#ifndef CONFIG_H
#define CONFIG_H
-void cvs_parse_configfile(void);
void cvs_read_config(char *name, void (*cb)(char *));
+void cvs_parse_configfile(void);
+void cvs_parse_modules(void);
+
void config_parse_line(char *);
+void modules_parse_line(char *);
+
+#include <sys/queue.h>
+
+/* module stuff */
+
+char *cvs_module_lookup(char *);
+
+struct module_info {
+ char *mi_name;
+ char *mi_repository;
+
+ TAILQ_ENTRY(module_info) m_list;
+};
#endif
diff --git a/usr.bin/cvs/cvs.c b/usr.bin/cvs/cvs.c
index 73dbc1fc916..b8e516acdf4 100644
--- a/usr.bin/cvs/cvs.c
+++ b/usr.bin/cvs/cvs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cvs.c,v 1.141 2008/01/28 21:32:00 tobias Exp $ */
+/* $OpenBSD: cvs.c,v 1.142 2008/02/02 19:32:28 joris Exp $ */
/*
* Copyright (c) 2006, 2007 Joris Vink <joris@openbsd.org>
* Copyright (c) 2004 Jean-Francois Brousseau <jfb@openbsd.org>
@@ -270,8 +270,10 @@ main(int argc, char **argv)
current_cvsroot->cr_dir);
}
- if (cvs_cmdop != CVS_OP_INIT)
+ if (cvs_cmdop != CVS_OP_INIT) {
cvs_parse_configfile();
+ cvs_parse_modules();
+ }
umask(cvs_umask);
diff --git a/usr.bin/cvs/modules.c b/usr.bin/cvs/modules.c
new file mode 100644
index 00000000000..8e7c13f4181
--- /dev/null
+++ b/usr.bin/cvs/modules.c
@@ -0,0 +1,111 @@
+/* $OpenBSD: modules.c,v 1.1 2008/02/02 19:32:28 joris Exp $ */
+/*
+ * Copyright (c) 2008 Joris Vink <joris@openbsd.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <sys/dirent.h>
+#include <sys/resource.h>
+
+#include <errno.h>
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "cvs.h"
+#include "config.h"
+
+TAILQ_HEAD(, module_info) modules;
+
+void
+cvs_parse_modules(void)
+{
+ cvs_log(LP_TRACE, "cvs_parse_modules()");
+
+ TAILQ_INIT(&modules);
+ cvs_read_config(CVS_PATH_MODULES, modules_parse_line);
+}
+
+void
+modules_parse_line(char *line)
+{
+ int flags;
+ char *val, *p, *module;
+ struct module_info *mi;
+
+ flags = 0;
+ p = val = line;
+ while (*p != ' ' && *p != '\t')
+ p++;
+
+ *(p++) = '\0';
+ module = val;
+
+ while (*p == ' ' || *p == '\t')
+ p++;
+
+ if (*p == '\0') {
+ cvs_log(LP_NOTICE, "premature ending of CVSROOT/modules line");
+ return;
+ }
+
+ val = p;
+ while (*p != ' ' && *p != '\t')
+ p++;
+
+ if (*p == '\0') {
+ cvs_log(LP_NOTICE, "premature ending of CVSROOT/modules line");
+ return;
+ }
+
+ while (val[0] == '-') {
+ p = val;
+ while (*p != ' ' && *p != '\t' && *p != '\0')
+ p++;
+
+ if (*p == '\0') {
+ cvs_log(LP_NOTICE,
+ "misplaced option in CVSROOT/modules");
+ return;
+ }
+
+ *(p++) = '\0';
+
+ switch (val[1]) {
+ case 'a':
+ break;
+ }
+
+ val = p;
+ }
+
+ mi = xmalloc(sizeof(*mi));
+ mi->mi_name = xstrdup(module);
+ mi->mi_repository = xstrdup(val);
+ TAILQ_INSERT_TAIL(&modules, mi, m_list);
+}
+
+char *
+cvs_module_lookup(char *name)
+{
+ struct module_info *mi;
+
+ TAILQ_FOREACH(mi, &modules, m_list) {
+ if (!strcmp(name, mi->mi_name))
+ return (mi->mi_repository);
+ }
+
+ return (name);
+}