diff options
author | Timo Teras <timo.teras@iki.fi> | 2009-08-04 15:19:29 +0300 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2009-08-04 15:19:29 +0300 |
commit | 1fea5639b455ae4267a7dc17ef19b8d2506978b0 (patch) | |
tree | b02744d22dd0c762bf4b3d6e57b5229f223d8f29 /src/database.c | |
parent | ec2ade154289ce587eab3375445a33cad992c234 (diff) | |
download | aports-1fea5639b455ae4267a7dc17ef19b8d2506978b0.tar.bz2 aports-1fea5639b455ae4267a7dc17ef19b8d2506978b0.tar.xz |
fix: new applet to reinstall and fix package
also makes it possibly to upgrade package without adding it to
top-level deps. fixes #69.
Diffstat (limited to 'src/database.c')
-rw-r--r-- | src/database.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/src/database.c b/src/database.c index 9a09ecd7d0..804e6c4e1a 100644 --- a/src/database.c +++ b/src/database.c @@ -1425,6 +1425,7 @@ static int apk_db_install_archive_entry(void *_ctx, return -1; } + opkg = NULL; file = apk_db_file_query(db, bdir, bfile); if (file != NULL) { opkg = file->diri->pkg; @@ -1442,8 +1443,10 @@ static int apk_db_install_archive_entry(void *_ctx, } } - /* Create the file entry without adding it to hash */ - file = apk_db_file_new(diri, bfile, &ctx->file_diri_node); + if (opkg != pkg) { + /* Create the file entry without adding it to hash */ + file = apk_db_file_new(diri, bfile, &ctx->file_diri_node); + } if (apk_verbosity >= 3) apk_message("%s", ae->name); @@ -1555,7 +1558,7 @@ static void apk_db_migrate_files(struct apk_database *db, struct apk_file_info fi; struct hlist_node *dc, *dn, *fc, *fn; unsigned long hash; - char name[1024], tmpname[1024]; + char name[PATH_MAX], tmpname[PATH_MAX]; int cstype, r; hlist_for_each_entry_safe(diri, dc, dn, &pkg->owned_dirs, pkg_dirs_list) { @@ -1610,22 +1613,25 @@ static void apk_db_migrate_files(struct apk_database *db, } /* Claim ownership of the file in db */ - if (ofile != NULL) { - hlist_del(&ofile->diri_files_list, - &ofile->diri->owned_files); - apk_hash_delete_hashed(&db->installed.files, - APK_BLOB_BUF(&key), hash); - } else - db->installed.stats.files++; - - apk_hash_insert_hashed(&db->installed.files, file, hash); + if (ofile != file) { + if (ofile != NULL) { + hlist_del(&ofile->diri_files_list, + &ofile->diri->owned_files); + apk_hash_delete_hashed(&db->installed.files, + APK_BLOB_BUF(&key), hash); + } else + db->installed.stats.files++; + + apk_hash_insert_hashed(&db->installed.files, file, hash); + } } } } static int apk_db_unpack_pkg(struct apk_database *db, struct apk_package *newpkg, - int upgrade, apk_progress_cb cb, void *cb_ctx) + int upgrade, int reinstall, + apk_progress_cb cb, void *cb_ctx) { struct install_ctx ctx; struct apk_bstream *bs = NULL; @@ -1706,7 +1712,8 @@ static int apk_db_unpack_pkg(struct apk_database *db, return 0; err: - apk_db_purge_pkg(db, newpkg, ".apk-new"); + if (!reinstall) + apk_db_purge_pkg(db, newpkg, ".apk-new"); return r; } @@ -1733,14 +1740,14 @@ int apk_db_install_pkg(struct apk_database *db, /* Install the new stuff */ if (newpkg->installed_size != 0) { - r = apk_db_unpack_pkg(db, newpkg, (oldpkg != NULL), cb, cb_ctx); + r = apk_db_unpack_pkg(db, newpkg, (oldpkg != NULL), + (oldpkg == newpkg), cb, cb_ctx); if (r != 0) return r; } apk_pkg_set_state(db, newpkg, APK_PKG_INSTALLED); - - if (oldpkg != NULL) + if (oldpkg != NULL && oldpkg != newpkg) apk_db_purge_pkg(db, oldpkg, NULL); r = apk_pkg_run_script(newpkg, db->root_fd, |