Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 168772 - Portage (successfully?) trying to delete files on a read only file system
Summary: Portage (successfully?) trying to delete files on a read only file system
Status: RESOLVED FIXED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core - Interface (emerge) (show other bugs)
Hardware: x86 Linux
: High major (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords: InVCS
Depends on:
Blocks: 194041
  Show dependency tree
 
Reported: 2007-02-28 18:21 UTC by Mrugesh Karnik
Modified: 2007-09-29 07:47 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
app-misc/rofs-bug-demo-0.1.ebuild (rofs-bug-demo-0.1.ebuild,514 bytes, text/plain)
2007-05-12 02:47 UTC, Ron Gemeinhardt (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mrugesh Karnik 2007-02-28 18:21:28 UTC
Hi,

I ran an emerge --depclean. That went smoothly. Later I found that /usr was mounted ro at the time. Basically, portage told me that it was removing all those files from the system, when it actually didn't happen because /usr was mounted read only.

Reproducible: Always

Steps to Reproduce:
1. Mount /usr read only.
2. Unmerge a package that installs its files in /usr.

Actual Results:  
Portage told me that it was removing the files, when it couldn't actually do it because /usr was ro. Portage didn't recognise that the files weren't actually deleted and assumed that the unmerge was successful.

Expected Results:  
Portage should actually notice if the files its trying to remove are actually removed from the disk. I think it should also notice that it is trying to remove a file on a read only filesystem.
Comment 1 Andrew Gaffney (RETIRED) gentoo-dev 2007-02-28 19:20:27 UTC
What exactly is it supposed to do if it realizes in the middle of an unmerge that 1 file can't be deleted? You can't really abort an unmerge in the middle.
Comment 2 Zac Medico gentoo-dev 2007-02-28 20:04:37 UTC
(In reply to comment #1)
> What exactly is it supposed to do if it realizes in the middle of an unmerge
> that 1 file can't be deleted? You can't really abort an unmerge in the middle.

Well, emerge will abort if pkg_postrm() fails, for example.  I suppose we can do the same if an OSError occurs when trying to unlink a file.  Then, at least the user will have an opportunity to retry the unmerge.
Comment 3 Mrugesh Karnik 2007-03-06 16:33:44 UTC
!!! Cannot write to '/usr'.
!!! Please check permissions and directories for broken symlinks.
!!! You may start the merge process again by using ebuild:
!!! ebuild /usr/portage/app-text/nopaste/nopaste-1992.ebuild merge
!!! And finish by running this: env-update

If that happens while installing a package, why can't it happen while uninstalling it?  And no, portage shouldn't stop after deleting a few files and leaving the package in a chaotic state, but it should at least warn the user or something. Maybe keep available the list of files not removed, due to an error, so the user doesn't have emerge and then unmerge the package again. I had to remerge 63 packages and then unmerge them to recover all the wasted hard disk space.
Comment 4 Ron Gemeinhardt (RETIRED) gentoo-dev 2007-05-12 02:42:57 UTC
I was about to report this when I remembered I need to search first.... :-)

The unlink(2) system call sets a specific error code (EROFS) when requested to unlink a file on a read-only filesystem.  Portage could perhaps check for this result, as distinguished from harmless errors (file not found, etc.) and abort the unmerge with a message similar to that cited in comment #3.  This would squash the nasty part of this bug: removal of a package from the database while its contents remain on the live filesystem.

Speaking as a user, this is behavior I would understand and desire.  I wouldn't mind if Portage left a package half-cleaned, provided: 1) it didn't uninstall such a package from the database. and 2) it gracefully continued past already-cleaned files on subsequent unmerge attempts.  At least this way, a record of any cruft would still exist on the system, in /var/db/pkg/${package}/CONTENTS.

I will attach a simple ebuild I slapped together to verify this as a bug; perhaps it will be useful. To use:

1. Install the ebuild in an overlay.
2. Make a small filesystem (1MB on a loopback is more than plenty) and mount it read-write at /mnt.
3. ACCEPT_KEYWORDS="~x86" emerge -1a rofs-bug-demo
4. Note the file installed to /mnt.
5. mount -o remount,ro /mnt
6. emerge -C rofs-bug-demo
7. ls /mnt -- you will see the installed file still exists
8. emerge -s rofs-bug-demo -- Portage claims the package is not installed.
Comment 5 Ron Gemeinhardt (RETIRED) gentoo-dev 2007-05-12 02:47:53 UTC
Created attachment 118959 [details]
app-misc/rofs-bug-demo-0.1.ebuild

Installs a single file under /mnt.  Unmerge it with /mnt mounted RO to reproduce this bug.
Comment 6 Zac Medico gentoo-dev 2007-09-24 23:28:13 UTC
In svn r7804 it's fixed so that it will only ignore some specific exceptions.
Comment 7 Zac Medico gentoo-dev 2007-09-28 00:08:37 UTC
This has been released in 3.1.3.10.
Comment 8 Alec Warner (RETIRED) archtester gentoo-dev Security 2007-09-29 07:47:54 UTC
(In reply to comment #7)
> This has been released in 3.1.3.10.
> 

I pray you meant 2.1.3.10, as I don't recall jumping an entire version ahead ;)