opkg_error_t opkg_install_by_name(opkg_conf_t *conf, const char *pkg_name)
{
- int cmp, err;
+ int cmp, err = 0;
pkg_t *old, *new;
char *old_version, *new_version;
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(new_pkg);
- str_list_elt_t *iter;
+ str_list_elt_t *iter, *niter;
- for (iter = str_list_first(new_list); iter; iter = str_list_next(new_list, iter)) {
+ for (iter = str_list_first(new_list), niter = str_list_next(new_list, iter);
+ iter;
+ iter = niter, niter = str_list_next(new_list, niter)) {
char *new_file = (char *)iter->data;
pkg_t *owner = file_hash_get_file_owner(conf, new_file);
if (!new_file)
}
if (old_pkg) {
str_list_t *old_list = pkg_get_installed_files(old_pkg);
- for (iter = str_list_first(old_list); iter; iter = str_list_next(old_list, iter)) {
+ for (iter = str_list_first(old_list), niter = str_list_next(old_list, iter);
+ iter;
+ iter = niter, niter = str_list_next(old_list, niter)) {
char *old_file = (char *)iter->data;
pkg_t *owner = file_hash_get_file_owner(conf, old_file);
if (owner == old_pkg) {
* 3) return a proper error code instead of 1
*/
int comp_size, blocks_available;
+ char *root_dir;
if (!conf->force_space && pkg->installed_size != NULL) {
- blocks_available = get_available_blocks(conf->default_dest->root_dir);
+ root_dir = pkg->dest ? pkg->dest->root_dir : conf->default_dest->root_dir;
+ blocks_available = get_available_blocks(root_dir);
comp_size = strtoul(pkg->installed_size, NULL, 0);
/* round up a blocks count without doing fancy-but-slow casting jazz */
if (comp_size >= blocks_available) {
opkg_message(conf, OPKG_ERROR,
"Only have %d available blocks on filesystem %s, pkg %s needs %d\n",
- blocks_available, conf->default_dest->root_dir, pkg->name, comp_size);
+ blocks_available, root_dir, pkg->name, comp_size);
return ENOSPC;
}
}
other package.
*/
str_list_t *files_list;
- str_list_elt_t *iter;
+ str_list_elt_t *iter, *niter;
int clashes = 0;
files_list = pkg_get_installed_files(pkg);
- for (iter = str_list_first(files_list); iter; iter = str_list_next(files_list, iter)) {
+ for (iter = str_list_first(files_list), niter = str_list_next(files_list, iter);
+ iter;
+ iter = niter, niter = str_list_next(files_list, iter)) {
char *root_filename;
char *filename = (char *) iter->data;
root_filename = root_filename_alloc(conf, filename);
@@@ To change after 1.0 release.
*/
str_list_t *files_list;
- str_list_elt_t *iter;
+ str_list_elt_t *iter, *niter;
+
+ char *root_filename = NULL;
int clashes = 0;
files_list = pkg_get_installed_files(pkg);
- for (iter = str_list_first(files_list); iter; iter = str_list_next(files_list, iter)) {
- char *root_filename;
+ for (iter = str_list_first(files_list), niter = str_list_next(files_list, iter);
+ iter;
+ iter = niter, niter = str_list_next(files_list, niter)) {
char *filename = (char *) iter->data;
+ if (root_filename) {
+ free(root_filename);
+ root_filename = NULL;
+ }
root_filename = root_filename_alloc(conf, filename);
if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
pkg_t *owner;
+ owner = file_hash_get_file_owner(conf, filename);
+
if (conf->force_overwrite) {
/* but we need to change who owns this file */
file_hash_set_file_owner(conf, filename, pkg);
continue;
}
- owner = file_hash_get_file_owner(conf, filename);
/* Pre-existing files are OK if owned by a package replaced by new pkg. */
if (owner) {
}
}
- free(root_filename);
+ }
+ if (root_filename) {
+ free(root_filename);
+ root_filename = NULL;
}
pkg_free_installed_files(pkg);
cf_backup = backup_filename_alloc(root_filename);
- if (file_exists(cf_backup)) {
- /* Let's compute md5 to test if files are changed */
- md5sum = file_md5sum_alloc(cf_backup);
- if (strcmp( cf->value,md5sum) != 0 ) {
- if (conf->force_defaults
- || user_prefers_old_conffile(cf->name, cf_backup) ) {
- rename(cf_backup, root_filename);
- }
- }
- unlink(cf_backup);
- free(md5sum);
- }
+ if (file_exists(cf_backup)) {
+ /* Let's compute md5 to test if files are changed */
+ md5sum = file_md5sum_alloc(cf_backup);
+ if (strcmp( cf->value,md5sum) != 0 ) {
+ if (conf->force_maintainer) {
+ opkg_message(conf, OPKG_NOTICE, "Conffile %s using maintainer's setting.\n", cf_backup);
+ } else if (conf->force_defaults
+ || user_prefers_old_conffile(cf->name, cf_backup) ) {
+ rename(cf_backup, root_filename);
+ }
+ }
+ unlink(cf_backup);
+ free(md5sum);
+ }
free(cf_backup);
free(root_filename);