Changes to allow simple symlink handling

This commit is contained in:
Jordan K. Hubbard 1993-06-24 23:55:44 +00:00
parent c8378b88c6
commit 73a9cb0a32
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=44
3 changed files with 65 additions and 1 deletions

View File

@ -1,7 +1,7 @@
PROG = cvs PROG = cvs
CFLAGS += -I${.CURDIR}/../lib \ CFLAGS += -I${.CURDIR}/../lib \
-DDIRENT -DSTDC_HEADERS -DPOSIX -DBROKEN_SIGISMEMBER \ -DDIRENT -DSTDC_HEADERS -DPOSIX -DBROKEN_SIGISMEMBER \
-DFTIME_MISSING -DHAVE_TIMEZONE -DUTIME_NULL_MISSING -DFTIME_MISSING -DHAVE_TIMEZONE -DUTIME_NULL_MISSING -DDO_LINKS
LDADD= -L${.CURDIR}/../lib/obj -lcvs LDADD= -L${.CURDIR}/../lib/obj -lcvs

View File

@ -252,6 +252,7 @@ import_descend (message, vtag, targc, targv)
struct direct *dp; struct direct *dp;
int err = 0; int err = 0;
int has_dirs = 0; int has_dirs = 0;
FILE *links = (FILE *)0;
/* first, load up any per-directory ignore lists */ /* first, load up any per-directory ignore lists */
ign_add_file (CVSDOTIGNORE, 1); ign_add_file (CVSDOTIGNORE, 1);
@ -279,8 +280,38 @@ import_descend (message, vtag, targc, targv)
{ {
if (islink (dp->d_name)) if (islink (dp->d_name))
{ {
#ifdef DO_LINKS
char lnbuf[PATH_MAX];
int lln;
add_log ('L', dp->d_name);
if ((lln = readlink(dp->d_name, lnbuf, PATH_MAX)) == -1) {
error(0, errno, "Can't read contents of symlink %s",
dp->d_name);
return (1);
}
else {
if (!links) {
char lnrep[PATH_MAX];
sprintf(lnrep, "%s/SymLinks", repository);
links = fopen(lnrep, "a+");
if (!links) {
error (0, errno,
"Can't open SymLinks file %s", lnrep);
return (1);
}
}
lnbuf[lln] = '\0';
fputs(dp->d_name, links);
fputc('\n', links);
fputs(lnbuf, links);
fputc('\n', links);
}
#else
add_log ('L', dp->d_name); add_log ('L', dp->d_name);
err++; err++;
#endif
} }
else else
{ {
@ -307,6 +338,8 @@ import_descend (message, vtag, targc, targv)
(void) closedir (dirp); (void) closedir (dirp);
} }
} }
if (links)
fclose(links);
return (err); return (err);
} }

View File

@ -424,6 +424,37 @@ update_filesdone_proc (err, repository, update_dir)
(void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL); (void) run_exec (RUN_TTY, RUN_TTY, RUN_TTY, RUN_NORMAL);
} }
#ifdef DO_LINKS
{
char lnfile[PATH_MAX];
FILE *links;
sprintf(lnfile, "%s/SymLinks", repository);
links = fopen(lnfile, "r");
if (links) {
char from[PATH_MAX], to[PATH_MAX];
/* Read all the link pairs from the symlinks file */
while (fgets(from, PATH_MAX, links)) {
fgets(to, PATH_MAX, links);
/* Strip off the newlines */
to[strlen(to) - 1] = '\0';
from[strlen(from) - 1] = '\0';
/* Do it */
if (symlink(to, from) == -1) {
error (0, errno, "Unable to create symlink `%s'", to);
return 1;
}
else if (!quiet)
error (0, 0, "Creating symlink %s", to);
}
fclose(links);
}
}
#endif
return (err); return (err);
} }