From ec0f3eb2e2cbfd9e85e27a4adc246f36aa2cb9d3 Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Thu, 17 Aug 2017 15:52:29 +0200 Subject: [PATCH] More standard shebang for modulecmd.tcl Make use of './configure' information to set a precise tclsh shebang on modulecmd.tcl script. This change requires to move modulecmd.tcl to modulecmd.tcl.in within repository. Shebang is set to '@TCLSHDIR@/tclsh' rather just '@TCLSH@' in modulecmd.tcl.in to help forge code determines that this file is a Tcl script. --- .gitignore | 1 + Makefile | 13 +++++++++---- contrib/nglfar2ccov | 19 +++++++++++++------ doc/Makefile | 2 +- modulecmd.tcl => modulecmd.tcl.in | 16 +++------------- 5 files changed, 27 insertions(+), 24 deletions(-) rename modulecmd.tcl => modulecmd.tcl.in (99%) diff --git a/.gitignore b/.gitignore index 51e5ca1c..d4d5589d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +modulecmd.tcl ChangeLog README Makefile.inc diff --git a/Makefile b/Makefile index 284d74a3..039031ab 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ test testinstall instrument testcoverage CURRENT_VERSION := $(shell grep '^set MODULES_CURRENT_VERSION' \ - modulecmd.tcl | cut -d ' ' -f 3) + modulecmd.tcl.in | cut -d ' ' -f 3) DIST_PREFIX := modules-tcl-$(CURRENT_VERSION) # definitions for code coverage @@ -19,7 +19,7 @@ ifneq ($(wildcard Makefile.inc),Makefile.inc) endif include Makefile.inc -all: initdir pkgdoc ChangeLog README +all: initdir pkgdoc modulecmd.tcl ChangeLog README initdir: make -C init all @@ -33,13 +33,17 @@ doc: www: make -C www all +modulecmd.tcl: modulecmd.tcl.in + perl -pe 's|\@TCLSHDIR\@/tclsh|$(TCLSH)|g;' $< > $@ + chmod +x $@ + ChangeLog: contrib/gitlog2changelog.py README: perl -pe 's|^\[\!\[.*\].*\n||;' $@.md > $@ -install: ChangeLog README +install: modulecmd.tcl ChangeLog README mkdir -p $(DESTDIR)$(libexecdir) mkdir -p $(DESTDIR)$(bindir) cp modulecmd.tcl $(DESTDIR)$(libexecdir)/ @@ -94,6 +98,7 @@ endif ifeq ($(wildcard .git) $(wildcard README.md),.git README.md) rm -f README endif + rm -f modulecmd.tcl rm -f modules-tcl-*.tar.gz rm -f modules-tcl-*.srpm make -C init clean @@ -107,7 +112,7 @@ distclean: clean rm -f site.exp rm -rf $(NAGELFAR_RELEASE) -test: +test: modulecmd.tcl TCLSH=$(TCLSH); export TCLSH; \ MODULEVERSION=Tcl; export MODULEVERSION; \ OBJDIR=`pwd -P`; export OBJDIR; \ diff --git a/contrib/nglfar2ccov b/contrib/nglfar2ccov index 895b40dc..d29e8172 100755 --- a/contrib/nglfar2ccov +++ b/contrib/nglfar2ccov @@ -42,6 +42,13 @@ if {[catch { exit 1 } +# determine source file name to report coverage against +if {[file exists "${srcfile}.in"]} { + set targetfile "${srcfile}.in" +} else { + set targetfile $srcfile +} + # parse coverage result array set line_hits {} set covered_lines 0 @@ -66,20 +73,20 @@ puts "Found $covered_lines lines covered over $total_lines ($percent_covered %)" # catch additional information to build reports set fmtime [file mtime $covres] set fmtime_date [clock format $fmtime -format "%Y-%m-%d %H:%M:%S"] -regsub -all "\\." $srcfile "_" srcname +regsub -all "\\." $targetfile "_" srcname # build json report content array set content {} set content(json) "{ \"files\": \[ - {\"file\": \"$srcfile\", \"percent_covered\": \"$percent_covered\", \"covered_lines\": \"$covered_lines\", \"total_lines\": \"$total_lines\"} + {\"file\": \"$targetfile\", \"percent_covered\": \"$percent_covered\", \"covered_lines\": \"$covered_lines\", \"total_lines\": \"$total_lines\"} \], \"percent_covered\": \"$percent_covered\", \"covered_lines\": $covered_lines, \"total_lines\": $total_lines, \"percent_low\": 25, \"percent_high\": 75, - \"command\": \"$srcfile\", + \"command\": \"$targetfile\", \"date\": \"$fmtime_date\" }" @@ -88,12 +95,12 @@ set content(xml) " - $srcfile + $targetfile - + " foreach n [lsort -integer [array names line_hits]] { @@ -107,7 +114,7 @@ append content(xml) " " # write reports -set reportdir "[file dirname $srcfile]/coverage/$srcfile" +set reportdir "[file dirname $srcfile]/coverage/$targetfile" if {[catch {file mkdir $reportdir} errMsg ]} { puts stderr "Report directory '$reportdir' cannot be created.\n$errMsg" exit 1 diff --git a/doc/Makefile b/doc/Makefile index dee56b92..763510b6 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,6 +1,6 @@ .PHONY: install uninstall clean -VERSION_FILE := ../modulecmd.tcl +VERSION_FILE := ../modulecmd.tcl.in MAN_VERSION := "modules-tcl $(shell grep '^set MODULES_CURRENT_VERSION' \ $(VERSION_FILE) | cut -d ' ' -f 3)" MAN_HEADER := "Environment Modules" diff --git a/modulecmd.tcl b/modulecmd.tcl.in similarity index 99% rename from modulecmd.tcl rename to modulecmd.tcl.in index 61104972..ac9807fc 100755 --- a/modulecmd.tcl +++ b/modulecmd.tcl.in @@ -1,15 +1,5 @@ -#!/bin/sh -# \ -tclshbin=$(type -p tclsh) && exec $tclshbin "$0" "$@" -# \ -[ -x /usr/local/bin/tclsh ] && exec /usr/local/bin/tclsh "$0" "$@" -# \ -[ -x /usr/bin/tclsh ] && exec /usr/bin/tclsh "$0" "$@" -# \ -[ -x /bin/tclsh ] && exec /bin/tclsh "$0" "$@" -# \ -echo "FATAL: module: Could not find tclsh in \$PATH or in standard directories" >&2; exit 1 - +#!@TCLSHDIR@/tclsh +# # MODULECMD.TCL, a pure TCL implementation of the module command # Copyright (C) 2002-2004 Mark Lakata # Copyright (C) 2004-2017 Kent Mein @@ -33,7 +23,7 @@ echo "FATAL: module: Could not find tclsh in \$PATH or in standard directories" # # Some Global Variables..... # -set MODULES_CURRENT_VERSION 1.969 +set MODULES_CURRENT_VERSION 1.971 set MODULES_CURRENT_RELEASE_DATE "2017-08-17" set g_debug 0 ;# Set to 1 to enable debugging set error_count 0 ;# Start with 0 errors