1 This patch adds a new configuration option (overlay_root) specifying
2 what mount point opkg should check for available storage space.
4 Signed-off-by: Nicolas Thill <nico@openwrt.org>
7 --- a/libopkg/opkg_conf.c
8 +++ b/libopkg/opkg_conf.c
9 @@ -70,6 +70,7 @@ int opkg_init_options_array(const opkg_c
10 { "offline_root_path", OPKG_OPT_TYPE_STRING, &conf->offline_root_path },
11 { "offline_root_post_script_cmd", OPKG_OPT_TYPE_STRING, &conf->offline_root_post_script_cmd },
12 { "offline_root_pre_script_cmd", OPKG_OPT_TYPE_STRING, &conf->offline_root_pre_script_cmd },
13 + { "overlay_root", OPKG_OPT_TYPE_STRING, &conf->overlay_root },
14 { "proxy_passwd", OPKG_OPT_TYPE_STRING, &conf->proxy_passwd },
15 { "proxy_user", OPKG_OPT_TYPE_STRING, &conf->proxy_user },
16 { "query-all", OPKG_OPT_TYPE_BOOL, &conf->query_all },
17 --- a/libopkg/opkg_conf.h
18 +++ b/libopkg/opkg_conf.h
19 @@ -70,6 +70,7 @@ struct opkg_conf
20 char *offline_root_path;
21 char *offline_root_pre_script_cmd;
22 char *offline_root_post_script_cmd;
27 --- a/libopkg/opkg_install.c
28 +++ b/libopkg/opkg_install.c
29 @@ -474,12 +474,15 @@ static int verify_pkg_installable(opkg_c
30 * my diddling with the .opk file size below isn't going to cut it.
31 * 3) return a proper error code instead of 1
33 - int comp_size, blocks_available;
34 + int comp_size, blocks_available = -1;
37 if (!conf->force_space && pkg->installed_size != NULL) {
38 root_dir = pkg->dest ? pkg->dest->root_dir : conf->default_dest->root_dir;
39 - blocks_available = get_available_blocks(root_dir);
40 + if (conf->overlay_root != NULL)
41 + blocks_available = get_available_blocks(conf->overlay_root);
42 + if (blocks_available < 0)
43 + blocks_available = get_available_blocks(root_dir);
45 comp_size = strtoul(pkg->installed_size, NULL, 0);
46 /* round up a blocks count without doing fancy-but-slow casting jazz */
47 --- a/libopkg/opkg_utils.c
48 +++ b/libopkg/opkg_utils.c
49 @@ -30,10 +30,8 @@ long unsigned int get_available_blocks(c
53 - if(statfs(filesystem, &sfs)){
54 - fprintf(stderr, "bad statfs\n");
57 + if(statfs(filesystem, &sfs))
59 /* fprintf(stderr, "reported fs type %x\n", sfs.f_type); */
61 // Actually ((sfs.f_bavail * sfs.f_bsize) / 1024)