Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 219733 - portage doesn't track and revert filesystem changes from pkg_* on failure
Summary: portage doesn't track and revert filesystem changes from pkg_* on failure
Status: CONFIRMED
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Core (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Portage team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-04-29 16:50 UTC by Joakim Tjernlund
Modified: 2022-03-26 05:56 UTC (History)
1 user (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joakim Tjernlund 2008-04-29 16:50:51 UTC
Doing this as a non-priv user:
 ebuild /usr/portage/x11-base/xorg-server/xorg-server-1.3.0.0-r5.ebuild unpack
gets me this:
* MesaLib-6.5.2.tar.bz2 RMD160 SHA1 SHA256 size ;-) ...                  [ ok ]
 * xorg-server-1.3.0.0.tar.bz2 RMD160 SHA1 SHA256 size ;-) ...            [ ok ]
 * checking ebuild checksums ;-) ...                                      [ ok ]
 * checking auxfile checksums ;-) ...                                     [ ok ]
 * checking miscfile checksums ;-) ...                                    [ ok ]
 * checking xorg-server-1.3.0.0.tar.bz2 ;-) ...                           [ ok ]
 * checking MesaLib-6.5.2.tar.bz2 ;-) ...                                 [ ok ]
>>> cfg-update-1.8.2-r1: You need root privileges for this mode...
 * Forcing on xorg-x11 for new enough glxtokens.h...
Switching to xorg-x11 OpenGL interface...rm: cannot remove `//etc/env.d/03opengl': Permission denied
!!! Error: Failed to remove //etc/env.d/03opengl
/usr/portage/x11-base/xorg-server/xorg-server-1.3.0.0-r5.ebuild: line 294: 18771 Killed                  eselect opengl set --impl-headers ${OPENGL_DIR}
>>> Unpacking source...
Comment 1 Donnie Berkholz (RETIRED) gentoo-dev 2008-04-30 17:43:09 UTC
Not sure I follow you ... you're using portage to emerge packages as a nonroot user? If so, I can't say it's surprising that you aren't allowed to write to arbitrary locations of the filesystem during the pkg_* ebuild phases.
Comment 2 Joakim Tjernlund 2008-04-30 20:29:30 UTC
No, I am just trying to unpack xorg-server using ebuild and it tries
to remove a file in /etc. That is not what I expected. Surely
I should be able to unpack and compile pkgs without it trying to
remove/modify stuff in /etc?
Comment 3 Donnie Berkholz (RETIRED) gentoo-dev 2008-05-02 00:39:41 UTC
Not really, no. The pkg_setup() phase runs first, and its a dependency of everything afterwards -- src_unpack(), src_compile(), etc. All pkg_* phases are allowed to touch the live filesystem as required. In this case, it has to set up eselect-opengl correctly to ensure that xorg-server actually compiles.

One thing you could try is just running the setup step as root, like this:

sudo ebuild foo.ebuild setup
ebuild foo.ebuild unpack
<stuff>
ebuild foo.ebuild compile
Comment 4 Joakim Tjernlund 2008-05-02 17:28:29 UTC
hmm, this was news to me. I figured it was safe to test stuff using
plain ebuild unpack/compile. Now you are telling me that
this can break my system as these can mess with my root FS and
even delete stuff. What is the safe way to unpack/compile
ebuilds?

Suppose emerge <a pkg> fails during compile, isn't there a chance
you end up with a broken system as the pkg may have shuffled around stuff
in /etc(or any other directory)?
Comment 5 Donnie Berkholz (RETIRED) gentoo-dev 2008-05-03 23:30:25 UTC
(In reply to comment #4)
> hmm, this was news to me. I figured it was safe to test stuff using
> plain ebuild unpack/compile. Now you are telling me that
> this can break my system as these can mess with my root FS and
> even delete stuff. What is the safe way to unpack/compile
> ebuilds?
> 
> Suppose emerge <a pkg> fails during compile, isn't there a chance
> you end up with a broken system as the pkg may have shuffled around stuff
> in /etc(or any other directory)?

Yes, you're absolutely right, there is a chance. Portage (wrongly) assumes success and makes no attempt to track filesystem changes during pkg_* phases for later reversion upon failure.

Most changes involving file deletion and such (of which there are still very few) happen during pkg_preinst and pkg_postinst, which both happen after a successful compilation, because they're needed for installation rather than for compilation. That's why in general I don't get too concerned.

If you want a guarantee, you could either implement the above Portage enhancement or do everything in a chroot.
Comment 6 Joakim Tjernlund 2008-05-05 08:35:57 UTC
ouch, I am not in a position to fix this in portage. Perhaps you
can reassign this bug to the portage herd?