Subject: Re: about pkg_path
To: Johnny C. Lam <jlam@pkgsrc.org>
From: Rui-Xiang Guo <rxg@myrealbox.com>
List: tech-pkg
Date: 01/31/2006 02:38:41
On Sat, Jan 28, 2006 at 10:34:29PM +0000, Johnny C. Lam wrote:
> On Sat, Jan 28, 2006 at 01:20:24PM +0800, Rui-Xiang Guo wrote:
> > Index: pkg_path
> > ===================================================================
> > RCS file: /cvsroot/pkgsrc/mk/scripts/pkg_path,v
> > retrieving revision 1.3
> > diff -b -u -r1.3 pkg_path
> > --- pkg_path    23 Jan 2006 18:38:27 -0000      1.3
> > +++ pkg_path    28 Jan 2006 03:11:20 -0000
> > @@ -108,8 +108,7 @@
> >                 exitcode=1
> >                 continue
> >         fi
> > -       pkgpath=`cd $startdir/$dir && ${PWD_CMD}`
> > -       pkgpath="${pkgpath#${PKGSRCDIR}/}"
> > +       pkgpath="${dir#../../}"
> >         ${ECHO} "$pkgpath"
> >  done
> >  
> > Because the $dir comes from ${_ALL_DEPENDS:C/^[^:]*://:O:u} which is always
> > with prefix "../../".
> 
> This breaks for package directory references that don't start with
> "../../".  Please try the following patch instead.
> 
> 	Cheers,
> 
> 	-- Johnny Lam <jlam@pkgsrc.org>

> Index: pkg_path
> ===================================================================
> RCS file: /cvsroot/pkgsrc/mk/scripts/pkg_path,v
> retrieving revision 1.3
> diff -u -r1.3 pkg_path
> --- pkg_path	23 Jan 2006 18:38:27 -0000	1.3
> +++ pkg_path	28 Jan 2006 22:29:37 -0000
> @@ -92,12 +92,18 @@
>  	esac
>  done
>  
> +if ${TEST} ! -d "${PKGSRCDIR}"; then
> +	${ECHO} 1>&2 "$self: \`\`${PKGSRCDIR}'' not found"
> +	exit 1
> +fi
> +pkgsrcdir=`cd ${PKGSRCDIR} && ${PWD_CMD}`
> +
>  # Process required arguments
>  startdir=`${PWD_CMD}`
>  while ${TEST} $# -gt 0; do
>  	dir="$1"; shift
>  	case "$dir" in
> -	${PKGSRCDIR}/*)	;;
> +	${PKGSRCDIR}/*|$pkgsrcdir/*)	;;
>  	/*)	 ${ECHO} 1>&2 "$self: \`\`$dir'' not a valid package directory"
>  		exitcode=1
>  		continue
> @@ -109,7 +115,7 @@
>  		continue
>  	fi
>  	pkgpath=`cd $startdir/$dir && ${PWD_CMD}`
> -	pkgpath="${pkgpath#${PKGSRCDIR}/}"
> +	pkgpath="${pkgpath#$pkgsrcdir/}"
>  	${ECHO} "$pkgpath"
>  done
>  

Hi,
it seems there is no different, pkgsrcdir and PKGSRCDIR are always equal.
And it is still broken in such case -
hive[/home/rxg/opt2/pkgsrc/wip/supertux]% make clean-depends
cd: can't cd to /home/rxg/opt2/pkgsrc/wip/supertux/../..//usr/pkgsrc/audio/SDL_mixer
cd: can't cd to /home/rxg/opt2/pkgsrc/wip/supertux/../..//usr/pkgsrc/devel/SDL
cd: can't cd to /home/rxg/opt2/pkgsrc/wip/supertux/../..//usr/pkgsrc/devel/gmake
cd: can't cd to /home/rxg/opt2/pkgsrc/wip/supertux/../..//usr/pkgsrc/graphics/SDL_image
cd: can't cd to /home/rxg/opt2/pkgsrc/wip/supertux/../..//usr/pkgsrc/pkgtools/x11-links
*** Error code 2

Stop.
make: stopped in /home/rxg/opt2/pkgsrc/wip/supertux
hive[/home/rxg/opt2/pkgsrc/wip/supertux]% ls -l ../../audio ../../devel 
lrwxr-xr-x  1 rxg  wheel  17 Jan 30 23:56 ../../audio@ -> /usr/pkgsrc/audio
lrwxr-xr-x  1 rxg  wheel  17 Jan 30 23:56 ../../devel@ -> /usr/pkgsrc/devel

Yes, it's a special case, but 'make clean-depends' was broken after pkg_path
existed.