Subject: Re: pkg/21197: several packages install #!/usr/bin/perl scripts
To: None <tech-pkg@netbsd.org>
From: Soren Jacobsen <soren@blef.org>
List: tech-pkg
Date: 04/15/2003 23:26:17
On Tue, Apr 15, 2003 at 04:17:00PM -0400, nathanw@wasabisystems.com wrote:
> Poking around for useful SMB tools after installing samba, I
> tried to run /usr/pkg/bin/findsmb, only to discover that it is a
> script that starts with "#!/usr/bin/perl". Since perl is installed in
> /usr/pkg/bin/perl, the script doesn't work.
>
> Here is the set of offenders I found by grepping for /usr/bin/perl in
> /usr/pkg/*bin:
>
> audio/nas-1.6nb1: /usr/pkg/bin/auscope
> audio/kdemultimedia-3.1: /usr/pkg/bin/workman2cddb.pl
> editors/emacs-21.3nb1: /usr/pkg/bin/emacs-grep-changelog
> graphics/libungif-4.1.0.1: /usr/pkg/bin/gifburst
> net/kdenetwork-3.1: /usr/pkg/bin/dsirc
> net/samba-2.2.8a: /usr/pkg/bin/findsmb
> print/ghostscript-6.01nb4: /usr/pkg/bin/fixmswrd.pl
> x11/kdebase-3.1: /usr/pkg/bin/filesharelist
> /usr/pkg/bin/fileshareset
> x11/kdelibs-3.1: /usr/pkg/bin/preparetips
I've been annoyed by this in the past as well.
How does this solution look? Packages can define PERL_SCRIPTS as
whatever perl scripts they may contain, and they'll be taken care of
accordingly. This is (or should be) a fairly commonly done thing, as
many packages contain perl scripts, and it would make sense to have a
standard way of giving them proper interpreters.
If accepted, I have patches to address the packages Nathan mentioned,
and I'll submit them for other packages (there are a bunch of offending
packages in the mere 240 that I have installed locally) soon after.
Index: buildlink2.mk
===================================================================
RCS file: /cvsroot/pkgsrc/lang/perl5/buildlink2.mk,v
retrieving revision 1.4
diff -b -u -r1.4 buildlink2.mk
--- buildlink2.mk 2002/09/05 20:43:19 1.4
+++ buildlink2.mk 2003/04/16 06:14:21
@@ -28,4 +28,21 @@
perl-buildlink: _BUILDLINK_USE
+# PERL_SCRIPTS is defined by packages, and is a list of files, relative to
+# WRKSRC, that will have their interpreter transformed into the correct one.
+.if defined(PERL_SCRIPTS)
+_PERL_SED_COMMAND= -e "1s|^\#!.*perl|\#!${PERL5}|"
+perl-patch-interpreter:
+.for F in ${PERL_SCRIPTS}
+ cd ${WRKSRC}; \
+ ${SED} ${_PERL_SED_COMMAND} ${F} > ${F}.new; \
+ if [ -x ${F} ]; then \
+ ${CHMOD} +x ${F}.new; \
+ fi; \
+ ${MV} -f ${F}.new ${F}
+.endfor
+
+post-patch: perl-patch-interpreter
+.endif
+
.endif # PERL5_BUILDLINK2_MK
--
Soren Jacobsen