Skip to content

Commit

Permalink
using ts.addReinstall for package reinstallation (RhBug:1071854)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Silhan committed Aug 27, 2014
1 parent 80a23d2 commit 516aad9
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 15 deletions.
5 changes: 0 additions & 5 deletions dnf/base.py
Expand Up @@ -1401,7 +1401,6 @@ def remove(self, pkg_spec, reponame=None):

def reinstall(self, pkg_spec, old_reponame=None, new_reponame=None,
new_reponame_neq=None, remove_na=False):
self._add_reinstall_rpm_probfilters()
subj = dnf.subject.Subject(pkg_spec)
q = subj.get_best_query(self.sack)
installed_pkgs = [
Expand Down Expand Up @@ -1540,7 +1539,6 @@ def handle_reinstall(new_nevra, old_nevra, obsoleted_nevras):
assert len(obsoleteds_) == 1
obsoleteds.append(obsoleteds_[0])
assert len(news) == 1
self._add_reinstall_rpm_probfilters()
self._transaction.add_reinstall(dnf.util.first(olds), news[0],
obsoleteds)

Expand Down Expand Up @@ -1686,6 +1684,3 @@ def _store_config_in_history(self):
myrepos += repo.dump()
myrepos += '\n'
self.history.write_addon_data('config-repos', myrepos)

def _add_reinstall_rpm_probfilters(self):
self.rpm_probfilter.add(rpm.RPMPROB_FILTER_REPLACEPKG)
1 change: 0 additions & 1 deletion dnf/cli/commands/reinstall.py
Expand Up @@ -75,7 +75,6 @@ def run(self, extcmds):
local_pkgs = map(self.base.add_remote_rpm, filenames)
results = map(self.base.package_install, local_pkgs)
done = functools.reduce(operator.or_, results, False)
self.base._add_reinstall_rpm_probfilters()

# Reinstall packages.
for pkg_spec in pkg_specs:
Expand Down
1 change: 1 addition & 0 deletions dnf/rpm/transaction.py
Expand Up @@ -25,6 +25,7 @@ def __init__(self, root='/'):
'order',
'addErase',
'addInstall',
'addReinstall',
'run',
'pgpImportPubkey',
'pgpPrtPkts',
Expand Down
6 changes: 3 additions & 3 deletions dnf/transaction.py
Expand Up @@ -182,9 +182,9 @@ def populate_rpm_ts(self, ts):
else:
ts.addInstall(hdr, tsi, 'i')
elif tsi.op_type == REINSTALL:
ts.addErase(tsi.erased.idx)
hdr = tsi.installed.header
ts.addInstall(hdr, tsi, 'i')
# note: in rpm 4.12 there should not be set
# rpm.RPMPROB_FILTER_REPLACEPKG to work
ts.addReinstall(tsi.installed.header, tsi)
elif tsi.op_type == UPGRADE:
hdr = tsi.installed.header
ts.addInstall(hdr, tsi, 'u')
Expand Down
9 changes: 5 additions & 4 deletions package/dnf.spec.in
Expand Up @@ -2,6 +2,7 @@
%global hawkey_version 0.5.0
%global librepo_version 1.7.5
%global libcomps_version 0.1.6
%global rpm_version 4.12.0

%global confdir %{_sysconfdir}/dnf

Expand All @@ -26,7 +27,7 @@ BuildRequires: python-libcomps >= %{libcomps_version}
BuildRequires: python-librepo >= %{librepo_version}
BuildRequires: python-nose
BuildRequires: python-sphinx
BuildRequires: rpm-python
BuildRequires: rpm-python >= %{rpm_version}
BuildRequires: systemd
BuildRequires: gettext
Requires: deltarpm
Expand All @@ -37,7 +38,7 @@ Requires: python-hawkey >= %{hawkey_version}
Requires: python-iniparse
Requires: python-libcomps >= %{libcomps_version}
Requires: python-librepo >= %{librepo_version}
Requires: rpm-python
Requires: rpm-python >= %{rpm_version}
Requires(post): systemd
Requires(preun): systemd
Requires(postun): systemd
Expand All @@ -56,14 +57,14 @@ BuildRequires: python3-libcomps >= %{libcomps_version}
BuildRequires: python3-librepo >= %{librepo_version}
BuildRequires: python3-nose
BuildRequires: python3-pygpgme
BuildRequires: rpm-python3
BuildRequires: rpm-python3 >= %{rpm_version}
Requires: dnf = %{version}-%{release}
Requires: python3-hawkey >= %{hawkey_version}
Requires: python3-iniparse
Requires: python3-libcomps >= %{libcomps_version}
Requires: python3-librepo >= %{librepo_version}
Requires: python3-pygpgme
Requires: rpm-python3
Requires: rpm-python3 >= %{rpm_version}

%description -n python3-dnf
Package manager forked from Yum, using libsolv as a dependency resolver.
Expand Down
3 changes: 1 addition & 2 deletions tests/test_transaction.py
Expand Up @@ -173,6 +173,5 @@ def test_filters_reinstall(self, ts):
self.base._sack = tests.support.mock_sack('main')
self.base._goal = dnf.goal.Goal(self.base.sack)
self.base.reinstall("librita")
expected = rpm.RPMPROB_FILTER_REPLACEPKG |\
rpm.rpm.RPMPROB_FILTER_OLDPACKAGE
expected = rpm.rpm.RPMPROB_FILTER_OLDPACKAGE
self.base.ts.setProbFilter.assert_called_with(expected)

0 comments on commit 516aad9

Please sign in to comment.