summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Makefile2
-rw-r--r--src/apk_database.h2
-rw-r--r--src/app_cache.c20
-rw-r--r--src/database.c9
-rw-r--r--src/solver.c10
5 files changed, 22 insertions, 21 deletions
diff --git a/src/Makefile b/src/Makefile
index 186823f..7d3255d 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -97,7 +97,7 @@ else
cmd_genhelp = echo \\\#define NO_HELP > $@
endif
-$(obj)/help.h: $(src)/genhelp.lua $(wildcard doc/apk*.8.scd) FORCE
+$(obj)/help.h: $(src)/genhelp.lua $(wildcard doc/apk*.8.scd)
$(call if_changed,genhelp)
CFLAGS_help.o := -I$(obj)
diff --git a/src/apk_database.h b/src/apk_database.h
index 3488031..81d04b0 100644
--- a/src/apk_database.h
+++ b/src/apk_database.h
@@ -254,7 +254,7 @@ int apk_cache_download(struct apk_database *db, struct apk_repository *repo,
struct apk_package *pkg, int verify, int autoupdate,
apk_progress_cb cb, void *cb_ctx);
-typedef void (*apk_cache_item_cb)(struct apk_database *db,
+typedef int (*apk_cache_item_cb)(struct apk_database *db,
int dirfd, const char *name,
struct apk_package *pkg);
int apk_db_cache_foreach_item(struct apk_database *db, apk_cache_item_cb cb);
diff --git a/src/app_cache.c b/src/app_cache.c
index f4dd951..75d27c2 100644
--- a/src/app_cache.c
+++ b/src/app_cache.c
@@ -13,6 +13,7 @@
#include <dirent.h>
#include <unistd.h>
#include <limits.h>
+#include <string.h>
#include "apk_defines.h"
#include "apk_applet.h"
@@ -108,35 +109,42 @@ static int cache_download(struct cache_ctx *cctx, struct apk_database *db)
return ret;
}
-static void cache_clean_item(struct apk_database *db, int dirfd, const char *name, struct apk_package *pkg)
+static int cache_clean_item(struct apk_database *db, int dirfd, const char *name, struct apk_package *pkg)
{
char tmp[PATH_MAX];
apk_blob_t b;
int i;
- if (strcmp(name, "installed") == 0) return;
+ if (strcmp(name, "installed") == 0) return 0;
if (pkg) {
if ((apk_flags & APK_PURGE) && pkg->ipkg == NULL) goto delete;
if (pkg->repos & db->local_repos & ~BIT(APK_REPOSITORY_CACHED)) goto delete;
if (pkg->ipkg == NULL && !(pkg->repos & ~BIT(APK_REPOSITORY_CACHED))) goto delete;
- return;
+ return 0;
}
b = APK_BLOB_STR(name);
for (i = 0; i < db->num_repos; i++) {
/* Check if this is a valid index */
apk_repo_format_cache_index(APK_BLOB_BUF(tmp), &db->repos[i]);
- if (apk_blob_compare(b, APK_BLOB_STR(tmp)) == 0) return;
+ if (apk_blob_compare(b, APK_BLOB_STR(tmp)) == 0) return 0;
}
delete:
if (apk_verbosity >= 2)
apk_message("deleting %s", name);
if (!(apk_flags & APK_SIMULATE)) {
- if (unlinkat(dirfd, name, 0) < 0 && errno == EISDIR)
- unlinkat(dirfd, name, AT_REMOVEDIR);
+ if (unlinkat(dirfd, name, 0) < 0) {
+ if (errno != EISDIR ||
+ (errno == EISDIR && unlinkat(dirfd, name, AT_REMOVEDIR) < 0)) {
+ apk_error("Unable to delete %s: %s", name, strerror(errno));
+ return -errno;
+ }
+ }
}
+
+ return 0;
}
static int cache_clean(struct apk_database *db)
diff --git a/src/database.c b/src/database.c
index bbf072e..80f9d1b 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1393,12 +1393,13 @@ static char *find_mountpoint(int atfd, const char *rel_path)
return ret;
}
-static void mark_in_cache(struct apk_database *db, int dirfd, const char *name, struct apk_package *pkg)
+static int mark_in_cache(struct apk_database *db, int dirfd, const char *name, struct apk_package *pkg)
{
if (pkg == NULL)
- return;
+ return 0;
pkg->repos |= BIT(APK_REPOSITORY_CACHED);
+ return 0;
}
static int add_repos_from_file(void *ctx, int dirfd, const char *file)
@@ -2048,9 +2049,7 @@ static int foreach_cache_file(void *pctx, int dirfd, const char *name)
}
}
no_pkg:
- ctx->cb(db, dirfd, name, pkg);
-
- return 0;
+ return ctx->cb(db, dirfd, name, pkg);
}
int apk_db_cache_foreach_item(struct apk_database *db, apk_cache_item_cb cb)
diff --git a/src/solver.c b/src/solver.c
index df63060..7033e75 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -8,6 +8,7 @@
*/
#include <stdint.h>
+#include <stdio.h>
#include <unistd.h>
#include <strings.h>
#include "apk_defines.h"
@@ -17,14 +18,7 @@
#include "apk_print.h"
-//#define DEBUG_PRINT
-
-#ifdef DEBUG_PRINT
-#include <stdio.h>
-#define dbg_printf(args...) fprintf(stderr, args)
-#else
-#define dbg_printf(args...)
-#endif
+#define dbg_printf(args...) if (apk_verbosity > 5) { fprintf(stderr, args); }
#define ASSERT(cond, fmt...) if (!(cond)) { apk_error(fmt); *(char*)NULL = 0; }