ae68691bf0
StarlingX needs to download a variety of rpms and tarballs from various upstream sources. Unfortunately the upstream sources are not always dependable. Either servers go down, are unreachable, or drop older content that we still depend on. Our proposed solution is to run our own mirror to capture an independent copy of the content needed by StarlingX. For this purpose, a server has been set up at http://mirror.starlingx.cengn.ca/mirror/centos The mirror will use deterministic paths derived from the upstream urls. Scripts will be used to convert an upstream url to the mirror's equivalent url (see function url_to_stx_mirror_url in url_utils.sh) The mirror will be refreshed daily. New .lst entries will be processed at that time. Processing of changes under yum.repos.d is not automated by this update. Expect a follow-up update to address this issue soon. These scripts are found under the 'stx_mirror_scripts' subdirectory. Changes are made to the download_mirror.sh script, and it's supporting scripts. New arguments have been added to each script to select the download source. -s StarlingX mirror only -S StarlingX mirror, with upstream source as backup -u Upstream source only -U Upstream source, with StarlingX mirror as backup You do not need to provide any of these flags. Continue to us download_mirror.sh as you always have. The default behavior is currently set to '-S', i.e. first try the StarlingX mirror, with upstream source as backup. If this proves to place to heavy a load on the existing server, we might switch the default to '-U', i.e. first try the upstream source, with StarlingX mirror as backup. If poor download performance is seen, you might want to try explicitly adding -U as an argument. The remaining two options are not recommended for regular use. Upstream only, i.e. '-u', restores original behaviour, but you may once again encounter rpms that have aged out, and been removed from their original repos. StarlingX only, i.e. '-s', is vulnerable if a .lst file has been updated, but the mirror has not yet processed it. Change-Id: I7e0f3d9fb99253662f9f4bf12457d39250408c0b Story: 2003906 Task: 26785 Signed-off-by: Scott Little <scott.little@windriver.com>
130 lines
3.6 KiB
Bash
Executable File
130 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
#
|
|
# Daily update script for mirror.starlingx.cengn.ca covering
|
|
# rpms and src.rpms downloaded from a yum repository.
|
|
#
|
|
# IMPORTANT: This script is only to be run on the StarlingX mirror.
|
|
# It is not for use by the general StarlinX developer.
|
|
#
|
|
# Configuration files for repositories to be downloaded are currently
|
|
# stored at mirror.starlingx.cengn.ca:/export/config/yum.repos.d.
|
|
# Those repos were derived from stx-tools/centos-mirror-tools/yum.repos.d
|
|
# with some modifications that will need to be automated in a
|
|
# future update.
|
|
#
|
|
# This script was originated by Scott Little.
|
|
#
|
|
|
|
LOGFILE="/export/log/daily_repo_sync.log"
|
|
YUM_CONF_DIR="/export/config"
|
|
YUM_REPOS_DIR="$YUM_CONF_DIR/yum.repos.d"
|
|
DOWNLOAD_PATH_ROOT="/export/mirror/centos"
|
|
URL_UTILS="url_utils.sh"
|
|
|
|
DAILY_REPO_SYNC_DIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}" )" )"
|
|
|
|
if [ -f "$DAILY_REPO_SYNC_DIR/$URL_UTILS" ]; then
|
|
source "$DAILY_REPO_SYNC_DIR/$URL_UTILS"
|
|
elif [ -f "$DAILY_REPO_SYNC_DIR/../$URL_UTILS" ]; then
|
|
source "$DAILY_REPO_SYNC_DIR/../$URL_UTILS"
|
|
else
|
|
echo "Error: Can't find '$URL_UTILS'"
|
|
exit 1
|
|
fi
|
|
|
|
CREATEREPO=$(which createrepo_c)
|
|
if [ $? -ne 0 ]; then
|
|
CREATEREPO="createrepo"
|
|
fi
|
|
|
|
number_of_cpus () {
|
|
/usr/bin/nproc
|
|
}
|
|
|
|
if [ -f $LOGFILE ]; then
|
|
rm -f $LOGFILE
|
|
fi
|
|
|
|
ERR_COUNT=0
|
|
YUM_CONF="$YUM_CONF_DIR/yum.conf"
|
|
if [ ! -f "$YUM_CONF" ]; then
|
|
echo "Error: Missing yum.conf file at '$YUM_CONF'"
|
|
exit 1
|
|
fi
|
|
|
|
for REPO in $(find $YUM_REPOS_DIR -name '*.repo'); do
|
|
for REPO_ID in $(grep '^[[]' $REPO | sed 's#[][]##g'); do
|
|
|
|
REPO_URL=$(yum repoinfo --config="$YUM_CONF" --disablerepo="*" --enablerepo="$REPO_ID" | grep Repo-baseurl | cut -d ' ' -f 3)
|
|
DOWNLOAD_PATH="$DOWNLOAD_PATH_ROOT/$(repo_url_to_sub_path "$REPO_URL")"
|
|
|
|
echo "Processing: REPO=$REPO REPO_ID=$REPO_ID REPO_URL=$REPO_URL DOWNLOAD_PATH=$DOWNLOAD_PATH"
|
|
|
|
# Assume it's a repo of binary rpms unless repoid ends in
|
|
# some variation of 'source'.
|
|
SOURCE_FLAG=""
|
|
echo "$REPO_ID" | grep -q '[-_][Ss]ource$' && SOURCE_FLAG="--source"
|
|
echo "$REPO_ID" | grep -q '[-_][Ss]ources$' && SOURCE_FLAG="--source"
|
|
echo "$REPO_ID" | grep -q '[-_][Ss]ource[-_]' && SOURCE_FLAG="--source"
|
|
echo "$REPO_ID" | grep -q '[-_][Ss]ources[-_]' && SOURCE_FLAG="--source"
|
|
|
|
if [ ! -d "$DOWNLOAD_PATH" ]; then
|
|
CMD="mkdir -p '$DOWNLOAD_PATH'"
|
|
echo "$CMD"
|
|
eval $CMD
|
|
if [ $? -ne 0 ]; then
|
|
echo "Error: $CMD"
|
|
ERR_COUNT=$((ERR_COUNT+1))
|
|
continue
|
|
fi
|
|
fi
|
|
|
|
CMD="reposync --norepopath $SOURCE_FLAG -l --config=$YUM_CONF --repoid=$REPO_ID --download_path='$DOWNLOAD_PATH'"
|
|
echo "$CMD"
|
|
eval $CMD
|
|
if [ $? -ne 0 ]; then
|
|
echo "Error: $CMD"
|
|
ERR_COUNT=$((ERR_COUNT+1))
|
|
continue
|
|
fi
|
|
|
|
CMD="pushd '$DOWNLOAD_PATH'"
|
|
echo "$CMD"
|
|
eval $CMD
|
|
if [ $? -ne 0 ]; then
|
|
echo "Error: $CMD"
|
|
ERR_COUNT=$((ERR_COUNT+1))
|
|
continue
|
|
fi
|
|
|
|
OPTIONS="--workers $(number_of_cpus)"
|
|
if [ -f comps.xml ]; then
|
|
OPTIONS="$OPTIONS -g comps.xml"
|
|
fi
|
|
if [ -d repodata ]; then
|
|
OPTIONS="$OPTIONS --update"
|
|
fi
|
|
|
|
CMD="$CREATEREPO $OPTIONS ."
|
|
echo "$CMD"
|
|
eval $CMD
|
|
if [ $? -ne 0 ]; then
|
|
echo "Error: $CMD"
|
|
ERR_COUNT=$((ERR_COUNT+1))
|
|
popd
|
|
continue
|
|
fi
|
|
|
|
popd
|
|
done
|
|
done | tee $LOGFILE
|
|
|
|
if [ $ERR_COUNT -ne 0 ]; then
|
|
exit 1
|
|
fi
|
|
|
|
exit 0
|