r4190 - trunk/src/target/opkg/libopkg
thomas at sita.openmoko.org
thomas at sita.openmoko.org
Mon Mar 10 17:33:01 CET 2008
Author: thomas
Date: 2008-03-10 17:33:00 +0100 (Mon, 10 Mar 2008)
New Revision: 4190
Modified:
trunk/src/target/opkg/libopkg/opkg_cmd.c
Log:
opkg: use a single temporary directory for entire update transaction and remove
it when done.
Modified: trunk/src/target/opkg/libopkg/opkg_cmd.c
===================================================================
--- trunk/src/target/opkg/libopkg/opkg_cmd.c 2008-03-10 05:47:55 UTC (rev 4189)
+++ trunk/src/target/opkg/libopkg/opkg_cmd.c 2008-03-10 16:33:00 UTC (rev 4190)
@@ -184,6 +184,7 @@
static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
{
+ char *tmp;
int err;
int failures;
char *lists_dir;
@@ -212,6 +213,16 @@
}
failures = 0;
+
+
+ tmp = strdup ("/tmp/opkg.XXXXXX");
+
+ if (mkdtemp (tmp) == NULL) {
+ perror ("mkdtemp");
+ failures++;
+ }
+
+
for (iter = conf->pkg_src_list.head; iter; iter = iter->next) {
char *url, *list_file_name;
@@ -225,17 +236,8 @@
sprintf_alloc(&list_file_name, "%s/%s", lists_dir, src->name);
if (src->gzip) {
- char *tmp;
char *tmp_file_name;
FILE *in, *out;
-
- tmp = strdup ("/tmp/opkg.XXXXXX");
-
- if (mkdtemp (tmp) == NULL) {
- perror ("mkdtemp");
- failures++;
- continue;
- }
sprintf_alloc (&tmp_file_name, "%s/%s.gz", tmp, src->name);
err = opkg_download(conf, url, tmp_file_name);
@@ -252,8 +254,6 @@
if (out)
fclose (out);
unlink (tmp_file_name);
- rmdir (tmp);
- free (tmp);
}
} else
err = opkg_download(conf, url, list_file_name);
@@ -274,14 +274,9 @@
else
sprintf_alloc(&url, "%s/%s", src->value, "Packages.sig");
- /* create temporary dir for it */
- char *tmp, *tmp_file_name;
- tmp = strdup ("/tmp/opkg.XXXXXX");
- if (mkdtemp (tmp) == NULL) {
- perror ("mkdtemp");
- failures++;
- continue;
- }
+ /* create temporary file for it */
+ char *tmp_file_name;
+
sprintf_alloc (&tmp_file_name, "%s/%s", tmp, "Packages.sig");
err = opkg_download(conf, url, tmp_file_name);
@@ -297,12 +292,13 @@
opkg_message (conf, OPKG_NOTICE, "Signature check failed\n");
}
unlink (tmp_file_name);
- unlink (tmp);
free (tmp_file_name);
free (url);
free(list_file_name);
}
+ rmdir (tmp);
+ free (tmp);
free(lists_dir);
#ifdef CONFIG_CLEAR_SW_INSTALL_FLAG
More information about the commitlog
mailing list