[package] opkg: bump to r284
[openwrt/svn-archive/archive.git] / package / opkg / patches / 003-fs_overlay_support.patch
1 This patch adds a new configuration option (overlay_root) specifying
2 what mount point opkg should check for available storage space.
3
4 Signed-off-by: Nicolas Thill <nico@openwrt.org>
5
6
7 --- a/libopkg/opkg_conf.c
8 +++ b/libopkg/opkg_conf.c
9 @@ -72,6 +72,7 @@
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 @@
20 char *offline_root_path;
21 char *offline_root_pre_script_cmd;
22 char *offline_root_post_script_cmd;
23 + char *overlay_root;
24 int query_all;
25 int verbosity;
26 int noaction;
27 --- a/libopkg/opkg_install.c
28 +++ b/libopkg/opkg_install.c
29 @@ -470,12 +470,15 @@
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
32 */
33 - int comp_size, blocks_available;
34 + int comp_size, blocks_available = -1;
35 char *root_dir;
36
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);
44
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 @@ -31,10 +31,8 @@
50 {
51 struct statfs sfs;
52
53 - if(statfs(filesystem, &sfs)){
54 - fprintf(stderr, "bad statfs\n");
55 - return 0;
56 - }
57 + if(statfs(filesystem, &sfs))
58 + return -1;
59 /* fprintf(stderr, "reported fs type %x\n", sfs.f_type); */
60
61 // Actually ((sfs.f_bavail * sfs.f_bsize) / 1024)