"mentioned above do not yet exist (try 'opkg update'). To proceed in spite\n"
"of this problem try again with the '-force-depends' option.\n");
pkg_vec_free(depends);
- return OPKG_PKG_DEPS_UNSATISFIED;
+ return -1;
}
}
opkg_message(conf, level, " %s", conflicts->pkgs[i++]->name);
opkg_message(conf, level, "\n");
pkg_vec_free(conflicts);
- return OPKG_PKG_DEPS_UNSATISFIED;
+ return -1;
}
return 0;
}
static int
update_file_ownership(opkg_conf_t *conf, pkg_t *new_pkg, pkg_t *old_pkg)
{
- str_list_t *new_list = pkg_get_installed_files(conf, new_pkg);
+ str_list_t *new_list, *old_list;
str_list_elt_t *iter, *niter;
+ new_list = pkg_get_installed_files(conf, new_pkg);
+ if (new_list == NULL)
+ return -1;
+
for (iter = str_list_first(new_list), niter = str_list_next(new_list, iter);
iter;
iter = niter, niter = str_list_next(new_list, niter)) {
if (!owner || (owner == old_pkg))
file_hash_set_file_owner(conf, new_file, new_pkg);
}
+
if (old_pkg) {
- str_list_t *old_list = pkg_get_installed_files(conf, old_pkg);
+ old_list = pkg_get_installed_files(conf, old_pkg);
+ if (old_list == NULL) {
+ pkg_free_installed_files(new_pkg);
+ return -1;
+ }
+
for (iter = str_list_first(old_list), niter = str_list_next(old_list, iter);
iter;
iter = niter, niter = str_list_next(old_list, niter)) {
opkg_message(conf, OPKG_ERROR,
"%s: Failed to create temporary directory '%s': %s\n",
__FUNCTION__, pkg->tmp_unpack_dir, strerror(errno));
- return errno;
+ return -1;
}
err = pkg_extract_control_files_to_dir(pkg, pkg->tmp_unpack_dir);
fprintf(stderr, "%s: failed to open %s: %s\n",
__FUNCTION__, conffiles_file_name, strerror(errno));
free(conffiles_file_name);
- return errno;
+ return -1;
}
free(conffiles_file_name);
int clashes = 0;
files_list = pkg_get_installed_files(conf, pkg);
+ if (files_list == NULL)
+ return -1;
+
for (iter = str_list_first(files_list), niter = str_list_next(files_list, iter);
iter;
iter = niter, niter = str_list_next(files_list, iter)) {
return clashes;
}
+/*
+ * XXX: This function sucks, as does the below comment.
+ */
static int
check_data_file_clashes_change(opkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
{
char *root_filename = NULL;
- int clashes = 0;
-
files_list = pkg_get_installed_files(conf, pkg);
+ if (files_list == NULL)
+ return -1;
+
for (iter = str_list_first(files_list), niter = str_list_next(files_list, iter);
iter;
iter = niter, niter = str_list_next(files_list, niter)) {
}
pkg_free_installed_files(pkg);
- return clashes;
+ return 0;
}
static int
str_list_elt_t *nf;
hash_table_t new_files_table;
- if (old_pkg == NULL) {
- return 0;
- }
-
old_files = pkg_get_installed_files(conf, old_pkg);
+ if (old_files == NULL)
+ return -1;
+
new_files = pkg_get_installed_files(conf, pkg);
+ if (new_files == NULL) {
+ pkg_free_installed_files(old_pkg);
+ return -1;
+ }
new_files_table.entries = NULL;
hash_table_init("new_files" , &new_files_table, 20);
}
-opkg_error_t
+int
opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name)
{
- int cmp, err = 0;
+ int cmp;
pkg_t *old, *new;
char *old_version, *new_version;
- opkg_message(conf, OPKG_DEBUG2, " Getting old from pkg_hash_fetch \n" );
old = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg_name);
- if ( old )
- opkg_message(conf, OPKG_DEBUG2, " Old versions from pkg_hash_fetch %s \n", old->version );
+ if (old)
+ opkg_message(conf, OPKG_DEBUG2, "Old versions from pkg_hash_fetch %s \n", old->version);
- opkg_message(conf, OPKG_DEBUG2, " Getting new from pkg_hash_fetch \n" );
- new = pkg_hash_fetch_best_installation_candidate_by_name(conf, pkg_name, &err);
- if ( new )
- opkg_message(conf, OPKG_DEBUG2, " New versions from pkg_hash_fetch %s \n", new->version );
-
-/* Pigi Basically here is broken the version stuff.
- What's happening is that nothing provide the version to differents
- functions, so the returned struct is always the latest.
- That's why the install by name don't work.
-*/
- opkg_message(conf, OPKG_DEBUG2, " Versions from pkg_hash_fetch in %s ", __FUNCTION__ );
+ new = pkg_hash_fetch_best_installation_candidate_by_name(conf, pkg_name);
+ if (new == NULL)
+ return -1;
+ opkg_message(conf, OPKG_DEBUG2, "Versions from pkg_hash_fetch in %s ", __FUNCTION__);
if ( old )
- opkg_message(conf, OPKG_DEBUG2, " old %s ", old->version );
- if ( new )
- opkg_message(conf, OPKG_DEBUG2, " new %s ", new->version );
- opkg_message(conf, OPKG_DEBUG2, " \n");
-
- if (new == NULL) {
- if (err)
- return err;
- else
- return OPKG_PKG_HAS_NO_CANDIDATE;
- }
+ opkg_message(conf, OPKG_DEBUG2, " old %s ", old->version);
+ opkg_message(conf, OPKG_DEBUG2, " new %s\n", new->version);
new->state_flag |= SF_USER;
if (old) {
free(new_version);
}
- /* XXX: CLEANUP: The error code of opkg_install_by_name is really
- supposed to be an opkg_error_t, but opkg_install_pkg could
- return any kind of integer, (might be errno from a syscall,
- etc.). This is a real mess and will need to be cleaned up if
- anyone ever wants to make a nice libopkg. */
-
- opkg_message(conf, OPKG_DEBUG2,"Function: %s calling opkg_install_pkg \n",__FUNCTION__);
+ opkg_message(conf, OPKG_DEBUG2,"%s: calling opkg_install_pkg \n",__FUNCTION__);
return opkg_install_pkg(conf, new,0);
}
#ifdef HAVE_SHA256
char* file_sha256;
#endif
+ sigset_t newset, oldset;
if ( from_upgrade )
message = 1; /* Coming from an upgrade, and should change the output message */
if (!pkg) {
opkg_message(conf, OPKG_ERROR,
"INTERNAL ERROR: null pkg passed to opkg_install_pkg\n");
- return OPKG_INSTALL_ERR_INTERNAL;
+ return -1;
}
opkg_message(conf, OPKG_DEBUG2, "Function: %s calling pkg_arch_supported %s \n", __FUNCTION__, __FUNCTION__);
if (!pkg_arch_supported(conf, pkg)) {
opkg_message(conf, OPKG_ERROR, "INTERNAL ERROR: architecture %s for pkg %s is unsupported.\n",
pkg->architecture, pkg->name);
- return OPKG_INSTALL_ERR_INTERNAL;
+ return -1;
}
if (pkg->state_status == SS_INSTALLED && conf->force_reinstall == 0 && conf->nodeps == 0) {
err = satisfy_dependencies_for(conf, pkg);
- if (err) { return OPKG_INSTALL_ERR_DEPENDENCIES; }
+ if (err)
+ return -1;
opkg_message(conf, OPKG_NOTICE,
"Package %s is already installed in %s.\n",
old_pkg = pkg_hash_fetch_installed_by_name(&conf->pkg_hash, pkg->name);
err = opkg_install_check_downgrade(conf, pkg, old_pkg, message);
- if (err) { return OPKG_INSTALL_ERR_NO_DOWNGRADE; }
+ if (err)
+ return -1;
pkg->state_want = SW_INSTALL;
if (old_pkg){
old_pkg->state_want = SW_DEINSTALL; /* needed for check_data_file_clashes of dependences */
}
-
- /* Abhaya: conflicts check */
err = check_conflicts_for(conf, pkg);
- if (err) { return OPKG_INSTALL_ERR_CONFLICTS; }
+ if (err)
+ return -1;
/* this setup is to remove the upgrade scenario in the end when
installing pkg A, A deps B & B deps on A. So both B and A are
installed. Then A's installation is started resulting in an
uncecessary upgrade */
- if (pkg->state_status == SS_INSTALLED
- && conf->force_reinstall == 0) return 0;
+ if (pkg->state_status == SS_INSTALLED && conf->force_reinstall == 0)
+ return 0;
err = verify_pkg_installable(conf, pkg);
- if (err) { return OPKG_INSTALL_ERR_NO_SPACE; }
+ if (err)
+ return -1;
if (pkg->local_filename == NULL) {
err = opkg_download_pkg(conf, pkg, conf->tmp_dir);
opkg_message(conf, OPKG_ERROR,
"Failed to download %s. Perhaps you need to run 'opkg update'?\n",
pkg->name);
- return OPKG_INSTALL_ERR_DOWNLOAD;
+ return -1;
}
}
if (opkg_verify_file (conf, list_file_name, sig_file_name)){
opkg_message(conf, OPKG_ERROR, "Failed to verify the signature of: %s\n",
list_file_name);
- return OPKG_INSTALL_ERR_SIGNATURE;
+ return -1;
}
}else{
opkg_message(conf, OPKG_ERROR, "Signature file is missing. "
"Perhaps you need to run 'opkg update'?\n");
- return OPKG_INSTALL_ERR_SIGNATURE;
+ return -1;
}
free (lists_dir);
"Package %s md5sum mismatch. Either the opkg or the package index are corrupt. Try 'opkg update'.\n",
pkg->name);
free(file_md5);
- return OPKG_INSTALL_ERR_MD5;
+ return -1;
}
if (file_md5)
free(file_md5);
"Package %s sha256sum mismatch. Either the opkg or the package index are corrupt. Try 'opkg update'.\n",
pkg->name);
free(file_sha256);
- return OPKG_INSTALL_ERR_SHA256;
+ return -1;
}
if (file_sha256)
free(file_sha256);
#endif
if (pkg->tmp_unpack_dir == NULL) {
- unpack_pkg_control_files(conf, pkg);
+ if (unpack_pkg_control_files(conf, pkg) == -1) {
+ opkg_message(conf, OPKG_ERROR, "Failed to unpack control"
+ " files from %s.\n", pkg->local_filename);
+ return -1;
+ }
}
/* We should update the filelist here, so that upgrades of packages that split will not fail. -Jamey 27-MAR-03 */
/* Pigi: check if it will pass from here when replacing. It seems to fail */
/* That's rather strange that files don't change owner. Investigate !!!!!!*/
err = update_file_ownership(conf, pkg, old_pkg);
- if (err) { return OPKG_ERR_UNKNOWN; }
+ if (err)
+ return -1;
if (conf->nodeps == 0) {
err = satisfy_dependencies_for(conf, pkg);
- if (err) { return OPKG_INSTALL_ERR_DEPENDENCIES; }
+ if (err)
+ return -1;
if (pkg->state_status == SS_UNPACKED)
/* Circular dependency has installed it for us. */
- return 0;
+ return 0;
}
replacees = pkg_vec_alloc();
pkg_get_installed_replacees(conf, pkg, replacees);
/* this next section we do with SIGINT blocked to prevent inconsistency between opkg database and filesystem */
- {
- sigset_t newset, oldset;
sigemptyset(&newset);
sigaddset(&newset, SIGINT);
* Instead, we're going to remove the replacees
*/
err = pkg_remove_installed_replacees(conf, replacees);
- if (err) goto UNWIND_REMOVE_INSTALLED_REPLACEES;
+ if (err)
+ goto UNWIND_REMOVE_INSTALLED_REPLACEES;
err = prerm_upgrade_old_pkg(conf, pkg, old_pkg);
- if (err) goto UNWIND_PRERM_UPGRADE_OLD_PKG;
+ if (err)
+ goto UNWIND_PRERM_UPGRADE_OLD_PKG;
err = prerm_deconfigure_conflictors(conf, pkg, replacees);
- if (err) goto UNWIND_PRERM_DECONFIGURE_CONFLICTORS;
+ if (err)
+ goto UNWIND_PRERM_DECONFIGURE_CONFLICTORS;
err = preinst_configure(conf, pkg, old_pkg);
- if (err) goto UNWIND_PREINST_CONFIGURE;
+ if (err)
+ goto UNWIND_PREINST_CONFIGURE;
err = backup_modified_conffiles(conf, pkg, old_pkg);
- if (err) goto UNWIND_BACKUP_MODIFIED_CONFFILES;
+ if (err)
+ goto UNWIND_BACKUP_MODIFIED_CONFFILES;
err = check_data_file_clashes(conf, pkg, old_pkg);
- if (err) goto UNWIND_CHECK_DATA_FILE_CLASHES;
+ if (err)
+ goto UNWIND_CHECK_DATA_FILE_CLASHES;
err = postrm_upgrade_old_pkg(conf, pkg, old_pkg);
- if (err) goto UNWIND_POSTRM_UPGRADE_OLD_PKG;
+ if (err)
+ goto UNWIND_POSTRM_UPGRADE_OLD_PKG;
- if (conf->noaction) return 0;
+ if (conf->noaction)
+ return 0;
/* point of no return: no unwinding after this */
if (old_pkg && !conf->force_reinstall) {
} else {
opkg_message(conf, OPKG_INFO,
" removing obsolesced files\n");
- remove_obsolesced_files(conf, pkg, old_pkg);
+ if (remove_obsolesced_files(conf, pkg, old_pkg)) {
+ opkg_message(conf, OPKG_ERROR, "Failed to determine "
+ "obsolete files from previously "
+ "installed %s\n", old_pkg->name);
+ }
}
/* removing files from old package, to avoid ghost files */
opkg_message(conf, OPKG_INFO,
" installing maintainer scripts\n");
- install_maintainer_scripts(conf, pkg, old_pkg);
+ if (install_maintainer_scripts(conf, pkg, old_pkg)) {
+ opkg_message(conf, OPKG_ERROR, "Failed to extract maintainer"
+ " scripts for %s. Package debris may remain!\n",
+ pkg->name);
+ goto pkg_is_hosed;
+ }
/* the following just returns 0 */
remove_disappeared(conf, pkg);
opkg_message(conf, OPKG_INFO,
" installing data files\n");
- install_data_files(conf, pkg);
-/* read comments from function for detail but I will execute this here as all other tests are ok.*/
+ if (install_data_files(conf, pkg)) {
+ opkg_message(conf, OPKG_ERROR, "Failed to extract data files "
+ "for %s. Package debris may remain!\n",
+ pkg->name);
+ goto pkg_is_hosed;
+ }
+
err = check_data_file_clashes_change(conf, pkg, old_pkg);
+ if (err) {
+ opkg_message(conf, OPKG_ERROR,
+ "check_data_file_clashes_change() failed for "
+ "for files belonging to %s.\n",
+ pkg->name);
+ }
opkg_message(conf, OPKG_INFO,
" resolving conf files\n");
UNWIND_REMOVE_INSTALLED_REPLACEES:
pkg_remove_installed_replacees_unwind(conf, replacees);
+pkg_is_hosed:
opkg_message(conf, OPKG_INFO,
"Failed.\n");
sigprocmask(SIG_UNBLOCK, &newset, &oldset);
pkg_vec_free (replacees);
- return OPKG_ERR_UNKNOWN;
- }
+ return -1;
}