diff --git a/manpages/bee-update.1.in b/manpages/bee-update.1.in index c76da8a..0e18c8a 100644 --- a/manpages/bee-update.1.in +++ b/manpages/bee-update.1.in @@ -1 +1 @@ -.so bee-install.1 +.so man1/bee-install.1 diff --git a/src/bee-cache-inventory.c b/src/bee-cache-inventory.c index c97a325..588f3c5 100644 --- a/src/bee-cache-inventory.c +++ b/src/bee-cache-inventory.c @@ -59,6 +59,7 @@ struct item { char *type; char *filename; char *destination; + char free_destination; }; struct inventory_meta { @@ -146,6 +147,28 @@ int substitute(char *data, char from, char to) return 1; } +char *read_symlink(const char *filename) +{ + ssize_t ret; + char buffer[PATH_MAX + 1] = {0}; + char *copy; + + ret = readlink(filename, buffer, PATH_MAX); + + if (ret == -1) { + fprintf(stderr, "bee-cache-inventory: warning: " + "cannot restore empty symlink destination for file '%s': %m\n", filename); + return NULL; + } + + copy = strdup(buffer); + + if (!copy) + fprintf(stderr, "bee-cache-inventory: read_symlink: strdup: %m\n"); + + return copy; +} + BEE_STATIC_INLINE char *_extract_pattern(struct item *item, char **dest, char *hint, char *pattern, char size, int failok) { char *p; @@ -182,12 +205,17 @@ int do_separation(char *line, struct item *item) /* get possible symlink destination */ q = strstr(item->filename, "//"); if (q) { + *q = '\0'; item->destination = q + 2; + if (!*item->destination) { - fprintf (stderr, "bee-cache-inventory: syntax error: empty destination for file '%s'\n", item->filename); - return 0; + item->destination = read_symlink(item->filename); + + if (!item->destination) + item->destination = item->filename; + else + item->free_destination = 1; } - *q = '\0'; } *(p-6) = 0; @@ -344,6 +372,9 @@ int inventory_fhfh(FILE *infh, FILE *outfh, struct inventory_meta meta) print_item(outfh, item, meta); + if (item.free_destination) + /* symlink destination was generated by read_symlink */ + free(item.destination); } return 1; diff --git a/src/beelib.config.sh.in b/src/beelib.config.sh.in index 9d63f6f..1cd1586 100644 --- a/src/beelib.config.sh.in +++ b/src/beelib.config.sh.in @@ -366,6 +366,7 @@ function config_export() { export BEE_TMP_TMPDIR export BEE_TMP_BUILDROOT + export BEE_BINDIR export BEE_SYSCONFDIR export BEE_DATADIR export BEE_LIBEXECDIR