Changes to allow simple symlink handling
This commit is contained in:
parent
f58e2612b9
commit
683ac3d341
@ -1,7 +1,7 @@
|
||||
PROG = cvs
|
||||
CFLAGS += -I${.CURDIR}/../lib \
|
||||
-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
|
||||
|
||||
|
@ -252,6 +252,7 @@ import_descend (message, vtag, targc, targv)
|
||||
struct direct *dp;
|
||||
int err = 0;
|
||||
int has_dirs = 0;
|
||||
FILE *links = (FILE *)0;
|
||||
|
||||
/* first, load up any per-directory ignore lists */
|
||||
ign_add_file (CVSDOTIGNORE, 1);
|
||||
@ -279,8 +280,38 @@ import_descend (message, vtag, targc, targv)
|
||||
{
|
||||
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);
|
||||
err++;
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -307,6 +338,8 @@ import_descend (message, vtag, targc, targv)
|
||||
(void) closedir (dirp);
|
||||
}
|
||||
}
|
||||
if (links)
|
||||
fclose(links);
|
||||
return (err);
|
||||
}
|
||||
|
||||
|
@ -424,6 +424,37 @@ update_filesdone_proc (err, repository, update_dir)
|
||||
(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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user