From owner-svn-ports-all@FreeBSD.ORG Mon May 6 22:23:10 2013 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id ECC4A89F; Mon, 6 May 2013 22:23:10 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id C4D63B54; Mon, 6 May 2013 22:23:10 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r46MNALb093412; Mon, 6 May 2013 22:23:10 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r46MNA3K093410; Mon, 6 May 2013 22:23:10 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201305062223.r46MNA3K093410@svn.freebsd.org> From: Baptiste Daroussin Date: Mon, 6 May 2013 22:23:10 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r317555 - in head: . Mk/Uses X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 May 2013 22:23:11 -0000 Author: bapt Date: Mon May 6 22:23:09 2013 New Revision: 317555 URL: http://svnweb.freebsd.org/changeset/ports/317555 Log: Add new USES: shebangfix use it to fix shebang on files specified by SHEBANG_FILES macro, by default it proposes default values for bash, perl, php, python, ruby, it can be customized and extended Added: head/Mk/Uses/shebangfix.mk (contents, props changed) Modified: head/CHANGES Modified: head/CHANGES ============================================================================== --- head/CHANGES Mon May 6 22:07:11 2013 (r317554) +++ head/CHANGES Mon May 6 22:23:09 2013 (r317555) @@ -10,6 +10,16 @@ in the release notes and/or placed into All ports committers are allowed to commit to this file. +20130507: +AUTHOR: bapt@FreeBSD.org + + * New USES macro to handle setting correct shebang to scripts + + By default it will fix bash, perl, php, ruby and python on all files specified + in the SHEBANG_FILES macro (glob pattern relative to ${WRKSRC}) + + Paths can be customized, and number of languages supported can be extended. + 20130506: AUTHOR: bapt@FreeBSD.org Added: head/Mk/Uses/shebangfix.mk ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/Mk/Uses/shebangfix.mk Mon May 6 22:23:09 2013 (r317555) @@ -0,0 +1,53 @@ +# $FreeBSD$ +# +# common templates for replacing #! interpreters in scripts file +# +# MAINTAINER: portmgr@FreeBSD.org +# +# Feature: shebangfix +# Usage: USES=shebangfix +# +# To define new shebang scheme, in the port Makefile add: +# +# SHEBANG_LANG= lua +# lua_OLD_CMD= /usr/bin/lua +# lua_CMD= ${LOCALBASE}/bin/lua +# +# To override a definition for example replacing /usr/bin/perl by /usr/bin/env perl +# add to the port Makefile: +# perl_CMD= ${SENTENV} perl +# + +.if !defined(_INCLUDE_USES_SHEBANGFIX_Mk) +_INCLUDE_USES_SHEBANGFIX_MK= yes + +bash_OLD_CMD?= /bin/bash +bash_CMD?= ${LOCALBASE}/bin/bash +perl_OLD_CMD?= /usr/bin/perl +perl_CMD?= ${LOCALBASE}/bin/perl +python_OLD_CMD?= /usr/bin/python +python_CMD?= ${LOCALBASE}/bin/python +ruby_OLD_CMD?= /usr/bin/ruby +ruby_CMD?= ${LOCALBASE}/bin/ruby +php_OLD_CMD?= /usr/bin/php +php_CMD?= ${LOCALBASE}/bin/php + +SHEBANG_LANG+= bash perl python ruby php + +.for lang in ${SHEBANG_LANG} +.if !defined(${lang}_CMD) +IGNORE+= missing definition for ${lang}_CMD +.endif +.if !defined(${lang}_OLD_CMD) +IGNORE+= missing definition for ${lang}_OLD_CMD +.endif +_SHEBANG_REINPLACE_ARGS+= -e "1s|^\#![[:space:]]*${${lang}_OLD_CMD}|\#!${${lang}_CMD}|" +.endfor + +pre-patch: fix-shebang + +fix-shebang: + @cd ${WRKSRC}; \ + ${ECHO_CMD} ${SHEBANG_FILES} | ${XARGS} ${REINPLACE_CMD} ${_SHEBANG_REINPLACE_ARGS} + +.endif