chiark / gitweb /
build-sys: add Arch Linux support
[elogind.git] / hostname-setup.c
index eca33a9..67891a5 100644 (file)
@@ -75,6 +75,64 @@ finish:
         fclose(f);
         return r;
 
+#elif defined(TARGET_ARCH)
+        int r;
+        FILE *f;
+
+        assert(hn);
+
+        if (!(f = fopen("/etc/rc.conf", "re")))
+                return -errno;
+
+        for (;;) {
+                char line[LINE_MAX];
+                char *s, *k;
+
+                if (!fgets(line, sizeof(line), f)) {
+                        if (feof(f))
+                                break;
+
+                        r = -errno;
+                        goto finish;
+                }
+
+                s = strstrip(line);
+
+                if (!startswith(s, "HOSTNAME="))
+                        continue;
+
+                if (!(k = strdup(s+9))) {
+                        r = -ENOMEM;
+                        goto finish;
+                }
+
+                *hn = k;
+                break;
+        }
+
+        r = 0;
+
+finish:
+        fclose(f);
+        return r;
+
+#elif defined(TARGET_SUSE)
+        int r;
+        char *s, *k;
+
+        assert(hn);
+
+        if ((r = read_one_line_file("/etc/HOSTNAME", &s)) < 0)
+                return r;
+
+        k = strdup(strstrip(s));
+        free(s);
+
+        if (!k)
+                return -ENOMEM;
+
+        *hn = k;
+
 #elif defined(TARGET_DEBIAN)
         int r;
         char *s, *k;
@@ -92,7 +150,7 @@ finish:
 
         *hn = k;
 #else
-#warn "Don't know how to read the hostname"
+#warning "Don't know how to read the hostname"
 
         return -ENOENT;
 #endif