]> git.ipfire.org Git - pakfire.git/commitdiff
repo: Make functions to check if internal or local available everywhere
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Nov 2022 14:00:28 +0000 (14:00 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 1 Nov 2022 14:00:28 +0000 (14:00 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/include/pakfire/repo.h
src/libpakfire/repo.c

index df52cd2cccc934b9f47e8183b3380eeaa47e2d24..cf96d5c1db14a84700ed936d25a15d44b558452b 100644 (file)
@@ -109,6 +109,8 @@ int pakfire_repo_compose(struct pakfire* pakfire, const char* path, int flags,
 #define PAKFIRE_REPO_SYSTEM                            "@system"
 
 int pakfire_repo_name_equals(struct pakfire_repo* repo, const char* name);
+int pakfire_repo_is_internal(struct pakfire_repo* repo);
+int pakfire_repo_is_local(struct pakfire_repo* repo);
 
 int pakfire_repo_import(struct pakfire* pakfire, struct pakfire_config* config);
 const char* pakfire_repo_get_path(struct pakfire_repo* repo);
index c5276f845f4b0e531d74ecedfb6a86fa2b9d1111..548828bd1a9360420f2dbd7fb094c7cc656a7c56 100644 (file)
@@ -81,7 +81,7 @@ struct pakfire_repo {
        struct pakfire_mirrorlist* mirrorlist;
 };
 
-static int pakfire_repo_is_internal(struct pakfire_repo* repo) {
+int pakfire_repo_is_internal(struct pakfire_repo* repo) {
        const char* name = pakfire_repo_get_name(repo);
        if (!name)
                return 0;
@@ -89,6 +89,13 @@ static int pakfire_repo_is_internal(struct pakfire_repo* repo) {
        return (*name == '@');
 }
 
+int pakfire_repo_is_local(struct pakfire_repo* repo) {
+       if (!repo->appdata->baseurl)
+               return 0;
+
+       return pakfire_string_startswith(repo->appdata->baseurl, "file://");
+}
+
 int pakfire_repo_name_equals(struct pakfire_repo* repo, const char* name) {
        const char* n = pakfire_repo_get_name(repo);
        if (!n)
@@ -746,13 +753,6 @@ PAKFIRE_EXPORT int pakfire_repo_set_baseurl(struct pakfire_repo* repo, const cha
        return 0;
 }
 
-static int pakfire_repo_is_local(struct pakfire_repo* repo) {
-       if (!repo->appdata->baseurl)
-               return 0;
-
-       return pakfire_string_startswith(repo->appdata->baseurl, "file://");
-}
-
 const char* pakfire_repo_get_path(struct pakfire_repo* repo) {
        if (!pakfire_repo_is_local(repo))
                return NULL;
@@ -784,7 +784,7 @@ PAKFIRE_EXPORT int pakfire_repo_write_config(struct pakfire_repo* repo, FILE* f)
        int r;
 
        // Do nothing for the installed repository
-       if (pakfire_repo_is_installed_repo(repo) == 0)
+       if (pakfire_repo_is_installed_repo(repo))
                return 0;
 
        struct pakfire_config* config = NULL;
@@ -888,13 +888,13 @@ ERROR:
 PAKFIRE_EXPORT int pakfire_repo_is_installed_repo(struct pakfire_repo* repo) {
        struct pakfire_repo* installed_repo = pakfire_get_installed_repo(repo->pakfire);
        if (!installed_repo)
-               return 1;
+               return 0;
 
        int r = pakfire_repo_identical(repo, installed_repo);
 
        pakfire_repo_unref(installed_repo);
 
-       return r;
+       return (r == 0);
 }
 
 PAKFIRE_EXPORT int pakfire_repo_read_solv(struct pakfire_repo* repo, FILE *f, int flags) {