install: add --with-pager and --with-pager-opts

Add --with-pager and --with-pager-opts configure options to choose at
build time pager setup.
This commit is contained in:
Xavier Delaruelle
2017-10-31 07:36:26 +01:00
parent 42134fae03
commit da5aaa4378
8 changed files with 81 additions and 29 deletions

View File

@@ -230,6 +230,13 @@ instance ``--without-modulepath``):
--with-tclsh=BIN Name or full path of Tcl interpreter shell
(default=\ ``tclsh``)
--with-pager=BIN Name or full path of default pager program to use to
paginate informational message output (can be super-
seeded at run-time by environment variable)
(default=\ ``less``)
--with-pager-opts=OPTLIST
Settings to apply to default pager program
(default=\ ``-eFKRX``)
--with-modulepath=PATHLIST
Default path list to setup as the default modulepaths.
Each path in this list should be separated by ``:``.

View File

@@ -102,6 +102,8 @@ sed -e 's|@prefix@|$(prefix)|g' \
-e 's|@modulefilesdir@|$(modulefilesdir)|g' \
-e 's|@TCLSHDIR@/tclsh|$(TCLSH)|g' \
-e 's|@TCLSH@|$(TCLSH)|g' \
-e 's|@pager@|$(pager)|g' \
-e 's|@pageropts@|$(pageropts)|g' \
-e 's|@MODULES_RELEASE@|$(MODULES_RELEASE)|g' \
-e 's|@MODULES_BUILD@|$(MODULES_BUILD)|g' \
-e 's|@MODULES_RPM_RELEASE@|$(MODULES_RPM_RELEASE)|g' \

View File

@@ -25,6 +25,10 @@ setdotmodulespath := @setdotmodulespath@
docinstall := @docinstall@
examplemodulefiles := @examplemodulefiles@
# pager setup
pager := @pager@
pageropts := @pageropts@
# command location
TCLSH := @TCLSH@
SPHINXBUILD := @SPHINXBUILD@

28
configure vendored
View File

@@ -28,12 +28,14 @@ targetlist="${progdir}/Makefile.inc ${progdir}/site.exp"
# argument list
arglist="TCLSH SPHINXBUILD prefix bindir libexecdir initdir datarootdir \
mandir docdir modulefilesdir setmanpath setbinpath setdotmodulespath \
docinstall examplemodulefiles compatversion modulepath loadedmodules"
docinstall examplemodulefiles compatversion pager pageropts modulepath \
loadedmodules"
compatarglist=
# flags to know if argument has been specified on command-line
defdotmodulespath=1
defcompatversion=1
defpageropts=1
# set argument default values
prefix=/usr/local/Modules
@@ -46,6 +48,8 @@ compatversion=y
loadedmodules=
TCLSH=tclsh
SPHINXBUILD=sphinx-build
pager=less
pageropts='-eFKRX'
# these args are initialized here but as they depend on other argument value
# they will get their default value later (after command-line parse)
bindir=
@@ -123,6 +127,11 @@ Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-tclsh=BIN name or full path of Tcl interpreter shell [tclsh]
--with-pager=BIN name or full path of default pager program to use to
paginate informational message output (can be super-
seeded at run-time by environment variable) [$pager]
--with-pager-opts=OPTLIST
settings to apply to default pager program [$pageropts]
--with-modulepath=PATHLIST
default modulepaths to set in default configuration
file to be enabled (each path in PATHLIST should
@@ -247,6 +256,11 @@ for arg in "$@"; do
defcompatversion=0 ;;
--with-tclsh=*|--without-tclsh)
tclshbin=$(get_package_value "$arg") ;;
--with-pager=*|--without-pager)
pager=$(get_package_value "$arg") ;;
--with-pager-opts=*|--without-pager-opts)
pageropts=$(get_package_value "$arg")
defpageropts=0 ;;
--with-modulepath=*|--without-modulepath)
modulepath=$(get_package_value "$arg") ;;
--with-loadedmodules=*|--without-loadedmodules)
@@ -294,6 +308,18 @@ fi
check_requirement $tclshbin '' '' 'PATH=/usr/bin:/bin:/usr/local/bin'
TCLSH=$reqpath
# get pager program location from standard PATHs or /usr/local/bin
# or validate location passed as argument
if [ -n "$pager" ]; then
check_requirement $pager '' '' 'PATH=/usr/bin:/bin:/usr/local/bin'
pager=$reqpath
fi
# adapt pager program settings dependings of specified args
if [ $defpageropts -eq 1 -a "${pager##*/}" != 'less' ]; then
pageropts=''
echo_warning "As chosen pager is not \`less', default pager options are cleared"
fi
# check feature requirements are met
if [ "$setdotmodulespath" = 'y' -a -n "$loadedmodules" ]; then
featmesg="As \`setdotmodulespath' is enabled beware that \`loadedmodules' may be ignored by init scripts"

View File

@@ -22,6 +22,7 @@ BuildRequires: hostname
BuildRequires: tcl-devel, tclx-devel, libX11-devel
Requires: tcl
Requires: sed
Requires: less
%if 0%{?rhel} && 0%{?rhel} <= 6
Requires: procps
Requires: man

View File

@@ -35,8 +35,8 @@ set flag_default_dir 1 ;# Report default directories
set flag_default_mf 1 ;# Report default modulefiles and version alias
set reportfd "stderr" ;# File descriptor to use to report messages
set g_pager "less" ;# Default command to page into, set empty to disable
set g_pager_opts "-eFKRX" ;# Options to pass to the pager command
set g_pager "@pager@" ;# Default command to page into, empty=disable
set g_pager_opts "@pageropts@" ;# Options to pass to the pager command
# Used to tell if a machine is running Windows or not
proc isWin {} {

View File

@@ -13,3 +13,6 @@ set install_compatversion "@compatversion@"
set install_setmanpath "@setmanpath@"
set install_setbinpath "@setbinpath@"
set install_examplemodulefiles "@examplemodulefiles@"
set install_pager "@pager@"
set install_pageropts "@pageropts@"

View File

@@ -19,12 +19,15 @@
#
##############################################################################
set pager_dft_cmd "less"
set pager_dft_opts "-eFKRX"
if {$install_pager eq "" || [file tail $install_pager] eq "cat"} {
set pager_dfl_use 0
} else {
set pager_dfl_use 1
}
# helper proc to generate pager test and expected debugging output
proc pager_test_case {modarg use asked cmd opts} {
global MODULECMD env
global MODULECMD env install_pager install_pageropts
if {$modarg ne ""} {
set modarg " $modarg"
@@ -33,7 +36,7 @@ proc pager_test_case {modarg use asked cmd opts} {
set ans [list]
lappend ans "DEBUG CALLING $MODULECMD sh -V -D$modarg"
if {[info exists env(LESS)]} {
if {[info exists env(LESS)] && $install_pageropts ne "" & [file tail $install_pager] eq "less"} {
lappend ans "DEBUG initPager: clear 'less' pager options as LESS variable defined"
}
foreach envvar [list MODULES_PAGER PAGER] {
@@ -54,9 +57,9 @@ proc pager_test_case {modarg use asked cmd opts} {
#
# vanilla test, no related-env variable set
pager_test_case "" 1 "-" $pager_dft_cmd $pager_dft_opts
pager_test_case "--paginate" 1 "1" $pager_dft_cmd $pager_dft_opts
pager_test_case "--no-pager" 0 "0" $pager_dft_cmd $pager_dft_opts
pager_test_case "" $pager_dfl_use "-" $install_pager $install_pageropts
pager_test_case "--paginate" $pager_dfl_use "1" $install_pager $install_pageropts
pager_test_case "--no-pager" 0 "0" $install_pager $install_pageropts
# play with LESS env variable
set opts "-K"
@@ -64,18 +67,26 @@ if { $verbose > 0 } {
send_user "\tSetup LESS = '$opts'\n"
}
set env(LESS) $opts
pager_test_case "" 1 "-" $pager_dft_cmd ""
pager_test_case "--paginate" 1 "1" $pager_dft_cmd ""
pager_test_case "--no-pager" 0 "0" $pager_dft_cmd ""
if {[file tail $install_pager] eq "less"} {
set opts ""
} else {
set opts $install_pageropts
}
pager_test_case "" $pager_dfl_use "-" $install_pager $opts
pager_test_case "--paginate" $pager_dfl_use "1" $install_pager $opts
pager_test_case "--no-pager" 0 "0" $install_pager $opts
set opts ""
if { $verbose > 0 } {
send_user "\tSetup LESS = '$opts'\n"
}
set env(LESS) $opts
pager_test_case "" 1 "-" $pager_dft_cmd ""
pager_test_case "--paginate" 1 "1" $pager_dft_cmd ""
pager_test_case "--no-pager" 0 "0" $pager_dft_cmd ""
if {[file tail $install_pager] ne "less"} {
set opts $install_pageropts
}
pager_test_case "" $pager_dfl_use "-" $install_pager $opts
pager_test_case "--paginate" $pager_dfl_use "1" $install_pager $opts
pager_test_case "--no-pager" 0 "0" $install_pager $opts
if { $verbose > 0 } {
send_user "\tUnset LESS\n"
@@ -89,8 +100,8 @@ if { $verbose > 0 } {
send_user "\tSetup PAGER = '$cmd'\n"
}
set env(PAGER) $cmd
pager_test_case "" 1 "-" $cmd ""
pager_test_case "--paginate" 1 "1" $cmd ""
pager_test_case "" $pager_dfl_use "-" $cmd ""
pager_test_case "--paginate" $pager_dfl_use "1" $cmd ""
pager_test_case "--no-pager" 0 "0" $cmd ""
set cmd ""
@@ -125,8 +136,8 @@ if { $verbose > 0 } {
send_user "\tSetup PAGER = '$cmd'\n"
}
set env(PAGER) $cmd
pager_test_case "" 1 "-" $cmd ""
pager_test_case "--paginate" 1 "1" $cmd ""
pager_test_case "" $pager_dfl_use "-" $cmd ""
pager_test_case "--paginate" $pager_dfl_use "1" $cmd ""
pager_test_case "--no-pager" 0 "0" $cmd ""
set cmd "/usr/bin/less"
@@ -134,8 +145,8 @@ if { $verbose > 0 } {
send_user "\tSetup PAGER = '$cmd'\n"
}
set env(PAGER) $cmd
pager_test_case "" 1 "-" $cmd ""
pager_test_case "--paginate" 1 "1" $cmd ""
pager_test_case "" $pager_dfl_use "-" $cmd ""
pager_test_case "--paginate" $pager_dfl_use "1" $cmd ""
pager_test_case "--no-pager" 0 "0" $cmd ""
set cmd "less"
@@ -144,8 +155,8 @@ if { $verbose > 0 } {
send_user "\tSetup PAGER = '$cmd $opts'\n"
}
set env(PAGER) "$cmd $opts"
pager_test_case "" 1 "-" $cmd $opts
pager_test_case "--paginate" 1 "1" $cmd $opts
pager_test_case "" $pager_dfl_use "-" $cmd $opts
pager_test_case "--paginate" $pager_dfl_use "1" $cmd $opts
pager_test_case "--no-pager" 0 "0" $cmd $opts
set cmd "/usr/bin/less"
@@ -155,8 +166,8 @@ if { $verbose > 0 } {
}
unset env(LESS)
set env(PAGER) $cmd
pager_test_case "" 1 "-" $cmd ""
pager_test_case "--paginate" 1 "1" $cmd ""
pager_test_case "" $pager_dfl_use "-" $cmd ""
pager_test_case "--paginate" $pager_dfl_use "1" $cmd ""
pager_test_case "--no-pager" 0 "0" $cmd ""
@@ -227,9 +238,7 @@ if { $verbose > 0 } {
unset env(LESS)
unset env(MODULES_PAGER)
unset pager_dft_cmd
unset pager_dft_opts
unset pager_dfl_use
unset opts
unset cmd