Unable to install ports from git source as root : Could not open file

Joël Tourscher joel.tourscher at gmail.com
Sat Jan 12 19:50:05 UTC 2019


Hello,

I'm trying to use macports and ports from git sources. I have followed 
the instructions from the 
[https://guide.macports.org/#installing.macports.git 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

https://trac.macports.org/ticket/57894


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



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macports.org/pipermail/macports-users/attachments/20190112/28a9f618/attachment.html>


More information about the macports-users mailing list