<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<p><tt>Hello, </tt><tt><br>
</tt><tt><br>
</tt><tt>I'm trying to use macports and ports from git sources. I
have followed the instructions from the
[<a class="moz-txt-link-freetext" href="https://guide.macports.org/#installing.macports.git">https://guide.macports.org/#installing.macports.git</a> manual],
but it doesn't work.</tt><tt><br>
</tt><tt><br>
</tt><tt>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.</tt><tt><br>
</tt><tt> - As sudo : <i>"Error: Unable to execute port: Could
not open file: macports-ports/sysutils/coreutils/Portfile"</i></tt><tt><br>
</tt><tt> - As user : <i>"Error: Insufficient privileges to write
to MacPorts install prefix."</i></tt><tt><br>
</tt><tt><br>
</tt><tt>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.</tt><tt><br>
</tt><font size="-1"><font color="#000099"><tt> sudo chown -R
$UID:$GROUPS $MACPORTS_DIR/macports-base</tt><tt><br>
</tt><tt> sudo chown -R $UID:$GROUPS
$MACPORTS_DIR/macports-ports</tt></font><tt><br>
</tt></font><tt><br>
</tt><tt><br>
</tt><tt>Some of ports still need to have root access, and cannot
be installed (eg libnetpbm) and then cannot be installed.</tt><tt><br>
</tt><tt><br>
</tt><tt>The error message is : <i>"Error: Failed to destroot
libnetpbm: command execution failed"</i></tt><tt><br>
</tt><tt><br>
</tt><tt>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.</tt><tt><br>
</tt><tt><br>
</tt><tt>Here is a script that simulates the test cases.</tt><tt><br>
</tt><tt><br>
</tt><tt>Regards, Joel</tt></p>
<p><tt><a class="moz-txt-link-freetext" href="https://trac.macports.org/ticket/57894">https://trac.macports.org/ticket/57894</a></tt></p>
<p><tt></tt><tt> </tt><tt><br>
</tt><font size="-1" color="#000099"><tt>MACPORTS_DIR=$HOME/macports/WORK</tt><tt><br>
</tt><tt><br>
</tt><tt>mkdir -p $MACPORTS_DIR</tt><tt><br>
</tt><tt>chmod 755 $MACPORTS_DIR</tt><tt><br>
</tt><tt>cd $MACPORTS_DIR</tt><tt><br>
</tt><tt>git clone --depth 1 --branch v2.5.4
<a class="moz-txt-link-freetext" href="https://github.com/macports/macports-base.git">https://github.com/macports/macports-base.git</a></tt><tt><br>
</tt><tt>git clone --depth 1 --branch master
<a class="moz-txt-link-freetext" href="https://github.com/macports/macports-ports.git">https://github.com/macports/macports-ports.git</a></tt><tt><br>
</tt><tt><br>
</tt><tt># Adapting to use local ports (replacing rsync:// and
<a class="moz-txt-link-freetext" href="file://">file://</a> in sources with <a class="moz-txt-link-freetext" href="file://$MACPORTS_DIR/macports-ports">file://$MACPORTS_DIR/macports-ports</a>)</tt><tt><br>
</tt><tt>find $MACPORTS_DIR/macports-base -name 'sources.conf'
-exec /usr/bin/sed -i '' -E 's/^(rsync|file)(.*)$/#\1\2/' {}
\;</tt><tt><br>
</tt><tt>find $MACPORTS_DIR/macports-base -name 'sources.conf'
-exec sh -c "echo '<a class="moz-txt-link-freetext" href="file://$MACPORTS_DIR/macports-ports">file://$MACPORTS_DIR/macports-ports</a>
[default]' >> {}" \;</tt><tt><br>
</tt><tt><br>
</tt><tt># Building base ports</tt><tt><br>
</tt><tt>cd $MACPORTS_DIR/macports-base</tt><tt><br>
</tt><tt>export PATH=/bin:/sbin:/usr/bin:/usr/sbin</tt><tt><br>
</tt><tt>mkdir -p $MACPORTS_DIR/macports-base/Applications</tt><tt><br>
</tt><tt>./configure --enable-readline
--prefix=$MACPORTS_DIR/macports-base
--with-applications-dir=$MACPORTS_DIR/macports-base/Applications
--without-startupitems</tt><tt><br>
</tt><tt>make -j8</tt><tt><br>
</tt><tt><br>
</tt><tt># make install needs sudo, but it changes owner to root
on installed files</tt><tt><br>
</tt><tt>sudo make install</tt><tt><br>
</tt><tt>sudo make distclean</tt><tt><br>
</tt><tt><br>
</tt><tt>export
PATH=$MACPORTS_DIR/macports-base:$MACPORTS_DIR/macports-base/bin:$MACPORTS_DIR/macports-base/sbin:$PATH</tt><tt><br>
</tt><tt>cd $MACPORTS_DIR/macports-ports</tt><tt><br>
</tt><tt>$MACPORTS_DIR/macports-base/bin/portindex</tt><tt><br>
</tt><tt><br>
</tt><tt># Failure when installing as sudo</tt><tt><br>
</tt><tt>sudo $MACPORTS_DIR/macports-base/bin/port install -vd
coreutils</tt><tt><br>
</tt><tt>sudo $MACPORTS_DIR/macports-base/bin/port install -vd
libnetpbm</tt><tt><br>
</tt><tt><br>
</tt><tt>sudo chown -R $UID:$GROUPS $MACPORTS_DIR/macports-base</tt><tt><br>
</tt><tt>sudo chown -R $UID:$GROUPS $MACPORTS_DIR/macports-ports</tt><tt><br>
</tt><tt><br>
</tt><tt># After chown done, some ports can build, but not when
sudo access is needed</tt><tt><br>
</tt><tt>$MACPORTS_DIR/macports-base/bin/port install -vd
coreutils</tt><tt><br>
</tt><tt>$MACPORTS_DIR/macports-base/bin/port install -vd
libnetpbm</tt><tt><br>
</tt></font><tt><br>
</tt><tt><br>
</tt><tt><br>
</tt></p>
</body>
</html>