aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--src/package.c18
-rw-r--r--src/package.h3
3 files changed, 16 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 0063d07..cf9746f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,6 @@
0.11.0 Jun 21, 2018
+ * support package data in /var/lib/pkgtools
* move default cache directory to /var/cache/slapt-get
0.10.2t Jul 04, 2016
diff --git a/src/package.c b/src/package.c
index f17d781..339a478 100644
--- a/src/package.c
+++ b/src/package.c
@@ -3623,10 +3623,11 @@ char *slapt_gen_package_log_dir_name(void)
{
char *root_env_entry = NULL;
char *pkg_log_dirname = NULL;
+ char *path = NULL;
+ struct stat stat_buf;
/* Generate package log directory using ROOT env variable if set */
- if (getenv(SLAPT_ROOT_ENV_NAME) &&
- strlen(getenv(SLAPT_ROOT_ENV_NAME)) < SLAPT_ROOT_ENV_LEN) {
+ if (getenv(SLAPT_ROOT_ENV_NAME) && strlen(getenv(SLAPT_ROOT_ENV_NAME)) < SLAPT_ROOT_ENV_LEN) {
root_env_entry = getenv(SLAPT_ROOT_ENV_NAME);
}
pkg_log_dirname = slapt_calloc(
@@ -3634,12 +3635,19 @@ char *slapt_gen_package_log_dir_name(void)
(root_env_entry ? strlen(root_env_entry) : 0) + 1 ,
sizeof *pkg_log_dirname
);
+
+ if (stat(SLAPT_PKG_LOG_DIR, &stat_buf) == 0) {
+ path = SLAPT_PKG_LOG_DIR;
+ } else if (stat(SLAPT_OLD_PKG_LOG_DIR, &stat_buf) == 0) {
+ path = SLAPT_OLD_PKG_LOG_DIR;
+ }
+
*pkg_log_dirname = '\0';
if (root_env_entry) {
- strncpy(pkg_log_dirname, root_env_entry,strlen(root_env_entry));
- strncat(pkg_log_dirname, SLAPT_PKG_LOG_DIR,strlen(SLAPT_PKG_LOG_DIR));
+ strncpy(pkg_log_dirname, root_env_entry, strlen(root_env_entry));
+ strncat(pkg_log_dirname, path, strlen(path));
} else {
- strncat(pkg_log_dirname, SLAPT_PKG_LOG_DIR,strlen(SLAPT_PKG_LOG_DIR));
+ strncat(pkg_log_dirname, path, strlen(path));
}
return pkg_log_dirname;
diff --git a/src/package.h b/src/package.h
index bbac5de..4555553 100644
--- a/src/package.h
+++ b/src/package.h
@@ -27,7 +27,8 @@
#define SLAPT_PKG_SIZEU_PATTERN "^PACKAGE SIZE [(]+uncompressed[)]{1,}:[ ]{1,}([0-9]{1,}) K$"
#define SLAPT_PKG_LOG_SIZEC_PATTERN "^COMPRESSED PACKAGE SIZE:[ ]{1,}([0-9\\.]{1,})[ ]{0,}([MK])$"
#define SLAPT_PKG_LOG_SIZEU_PATTERN "^UNCOMPRESSED PACKAGE SIZE:[ ]{1,}([0-9\\.]{1,})[ ]{0,}([MK])$"
-#define SLAPT_PKG_LOG_DIR "/var/log/packages"
+#define SLAPT_OLD_PKG_LOG_DIR "/var/log/packages"
+#define SLAPT_PKG_LOG_DIR "/var/lib/pkgtools"
#define SLAPT_ROOT_ENV_NAME "ROOT"
#define SLAPT_ROOT_ENV_LEN 255
#define SLAPT_PKG_LOG_PATTERN "^(.*{1,})\\-(.*[\\-].*[\\-].*)"