Skip to content

Commit

Permalink
Use actual repository ID in stored transactions
Browse files Browse the repository at this point in the history
Currently, when replaying a stored transaction, all RPM files are
placed into a single `@stored_transaction` repository. This can be
confusing, especially during a system upgrade, which also uses stored
transactions.

With this patch, local RPM files from stored transactions are
placed to the repository they originally came from.

Fixes: #1851
  • Loading branch information
m-blaha committed Feb 14, 2025
1 parent d796536 commit af91b74
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion include/libdnf5/repo/repo_sack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ class LIBDNF_API RepoSack : public sack::Sack<Repo> {
/// @param calculate_checksum Whether libsolv should calculate and store checksum of added packages. Setting to true significantly reduces performance.
/// @return Newly created rpm::Package object in cmdline repo
LIBDNF_LOCAL libdnf5::rpm::Package add_stored_transaction_package(
const std::string & path, bool calculate_checksum = false);
const std::string & path, const std::string & repo_id, bool calculate_checksum = false);

LIBDNF_LOCAL void internalize_repos();

Expand Down
4 changes: 2 additions & 2 deletions libdnf5/base/goal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,8 +791,8 @@ GoalProblem Goal::Impl::add_replay_to_goal(
std::optional<libdnf5::rpm::Package> local_pkg;
if (!package_replay.package_path.empty()) {
// Package paths are relative to replay location
local_pkg =
base->get_repo_sack()->add_stored_transaction_package(replay_location / package_replay.package_path);
local_pkg = base->get_repo_sack()->add_stored_transaction_package(
replay_location / package_replay.package_path, package_replay.repo_id);
}

const auto nevras = rpm::Nevra::parse(package_replay.nevra, {rpm::Nevra::Form::NEVRA});
Expand Down
3 changes: 3 additions & 0 deletions libdnf5/repo/repo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,9 @@ rpm::Package Repo::add_rpm_package(const std::string & path, bool with_hdrid) {
M_("Failed to load RPM \"{}\": {}"), path, std::string(pool_errstr(p_impl->solv_repo->repo->pool)));
}

// convert repo to COMMANDLINE type
p_impl->type = Repo::Type::COMMANDLINE;

p_impl->solv_repo->set_needs_internalizing();
p_impl->base->get_rpm_package_sack()->p_impl->invalidate_provides();

Expand Down
16 changes: 14 additions & 2 deletions libdnf5/repo/repo_sack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,20 @@ void RepoSack::add_stored_transaction_comps(const std::string & path) {
}


libdnf5::rpm::Package RepoSack::add_stored_transaction_package(const std::string & path, bool calculate_checksum) {
auto stored_repo = get_stored_transaction_repo();
libdnf5::rpm::Package RepoSack::add_stored_transaction_package(
const std::string & path, const std::string & repo_id, bool calculate_checksum) {
RepoWeakPtr stored_repo;
if (!repo_id.empty()) {
for (const auto & existing_repo : get_data()) {
if (existing_repo->get_id() == repo_id) {
stored_repo = existing_repo->get_weak_ptr();
break;
}
}
}
if (!stored_repo.is_valid()) {
stored_repo = get_stored_transaction_repo();
}

auto pkg = stored_repo->add_rpm_package(path, calculate_checksum);

Expand Down

0 comments on commit af91b74

Please sign in to comment.