61f454ae1c1723f61ba89e1b58246ab9d46e1b90
[openwrt/openwrt.git] / package / system / opkg / patches / 110-upgrade.patch
1 --- a/libopkg/opkg_install.c
2 +++ b/libopkg/opkg_install.c
3 @@ -1405,9 +1405,11 @@ opkg_install_pkg(pkg_t *pkg, int from_up
4 opkg_state_changed++;
5 pkg->state_flag |= SF_FILELIST_CHANGED;
6
7 - if (old_pkg)
8 + if (old_pkg) {
9 pkg_remove_orphan_dependent(pkg, old_pkg);
10 -
11 + old_pkg->is_upgrade = 1;
12 + pkg->is_upgrade = 1;
13 + }
14 /* XXX: BUG: we really should treat replacement more like an upgrade
15 * Instead, we're going to remove the replacees
16 */
17 @@ -1466,7 +1468,7 @@ opkg_install_pkg(pkg_t *pkg, int from_up
18 }
19
20
21 - opkg_msg(INFO, "Installing maintainer scripts.\n");
22 + opkg_msg(INFO, "%s maintainer scripts.\n", (pkg->is_upgrade) ? ("Upgrading") : ("Installing"));
23 if (install_maintainer_scripts(pkg, old_pkg)) {
24 opkg_msg(ERROR, "Failed to extract maintainer scripts for %s."
25 " Package debris may remain!\n",
26 --- a/libopkg/pkg.c
27 +++ b/libopkg/pkg.c
28 @@ -1285,6 +1285,12 @@ pkg_run_script(pkg_t *pkg, const char *s
29 setenv("PKG_ROOT",
30 pkg->dest ? pkg->dest->root_dir : conf->default_dest->root_dir, 1);
31
32 + if (pkg->is_upgrade)
33 + setenv("PKG_UPGRADE", "1", 1);
34 + else
35 + setenv("PKG_UPGRADE", "0", 1);
36 +
37 +
38 if (! file_exists(path)) {
39 free(path);
40 return 0;
41 --- a/libopkg/pkg.h
42 +++ b/libopkg/pkg.h
43 @@ -184,6 +184,7 @@ struct pkg
44 /* this flag specifies whether the package was installed to satisfy another
45 * package's dependancies */
46 int auto_installed;
47 + int is_upgrade;
48 };
49
50 pkg_t *pkg_new(void);