Opened 6 years ago

Last modified 6 years ago

#57894 reopened defect

Guide: Document required permissions for local repos

Reported by: toki07 (jotl) Owned by:
Priority: Normal Milestone:
Component: guide Version:
Keywords: Cc:
Port:

Description

Hello,

I'm trying to use macports and ports from git sources. I have followed the instructions from the manual, but it doesn't work.

The port macports-base compiles well, but it is impossible to install any port as root (as well as user). I have an error message.

  • As sudo : "Error: Unable to execute port: Could not open file: macports-ports/sysutils/coreutils/Portfile"
  • As user : "Error: Insufficient privileges to write to MacPorts install prefix."

I need to chown the macports-base tree to the user who is running the port, and then most of them can compile, but only as user, and not as root.

sudo chown -R $UID:$GROUPS $MACPORTS_DIR/macports-base
sudo chown -R $UID:$GROUPS $MACPORTS_DIR/macports-ports

Some of ports still need to have root access, and cannot be installed (eg libnetpbm) and then cannot be installed.

The error message is : "Error: Failed to destroot libnetpbm: command execution failed"

Note that this seems to work if instead of using a subdir of $HOME as root for projects, a subdir of /tmp is used to build the ports.

Here is a script that simulates the test cases.

Regards, Joel

MACPORTS_DIR=$HOME/macports/WORK

mkdir -p $MACPORTS_DIR
chmod 755 $MACPORTS_DIR
cd $MACPORTS_DIR
git clone --depth 1 --branch v2.5.4 https://github.com/macports/macports-base.git
git clone --depth 1 --branch master https://github.com/macports/macports-ports.git

# Adapting to use local ports (replacing rsync:// and file:// in sources with file://$MACPORTS_DIR/macports-ports)
find $MACPORTS_DIR/macports-base -name 'sources.conf' -exec /usr/bin/sed -i '' -E 's/^(rsync|file)(.*)$/#\1\2/' {} \;
find $MACPORTS_DIR/macports-base -name 'sources.conf' -exec sh -c "echo 'file://$MACPORTS_DIR/macports-ports [default]' >> {}" \;

# Building base ports
cd $MACPORTS_DIR/macports-base
export PATH=/bin:/sbin:/usr/bin:/usr/sbin
mkdir -p $MACPORTS_DIR/macports-base/Applications
./configure --enable-readline --prefix=$MACPORTS_DIR/macports-base --with-applications-dir=$MACPORTS_DIR/macports-base/Applications --without-startupitems
make -j8

# make install needs sudo, but it changes owner to root on installed files
sudo make install
sudo make distclean

export PATH=$MACPORTS_DIR/macports-base:$MACPORTS_DIR/macports-base/bin:$MACPORTS_DIR/macports-base/sbin:$PATH
cd $MACPORTS_DIR/macports-ports
$MACPORTS_DIR/macports-base/bin/portindex

# Failure when installing as sudo
sudo $MACPORTS_DIR/macports-base/bin/port install -vd coreutils
sudo $MACPORTS_DIR/macports-base/bin/port install -vd libnetpbm

sudo chown -R $UID:$GROUPS $MACPORTS_DIR/macports-base
sudo chown -R $UID:$GROUPS $MACPORTS_DIR/macports-ports

# After chown done, some ports can build, but not when sudo access is needed
$MACPORTS_DIR/macports-base/bin/port install -vd coreutils
$MACPORTS_DIR/macports-base/bin/port install -vd libnetpbm

Change History (3)

comment:1 Changed 6 years ago by mf2k (Frank Schima)

Resolution: invalid
Status: newclosed

Note that Trac is not for tech support. Post on the Macports-Users mailing list, which has a much larger audience, instead.

comment:2 Changed 6 years ago by jmroot (Joshua Root)

Component: baseguide
Resolution: invalid
Status: closedreopened
Summary: Unable to install ports from git source as root : Could not open fileGuide: Document required permissions for local repos
Version: 2.5.4

MacPorts is working as intended, but the documentation should mention that the ports tree needs to be readable by the macports user.

comment:3 Changed 6 years ago by toki07 (jotl)

I think I have been misunderstood :

Before chown the whole tree to user :

  • As root, the port tree is readable (root has all rights), but the process gives an error (Could not open file: .../Portfile)
  • As user, the port tree is readable (I have made a chmod 755 to the macports tree), but I have an error (Insufficient privileges)

After chown :

  • As root, it is impossible to install anything (Could not open file: .../Portfile)
  • As user, it is impossible to install some ports, when root access is needed
Last edited 6 years ago by toki07 (jotl) (previous) (diff)
Note: See TracTickets for help on using tickets.