Bug 106613 - Installation of misc/ldconfig_compat as non-root on freebsd < 600101 but > 500037 does not respect $PREFIX env var
Summary: Installation of misc/ldconfig_compat as non-root on freebsd < 600101 but > 50...
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Port Management Team
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-12-11 19:10 UTC by boelaars
Modified: 2007-10-03 23:30 UTC (History)
0 users

See Also:


Attachments
file.diff (603 bytes, patch)
2006-12-11 19:10 UTC, boelaars
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description boelaars 2006-12-11 19:10:03 UTC
The Makefile for misc/ldconfig_compat does not respect the $PREFIX env variable when installing this port on freebsd with OSVERSION less than 600101 but greater than 500037, and thus fails to install for non-root users, as shown in the following output:


===== CONSOLE OUTPUT START =====
===>  Installing for ldconfig_compat-1.0_8
===>   Generating temporary packing list
===>  Checking if misc/ldconfig_compat already installed
Warning: not superuser, you may get some errors during installation.
Warning: not superuser, can't run mtree.
You may want to become root and try again to ensure correct permissions.
install: /etc/rc.d/ldconfig_compat: Permission denied
*** Error code 71

Stop in /home/users/whiter/ports/misc/ldconfig_compat.
===== CONSOLE OUTPUT END =====


The error is in the following code in the Makefile:

===== MAKEFILE SNIPPET START =====
do-install:
.if ${OSVERSION} >= 600101
        @${INSTALL_SCRIPT} ${WRKDIR}/ldconfig_compat.sh ${PREFIX}/etc/rc.d/ldconfig_compat
        @${ECHO_CMD} "etc/rc.d/ldconfig_compat" >> ${TMPPLIST}
.elif ${OSVERSION} >= 500037
        @${INSTALL_SCRIPT} ${WRKDIR}/ldconfig_compat.sh /etc/rc.d/ldconfig_compat
        @${ECHO_CMD} "@cwd /" >> ${TMPPLIST}
        @${ECHO_CMD} "etc/rc.d/ldconfig_compat" >> ${TMPPLIST}
.else
        @${INSTALL_SCRIPT} ${WRKDIR}/ldconfig_compat.sh ${PREFIX}/etc/rc.d/000.ldconfig_compat.sh
        @${ECHO_CMD} "etc/rc.d/000.ldconfig_compat.sh" >> ${TMPPLIST}
.endif
===== MAKEFILE SNIPPET START =====

As can be seen, $PREFIX is not used when jumping into the ".elif ${OSVERSION} >= 500037" block, resulting in the crash.

Fix: Apply the following patch:
How-To-Repeat: Set your env to contain everything as pasted below, and do a make install in the mist/ldconfig_compat ports folder. (For more information read the article on ports as non root on my website at http://www.white-russian.nl/?page=/blog/2006/07/installing_free.html )

# Set the main path to include the apps in our homedir
PATH=${HOME}/apps/bin:${HOME}/apps/sbin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin; export PATH;

# Set the different variables that define where packages are installed
LOCALBASE=${HOME}/apps
X11BASE=${LOCALBASE}
PREFIX=${LOCALBASE}

# Set the paths to the folders the ports mechanism works in:
WRKDIR=${HOME}/tmp
PKG_DBDIR=${LOCALBASE}/var/db/pkg
PORT_DBDIR=${LOCALBASE}/var/db/ports
DISTDIR=${HOME}/distfiles

# Set user and group variables to ourself
BINOWN=`whoami`
BINGRP=`id -G -n ${BINOWN}`
SHAREOWN=${BINOWN}
SHAREGRP=${BINGRP}
MANOWN=${BINOWN}
MANGRP=${BINGRP}

# Make sure we don't really try to become root, but just execute everything as ourselves
SU_CMD="sh -c"

# Make sure that the main ports folder is checked for distfiles first, saving on download time
CD_MOUNTPTS=/usr

# If distfile found in $CD_MOUNTPTS, symlink to it, instead of copy
FETCH_SYMLINK_DISTFILES=YES

# Make sure the systemdefault make.conf is not read
__MAKE_CONF=${LOCALBASE}/etc/make.conf

# Do not try to chown files to root or other users
INSTALL_AS_USER=true

# Keep our own version of ldconfig hints
LDCONFIG="/sbin/ldconfig -i -f ${LOCALBASE}/var/run/ld-elf.so.hints"

# Set application specific variables to make sure it doesn't pick up things from the main system
APXS=${LOCALBASE}/sbin/apxs
PERL=${LOCALBASE}/bin/perl
PERL5=${PERL}
SITE_PERL=${LOCALBASE}/lib/perl5/site_perl/5.8.8
SITE_PERL5=${SITE_PERL}
PERL_VERSION=5.8.8
PERL_VER=${PERL_VERSION}
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2006-12-11 19:12:40 UTC
Responsible Changed
From-To: freebsd-ports-bugs->flz

Over to maintainer
Comment 2 Florent Thoumie freebsd_committer freebsd_triage 2007-01-02 21:55:02 UTC
State Changed
From-To: open->closed

ldconfig_compat isn't meant to be installed as unprivileged user. 
Installing the rc.d script in ${PREFIX}/etc/rc.d doesn't make sense 
here since it's supposed to be run early in the boot sequence. 
I could make a special case for INSTALL_AS_USER but I don't quite see 
the point. 

I'm closing the PR but willing to re-open it eventually.
Comment 3 boelaars 2007-01-02 22:13:47 UTC
I suggest reopening this case, because:

misc/ldconfig_compat is a dependency for (for example, in my case) the
following packages:

freetype2-2.2.1_1
lcms-1.15_1,1
libiconv-1.9.2_2
libxml2-2.6.26
mysql-client-5.0.27
p5-DBD-mysql50-3.0003
db42-4.2.52_5

which a non-root user might very well want to install.

If misc/ldconfig_compat install fails (like it does now) installation of
those other ports is impossible.
Comment 4 Florent Thoumie freebsd_committer freebsd_triage 2007-01-02 22:58:08 UTC
State Changed
From-To: closed->suspended

Re-open, will work on a fix.
Comment 5 Florent Thoumie freebsd_committer freebsd_triage 2007-04-13 13:01:39 UTC
State Changed
From-To: suspended->analyzed

I think USE_LDCONFIG should not depend on ldconfig_compat when 
INSTALL_AS_USER is defined. I'll send a patch to discuss/fix this.
Comment 6 Florent Thoumie 2007-04-19 13:42:14 UTC
I think this should fix the issue:

http://people.freebsd.org/~flz/local/ports/use-ldconfig-user.diff

Basically, if INSTALL_AS_USER is defined, we don't depend on
ldconfig_compat and we don't install any file in libdata/ldconfig{,32}.

Does this work for you?

-- 
Florent Thoumie
flz@FreeBSD.org
FreeBSD Committer
Comment 7 Florent Thoumie freebsd_committer freebsd_triage 2007-04-19 13:43:03 UTC
Responsible Changed
From-To: flz->portmgr

Over to portmgr since it's touching bsd.port.mk.
Comment 8 Pav Lucistnik freebsd_committer freebsd_triage 2007-10-03 23:22:36 UTC
State Changed
From-To: analyzed->closed

flz's patch was committed
Comment 9 dfilter service freebsd_committer freebsd_triage 2007-10-03 23:25:06 UTC
pav         2007-10-03 22:25:00 UTC

  FreeBSD ports repository

  Modified files:
    Mk                   bsd.port.mk bsd.xorg.mk 
  Log:
  - Fix issues with actual-package-depends, most notably fix bad list when a
    third party package with invalid or missing pkgorigin is installed; this
    resulted in silently discarding dependency records for some people
  
  PR:             ports/115010
  Submitted by:   netchild
  
  - Replace some calls to basename and dirname with make logic
  
  PR:             ports/115994
  Submitted by:   netchild
  
  - Fix bsd.xorg.mk to work when USE_XORG is used below
    .include <bsd.port.pre.mk>; should allow conditional X.Org component
    dependencies with OPTIONS, etc
  
  Submitted by:   flz
  
  - When installing as user, don't install any libdata/ldconfig entries
  
  Submitted by:   flz
  PR:             ports/106613 (in audit trail)
  
  - Introduce INSTALL_KLD; it's same as INSTALL_SCRIPT but the name is more
    obvious
  
  PR:             ports/116200
  Submitted by:   edwin
  
  Revision  Changes    Path
  1.588     +44 -26    ports/Mk/bsd.port.mk
  1.4       +11 -5     ports/Mk/bsd.xorg.mk
_______________________________________________
cvs-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/cvs-all
To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"