Allow to install a package from a read-only dir
authorpixdamix <pixdamix@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 23 Nov 2009 08:28:58 +0000 (08:28 +0000)
committerpixdamix <pixdamix@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>
Mon, 23 Nov 2009 08:28:58 +0000 (08:28 +0000)
This patch allows to install a package which is located on
a readonly filesystem or folder by moving the control file
into the tmp_dir directory

git-svn-id: http://opkg.googlecode.com/svn/trunk@351 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358

libopkg/opkg_download.c
libopkg/opkg_install.c
libopkg/pkg.c
libopkg/pkg.h

index 953627b026cede5646a4c18c2b44837c23a7130d..47892499ed6026067b816ae95b3a34c395d1feba 100644 (file)
@@ -276,7 +276,7 @@ int opkg_prepare_url_for_install(opkg_conf_t *conf, const char *url, char **name
          if (err)
               return err;
 
-         err = pkg_init_from_file(pkg, tmp_file);
+         err = pkg_init_from_file(conf, pkg, tmp_file);
          if (err)
               return err;
 
@@ -287,7 +287,7 @@ int opkg_prepare_url_for_install(opkg_conf_t *conf, const char *url, char **name
                 || strcmp(&url[strlen(url) - 4], IPKG_PKG_EXTENSION) == 0
                || strcmp(&url[strlen(url) - 4], DPKG_PKG_EXTENSION) == 0) {
 
-         err = pkg_init_from_file(pkg, url);
+         err = pkg_init_from_file(conf, pkg, url);
          if (err)
               return err;
          opkg_message(conf, OPKG_DEBUG2, "Package %s provided by hand (%s).\n", pkg->name,pkg->local_filename);
index f9245ca7985278ceef431b0bf725352390290d5d..96e6080d7c1cdbc598df59a012f1c9c71b9d690f 100644 (file)
@@ -85,7 +85,7 @@ int opkg_install_from_file(opkg_conf_t *conf, const char *filename)
 
      pkg = pkg_new();
 
-     err = pkg_init_from_file(pkg, filename);
+     err = pkg_init_from_file(conf, pkg, filename);
      if (err) {
          return err;
      }
index 75e95720b3282a9fffb75154531cface61b01dd5..89f47a9e46445b0646025f27c554dcb5560ba1da 100644 (file)
@@ -301,7 +301,7 @@ void pkg_deinit(pkg_t *pkg)
 }
 
 int
-pkg_init_from_file(pkg_t *pkg, const char *filename)
+pkg_init_from_file(opkg_conf_t *conf, pkg_t *pkg, const char *filename)
 {
        int fd, err = 0;
        FILE *control_file;
@@ -311,7 +311,9 @@ pkg_init_from_file(pkg_t *pkg, const char *filename)
 
        pkg->local_filename = xstrdup(filename);
 
-       sprintf_alloc(&control_path, "%s.control.XXXXXX", filename);
+       sprintf_alloc(&control_path, "%s/%s.control.XXXXXX", 
+                        conf->tmp_dir,
+                        basename(filename));
        fd = mkstemp(control_path);
        if (fd == -1) {
                perror_msg("%s: mkstemp(%s)", __FUNCTION__, control_path);
index 2e25443ff1bfb7d4968236e77a13b6a245a882b9..694bda95d5680cd2af460aa45758bf3d2bef46d3 100644 (file)
@@ -190,7 +190,7 @@ struct pkg
 pkg_t *pkg_new(void);
 int pkg_init(pkg_t *pkg);
 void pkg_deinit(pkg_t *pkg);
-int pkg_init_from_file(pkg_t *pkg, const char *filename);
+int pkg_init_from_file(opkg_conf_t *conf, pkg_t *pkg, const char *filename);
 abstract_pkg_t *abstract_pkg_new(void);
 int abstract_pkg_init(abstract_pkg_t *ab_pkg);