Initial stab at untangling the #include maze. Probably needs a second pass.
[oweals/opkg-lede.git] / libopkg / pkg.c
index e54182500d8798e05f09c29292902bf9ff661e70..bd7e9f8866fba6e01b25b9a6233b3de3bd2745df 100644 (file)
    General Public License for more details.
 */
 
-#include "includes.h"
-#include <ctype.h>
-#include <alloca.h>
+#include "config.h"
+
+#include <stdio.h>
 #include <string.h>
-#include <stdbool.h>
-#include <errno.h>
+#include <ctype.h>
+#include <unistd.h>
 
 #include "pkg.h"
 
@@ -274,15 +274,17 @@ pkg_init_from_file(pkg_t *pkg, const char *filename)
 {
        int fd, err = 0;
        FILE *control_file;
-       char *control_path;
+       char *control_path, *tmp;
 
        pkg_init(pkg);
 
        pkg->local_filename = xstrdup(filename);
 
+       tmp = xstrdup(filename);
        sprintf_alloc(&control_path, "%s/%s.control.XXXXXX", 
                         conf->tmp_dir,
-                        basename(filename));
+                        basename(tmp));
+       free(tmp);
        fd = mkstemp(control_path);
        if (fd == -1) {
                opkg_perror(ERROR, "Failed to make temp file %s", control_path);