toolkit/sync/sync-to-staging.sh

147 lines
4.7 KiB
Bash
Raw Normal View History

2021-07-05 06:50:25 +00:00
#!/bin/bash
2023-01-13 22:32:50 +00:00
# Short name (eg, NFV, extras, Rocky, gluster9)
SHORT=${1}
# Source common variables
2021-07-06 20:33:22 +00:00
# shellcheck disable=SC2046,1091,1090
source "$(dirname "$0")/common"
2021-07-08 02:54:12 +00:00
if [[ $# -eq 0 ]]; then
echo "You must specify a short name."
exit 1
fi
if [[ "${RLVER}" -ne "8" ]]; then
echo "This is only used for Rocky Linux 8 releases."
fi
2021-07-05 06:50:25 +00:00
# Major Version (eg, 8)
2023-05-18 00:19:35 +00:00
#MAJ=${RLVER}
2023-05-13 20:44:17 +00:00
#cd "${RELEASE_COMPOSE_ROOT}/compose" || { echo "Failed to change directory"; ret_val=1; exit 1; }
cd "${RELEASE_COMPOSE_ROOT}/" || { echo "Failed to change directory"; ret_val=1; exit 1; }
2021-07-05 06:50:25 +00:00
ret_val=$?
2021-07-05 06:50:25 +00:00
if [ $ret_val -eq "0" ]; then
2021-07-06 20:16:01 +00:00
TARGET="${STAGING_ROOT}/${CATEGORY_STUB}/${REV}"
# The target should already exist as this is used to do simple syncs.
2021-07-06 20:16:01 +00:00
mkdir -p "${TARGET}"
# Find all directories for this compose
2023-05-18 00:19:35 +00:00
mapfile -t repo_dirs < <(find compose -name repodata -type d | sed 's/compose\///g')
mapfile -t src_dirs < <(find compose -name repodata -type d | sed 's/compose\///g ; s/\/repodata//g' | grep source)
mapfile -t arch_dirs < <(find compose -name repodata -type d | sed 's/compose\///g ; s/\/repodata//g' | grep -v source)
mapfile -t debug_dirs < <(find compose -name repodata -type d | sed 's/compose\///g ; s/\/repodata//g' | grep debug)
# Delete all repodata for this compose
2023-05-18 00:19:35 +00:00
echo "** Removing all current repo data"
for x in "${repo_dirs[@]}"; do
test -d "${TARGET}/${x}"
ret_val=$?
if [ $ret_val -eq "0" ]; then
/bin/rm "${TARGET:?}/${x}/"*
else
echo "${x} not found"
fi
done
2023-05-18 00:19:35 +00:00
# Now that we've deleted the repo data, we need to sync
echo "** Syncing all new content"
rsync_no_delete_staging_pungi "${TARGET}"
2023-05-18 00:19:35 +00:00
# Now we need to createrepo
echo "** Running createrepo on source repos"
for src_repo in "${src_dirs[@]}"; do
echo "Trying ${src_repo}..."
test -d "${TARGET}/${src_repo}"
ret_val=$?
if [ $ret_val -eq "0" ]; then
2023-05-18 21:15:19 +00:00
createrepo_update "${TARGET}/${src_repo}" "${REVISION}"
2023-05-18 00:19:35 +00:00
fix_metadata "${TARGET}/${src_repo}/repodata/repomd.xml"
sign_data "${TARGET}/${src_repo}/repodata/repomd.xml"
else
echo "${src_repo} not found"
fi
done
# We need to be specific here. If the short name is "Rocky" we have extra
# work. Otherwise, normal createrepo is fine.
echo "** Running createrepo on arch repos"
if [[ "${SHORT}" == "Rocky" ]]; then
echo "** Updating all debug repos"
for debug_repo in "${debug_dirs[@]}"; do
echo "Trying ${debug_repo}..."
test -d "${TARGET}/${debug_repo}"
ret_val=$?
if [ $ret_val -eq "0" ]; then
2023-05-18 21:15:19 +00:00
createrepo_update "${TARGET}/${debug_repo}" "${REVISION}"
2023-05-18 00:19:35 +00:00
fix_metadata "${TARGET}/${debug_repo}/repodata/repomd.xml"
sign_data "${TARGET}/${debug_repo}/repodata/repomd.xml"
else
echo "${debug_repo} not found"
fi
done
echo "** Updating all repos with comps/groups"
for arch in "${ARCHES[@]}"; do
for comp_repo in "${MODS_REPOS[@]}"; do
echo "Trying ${arch} ${comp_repo}..."
REPO_PATH="${TARGET}/${comp_repo}/${arch}/os"
COMP_PATH="${RELEASE_COMPOSE_ROOT}/work/${arch}/comps/comps-${comp_repo}.${arch}.xml"
test -d "${REPO_PATH}"
ret_val=$?
if [ $ret_val -eq "0" ]; then
createrepo_comps "${REPO_PATH}" "${REVISION}" "${COMP_PATH}"
fix_metadata "${REPO_PATH}/repodata/repomd.xml"
sign_data "${REPO_PATH}/repodata/repomd.xml"
else
echo "${comp_repo} not found"
fi
done
done
echo "** Updating modules"
for arch in "${ARCHES[@]}"; do
2023-05-18 01:47:31 +00:00
for mod_repo in "${MODS[@]}"; do
2023-05-18 00:19:35 +00:00
echo "Trying ${arch} ${mod_repo}..."
MOD_PATH="${TARGET}/${mod_repo}/${arch}/os/repodata"
MOD_YAML="/mnt/compose/${RLVER}_metadata/${arch}/${mod_repo}-modules.yaml"
test -f "${MOD_YAML}"
ret_val=$?
if [ $ret_val -ne 0 ]; then
echo "Module yaml not found"
continue
fi
test -d "${MOD_PATH}"
ret_val=$?
if [ $ret_val -eq 0 ]; then
modifyrepo_module "${MOD_PATH}" "${MOD_YAML}"
fix_metadata "${MOD_PATH}/repomd.xml"
sign_data "${MOD_PATH}/repomd.xml"
else
echo "${mod_repo} not found"
fi
done
done
else
for arch_repo in "${arch_dirs[@]}"; do
echo "Trying ${arch_repo}..."
test -d "${TARGET}/${arch_repo}"
ret_val=$?
if [ $ret_val -eq "0" ]; then
2023-05-18 21:15:19 +00:00
createrepo_update "${TARGET}/${arch_repo}" "${REVISION}"
2023-05-18 00:19:35 +00:00
fix_metadata "${TARGET}/${arch_repo}/repodata/repomd.xml"
sign_data "${TARGET}/${arch_repo}/repodata/repomd.xml"
else
echo "${arch_repo} not found"
fi
done
fi
echo "** Hardlinking staging directory (${TARGET})"
perform_hardlink "${TARGET}"
2021-07-05 06:50:25 +00:00
fi