Pacman

Historical bug tracker for the Pacman package manager.

The pacman bug tracker has moved to gitlab:
https://gitlab.archlinux.org/pacman/pacman/-/issues

This tracker remains open for interaction with historical bugs during the transition period. Any new bugs reports will be closed without further action.
Tasklist

FS#10450 - makepkg uses fakeroot even if !fakeroot is in BUILDENV

Attached to Project: Pacman
Opened by Xilon (Xilon) - Monday, 19 May 2008, 15:22 GMT
Last edited by Dan McGee (toofishes) - Saturday, 31 May 2008, 13:11 GMT
Task Type Bug Report
Category General
Status Closed
Assigned To Xavier (shining)
Dan McGee (toofishes)
Architecture All
Severity Low
Priority Normal
Reported Version 3.1.3
Due in Version 3.2.0
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

Summary and Info:
I'm not sure if it makes sense or not to disable fakeroot, but there is an option to do so, and makepkg should respect it. Even with "!fakeroot" (or just the lack of fakeroot) in BUILDENV, fakeroot is called when packaging:

$ makepkg
==> WARNING: Running makepkg as an unprivileged user will result in non-root
ownership of the packaged files. Try using the fakeroot environment by
placing 'fakeroot' in the BUILDENV array in makepkg.conf.
==> Making package: test 1-1 (Mon 19 May 2008 22:56:00 WST)
==> Checking Runtime Dependencies...
==> Checking Buildtime Dependencies...
==> Retrieving Sources...
==> Validating source files with md5sums...
==> Extracting Sources...
==> Removing existing pkg/ directory...
==> Entering fakeroot environment...
/usr/local/bin/makepkg: line 1509: fakeroot: command not found

If fakeroot is really required for makepkg to function, then the option should be removed.

Looking at the code, it appears that it will be fine if the user is root, but I was unable to test it. makepkg errors out when running it as root without --asroot. Running makepkg with --asroot does not appear to work either. The fact that being root is required should be documented. The warning given seems to imply that building the package as an unprivileged user is possible, but this does not appear to be the case. I suggest that if makepkg is run without fakeroot in BUILDENV, and the user does not have root privaleges, makepkg should output an error stating that root, and the --asroot argument, is required.

$ sudo makepkg --asroot
==> ERROR: Running makepkg as root is a BAD idea and can cause
permanent, catastrophic damage to your system. If you
wish to run as root, please use the --asroot option.

I don't understand why this still occurs, since $EUID is 0 and --asroot is is specified. Running it on Archlinux seems to work, but I am testing this on Mac OS X 10.5.
After further investigation, it appears that no command line arguments work on OS X, they are simply ignored (even running makepkg --help is just like running makepkg by itself). This is getting a bit off topic of the original bug report.

Steps to Reproduce:
- Remove "fakeroot" (ore prefix with !) from the BUILDENV array in makepkg.conf
- Attempt creating a package without the fakeroot binary available.
This task depends upon

Closed by  Dan McGee (toofishes)
Saturday, 31 May 2008, 13:11 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed in commit b9369a747d0c2fa3ee8371f99f5ca7acbc89f7f9 in master
Comment by Xavier (shining) - Monday, 19 May 2008, 18:29 GMT
Wow that is crazy, I discovered that issue exactly today. I look at the bug tracker this evening and there it is. Incredible :)
I was trying to run makepkg on cygwin, where I am not root, and don't have fakeroot either. So I ran into the same issue.
I am not sure how to handle it.
Comment by Xilon (Xilon) - Monday, 19 May 2008, 18:44 GMT
After some tweaking of makepkg, I got it to work using "sudo makepkg --asroot". I think root is required for building a package, though I may be wrong. Afaik without fakeroot running the equivalent of "make install" wouldn't work without being root, or running sudo. So the possibility of running makepkg as user when building the package should be removed, imo. Obviously it's ok to generate checksums, etc, as a normal user.

Basically I think the real error here is that there's a warning shown, instead of an error.
Comment by Xavier (shining) - Monday, 19 May 2008, 18:47 GMT
Why shouldn't it be possible to run make install as user, as long as the destination directory is writable by user?
I think that should work. The problem is that all permissions will be wrong, the files will be owned by user instead of root.
Comment by Dan McGee (toofishes) - Tuesday, 20 May 2008, 20:02 GMT
Even if it is not at all advisable to run makepkg as either non-root or without fakeroot due to ownership issues, we should allow it as this could be useful for packaging your home directory or even a test harness somewhere where fakeroot is not available. So we should respect this BUILDENV setting as much as possible, even though we know any resultant packages are going to be most likely broken.
Comment by Xilon (Xilon) - Wednesday, 21 May 2008, 11:49 GMT
I agree, but at the moment it seems BUILDENV isn't respected when creating the package:

if [ $EUID -eq 0 ]; then
# SNIP
else
msg "$(gettext "Entering fakeroot environment...")"

if [ "$newpkgver" != "" ]; then
fakeroot -- $0 --forcever $newpkgver -F $ARGLIST || exit $?
else
fakeroot -- $0 -F $ARGLIST || exit $?
fi
fi

As an unprevilaged user without fakeroot installed, it's not possible to create a package. Now looking at the output of running makepkg as an unprivileged user, one would think that it's ok, since only a warning is printed, but fakeroot is called either way. As far as I can tell it would be possible to simply test if fakeroot is not in BUILDENV and attempt to build the package, then just call the normal run_build, tidy_install, create_package sequence. If it fails, that's up to the user.
Comment by Xavier (shining) - Wednesday, 21 May 2008, 12:11 GMT
What Dan meant is that patches are welcome for respecting that BUILDENV setting :)

Based on what you said, I think it makes more sense to change the following test :
if [ $EUID -eq 0 ]; then
to :
if [ "$(check_buildenv fakeroot)" = "n" -o $EUID -eq 0 ]; then

If that is what you meant, testing that change and submitting a git patch either here or on pacman-dev ML would greatly help.
Comment by Xavier (shining) - Monday, 26 May 2008, 23:04 GMT
ping :)
Can I merge this?
Comment by Xilon (Xilon) - Tuesday, 27 May 2008, 06:47 GMT
Works fine for me (tested on Archilnux and OSX). One small change from the code you provided, I test that fakeroot isn't enabled ("$(check_buildenv fakeroot)" != "y") instead of checking that it's disabled, since it may not be in BUILD_ENV at all (check_buildenv returns "?"). Patch is attatched
Comment by Aaron Griffin (phrakture) - Tuesday, 27 May 2008, 20:26 GMT
pong. I vote yes.
Comment by Xavier (shining) - Wednesday, 28 May 2008, 08:06 GMT
I made my own patch there :
http://shining.toofishes.net/gitweb/gitweb.cgi?p=pacman.git;a=commitdiff;h=d5c991f5a69e308df5cf2ef34b85ce4e1d7a1aeb
I wanted to replace it by Xilon's one which has a better handling of the option and better comment (minus typos).
I wanted to do this yesterday evening but the wifi is currently dead..

Loading...