Make system/config repo.d paths always relative to rootdir.
This commit is contained in:
parent
0953980d25
commit
387987b146
@ -15,13 +15,13 @@ syslog=true
|
||||
|
||||
## REPOSITORIES
|
||||
#
|
||||
# The default system repository directory "<prefix>/share/xbps/repo.d"
|
||||
# The default system repository directory "<rootdir>/usr/share/xbps/repo.d"
|
||||
# contains the system repository configuration files.
|
||||
#
|
||||
# Files on that system directory can be overrided in "<sysconfdir>/xbps/repo.d"
|
||||
# Files on that system directory can be overrided in "<rootdir>/etc/xbps/repo.d"
|
||||
# bearing the same file name, i.e:
|
||||
#
|
||||
# - <sysconfdir>/xbps/repo.d/main.conf overrides <prefix>/share/xbps/repo.d/main.conf
|
||||
# - /etc/xbps/repo.d/main.conf overrides /usr/share/xbps/repo.d/main.conf
|
||||
#
|
||||
# Local or remote repositories are accepted.
|
||||
#
|
||||
@ -31,7 +31,8 @@ syslog=true
|
||||
# - Repositories are added in the order in which are specified (top->bottom).
|
||||
#
|
||||
# The "repository" keyword can be used to include additional repositories in
|
||||
# addition to the files available in <sysconfdir>/xbps/repo.d/*.conf.
|
||||
# addition to the files available in /etc/xbps/repo.d/*.conf and
|
||||
# /usr/share/xbps/repo.d/*.conf.
|
||||
#
|
||||
#repository=<url>
|
||||
|
||||
|
@ -4,7 +4,7 @@ INCS = xbps.h
|
||||
|
||||
.PHONY: all
|
||||
all:
|
||||
sed -e "s|@@VERSION@@|${VERSION}|g;s|@@PREFIX@@|${PREFIX}|g" ${INCS}.in > ${INCS}
|
||||
sed -e "s|@@VERSION@@|${VERSION}|g" ${INCS}.in > ${INCS}
|
||||
|
||||
.PHONY: install
|
||||
install:
|
||||
|
@ -73,7 +73,7 @@
|
||||
# define XBPS_SYSCONF_PATH "/etc" XBPS_SYSDIR
|
||||
#endif
|
||||
#ifndef XBPS_SYSDEFCONF_PATH
|
||||
# define XBPS_SYSDEFCONF_PATH "@@PREFIX@@/share" XBPS_SYSDIR
|
||||
# define XBPS_SYSDEFCONF_PATH "usr/share" XBPS_SYSDIR
|
||||
#endif
|
||||
|
||||
/**
|
||||
@ -88,12 +88,18 @@
|
||||
*/
|
||||
#define XBPS_CACHE_PATH "var/cache/xbps"
|
||||
|
||||
/**
|
||||
/**
|
||||
* @def XBPS_VPKG_PATH
|
||||
* Default virtualpkg PATH to store virtualpkg overrides.
|
||||
* Configuration virtualpkg directory to store virtualpkg configuration files.
|
||||
*/
|
||||
#define XBPS_VPKG_PATH XBPS_SYSCONF_PATH "/virtualpkg.d"
|
||||
|
||||
/**
|
||||
* @def XBPS_SYS_VPKG_PATH
|
||||
* System virtualpkg PATH to store virtualpkg configuration files.
|
||||
*/
|
||||
#define XBPS_SYS_VPKG_PATH XBPS_SYSDEFCONF_PATH "/virtualpkg.d"
|
||||
|
||||
/**
|
||||
* @def XBPS_REPOD_PATH
|
||||
* Configuration directory to store repository configuration files.
|
||||
|
@ -312,17 +312,18 @@ parse_repodir(struct xbps_handle *xhp)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *dp;
|
||||
char *ext, conf[PATH_MAX];
|
||||
char *ext, repodir[PATH_MAX], conf[PATH_MAX];
|
||||
int rv = 0;
|
||||
|
||||
/*
|
||||
* Read all repository configuration files stored in the system
|
||||
* repo.d directory.
|
||||
*/
|
||||
if ((dirp = opendir(XBPS_SYS_REPOD_PATH)) == NULL)
|
||||
return 0;
|
||||
|
||||
xbps_dbg_printf(xhp, "Processing system repo.d directory: %s\n", XBPS_SYS_REPOD_PATH);
|
||||
snprintf(repodir, sizeof(repodir), "%s/%s",
|
||||
strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", XBPS_SYS_REPOD_PATH);
|
||||
xbps_dbg_printf(xhp, "Processing system repo.d directory: %s\n", repodir);
|
||||
if ((dirp = opendir(repodir)) == NULL)
|
||||
goto stage2;
|
||||
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
if ((strcmp(dp->d_name, "..") == 0) ||
|
||||
@ -333,17 +334,17 @@ parse_repodir(struct xbps_handle *xhp)
|
||||
if ((ext = strrchr(dp->d_name, '.')) == NULL)
|
||||
continue;
|
||||
if (strcmp(ext, ".conf")) {
|
||||
xbps_dbg_printf(xhp, "%s: ignoring %s\n", XBPS_SYS_REPOD_PATH, dp->d_name);
|
||||
xbps_dbg_printf(xhp, "%s: ignoring %s\n", repodir, dp->d_name);
|
||||
continue;
|
||||
}
|
||||
/* if the same file exists in configuration directory, ignore it */
|
||||
snprintf(conf, sizeof(conf), "%s/%s", XBPS_REPOD_PATH, dp->d_name);
|
||||
snprintf(conf, sizeof(conf), "%s/%s/%s", xhp->rootdir, XBPS_REPOD_PATH, dp->d_name);
|
||||
if (access(conf, R_OK) == 0) {
|
||||
xbps_dbg_printf(xhp, "%s: ignoring %s (exists in confdir)\n", XBPS_SYS_REPOD_PATH, dp->d_name);
|
||||
xbps_dbg_printf(xhp, "%s: ignoring %s (exists in confdir)\n", repodir, dp->d_name);
|
||||
continue;
|
||||
}
|
||||
/* parse repo conf file */
|
||||
snprintf(conf, sizeof(conf), "%s/%s", XBPS_SYS_REPOD_PATH, dp->d_name);
|
||||
snprintf(conf, sizeof(conf), "%s/%s", repodir, dp->d_name);
|
||||
if ((rv = parse_file(xhp, conf, false, false)) != 0) {
|
||||
break;
|
||||
}
|
||||
@ -352,15 +353,17 @@ parse_repodir(struct xbps_handle *xhp)
|
||||
if (rv != 0)
|
||||
return rv;
|
||||
|
||||
stage2:
|
||||
/*
|
||||
* Read all repository configuration files stored in the configuration
|
||||
* repo.d directory.
|
||||
*/
|
||||
snprintf(repodir, sizeof(repodir), "%s%s",
|
||||
strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", XBPS_REPOD_PATH);
|
||||
xbps_dbg_printf(xhp, "Processing configuration repo.d directory: %s\n", repodir);
|
||||
if ((dirp = opendir(XBPS_REPOD_PATH)) == NULL)
|
||||
return 0;
|
||||
|
||||
xbps_dbg_printf(xhp, "Processing configuration repo.d directory: %s\n", XBPS_REPOD_PATH);
|
||||
|
||||
while ((dp = readdir(dirp)) != NULL) {
|
||||
if ((strcmp(dp->d_name, "..") == 0) ||
|
||||
(strcmp(dp->d_name, ".") == 0))
|
||||
@ -370,11 +373,11 @@ parse_repodir(struct xbps_handle *xhp)
|
||||
if ((ext = strrchr(dp->d_name, '.')) == NULL)
|
||||
continue;
|
||||
if (strcmp(ext, ".conf")) {
|
||||
xbps_dbg_printf(xhp, "%s: ignoring %s\n", XBPS_REPOD_PATH, dp->d_name);
|
||||
xbps_dbg_printf(xhp, "%s: ignoring %s\n", repodir, dp->d_name);
|
||||
continue;
|
||||
}
|
||||
/* parse repo conf file */
|
||||
snprintf(conf, sizeof(conf), "%s/%s", XBPS_REPOD_PATH, dp->d_name);
|
||||
snprintf(conf, sizeof(conf), "%s/%s", repodir, dp->d_name);
|
||||
if ((rv = parse_file(xhp, conf, false, false)) != 0) {
|
||||
break;
|
||||
}
|
||||
@ -397,10 +400,6 @@ xbps_init(struct xbps_handle *xhp)
|
||||
if (xhp->conffile == NULL)
|
||||
xhp->conffile = XBPS_CONF_DEF;
|
||||
|
||||
/* parse repository configuration files */
|
||||
if ((rv = parse_repodir(xhp)) != 0) {
|
||||
xbps_dbg_printf(xhp, "failed to parse repo.d files: %s\n", strerror(rv));
|
||||
}
|
||||
/* parse configuration file */
|
||||
if ((rv = parse_file(xhp, xhp->conffile, false, false)) != 0) {
|
||||
xbps_dbg_printf(xhp, "failed to read configuration file %s: %s\n",
|
||||
@ -459,10 +458,14 @@ xbps_init(struct xbps_handle *xhp)
|
||||
"%s/%s", strcmp(xhp->rootdir, "/") ? xhp->rootdir : "", buf);
|
||||
free(buf);
|
||||
}
|
||||
/* parse virtualpkgdir */
|
||||
/* parse virtualpkg */
|
||||
if ((rv = parse_vpkgdir(xhp)))
|
||||
return rv;
|
||||
|
||||
/* parse repodirs */
|
||||
if ((rv = parse_repodir(xhp)) != 0)
|
||||
return rv;
|
||||
|
||||
xhp->target_arch = getenv("XBPS_TARGET_ARCH");
|
||||
if ((native_arch = getenv("XBPS_ARCH")) != NULL) {
|
||||
strlcpy(xhp->native_arch, native_arch, sizeof(xhp->native_arch));
|
||||
|
Loading…
Reference in New Issue
Block a user