Skip to content

Commit 6b0c0ec

Browse files
committed
makedist: update cvmfs package repo urls with fallback
Adds a fallback URL for the cvmfs package download. makedist currently looks for the latest package in the listing returned by package servers; since the s3 bucket we are mainly using (and which is the most reliable) does not support listings, this mechanism now relies on reading a small file .latest_cvmfs_version_prod (https://cvmrepo.web.cern.ch/cvmrepo/.latest_cvmfs_version_prod) containing a string with the latest version. I'll add this to our testing to ensure it is kept up to date. Obviously this won't work if you wanted to add mirrors maintained by a third party - one possibility would be to hardcode the latest version in the script. The downloads for the non-default config packages is kept the same, except for a small fix for the egi download. The ecsft.cern.ch url is removed alltogether, as this is the most likely one to cause issues.
1 parent 3bcc6ab commit 6b0c0ec

File tree

1 file changed

+76
-27
lines changed

1 file changed

+76
-27
lines changed

makedist

Lines changed: 76 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,19 @@ distroname() {
7979
fi
8080
}
8181

82+
# return the distroname as encountered in yum package repo URLS,
83+
# i.e https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs/EL/9/
84+
distroname_yum() {
85+
case " $1 " in
86+
*" ubuntu "*) echo EL;;
87+
*" debian "*) echo EL;;
88+
*" rhel "*) echo EL;;
89+
*" suse "*) echo suse;;
90+
*) echo "Distro name $1 not supported" >&2
91+
exit 2;;
92+
esac
93+
}
94+
8295
distroversion() {
8396
if [ -n "$MACHTYPE" ]; then
8497
echo "$MACHTYPE"|sed 's/^[^0-9]*\([0-9]*\)-.*/\1/'
@@ -103,6 +116,19 @@ distroarch() {
103116
fi
104117
}
105118

119+
# download and parse the listing from a package server (give URL as 1st argument)
120+
get_cvmfs_pkg_list() {
121+
echo "$(curl -Ls $1/|grep "cvmfs-"|sed 's/.*href="//;s/".*//;s,^\./,,')"
122+
}
123+
124+
125+
get_cvmfs_latest_version_from_pkg_list() {
126+
CVMFSPKG="`echo "$1"|grep "^cvmfs-[0-9]"|tail -1`"
127+
CVMFSVERSION="`echo "$CVMFSPKG"|sed 's/.*cvmfs-\([^-]*\)-.*/\1/'`"
128+
echo $CVMFSVERSION
129+
}
130+
131+
106132
DISTRO="`distroname`"
107133
VERS="`distroversion`"
108134
ARCH="`distroarch`"
@@ -144,7 +170,7 @@ EL=$VERS
144170
MACH=el$EL
145171
if [ "$DISTRO" = "suse" ]; then
146172
EL=7 # we get some suse stuff from rhel7
147-
MACH=sle
173+
MACH=sle$VERS
148174
fi
149175

150176
MISSINGCMDS=""
@@ -222,17 +248,27 @@ case $1 in
222248
EXT="/Packages/c"
223249
fi
224250
REPO=release
225-
BASEURL="https://repo.opensciencegrid.org/osg/$REL/el$EL/$REPO/x86_64$EXT";;
251+
BASEURL="https://repo.opensciencegrid.org/osg/$REL/el$EL/$REPO/x86_64$EXT"
252+
BASELIST="$(get_cvmfs_pkg_list $BASEURL)";;
226253
egi)
227254
OS=centos$EL
228-
BASEURL="https://repository.egi.eu/sw/production/umd/4/$OS/x86_64/updates";;
255+
if [ $EL -gt 8 ]; then
256+
BASEURL="https://repository.egi.eu/sw/production/umd/5/al9/release/x86_64/"
257+
elif [ $EL -eq 7 ]; then
258+
BASEURL="https://repository.egi.eu/sw/production/umd/4/centos7/x86_64/updates"
259+
else
260+
echo "ERROR: unsupported OS for egi! only centos7, almalinux9 supported." >&2
261+
exit 1
262+
fi
263+
BASELIST="$(get_cvmfs_pkg_list $BASEURL)";;
229264
default|none)
230265
INCLUDEHELPER=false
231266
BASEURL="https://cvmrepo.web.cern.ch/cvmrepo/yum/cvmfs/EL/$EL/x86_64";;
232267
*) usage;;
233268
esac
234269
DISTTYPE=$1
235270

271+
236272
if [ -d $DIST ]; then
237273
echo "$DIST already exists" >&2
238274
exit 1
@@ -271,20 +307,18 @@ if [ "$ARCH" != "x86_64" ]; then
271307
# we're looking at x86_64 version repositories for the config rpm
272308
INCLUDEHELPER=false
273309
fi
274-
275-
URLS=""
276-
BASELIST="`curl -Ls $BASEURL/|grep "cvmfs-"|sed 's/.*href="//;s/".*//'`"
277-
CVMFSPKG="`echo "$BASELIST"|grep "^cvmfs-[0-9]"|tail -1`"
278-
if [ -z "$CVMFSPKG" ]; then
279-
if [ "$DISTTYPE" = egi ] && [ "$EL" = 8 ]; then
280-
echo "egi's UMD does not yet support rhel8" 2>&1
281-
else
282-
echo "No cvmfs package found from $BASEURL" >&2
283-
fi
310+
if [ "$DISTTYPE" = egi ] && [ "$EL" = 8 ]; then
311+
echo "egi's UMD does not yet support rhel8" 2>&1
284312
exit 1
285313
fi
286314

315+
316+
URLS=""
287317
CVMFSURL=""
318+
CVMFSRPMURL=""
319+
CVMFS_BASEURL_MIRROR1="https://cvmrepo.s3.cern.ch/cvmrepo"
320+
CVMFS_BASEURL_MIRROR2="https://cvmrepo.web.cern.ch/cvmrepo"
321+
CVMFS_BASEURL=$CVMFS_BASEURL_MIRROR1
288322
if [ "$ARCH" = "ppc64le" ]; then
289323
# Grab cvmfs package from copr, using yumdownloader to calculate
290324
# the URL
@@ -297,32 +331,47 @@ if [ "$ARCH" = "ppc64le" ]; then
297331
CVMFSRPMNAME="$(basename $CVMFSRPMURL)"
298332
CVMFSVERSION="`echo "$CVMFSRPMNAME" 's/.*cvmfs-\([^-]*\)-.*/\1/'`"
299333
else
300-
# Now that we can figure out the latest cvmfs version, download the
301-
# corresponding cvmfs packages from CERN instead
302-
CVMFSVERSION="`echo "$CVMFSPKG"|sed 's/.*cvmfs-\([^-]*\)-.*/\1/'`"
303-
CVMFSURL="https://ecsft.cern.ch/dist/cvmfs/cvmfs-$CVMFSVERSION"
304-
CVMFSRPMNAME="`curl -Ls $CVMFSURL/|grep "cvmfs-$CVMFSVERSION-.*$MACH.*\.$ARCH"|sed 's/.*href="//;s/".*//'|tail -1`"
305-
if [ -z "$CVMFSRPMNAME" ]; then
306-
echo "No matching cvmfs rpm found at $CVMFSURL" >&2
334+
# Get CVMFS package download urls from CERN yum repo ( with possible fallback )
335+
DISTRO_YUM="`distroname_yum $DISTRO`"
336+
CVMFSURL="$CVMFS_BASEURL/yum/cvmfs/$DISTRO_YUM/$VERS/$ARCH"
337+
# for the listing, we need to query the "s3-website" variant of the s3 url
338+
CVMFS_BASELIST="$(get_cvmfs_pkg_list ${CVMFSURL/cvmrepo.s3/cvmrepo.s3-website})"
339+
CVMFSVERSION="$(get_cvmfs_latest_version_from_pkg_list $CVMFS_BASELIST)"
340+
if [ -z "CVMFSVERSION" ]; then
341+
echo "WARN: Couldn't find package listing in mirror $CVMFSURL, switching over.." >&2
342+
CVMFS_BASEURL="$CVMFS_BASE_URL_MIRROR2"
343+
CVMFSURL="$CVMFS_BASEURL/yum/cvmfs/$DISTRO_YUM/$VERS/$ARCH"
344+
CVMFS_BASELIST="$(get_cvmfs_pkg_list $CVMFSURL)"
345+
CVMFSVERSION="$(get_cvmfs_latest_version_from_pkg_list $CVMFS_BASELIST)"
346+
if [ -z "CVMFSVERSION" ]; then
347+
echo "ERROR: Couldn't find package listing in mirror $CVMFS_BASEURL, and no mirrors left! " >&2
307348
exit 1
349+
fi
308350
fi
351+
CVMFSRPMNAME="cvmfs-$CVMFSVERSION-1.$MACH.$ARCH.rpm"
309352
CVMFSRPMURL="$CVMFSURL/$CVMFSRPMNAME"
310353
fi
311-
URLS="$CVMFSRPMURL"
312354

355+
CVMFSRPMURL_LIBS=""
313356
MINORVERSION="`echo "$CVMFSVERSION"|cut -d. -f2`"
314357
if [ "$MINORVERSION" -ge 10 ]; then
315358
# include cvmfs-libs
316-
URLS="$URLS $CVMFSURL/`echo $CVMFSRPMNAME|sed 's/cvmfs-/cvmfs-libs-/'`"
359+
CVMFSRPMURL_LIBS="$CVMFSURL/`echo $CVMFSRPMNAME|sed 's/cvmfs-/cvmfs-libs-/'`"
317360
fi
318361

362+
URLS="$URLS $CVMFSRPMURL $CVMFSRPMURL_LIBS"
363+
319364
if [ "$DISTTYPE" != "none" ]; then
320-
CONFIGREPO="`echo "$BASELIST"|grep "^cvmfs-config-$DISTTYPE-[0-9]"|tail -1`"
321-
if [ -z "$CONFIGREPO" ]; then
322-
echo "cvmfs-config not found at $BASEURL!" >&2
323-
exit 1
365+
if [ "$DISTTYPE" != "default" ]; then
366+
CONFIGREPO="`echo "$BASELIST"|grep "^cvmfs-config-$DISTTYPE-[0-9]"|tail -1`"
367+
if [ -z "$CONFIGREPO" ]; then
368+
echo "cvmfs-config not found at $BASEURL!" >&2
369+
exit 1
370+
fi
371+
URLS="$URLS $BASEURL/$CONFIGREPO"
372+
else
373+
URLS="$URLS $CVMFS_BASEURL/yum/cvmfs-config-default-latest.noarch.rpm"
324374
fi
325-
URLS="$URLS $BASEURL/$CONFIGREPO"
326375
fi
327376

328377
# return the url of the latest version of a package given

0 commit comments

Comments
 (0)