Changeset 4395


Ignore:
Timestamp:
04/24/08 13:03:31 (5 years ago)
Author:
thomas
Message:

opkg: implement new opkg_upgrade_package and opkg_upgrade_all functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/target/opkg/libopkg/opkg.c

    r4394 r4395  
    407407opkg_upgrade_package (opkg_t *opkg, const char *package_name, opkg_progress_callback_t progress_callback, void *user_data) 
    408408{ 
    409   return 1; 
     409  pkg_t *pkg; 
     410 
     411  opkg_assert (opkg != NULL); 
     412  opkg_assert (package_name != NULL); 
     413 
     414  progress (0); 
     415 
     416  pkg_info_preinstall_check (opkg->conf); 
     417 
     418  if (opkg->conf->restrict_to_default_dest) 
     419  { 
     420    pkg = pkg_hash_fetch_installed_by_name_dest (&opkg->conf->pkg_hash, 
     421                                                 package_name, 
     422                                                 opkg->conf->default_dest); 
     423    if (pkg == NULL) 
     424    { 
     425      /* XXX: Error: Package not installed in default_dest */ 
     426      return 1; 
     427    } 
     428  } 
     429  else 
     430  { 
     431    pkg = pkg_hash_fetch_installed_by_name (&opkg->conf->pkg_hash, 
     432                                            package_name); 
     433  } 
     434 
     435  if (!pkg) 
     436  { 
     437    /* XXX: Error: Package not installed */ 
     438    return 1; 
     439  } 
     440 
     441  progress (25); 
     442 
     443  opkg_upgrade_pkg (opkg->conf, pkg); 
     444  progress (75); 
     445 
     446  opkg_configure_packages (opkg->conf, NULL); 
     447  progress (100); 
     448  return 0; 
    410449} 
    411450 
     
    413452opkg_upgrade_all (opkg_t *opkg, opkg_progress_callback_t progress_callback, void *user_data) 
    414453{ 
    415   return 1; 
     454  pkg_vec_t *installed; 
     455  int err = 0; 
     456  int i; 
     457  pkg_t *pkg; 
     458 
     459  opkg_assert (opkg != NULL); 
     460  progress (0); 
     461 
     462  installed = pkg_vec_alloc (); 
     463  pkg_info_preinstall_check (opkg->conf); 
     464 
     465  pkg_hash_fetch_all_installed (&opkg->conf->pkg_hash, installed); 
     466  for (i = 0; i < installed->len; i++) 
     467  { 
     468    pkg = installed->pkgs[i]; 
     469    err += opkg_upgrade_pkg (opkg->conf, pkg); 
     470    progress (100 * i / installed->len); 
     471  } 
     472  pkg_vec_free (installed); 
     473 
     474  if (err) 
     475    return 1; 
     476 
     477  err = opkg_configure_packages (opkg->conf, NULL); 
     478  if (err) 
     479    return 1; 
     480 
     481  progress (100); 
     482  return 0; 
    416483} 
    417484 
Note: See TracChangeset for help on using the changeset viewer.