summaryrefslogtreecommitdiffstats
path: root/libopkg/opkg_cmd.c
diff options
context:
space:
mode:
authorticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-14 23:52:54 (EST)
committer ticktock35 <ticktock35@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2008-12-14 23:52:54 (EST)
commitdb0e8730f2e7b2c584c4c16bf8c32170c5b372e4 (patch)
tree624a782455c1ebc3bc3d6c22f8a01fdac81743f6 /libopkg/opkg_cmd.c
parent99c7900b8a28d8f297f7d96905fff3114d3c3072 (diff)
opkg: use a single temporary directory for entire update transaction and remove
it when done. git-svn-id: http://opkg.googlecode.com/svn/trunk@46 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
Diffstat (limited to 'libopkg/opkg_cmd.c')
-rw-r--r--libopkg/opkg_cmd.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/libopkg/opkg_cmd.c b/libopkg/opkg_cmd.c
index db04a4a..27765f3 100644
--- a/libopkg/opkg_cmd.c
+++ b/libopkg/opkg_cmd.c
@@ -184,6 +184,7 @@ int opkg_cmd_exec(opkg_cmd_t *cmd, opkg_conf_t *conf, int argc, const char **arg
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 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
}
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 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
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 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
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 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
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 @@ static int opkg_update_cmd(opkg_conf_t *conf, int argc, char **argv)
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