Commit 5fa2e463 authored by Bryan Drewery's avatar Bryan Drewery
Browse files

pkg-repo: Follow symlinks and ignore directories starting with '.' or named 'Latest'.

This fixes running 'pkg repo' in a Poudriere-made directory that
would result in several different versions of packages being added
to the packagesite. Each of them would refer to some .real_* directory.
Poudriere uses these directories to manage multiple previous builds
and to have a "build in progress" directory that does not conflict
with currently served packages.

See also https://github.com/freebsd/poudriere/issues/293
See also Issue #1200
parent 65c51b3b
......@@ -15,7 +15,7 @@
.\" @(#)pkg.8
.\" $FreeBSD$
.\"
.Dd November 18, 2014
.Dd April 9, 2015
.Dt PKG-REPO 8
.Os
.Sh NAME
......@@ -57,7 +57,12 @@ top-level directory where all the packages are stored as
will search the filesystem beneath
.Ar repo-path
to find all the packages it contains.
Symbolic links are ignored.
Directories starting with
.Qq . Qc
or
named
.Pa Latest
are not traversed.
.Pp
The repository will be created in the package directory unless the
.Fl o Ar output-dir
......
......@@ -209,6 +209,34 @@ pkg_create_repo_read_fts(struct pkg_fts_item **items, FTS *fts,
errno = 0;
while ((fts_ent = fts_read(fts)) != NULL) {
/*
* Skip directories starting with '.' to avoid Poudriere
* symlinks.
*/
if ((fts_ent->fts_info == FTS_D ||
fts_ent->fts_info == FTS_DP) &&
fts_ent->fts_namelen > 2 &&
fts_ent->fts_name[0] == '.') {
fts_set(fts, fts_ent, FTS_SKIP);
continue;
}
/*
* Ignore 'Latest' directory as it is just symlinks back to
* already-processed packages.
*/
if ((fts_ent->fts_info == FTS_D ||
fts_ent->fts_info == FTS_DP ||
fts_ent->fts_info == FTS_SL) &&
strcmp(fts_ent->fts_name, "Latest") == 0) {
fts_set(fts, fts_ent, FTS_SKIP);
continue;
}
/* Follow symlinks. */
if (fts_ent->fts_info == FTS_SL) {
fts_set(fts, fts_ent, FTS_FOLLOW);
/* Restart. Next entry will be the resolved file. */
continue;
}
/* Skip everything that is not a file */
if (fts_ent->fts_info != FTS_F)
continue;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment