3 # Run to update the HTML page with the available versions.
7 # aside : for messages of lesser importance
8 # reponame : a code repository name
9 # GITbranch : GIT hash or branch tag
10 # version : a code version
11 # currentversion: the current code version
12 # updateline : (block) the "last updated" line
13 # warning : a message about possible failure
19 # 202004xx (petrillo@slac.stanford.edu) [v1.0]
21 # 20210412 (petrillo@slac.stanford.edu) [v1.1]
22 # added support for command line options
25 # -- BEGIN -- boilerplate settings and library loading -------------------------
30 for LibraryToLoad
in 'settings.sh' 'utilities.sh' ;
do
36 # -- END -- boilerplate settings and library loading ---------------------------
38 # ------------------------------------------------------------------------------
42 declare -
r RepoDir=
"./"
44 # template for the version list HTML file, relative to the script directory
45 declare -
r DefaultTemplateFileName=
'versionlisttemplate.html'
47 # the first line with this tag in the template will be replaced with the list
48 declare -
r DefaultVersionListTag=
'VERSIONLISTTAG'
49 # the first line with this tag in the template will be replaced with update info
50 declare -
r DefaultUpdateTag=
'UPDATETAG'
53 # ------------------------------------------------------------------------------
58 Updates
the HTML
file presenting
the list of available documentation of
68 configured PublishBaseDir${PublishBaseDir:+
", i.e. '${PublishBaseDir}'"})
69 --
reponame=REPONAME [${ExperimentCodeName:-autodetect}]
72 prints
the script version
and exits (hint: it
's version ${SCRIPTVERSION}
74 prints this usage message and exits
81 function printVersion() {
82 echo "${SCRIPTNAME} version ${SCRIPTVERSION}."
86 # ------------------------------------------------------------------------------
87 function FillVersionsList() {
89 local -r DocDir="${1%/}/"
91 [[ -d "$DocDir" ]] || FATAL 2 "Can't find documentation base
directory '${DocDir}'.
"
93 DocVersions=() # global
95 local VersionCandidatePath
96 for VersionCandidatePath in "${DocDir}
"* ; do
97 [[ -d "$VersionCandidatePath
" ]] || continue
98 local VersionCandidate="$(basename
"$VersionCandidatePath")
"
99 [[ "$VersionCandidate
" =~ ^v[[:digit:]]{2}_[[:digit:]]{2}_[[:digit:]]{2}(_[[:digit:]]{2})?$ ]] || continue
100 DocVersions+=( "$VersionCandidate
" )
104 } # FillVersionsList()
107 function MakeVersionItem() {
109 local -r DocVersion="$1
"
110 local -r DocPath="$2
"
111 local -r Indent="${3:-
" "}
"
113 local ExpCodeName="$ExperimentCodeName
"
114 local Version="$DocVersion
"
118 local -r MetadataFile="${DocPath%/}/${MetadataFileRelPath}
"
119 if [[ -r "$MetadataFile
" ]]; then
120 # metadata file is currently (version 1.0) created by UpdateFiles.sh
121 local MetadataVersion
122 MetadataVersion="$(ExtractFromMetadata
'MetadataVersion' "$MetadataFile")
"
124 ExpCodeName="$(ExtractFromMetadata
'ExperimentCode' "$MetadataFile")
" # maybe overwrite
125 Version="$(ExtractFromMetadata
'CodeVersion' "$MetadataFile")
" # maybe overwrite
126 DocDate="$(ExtractFromMetadata
'Date' "$MetadataFile")
" # maybe overwrite
127 DocGenExitCode="$(ExtractFromMetadata
'ExitCode' "$MetadataFile")
" # maybe overwrite
128 DocCodeGITreference="$(ExtractFromMetadata
'GITreference' "$MetadataFile")
" # maybe overwrite
132 local Msg="<span
class=\
"reponame\">${ExpCodeName}</span> <span class=\"version\">${Version}</span>"
133 if [[ -
z "$DocGenExitCode" ]]; then
134 Msg+=
' <span class="aside">(no additional information available)</span>'
136 Msg+=
" (documentation from ${DocDate}"
137 if [[ -
n "$DocCodeGITreference" ]] && [[
"$DocCodeGITreference" !=
"$Version" ]]; then
138 Msg+=
" for GIt reference <span class=\"GITbranch\">${DocCodeGITreference}</span>'"
141 if [[
"$DocGenExitCode" != 0 ]]; then
142 Msg+=
" <span class=\"warning\">[it may be incomplete: generation exited with code ${DocGenExitCode}]</span>"
146 echo
"${Indent}<li><a href=\"${DocVersion}\">${Msg}</a></li>"
148 } # MakeVersionItem()
151 function MakeHTMLlist() {
155 [[ -d
"$DocDir" ]] ||
FATAL 2
"Can't find documentation base directory '${DocDir}'."
157 # check for the special link
158 if [[ -
h "${DocDir%/}/${LatestLinkName}" ]]; then
159 local -
r LatestVersion=
"$(readlink "${DocDir%/}/${LatestLinkName}
")"
160 echo
" <li><a href=\"${LatestLinkName}\" class=\"currentversion\">latest documented version (${LatestVersion})</a></li>"
163 # look for the actual versions
164 local VersionCandidatePath
165 for VersionCandidatePath
in "${DocDir%/}/"* ;
do
167 [[ -d
"$VersionCandidatePath" ]] ||
continue
168 local VersionCandidate=
"$(basename "$VersionCandidatePath
")"
169 [[
"$VersionCandidate" =~ ^v[[:digit:]]{2}_[[:digit:]]{2}_[[:digit:]]{2}(_[[:digit:]]{2})?$ ]] ||
continue
171 MakeVersionItem
"$VersionCandidate" "$VersionCandidatePath"
178 function UpdatingRemarks() {
179 local -
r Indent=
"${1:-" "}"
183 ${Indent}<div
class=
"updateline">Last
list refresh: $(date)</div>
186 } # UpdatingRemarks()
189 function MakeVersionListFile() {
190 # Writes a HTML file on screen
192 local -
r TemplateFilePath=
"$1"
196 # write a header comment
200 This HTML
file was automatically generated:
206 Script version: ${SCRIPTVERSION}
212 # "parse" the template
219 if [[
"$Line" =~ ${VersionListTag} ]]; then #
replace this line
220 MakeHTMLlist
"$DocDir"
221 elif [[
"$Line" =~ ${UpdateTag} ]]; then #
replace this line
224 # trying hard to avoid any reinterpretation; `echo` *might* have sufficed
227 done <
"$TemplateFilePath"
230 } # MakeVersionListFile()
233 # ------------------------------------------------------------------------------
240 declare -i CleanOutputArea=0 UpdateOutputArea=0
241 declare TemplateFileName=
"$DefaultTemplateFileName"
242 declare VersionListTag=
"$DefaultVersionListTag"
243 declare UpdateTag=
"$DefaultUpdateTag"
248 for (( iParam = 1 ; iParam <= $# ; ++iParam ));
do
253 ( '--outputfile='* ) DestFile="${
Param#--*=}
" ;;
254 ( '--reponame='* ) ExperimentCodeName="${
Param#--*=}
" ;;
255 ( '--version' | '-V' ) DoVersion=1 ;;
256 ( '--help' | '-h' | '-?' ) DoHelp=1 ;;
257 ( '-' | '--' ) NoMoreOptions=1 ;;
259 ERROR "Unknown
option:
'${Param}'.
"
263 PositionalArguments+=( "$Param
" )
267 [[ "${#PositionalArguments[@]}
" -gt 0 ]] && FATAL 1 "Found ${#PositionalArguments[@]} spurious arguments on command line: ${PositionalArguments[@]}.
"
269 : ${ExperimentName:="$(FindExperiment)
"}
270 : ${ExperimentCodeName:="$(ExperimentCodeProduct
"$ExperimentName")
"}
272 if isFlagSet DoVersion ; then
274 [[ -z "$ExitWithCode
" ]] && ExitWithCode=0
276 if isFlagSet DoHelp ; then
278 [[ -z "$ExitWithCode
" ]] && ExitWithCode=0
281 [[ -n "$ExitWithCode
" ]] && exit "$ExitWithCode
"
287 # (some checks are delayed because they are not fatal when just printing help)
289 [[ -n "$ExperimentName
" ]] || FATAL 1 "Can
't detect the experiment name."
291 [[ -n "$ExperimentCodeName" ]] || FATAL 1 "Can't put together
the experiment code repository
name for '${ExperimentName}'.
"
293 declare TemplateFilePath="${
SCRIPTDIR%/}/${TemplateFileName}
"
294 [[ -r "$TemplateFilePath
" ]] || FATAL 2 "Can
't find template file '${TemplateFileName}
' in '${
SCRIPTDIR}
'."
296 # not controlled by option because used only to compose `DestFile`:
297 PublishDir="${PublishBaseDir%/}/${ExperimentCodeName}"
298 [[ -r "$PublishDir" ]] || FATAL 2 "Can't find publishing base
directory '${PublishDir}'.
"
300 # set a default destination if needed
301 : ${DestFile:="${PublishDir%/}/${VersionListFile}
"}
304 # write the HTML file
306 if [[ -e "$DestFile
" ]]; then
307 echo "Overwriting:
'${DestFile}'"
309 echo "Writing:
'${DestFile}'"
312 MakeVersionListFile "$TemplateFilePath
" "$PublishDir
" > "$DestFile
"
process_name opflash particleana ie ie ie z
then source cvmfs dune opensciencegrid org products dune setup_dune sh exit elif[-f/grid/fermiapp/products/dune/setup_dune_fermiapp.sh]
return match has_match and(match.match_pdg==11 or match.match_pdg==-11)
then echo Work directory not specified exit fi echo Work directory
if &&[-z"$BASH_VERSION"] then echo Attempting to switch to bash bash shellSwitch exit fi &&["$1"= 'shellSwitch'] shift declare a IncludeDirectives for Dir in
replace invalid UTF-8 sequences with U+FFFD
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker options