1212
1313# Only if it passes these checks, the tarball gets ingested to the base dir in the repository specified below.
1414
15- repo=software.eessi.io
1615basedir=versions
1716decompress=" gunzip -c"
1817cvmfs_server=" cvmfs_server"
@@ -42,15 +41,15 @@ function error() {
4241}
4342
4443function is_repo_owner() {
45- if [ -f " /etc/cvmfs/repositories.d/${repo } /server.conf" ]
44+ if [ -f " /etc/cvmfs/repositories.d/${cvmfs_repo } /server.conf" ]
4645 then
47- . " /etc/cvmfs/repositories.d/${repo } /server.conf"
46+ . " /etc/cvmfs/repositories.d/${cvmfs_repo } /server.conf"
4847 [ x" $( whoami) " = x" $CVMFS_USER " ]
4948 fi
5049}
5150
5251function check_repo_vars() {
53- if [ -z " ${repo } " ]
52+ if [ -z " ${cvmfs_repo } " ]
5453 then
5554 error " the 'repo' variable has to be set to the name of the CVMFS repository."
5655 fi
@@ -73,8 +72,8 @@ function check_version() {
7372 fi
7473
7574 # Check if the EESSI version number encoded in the filename
76- # is valid, i.e. matches the format YYYY.DD
77- if ! echo " ${version} " | egrep -q ' ^20[0-9][0-9]\.(0[0-9]|1[0-2])$'
75+ # is valid, i.e. matches the format YYYY.MM or YYYYMMDD
76+ if ! echo " ${version} " | egrep ' ( ^20[0-9][0-9]\.(0[0-9]|1[0-2])$)|(^20[0-9][0-9][0-9][0-9][0-9][0-9]$) '
7877 then
7978 error " ${version} is not a valid EESSI version."
8079 fi
@@ -113,28 +112,28 @@ function check_contents_type() {
113112function cvmfs_regenerate_nested_catalogs() {
114113 # Use the .cvmfsdirtab to generate nested catalogs for the ingested tarball
115114 echo " Generating the nested catalogs..."
116- ${cvmfs_server} transaction " ${repo } "
117- ${cvmfs_server} publish -m " Generate catalogs after ingesting ${tar_file_basename} " " ${repo } "
115+ ${cvmfs_server} transaction " ${cvmfs_repo } "
116+ ${cvmfs_server} publish -m " Generate catalogs after ingesting ${tar_file_basename} " " ${cvmfs_repo } "
118117 ec=$?
119118 if [ $ec -eq 0 ]
120119 then
121- echo_green " Nested catalogs for ${repo } have been created!"
120+ echo_green " Nested catalogs for ${cvmfs_repo } have been created!"
122121 else
123- echo_red " failure when creating nested catalogs for ${repo } ."
122+ echo_red " failure when creating nested catalogs for ${cvmfs_repo } ."
124123 fi
125124}
126125
127126function cvmfs_ingest_tarball() {
128127 # Do a regular "cvmfs_server ingest" for a given tarball,
129128 # followed by regenerating the nested catalog
130- echo " Ingesting tarball ${tar_file} to ${repo } ..."
131- ${decompress} " ${tar_file} " | ${cvmfs_server} ingest -t - -b " ${basedir} " " ${repo } "
129+ echo " Ingesting tarball ${tar_file} to ${cvmfs_repo } ..."
130+ ${decompress} " ${tar_file} " | ${cvmfs_server} ingest -t - -b " ${basedir} " " ${cvmfs_repo } "
132131 ec=$?
133132 if [ $ec -eq 0 ]
134133 then
135- echo_green " ${tar_file} has been ingested to ${repo } ."
134+ echo_green " ${tar_file} has been ingested to ${cvmfs_repo } ."
136135 else
137- error " ${tar_file} could not be ingested to ${repo } ."
136+ error " ${tar_file} could not be ingested to ${cvmfs_repo } ."
138137 fi
139138
140139 # "cvmfs_server ingest" doesn't automatically rebuild the nested catalogs,
@@ -180,9 +179,9 @@ function update_lmod_caches() {
180179 then
181180 error " the script for updating the Lmod caches (${update_caches_script} ) does not have execute permissions!"
182181 fi
183- ${cvmfs_server} transaction " ${repo } "
184- ${update_caches_script} /cvmfs/${repo } /${basedir} /${version}
185- ${cvmfs_server} publish -m " update Lmod caches after ingesting ${tar_file_basename} " " ${repo } "
182+ ${cvmfs_server} transaction " ${cvmfs_repo } "
183+ ${update_caches_script} /cvmfs/${cvmfs_repo } /${basedir} /${version}
184+ ${cvmfs_server} publish -m " update Lmod caches after ingesting ${tar_file_basename} " " ${cvmfs_repo } "
186185}
187186
188187function ingest_init_tarball() {
@@ -207,25 +206,25 @@ function ingest_compat_tarball() {
207206 # Handle the ingestion of tarballs containing a compatibility layer
208207 check_arch
209208 check_os
210- compat_layer_path=" /cvmfs/${repo } /${basedir} /${version} /compat/${os} /${arch} "
209+ compat_layer_path=" /cvmfs/${cvmfs_repo } /${basedir} /${version} /compat/${os} /${arch} "
211210 # Assume that we already had a compat layer in place if there is a startprefix script in the corresponding CVMFS directory
212211 if [ -f " ${compat_layer_path} /startprefix" ];
213212 then
214213 echo_yellow " Compatibility layer for version ${version} , OS ${os} , and architecture ${arch} already exists!"
215- ${cvmfs_server} transaction " ${repo } "
214+ ${cvmfs_server} transaction " ${cvmfs_repo } "
216215 last_suffix=$(( ls - 1 d ${compat_layer_path} -* | tail - n 1 | xargs basename | cut - d- - f2 ) 2 > / dev/ null)
217216 new_suffix=$(printf '%03 d\n' $((${last_suffix:- 0} + 1 )) )
218217 old_layer_suffixed_path=" ${compat_layer_path} -${new_suffix} "
219218 echo_yellow " Moving the existing compat layer from ${compat_layer_path} to ${old_layer_suffixed_path} ..."
220219 mv ${compat_layer_path} ${old_layer_suffixed_path}
221- tar -C " /cvmfs/${repo } /${basedir} /" -xzf " ${tar_file} "
222- ${cvmfs_server} publish -m " updated compat layer for ${version} , ${os} , ${arch} " " ${repo } "
220+ tar -C " /cvmfs/${cvmfs_repo } /${basedir} /" -xzf " ${tar_file} "
221+ ${cvmfs_server} publish -m " updated compat layer for ${version} , ${os} , ${arch} " " ${cvmfs_repo } "
223222 ec=$?
224223 if [ $ec -eq 0 ]
225224 then
226225 echo_green " Successfully ingested the new compatibility layer!"
227226 else
228- ${cvmfs_server} abort " ${repo } "
227+ ${cvmfs_server} abort " ${cvmfs_repo } "
229228 error " error while updating the compatibility layer, transaction aborted."
230229 fi
231230 else
@@ -236,11 +235,17 @@ function ingest_compat_tarball() {
236235
237236
238237# Check if a tarball has been specified
239- if [ " $# " -ne 1 ]; then
240- error " usage: $0 <gzipped tarball>"
238+ if [ " $# " -ne 2 ]; then
239+ error " usage: $0 <CVMFS repository name> < gzipped tarball>"
241240fi
242241
243- tar_file=" $1 "
242+ cvmfs_repo=" $1 "
243+ tar_file=" $2 "
244+
245+ # Check if the CVMFS repository exists
246+ if ( ! cvmfs_server list | grep -q " ${cvmfs_repo} " ); then
247+ error " CVMFS repository ${cvmfs_repo} does not exist!"
248+ fi
244249
245250# Check if the given tarball exists
246251if [ ! -f " ${tar_file} " ]; then
0 commit comments