]> git.ipfire.org Git - pakfire.git/commitdiff
arch: Enhance check for support by host and check for interpreter
authorMichael Tremer <michael.tremer@ipfire.org>
Wed, 30 Aug 2023 17:04:18 +0000 (17:04 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Wed, 30 Aug 2023 17:04:18 +0000 (17:04 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/libpakfire/arch.c
src/libpakfire/include/pakfire/arch.h
src/libpakfire/jail.c
src/libpakfire/pakfire.c

index dda1538f0942e359d2c9f2a4a109a4d85a0c1f62..18ab74b33982aac5def0e6bf9795231f8f194a1b 100644 (file)
@@ -203,7 +203,7 @@ int pakfire_arch_is_compatible(const char* name, const char* compatible_arch) {
        This function figures out which architecture the build environment has -
        which might not be the same as the requested architecture.
 */
-const char* pakfire_arch_supported_by_host(const char* name) {
+static const char* pakfire_arch_is_natively_supported_by_host(const char* name) {
        if (!name) {
                errno = EINVAL;
                return NULL;
@@ -220,7 +220,26 @@ const char* pakfire_arch_supported_by_host(const char* name) {
                return name;
 
        // Not supported
-       errno = ENOTSUP;
+       return NULL;
+}
+
+const char* pakfire_arch_is_supported_by_host(const char* name) {
+       const char* arch = NULL;
+
+       // Check if we natively support this architecture
+       arch = pakfire_arch_is_natively_supported_by_host(name);
+       if (arch)
+               return arch;
+
+       // Otherwise check if we have an interpreter
+       char* interpreter = pakfire_arch_find_interpreter(name);
+       if (interpreter) {
+               free(interpreter);
+
+               return name;
+       }
+
+       // Otherwise this architecture is not supported
        return NULL;
 }
 
@@ -296,7 +315,7 @@ char* pakfire_arch_find_interpreter(const char* name) {
 
        // If the host supports this architecture natively,
        // we do not need to search for the interpreter
-       if (pakfire_arch_supported_by_host(name))
+       if (pakfire_arch_is_natively_supported_by_host(name))
                goto ERROR;
 
        const struct pakfire_arch* arch = pakfire_arch_find(name);
index f09f777c3febc3b739e8607d025661c09ecff686..0fa67787b40645488f5163d63c1e369bbb101fa2 100644 (file)
@@ -40,7 +40,7 @@ int __pakfire_arch_buildtarget(char* buffer, size_t length, const char* arch, co
 const char* pakfire_arch_platform(const char* name);
 int pakfire_arch_is_compatible(const char* name, const char* compatible_arch);
 
-const char* pakfire_arch_supported_by_host(const char* name);
+const char* pakfire_arch_is_supported_by_host(const char* name);
 char* pakfire_arch_find_interpreter(const char* name);
 
 #endif
index e22feeca5ce62ec4695ee896165988dcafcb3993..b1f71c77ba4167f07494312308c3ddd641abfbdd 100644 (file)
@@ -280,7 +280,7 @@ PAKFIRE_EXPORT int pakfire_jail_create(struct pakfire_jail** jail, struct pakfir
        }
 
        // Enable all CPU features that CPU has to offer
-       if (!pakfire_arch_supported_by_host(arch)) {
+       if (!pakfire_arch_is_supported_by_host(arch)) {
                r = pakfire_jail_set_env(j, "QEMU_CPU", "max");
                if (r)
                        goto ERROR;
index e3f392dd78bb5c4d7e158fac8e74f28e883bf019..a4ab9f9cbe07fe791baaff379fad8bfe65c0e2d1 100644 (file)
@@ -866,7 +866,7 @@ PAKFIRE_EXPORT int pakfire_create(struct pakfire** pakfire, const char* path,
                goto ERROR;
 
        // Determine the effective architecture
-       p->arches.effective = pakfire_arch_supported_by_host(arch);
+       p->arches.effective = pakfire_arch_is_supported_by_host(arch);
        if (!p->arches.effective) {
                ERROR(p, "Unsupported architecture: %s\n", arch);
                r = errno;