ulovko 发表于 2012-06-10 10:18

coreutils and GNU_PROGRAM_PREFIX

本帖最后由 ulovko 于 2012-06-10 10:19 编辑

There’s a number of packages out there that assume you are using the GNU versions of ls, wc, and so on.However, you aren’t when using a BSD system.Pkgsrc has historically dealt with this when GNU tools are needed for a package by prefixing them with a ‘g’.’ls’ becomes ‘gls’, and so on.Aleksey Cheusov proposed a fix to keep these utilities under their original names, which I think will go into the next quarterly pkgsrc release.
FROM: http://mail-index.netbsd.org/pkgsrc-users/2012/05/27/msg016359.html
------------------------------------------------
To: pkgsrc-users%NetBSD.org@localhost
Subject: coreutils and GNU_PROGRAM_PREFIX
From: Aleksey Cheusov <cheusov%tut.by@localhost>
Date: Sun, 27 May 2012 19:25:28 +0300
------------------------------------------------
From time to time GNU coreutils is needed for building third party
software. By default all executables in sysutils/coreutils are installed
with a prefix "g" (ls as gls, wc as gwc etc.) in order to avoid clashes
with base system utilities.The problem is this prefix is changable by
user, for example executable prefix may be set to ''. As a result
dependents may fail to build due to absense of required tool (gfmt is
required but absent, for example). In my view GNU_PROGRAM_PREFIX creates
more problems than it solves.

The attached patch does the following:
- remove GNU_PROGRAM_PREFIX variable from coreutils and gnuls
- always set executable prefix to "g"
- remove unnecessary CONFLICTS
- create symlinks under bin/coreutils/ directory, e.g. ls, wc, cat etc.,
   to appropriate gls, gwc, gcat in bin/.
- those who want GNU_PROGRAM_PREFIX='' needn't rebuild coreutils and gnuls.

Symlinks are necessary for those users who want to call these utils by
their original names (PATH).

I think other GNU packages may be converted the same way
(archivers/gsharutils, archivers/gcpio, devel/m4 and some others).

Comments?

Index: misc/gnuls/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/misc/gnuls/Makefile,v
retrieving revision 1.23
diff -u -r1.23 Makefile
--- misc/gnuls/Makefile 1 Nov 2011 16:16:01 -0000       1.23
+++ misc/gnuls/Makefile 27 May 2012 16:13:20 -0000
@@ -4,6 +4,7 @@
.include "../../sysutils/coreutils/Makefile.common"

PKGNAME=       ${DISTNAME:S/coreutils/gnuls/}
+PKGREVISION=   1
CATEGORIES=    misc

COMMENT=       GNU ls utility with color support
@@ -15,17 +16,19 @@
      ${RUN} cd ${WRKSRC}/src && ${BUILD_MAKE_CMD} version.h
      ${RUN} cd ${WRKSRC}/src && ${BUILD_MAKE_CMD} dircolors ls

-INSTALLATION_DIRS=   bin ${PKGMANDIR}/man1
+INSTALLATION_DIRS=   bin bin/coreutils ${PKGMANDIR}/man1

do-install:
      ${INSTALL_PROGRAM} ${WRKSRC}/src/dircolors \
-               ${DESTDIR}${PREFIX}/bin/${GNU_PROGRAM_PREFIX}dircolors
+               ${DESTDIR}${PREFIX}/bin/gdircolors
      ${INSTALL_PROGRAM} ${WRKSRC}/src/ls \
-               ${DESTDIR}${PREFIX}/bin/${GNU_PROGRAM_PREFIX}ls
+               ${DESTDIR}${PREFIX}/bin/gls
      ${INSTALL_DATA} ${WRKSRC}/man/dircolors.1 \
-               
${DESTDIR}${PREFIX}/${PKGMANDIR}/man1/${GNU_PROGRAM_PREFIX}dircolors.1
+               ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1/gdircolors.1
      ${INSTALL_DATA} ${WRKSRC}/man/ls.1 \
-               ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1/${GNU_PROGRAM_PREFIX}ls.1
+               ${DESTDIR}${PREFIX}/${PKGMANDIR}/man1/gls.1
+       ln -s ../gls ${DESTDIR}${PREFIX}/bin/coreutils/ls
+       ln -s ../gdircolors ${DESTDIR}${PREFIX}/bin/coreutils/dircolors

.include "../../converters/libiconv/buildlink3.mk"
.include "../../devel/gettext-lib/buildlink3.mk"
Index: misc/gnuls/PLIST
===================================================================
RCS file: /cvsroot/pkgsrc/misc/gnuls/PLIST,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 PLIST
--- misc/gnuls/PLIST    11 Feb 2004 23:00:52 -0000      1.1.1.1
+++ misc/gnuls/PLIST    27 May 2012 16:13:20 -0000
@@ -1,5 +1,7 @@
@comment $NetBSD: PLIST,v 1.1.1.1 2004/02/11 23:00:52 jmmv Exp $
-bin/${GNU_PROGRAM_PREFIX}dircolors
-bin/${GNU_PROGRAM_PREFIX}ls
-man/man1/${GNU_PROGRAM_PREFIX}dircolors.1
-man/man1/${GNU_PROGRAM_PREFIX}ls.1
+bin/coreutils/dircolors
+bin/coreutils/ls
+bin/gdircolors
+bin/gls
+man/man1/gdircolors.1
+man/man1/gls.1
Index: sysutils/coreutils/Makefile
===================================================================
RCS file: /cvsroot/pkgsrc/sysutils/coreutils/Makefile,v
retrieving revision 1.53
diff -u -r1.53 Makefile
--- sysutils/coreutils/Makefile 17 Apr 2012 17:47:19 -0000      1.53
+++ sysutils/coreutils/Makefile 27 May 2012 16:13:20 -0000
@@ -2,23 +2,16 @@

.include "../../sysutils/coreutils/Makefile.common"

+PKGREVISION=   1
+
CONFLICTS=   fileutils-* gnuls-* linuxls-* sh-utils-*
textutils-*

-# if GNU_PROGRAM_PREFIX == 'g'
# devel/id-utils installs a 'gid' program, so conflict with it
# databases/geneweb a 'gwc' program, so conflict with it
# graphics/graphviz installs a 'gpr' program, so conflict with it
-.if ${GNU_PROGRAM_PREFIX} == "g"
CONFLICTS+=            id-utils-* gnome-utils<1.4.1.2nb2
CONFLICTS+=            geneweb-*
CONFLICTS+=            graphviz<1.12
-.endif
-# print/teTeX-bin installed a 'readlink' program, so
-# conflict with it if GNU_PROGRAM_PREFIX == '' (no problem in teTeX3-bin)
-.if empty(GNU_PROGRAM_PREFIX)
-CONFLICTS+=            teTeX-bin<3
-CONFLICTS+=            mktemp-*
-.endif

INFO_FILES=            yes

@@ -35,6 +28,18 @@
PLIST.stdbuf=          yes
.endif

+PROGS=               [ base64 basename cat chcon chgrp chmod chown chroot
cksum comm cp csplit cut date dd df dir dircolors dirname du hostid echo env
expand expr factor false fmt fold groups head id install join kill link ln
logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl nohup nproc od paste
pathchk pinky pr printenv printf ptx pwd readlink rm rmdir runcon seq sha1sum
sha224sum sha256sum sha384sum sha512sum shred shuf sleep sort split stat stdbuf
stty sum sync tac tail tee test timeout touch tr true truncate tsort tty uname
unexpand uniq unlink uptime users vdir wc who whoami yes
+
+LINKSSUBDIR=         coreutils
+INSTALLATION_DIRS+=    bin/${LINKSSUBDIR}
+
+post-install:
+       set -e; \
+       cd ${DESTDIR}${PREFIX}/bin/${LINKSSUBDIR}; \
+       for p in ${PROGS}; do \
+          if test -x "../g$${p}"; then ln -f -s "../g$${p}" "$${p}"; fi; \
+       done
+
#CONFIGURE_ARGS+=      --enable-install-program=su
#.if ${OPSYS} == "NetBSD" ||${OPSYS} == "FreeBSD" || \
#${OPSYS} == "OpenBSD"
Index: sysutils/coreutils/Makefile.common
===================================================================
RCS file: /cvsroot/pkgsrc/sysutils/coreutils/Makefile.common,v
retrieving revision 1.3
diff -u -r1.3 Makefile.common
--- sysutils/coreutils/Makefile.common3 Oct 2011 16:17:08 -0000       1.3
+++ sysutils/coreutils/Makefile.common27 May 2012 16:13:20 -0000
@@ -40,10 +40,7 @@
.endif
CONFIGURE_ENV+=                MKDIR_P=${MKDIR:Q}

-CONFIGURE_ARGS+=       --program-prefix=${GNU_PROGRAM_PREFIX:Q}
-
-PLIST_SUBST+=          GNU_PROGRAM_PREFIX=${GNU_PROGRAM_PREFIX:Q}
-BUILD_DEFS+=         GNU_PROGRAM_PREFIX
+CONFIGURE_ARGS+=       --program-prefix=g

#CONFIGURE_ARGS+=      --enable-install-program=su
#.if ${OPSYS} == "NetBSD" ||${OPSYS} == "FreeBSD" || \
Index: sysutils/coreutils/PLIST
===================================================================
RCS file: /cvsroot/pkgsrc/sysutils/coreutils/PLIST,v
retrieving revision 1.14
diff -u -r1.14 PLIST
--- sysutils/coreutils/PLIST    9 Mar 2012 13:31:29 -0000       1.14
+++ sysutils/coreutils/PLIST    27 May 2012 16:13:20 -0000
@@ -1,207 +1,308 @@
@comment $NetBSD: PLIST,v 1.14 2012/03/09 13:31:29 fhajny Exp $
-bin/${GNU_PROGRAM_PREFIX}[
-bin/${GNU_PROGRAM_PREFIX}base64
-bin/${GNU_PROGRAM_PREFIX}basename
-bin/${GNU_PROGRAM_PREFIX}cat
-bin/${GNU_PROGRAM_PREFIX}chcon
-bin/${GNU_PROGRAM_PREFIX}chgrp
-bin/${GNU_PROGRAM_PREFIX}chmod
-bin/${GNU_PROGRAM_PREFIX}chown
-bin/${GNU_PROGRAM_PREFIX}chroot
-bin/${GNU_PROGRAM_PREFIX}cksum
-bin/${GNU_PROGRAM_PREFIX}comm
-bin/${GNU_PROGRAM_PREFIX}cp
-bin/${GNU_PROGRAM_PREFIX}csplit
-bin/${GNU_PROGRAM_PREFIX}cut
-bin/${GNU_PROGRAM_PREFIX}date
-bin/${GNU_PROGRAM_PREFIX}dd
-bin/${GNU_PROGRAM_PREFIX}df
-bin/${GNU_PROGRAM_PREFIX}dir
-bin/${GNU_PROGRAM_PREFIX}dircolors
-bin/${GNU_PROGRAM_PREFIX}dirname
-bin/${GNU_PROGRAM_PREFIX}du
-bin/${GNU_PROGRAM_PREFIX}echo
-bin/${GNU_PROGRAM_PREFIX}env
-bin/${GNU_PROGRAM_PREFIX}expand
-bin/${GNU_PROGRAM_PREFIX}expr
-bin/${GNU_PROGRAM_PREFIX}factor
-bin/${GNU_PROGRAM_PREFIX}false
-bin/${GNU_PROGRAM_PREFIX}fmt
-bin/${GNU_PROGRAM_PREFIX}fold
-bin/${GNU_PROGRAM_PREFIX}groups
-bin/${GNU_PROGRAM_PREFIX}head
-${PLIST.hostid}bin/${GNU_PROGRAM_PREFIX}hostid
-bin/${GNU_PROGRAM_PREFIX}id
-bin/${GNU_PROGRAM_PREFIX}install
-bin/${GNU_PROGRAM_PREFIX}join
-bin/${GNU_PROGRAM_PREFIX}kill
-bin/${GNU_PROGRAM_PREFIX}link
-bin/${GNU_PROGRAM_PREFIX}ln
-bin/${GNU_PROGRAM_PREFIX}logname
-bin/${GNU_PROGRAM_PREFIX}ls
-bin/${GNU_PROGRAM_PREFIX}md5sum
-bin/${GNU_PROGRAM_PREFIX}mkdir
-bin/${GNU_PROGRAM_PREFIX}mkfifo
-bin/${GNU_PROGRAM_PREFIX}mknod
-bin/${GNU_PROGRAM_PREFIX}mktemp
-bin/${GNU_PROGRAM_PREFIX}mv
-bin/${GNU_PROGRAM_PREFIX}nice
-bin/${GNU_PROGRAM_PREFIX}nl
-bin/${GNU_PROGRAM_PREFIX}nohup
-bin/${GNU_PROGRAM_PREFIX}nproc
-bin/${GNU_PROGRAM_PREFIX}od
-bin/${GNU_PROGRAM_PREFIX}paste
-bin/${GNU_PROGRAM_PREFIX}pathchk
-bin/${GNU_PROGRAM_PREFIX}pinky
-bin/${GNU_PROGRAM_PREFIX}pr
-bin/${GNU_PROGRAM_PREFIX}printenv
-bin/${GNU_PROGRAM_PREFIX}printf
-bin/${GNU_PROGRAM_PREFIX}ptx
-bin/${GNU_PROGRAM_PREFIX}pwd
-bin/${GNU_PROGRAM_PREFIX}readlink
-bin/${GNU_PROGRAM_PREFIX}rm
-bin/${GNU_PROGRAM_PREFIX}rmdir
-bin/${GNU_PROGRAM_PREFIX}runcon
-bin/${GNU_PROGRAM_PREFIX}seq
-bin/${GNU_PROGRAM_PREFIX}sha1sum
-bin/${GNU_PROGRAM_PREFIX}sha224sum
-bin/${GNU_PROGRAM_PREFIX}sha256sum
-bin/${GNU_PROGRAM_PREFIX}sha384sum
-bin/${GNU_PROGRAM_PREFIX}sha512sum
-bin/${GNU_PROGRAM_PREFIX}shred
-bin/${GNU_PROGRAM_PREFIX}shuf
-bin/${GNU_PROGRAM_PREFIX}sleep
-bin/${GNU_PROGRAM_PREFIX}sort
-bin/${GNU_PROGRAM_PREFIX}split
-bin/${GNU_PROGRAM_PREFIX}stat
-${PLIST.stdbuf}bin/${GNU_PROGRAM_PREFIX}stdbuf
-bin/${GNU_PROGRAM_PREFIX}stty
-bin/${GNU_PROGRAM_PREFIX}sum
-bin/${GNU_PROGRAM_PREFIX}sync
-bin/${GNU_PROGRAM_PREFIX}tac
-bin/${GNU_PROGRAM_PREFIX}tail
-bin/${GNU_PROGRAM_PREFIX}tee
-bin/${GNU_PROGRAM_PREFIX}test
-bin/${GNU_PROGRAM_PREFIX}timeout
-bin/${GNU_PROGRAM_PREFIX}touch
-bin/${GNU_PROGRAM_PREFIX}tr
-bin/${GNU_PROGRAM_PREFIX}truncate
-bin/${GNU_PROGRAM_PREFIX}true
-bin/${GNU_PROGRAM_PREFIX}tsort
-bin/${GNU_PROGRAM_PREFIX}tty
-bin/${GNU_PROGRAM_PREFIX}uname
-bin/${GNU_PROGRAM_PREFIX}unexpand
-bin/${GNU_PROGRAM_PREFIX}uniq
-bin/${GNU_PROGRAM_PREFIX}unlink
-bin/${GNU_PROGRAM_PREFIX}uptime
-bin/${GNU_PROGRAM_PREFIX}users
-bin/${GNU_PROGRAM_PREFIX}vdir
-bin/${GNU_PROGRAM_PREFIX}wc
-bin/${GNU_PROGRAM_PREFIX}who
-bin/${GNU_PROGRAM_PREFIX}whoami
-bin/${GNU_PROGRAM_PREFIX}yes
+bin/coreutils/[
+bin/coreutils/base64
+bin/coreutils/basename
+bin/coreutils/cat
+bin/coreutils/chcon
+bin/coreutils/chgrp
+bin/coreutils/chmod
+bin/coreutils/chown
+bin/coreutils/chroot
+bin/coreutils/cksum
+bin/coreutils/comm
+bin/coreutils/cp
+bin/coreutils/csplit
+bin/coreutils/cut
+bin/coreutils/date
+bin/coreutils/dd
+bin/coreutils/df
+bin/coreutils/dir
+bin/coreutils/dircolors
+bin/coreutils/dirname
+bin/coreutils/du
+bin/coreutils/echo
+bin/coreutils/env
+bin/coreutils/expand
+bin/coreutils/expr
+bin/coreutils/factor
+bin/coreutils/false
+bin/coreutils/fmt
+bin/coreutils/fold
+bin/coreutils/groups
+bin/coreutils/head
+${PLIST.hostid}bin/coreutils/hostid
+bin/coreutils/id
+bin/coreutils/install
+bin/coreutils/join
+bin/coreutils/kill
+bin/coreutils/link
+bin/coreutils/ln
+bin/coreutils/logname
+bin/coreutils/ls
+bin/coreutils/md5sum
+bin/coreutils/mkdir
+bin/coreutils/mkfifo
+bin/coreutils/mknod
+bin/coreutils/mktemp
+bin/coreutils/mv
+bin/coreutils/nice
+bin/coreutils/nl
+bin/coreutils/nohup
+bin/coreutils/nproc
+bin/coreutils/od
+bin/coreutils/paste
+bin/coreutils/pathchk
+bin/coreutils/pinky
+bin/coreutils/pr
+bin/coreutils/printenv
+bin/coreutils/printf
+bin/coreutils/ptx
+bin/coreutils/pwd
+bin/coreutils/readlink
+bin/coreutils/rm
+bin/coreutils/rmdir
+bin/coreutils/runcon
+bin/coreutils/seq
+bin/coreutils/sha1sum
+bin/coreutils/sha224sum
+bin/coreutils/sha256sum
+bin/coreutils/sha384sum
+bin/coreutils/sha512sum
+bin/coreutils/shred
+bin/coreutils/shuf
+bin/coreutils/sleep
+bin/coreutils/sort
+bin/coreutils/split
+bin/coreutils/stat
+${PLIST.stdbuf}bin/coreutils/stdbuf
+bin/coreutils/stty
+bin/coreutils/sum
+bin/coreutils/sync
+bin/coreutils/tac
+bin/coreutils/tail
+bin/coreutils/tee
+bin/coreutils/test
+bin/coreutils/timeout
+bin/coreutils/touch
+bin/coreutils/tr
+bin/coreutils/true
+bin/coreutils/truncate
+bin/coreutils/tsort
+bin/coreutils/tty
+bin/coreutils/uname
+bin/coreutils/unexpand
+bin/coreutils/uniq
+bin/coreutils/unlink
+bin/coreutils/uptime
+bin/coreutils/users
+bin/coreutils/vdir
+bin/coreutils/wc
+bin/coreutils/who
+bin/coreutils/whoami
+bin/coreutils/yes
+bin/g[
+bin/gbase64
+bin/gbasename
+bin/gcat
+bin/gchcon
+bin/gchgrp
+bin/gchmod
+bin/gchown
+bin/gchroot
+bin/gcksum
+bin/gcomm
+bin/gcp
+bin/gcsplit
+bin/gcut
+bin/gdate
+bin/gdd
+bin/gdf
+bin/gdir
+bin/gdircolors
+bin/gdirname
+bin/gdu
+bin/gecho
+bin/genv
+bin/gexpand
+bin/gexpr
+bin/gfactor
+bin/gfalse
+bin/gfmt
+bin/gfold
+bin/ggroups
+bin/ghead
+${PLIST.hostid}bin/ghostid
+bin/gid
+bin/ginstall
+bin/gjoin
+bin/gkill
+bin/glink
+bin/gln
+bin/glogname
+bin/gls
+bin/gmd5sum
+bin/gmkdir
+bin/gmkfifo
+bin/gmknod
+bin/gmktemp
+bin/gmv
+bin/gnice
+bin/gnl
+bin/gnohup
+bin/gnproc
+bin/god
+bin/gpaste
+bin/gpathchk
+bin/gpinky
+bin/gpr
+bin/gprintenv
+bin/gprintf
+bin/gptx
+bin/gpwd
+bin/greadlink
+bin/grm
+bin/grmdir
+bin/gruncon
+bin/gseq
+bin/gsha1sum
+bin/gsha224sum
+bin/gsha256sum
+bin/gsha384sum
+bin/gsha512sum
+bin/gshred
+bin/gshuf
+bin/gsleep
+bin/gsort
+bin/gsplit
+bin/gstat
+${PLIST.stdbuf}bin/gstdbuf
+bin/gstty
+bin/gsum
+bin/gsync
+bin/gtac
+bin/gtail
+bin/gtee
+bin/gtest
+bin/gtimeout
+bin/gtouch
+bin/gtr
+bin/gtrue
+bin/gtruncate
+bin/gtsort
+bin/gtty
+bin/guname
+bin/gunexpand
+bin/guniq
+bin/gunlink
+bin/guptime
+bin/gusers
+bin/gvdir
+bin/gwc
+bin/gwho
+bin/gwhoami
+bin/gyes
info/coreutils.info
...
...
--
Best regards, Aleksey Cheusov.
页: [1]
查看完整版本: coreutils and GNU_PROGRAM_PREFIX