Changeset 4097
- Timestamp:
- 02/21/08 11:28:30 (5 years ago)
- File:
-
- 1 edited
-
trunk/src/target/opkg/libopkg/opkg_remove.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/opkg/libopkg/opkg_remove.c
r4085 r4097 162 162 } 163 163 164 static int remove_autoinstalled (opkg_conf_t *conf, pkg_t *pkg) 165 { 166 /* 167 * find and remove packages that were autoinstalled and are orphaned by the removal of pkg 168 */ 169 170 char *buffer, *d_str; 171 int i; 172 173 for (i = 0; i < pkg->depends_count; ++i) 174 { 175 int x = 0; 176 pkg_t *p; 177 d_str = pkg->depends_str[i]; 178 buffer = malloc (strlen (d_str) + 1); 179 if (!buffer) 180 { 181 fprintf(stderr,"%s Unable to allocate memory.\n", __FUNCTION__); 182 return -1; 183 } 184 185 while (d_str[x] != '\0' && d_str[x] != ' ') 186 { 187 buffer[x] = d_str[x]; 188 ++x; 189 } 190 buffer[x] = '\0'; 191 buffer = realloc (buffer, strlen (buffer) + 1); 192 p = pkg_hash_fetch_installed_by_name (&conf->pkg_hash, buffer); 193 194 /* if the package is not installed, this could have been a circular 195 * depenancy and the package has already been removed */ 196 if (!p) 197 return -1; 198 199 if (p->auto_installed) 200 { 201 int deps; 202 abstract_pkg_t **dependents; 203 204 deps = pkg_has_installed_dependents(conf, NULL, p, &dependents); 205 if (deps == 0) 206 { 207 printf ("%s was autoinstalled but is now orphaned\n", buffer); 208 opkg_remove_pkg(conf, p,0); 209 } 210 else 211 printf ("%s was autoinstalled and is still required by %d installed packages\n", buffer, deps); 212 } 213 free (buffer); 214 } 215 216 return 0; 217 } 218 164 219 int opkg_remove_pkg(opkg_conf_t *conf, pkg_t *pkg,int message) 165 220 { … … 170 225 int err; 171 226 abstract_pkg_t *parent_pkg = NULL; 172 173 if (conf->autoremove)174 printf ("autoremove is enabled, but not yet implemented\n");175 227 176 228 if (pkg->essential && !message) { … … 252 304 if (parent_pkg) 253 305 parent_pkg->state_status = SS_NOT_INSTALLED; 306 307 308 /* remove autoinstalled packages that are orphaned by the removal of this one */ 309 if (conf->autoremove) 310 remove_autoinstalled (conf, pkg); 311 312 254 313 255 314 return 0;
Note: See TracChangeset
for help on using the changeset viewer.
