]> git.ipfire.org Git - people/ric9/pakfire.git/commitdiff
build: Simplify mounting the ccache
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 10 Jan 2025 16:44:40 +0000 (16:44 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 10 Jan 2025 16:44:40 +0000 (16:44 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/pakfire/build.c

index 3f7c95577c9e68f8868ef5f5fd84b126fdf37a08..4118102df6d2742de732836d41bdc0ec3cf8d17a 100644 (file)
@@ -1938,29 +1938,6 @@ static int pakfire_build_setup_jail(struct pakfire_build* build) {
 /*
        Sets up the ccache for this build
 */
-static int pakfire_build_mount_ccache(struct pakfire_build* build) {
-       int r;
-
-       // Do nothing if the ccache is disabled
-       if (pakfire_build_has_flag(build, PAKFIRE_BUILD_DISABLE_CCACHE))
-               return 0;
-
-       // Check that the path is set
-       if (!*build->ccache_path)
-               return -ENOTSUP;
-
-       // Make sure the path exists
-       r = pakfire_mkdir(build->ccache_path, 0755);
-       if (r) {
-               ERROR(build->ctx, "Could not create %s: %m\n", build->ccache_path);
-               return r;
-       }
-
-       // Bind-mount the directory
-       return pakfire_jail_bind(build->jail, build->ccache_path, CCACHE_DIR,
-               MS_NOSUID|MS_NOEXEC|MS_NODEV);
-}
-
 static int pakfire_build_setup_ccache(struct pakfire_build* build) {
        int r;
 
@@ -1997,6 +1974,14 @@ static int pakfire_build_setup_ccache(struct pakfire_build* build) {
        if (r)
                return r;
 
+       // Bind-mount the directory into the jail
+       r = pakfire_jail_bind(build->jail, build->ccache_path, CCACHE_DIR,
+                       MS_NOSUID|MS_NOEXEC|MS_NODEV);
+       if (r < 0) {
+               ERROR(build->ctx, "Could not mount the ccache: %s\n", strerror(-r));
+               return r;
+       }
+
        return 0;
 }
 
@@ -2621,13 +2606,6 @@ int pakfire_build_exec(struct pakfire_build* build, const char* path) {
                goto ERROR;
        }
 
-       // Mount the ccache
-       r = pakfire_build_mount_ccache(build);
-       if (r) {
-               ERROR(build->ctx, "Could not mount the ccache: %m\n");
-               goto ERROR;
-       }
-
        // Open the makefile
        r = pakfire_build_read_makefile(build, &makefile, package);
        if (r)