Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1186948 - [download] data loss: dnf download should not delete files from local repositories
Summary: [download] data loss: dnf download should not delete files from local reposit...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf-plugins-core
Version: rawhide
Hardware: Unspecified
OS: Unspecified
low
unspecified
Target Milestone: ---
Assignee: Packaging Maintenance Team
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: TRACKER-bugs-affecting-libguestfs supermin-dnf
TreeView+ depends on / blocked
 
Reported: 2015-01-28 23:13 UTC by Igor Gnatenko
Modified: 2015-05-21 13:02 UTC (History)
10 users (show)

Fixed In Version: dnf-plugins-core-0.1.7-1.fc22
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2015-05-08 07:27:37 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 965114 0 unspecified CLOSED When running dnf using file:/// as the media, it tries to erase packages in file:/// 2022-05-16 11:32:56 UTC

Internal Links: 965114

Description Igor Gnatenko 2015-01-28 23:13:33 UTC
I have repository on my local filesystem and `dnf download` crashing with OSError because it's not downloading pkg and trying to move pkg.

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/dnf/cli/main.py", line 134, in _main
    cli.run()
  File "/usr/lib/python2.7/site-packages/dnf/cli/cli.py", line 1059, in run
    return self.command.run(self.base.extcmds)
  File "/usr/lib/python2.7/site-packages/dnf-plugins/download.py", line 94, in run
    map(move, locations)
  File "/usr/lib/python2.7/site-packages/dnf-plugins/download.py", line 196, in _move_package
    os.unlink(location)
OSError: [Errno 13] Permission denied: '/var/lib/dnf/plugins/local/bc-1.06.95-13.fc22.x86_64.rpm'

Comment 1 Honza Silhan 2015-02-02 10:11:47 UTC
Hi Igor, what was your $PWD? Does it work with root access?

Comment 2 Igor Gnatenko 2015-02-03 16:10:26 UTC
(In reply to Jan Silhan from comment #1)
> Hi Igor, what was your $PWD? Does it work with root access?
$PWD = ~/

yes, it works with root access, because it's copying rpm file from local repo (only-root-rw) and removing rpm from local repo.

it's need to be fixed in code while we checking from what repo we are downloading package and repo url =~ file://.* - don't do os.unlink()

Comment 3 Honza Silhan 2015-02-13 11:03:10 UTC
Igor, if you already know how to fix this, make a PR, please. Otherwise I am giving it a low prio.

Comment 4 Jaroslav Reznik 2015-03-03 16:47:24 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 22 development cycle.
Changing version to '22'.

More information and reason for this action is here:
https://fedoraproject.org/wiki/Fedora_Program_Management/HouseKeeping/Fedora22

Comment 5 Richard W.M. Jones 2015-04-10 17:56:42 UTC
I was just filing a bug about this, but discovered this one.

*NB* all the following commands are executed as non-root.

Create a local repository:

mkdir /tmp/repo
cd /tmp/repo
dnf download bash
createrepo .
ls -l

Observe that the local repo contains a bash-*.rpm file and the
repodata/ subdirectory.

Create a yum.conf pointing to the local repository:

mkdir /tmp/download
cd /tmp/download
cat > yum.conf <<'EOF'
[main]
cachedir=/var/cache/yum
debuglevel=1
logfile=/var/log/yum.log
retries=20
obsoletes=1
gpgcheck=0
assumeyes=1
reposdir=/dev/null

[local]
name=local
baseurl=file:///tmp/repo
failovermethod=priority
enabled=1
gpgcheck=0
EOF

Now download files using the local repository:

cd /tmp/download
dnf download -v -c yum.conf bash

The 'dnf download' command works -- that is not the issue.  However
go and look back in the /tmp/repo directory.  The dnf command has
deleted the original RPM in the local repository!

Version-Release number of selected component (if applicable):

dnf-0.6.5-1.fc23.noarch

Comment 6 Richard W.M. Jones 2015-04-10 17:57:50 UTC
(In reply to Jan Silhan from comment #3)
> Igor, if you already know how to fix this, make a PR, please. Otherwise I am
> giving it a low prio.

What is a PR?  IMO this is a very serious bug.  dnf download
should not touch original repositories.

Comment 7 Radek Holy 2015-04-13 07:41:48 UTC
Moreover, I think that the plugin should not *move* the files, it should be enough to *copy* them since dnf.Base takes care of removing the packages downloaded using "download_packages" and it already tests whether they were really downloaded or whether they are available in a local repository.

Comment 8 Michael Mráka 2015-04-14 08:40:32 UTC
Fixed in
https://github.com/rpm-software-management/dnf-plugins-core/pull/82

Comment 9 Richard W.M. Jones 2015-04-14 09:00:37 UTC
I applied your test patch to dnf-plugins-core, and I can confirm that
it fixes the case outlined in comment 5.

Comment 10 Fedora Update System 2015-05-02 13:49:59 UTC
dnf-plugins-core-0.1.7-1.fc22,hawkey-0.5.5-1.fc22,dnf-1.0.0-1.fc22 has been submitted as an update for Fedora 22.
https://admin.fedoraproject.org/updates/dnf-plugins-core-0.1.7-1.fc22,hawkey-0.5.5-1.fc22,dnf-1.0.0-1.fc22

Comment 11 Fedora Update System 2015-05-03 17:24:53 UTC
Package dnf-plugins-core-0.1.7-1.fc22, hawkey-0.5.5-1.fc22, dnf-1.0.0-1.fc22:
* should fix your issue,
* was pushed to the Fedora 22 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-plugins-core-0.1.7-1.fc22 hawkey-0.5.5-1.fc22 dnf-1.0.0-1.fc22'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2015-7483/dnf-plugins-core-0.1.7-1.fc22,hawkey-0.5.5-1.fc22,dnf-1.0.0-1.fc22
then log in and leave karma (feedback).

Comment 12 Fedora Update System 2015-05-08 07:27:37 UTC
dnf-plugins-core-0.1.7-1.fc22, hawkey-0.5.5-1.fc22, dnf-1.0.0-1.fc22 has been pushed to the Fedora 22 stable repository.  If problems still persist, please make note of it in this bug report.

Comment 13 Richard W.M. Jones 2015-05-21 13:02:40 UTC
Can confirm this is fixed in
dnf-plugins-core-0.1.8-1.fc23.noarch


Note You need to log in before you can comment on or make changes to this bug.