return pakfire_execute_shell(pakfire);
}
+
+int pakfire_build_clean(struct pakfire* pakfire, int flags) {
+ struct pakfire_repo* local = NULL;
+ int r = 0;
+
+ // Fetch local repository
+ local = pakfire_get_repo(pakfire, "@local");
+ if (!local) {
+ ERROR(pakfire, "Could not find local repository: %m\n");
+ goto ERROR;
+ }
+
+ // Destroy everything in it
+ r = pakfire_repo_clean(local, PAKFIRE_REPO_CLEAN_FLAGS_DESTROY);
+ if (r)
+ goto ERROR;
+
+ERROR:
+ if (local)
+ pakfire_repo_unref(local);
+
+ return r;
+}
#define PAKFIRE_BUILD_H
#include <pakfire/execute.h>
+#include <pakfire/pakfire.h>
enum pakfire_build_flags {
PAKFIRE_BUILD_INTERACTIVE = (1 << 0),
int pakfire_build(struct pakfire* pakfire, const char* path, const char* target,
const char* id, int flags, pakfire_execute_logging_callback logging_callback, void* data);
int pakfire_shell(struct pakfire* pakfire);
+int pakfire_build_clean(struct pakfire* pakfire, int flags);
#endif /* PAKFIRE_BUILD_H */
// Cache
+enum pakfire_repo_clean_flags {
+ PAKFIRE_REPO_CLEAN_FLAGS_NONE = 0,
+ PAKFIRE_REPO_CLEAN_FLAGS_DESTROY = (1 << 0),
+};
+
int pakfire_repo_clean(struct pakfire_repo* repo, int flags);
// Scan
}
PAKFIRE_EXPORT int pakfire_clean(struct pakfire* pakfire, int flags) {
- return pakfire_foreach_repo(pakfire, pakfire_repo_clean, flags);
+ int r;
+
+ // Clean all repositories
+ r = pakfire_foreach_repo(pakfire, pakfire_repo_clean, flags);
+ if (r)
+ return r;
+
+ // Clean build environments
+ // Nothing to do if we are not in build mode
+ if (pakfire_has_flag(pakfire, PAKFIRE_FLAGS_BUILD)) {
+ r = pakfire_build_clean(pakfire, flags);
+ if (r)
+ return r;
+ }
+
+ return 0;
}
PAKFIRE_EXPORT int pakfire_refresh(struct pakfire* pakfire, int flags) {
PAKFIRE_EXPORT int pakfire_repo_clean(struct pakfire_repo* repo, int flags) {
char cache_path[PATH_MAX];
+ int r;
// Drop all meta-data from memory
repo_empty(repo->repo, 0);
return 0;
// Do not destroy files in local repositories
- if (pakfire_repo_is_local(repo))
+ if (pakfire_repo_is_local(repo)) {
+ if (flags & PAKFIRE_REPO_CLEAN_FLAGS_DESTROY) {
+ // Find path to repository
+ const char* path = pakfire_repo_get_path(repo);
+ if (!path)
+ return 1;
+
+ // Destroy it
+ r = pakfire_rmtree(path, 0);
+ if (r)
+ return r;
+ }
+
return 0;
+ }
// Destroy all files in the cache directory
- int r = pakfire_make_cache_path(repo->pakfire, cache_path,
+ r = pakfire_make_cache_path(repo->pakfire, cache_path,
"repodata/%s", pakfire_repo_get_name(repo));
if (r < 0)
return r;