@@ -143,6 +143,68 @@ rpm_repo_dir() {
143143  set  -u
144144}
145145
146+ _rpm_get_base_mirror_url () {
147+   local  branch=$1 
148+   echo  " https://rpm.mariadb.org/$branch " 
149+ }
150+ 
151+ _rpm_get_base_archive_url () {
152+   local  branch=$1 
153+   echo  " https://archive.mariadb.org/mariadb-$branch /yum/" 
154+ }
155+ 
156+ _rpm_get_repo_path () {
157+   #  Construct a distro repo URL path based on the file hierarchy set up
158+   #  by buildbot / release scripts.
159+   local  arch=$1 
160+   local  dist_name=$2 
161+   local  version_number=$3 
162+   local  path=" ${dist_name}${version_number} -${arch} " 
163+ 
164+   #  Special handling for centos 9
165+   #  This uses the previous hierarchy in release scripts instead of a flattened
166+   #  path.
167+   if  [[ " $dist_name "   ==  " centos"   &&  " $version_number "   -ge  9 ]];  then 
168+       #  Check if architecture is amd64 and convert to x86_64
169+       if  [[ " $arch "   ==  " amd64"   ]];  then 
170+           arch=" x86_64" 
171+       fi 
172+       path=" $dist_name /$version_number /$arch " 
173+   fi 
174+ 
175+   echo  " $path " 
176+ }
177+ 
178+ rpm_get_mirror_url () {
179+   #  Return full URL to corresponding distro repo on the mariadb mirror.
180+   local  branch=$1 
181+   local  arch=$2 
182+   local  dist_name=$3 
183+   local  version_number=$4 
184+   local  base
185+   local  path
186+ 
187+   base=$( _rpm_get_base_mirror_url " $branch " ) 
188+   path=$( _rpm_get_repo_path " $arch "   " $dist_name "   " $version_number " ) 
189+   #  Print the final constructed URL
190+   echo  " ${base} /${path} " 
191+ }
192+ 
193+ rpm_get_archive_url () {
194+   #  Return full URL to corresponding distro repo on the archive.
195+   local  branch=$1 
196+   local  arch=$2 
197+   local  dist_name=$3 
198+   local  version_number=$4 
199+   local  base
200+   local  path
201+ 
202+   base=$( _rpm_get_base_archive_url " $branch " ) 
203+   path=$( _rpm_get_repo_path " $arch "   " $dist_name "   " $version_number " ) 
204+   #  Print the final constructed URL
205+   echo  " ${base} /${path} " 
206+ }
207+ 
146208rpm_pkg () {
147209  #  ID_LIKE may not exist
148210  set  +u
@@ -279,15 +341,25 @@ rpm_setup_mariadb_mirror() {
279341    bb_log_err " missing the branch variable" 
280342    exit  1
281343  }
282-   branch=$1 
344+   [[ -n  $2  ]] ||  {
345+     bb_log_err " missing the mirror_url variable" 
346+     exit  1
347+   }
348+   [[ -n  $3  ]] ||  {
349+     bb_log_err " missing the archive_url variable" 
350+     exit  1
351+   }
352+   local  branch=$1 
353+   local  mirror_url=$2 
354+   local  archive_url=$3 
355+ 
283356  bb_log_info " setup MariaDB repository for $branch  branch" 
284357  command  -v wget > /dev/null ||  {
285358    bb_log_err " wget command not found" 
286359    exit  1
287360  }
288-   # //TEMP it's probably better to install the last stable release here...?
289-   mirror_url=" https://rpm.mariadb.org/$branch /$arch " 
290-   archive_url=" https://archive.mariadb.org/mariadb-$branch /yum/$arch " 
361+ 
362+   local  baseurl
291363  if  wget -q --spider " $mirror_url " ;  then 
292364    baseurl=" $mirror_url " 
293365  elif  wget -q --spider " $archive_url " ;  then 
@@ -297,7 +369,7 @@ rpm_setup_mariadb_mirror() {
297369    #  since we know it will always fail. But apparently, it's not going to
298370    #  happen soon in BB. Once done though, replace the warning with an error
299371    #  and use a non-zero exit code.
300-     bb_log_warn " rpm_setup_mariadb_mirror: $branch  packages for  $dist_name   $version_name  does  not exist on https://rpm.mariadb.org/ " 
372+     bb_log_warn " rpm_setup_mariadb_mirror: $branch  packages do  not exist on either  $mirror_url  or  $archive_url " 
301373    exit  0
302374  fi 
303375  cat << EOF  | sudo tee "$( rpm_repo_dir)  /MariaDB.repo"
0 commit comments