Set vars as local in funcs, fix minor release script

This commit is contained in:
Louis Abel 2023-05-13 14:46:12 -07:00
parent 78154eb23e
commit 10456f70b8
Signed by: label
GPG Key ID: B37E62D143879B36
3 changed files with 34 additions and 31 deletions

View File

@ -69,12 +69,12 @@ VARIANTS=(boot minimal dvd1)
# Syncing functions # Syncing functions
function parallel_rsync_no_delete_staging() { function parallel_rsync_no_delete_staging() {
TARGET="${1}" local TARGET="${1}"
sudo -l && find **/* -maxdepth 0 -type d | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable {} "${TARGET}" sudo -l && find **/* -maxdepth 0 -type d | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable {} "${TARGET}"
} }
function parallel_rsync_no_delete_prod() { function parallel_rsync_no_delete_prod() {
TARGET="${1}" local TARGET="${1}"
sudo -l && find ./ -mindepth 1 -maxdepth 1 -type d -exec find {}/ -mindepth 1 -maxdepth 1 -type d \;|sed 's/^..//g' | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable {} "${TARGET}" sudo -l && find ./ -mindepth 1 -maxdepth 1 -type d -exec find {}/ -mindepth 1 -maxdepth 1 -type d \;|sed 's/^..//g' | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable {} "${TARGET}"
# shellcheck disable=SC2035 # shellcheck disable=SC2035
sudo -l && find ** -maxdepth 0 -type l | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable {} "${TARGET}" sudo -l && find ** -maxdepth 0 -type l | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable {} "${TARGET}"
@ -86,36 +86,42 @@ function parallel_rsync_delete_staging() {
} }
function parallel_rsync_delete_prod() { function parallel_rsync_delete_prod() {
TARGET="${1}" local TARGET="${1}"
sudo -l && find ./ -mindepth 1 -maxdepth 1 -type d -exec find {}/ -mindepth 1 -maxdepth 1 -type d \;|sed 's/^..//g' | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable --delete {} "${TARGET}" sudo -l && find ./ -mindepth 1 -maxdepth 1 -type d -exec find {}/ -mindepth 1 -maxdepth 1 -type d \;|sed 's/^..//g' | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable --delete {} "${TARGET}"
# shellcheck disable=SC2035 # shellcheck disable=SC2035
sudo -l && find ** -maxdepth 0 -type l | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable {} "${TARGET}" sudo -l && find ** -maxdepth 0 -type l | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable {} "${TARGET}"
} }
function rsync_no_delete_staging() { function rsync_no_delete_staging() {
TARGET="${1}" local TARGET="${1}"
sudo -l && rsync -vrlptDSH --chown=10004:10005 --progress --human-readable compose/ "${TARGET}" sudo -l && rsync -vrlptDSH --chown=10004:10005 --progress --human-readable compose/ "${TARGET}"
} }
function rsync_no_delete_staging_with_excludes() {
local TARGET="${1}"
local EXCLUDE="${2}"
sudo -l && rsync -vrlptDSH --chown=10004:10005 --progress --human-readable --exclude "${EXCLUDE}" compose/ "${TARGET}"
}
function rsync_no_delete_prod() { function rsync_no_delete_prod() {
REV="${1}" local REV="${1}"
TARGET="${2}" local TARGET="${2}"
sudo -l && rsync -vrlptDSH --chown=10004:10005 --progress --human-readable "${REV}/" "${TARGET}" sudo -l && rsync -vrlptDSH --chown=10004:10005 --progress --human-readable "${REV}/" "${TARGET}"
} }
function rsync_delete_staging() { function rsync_delete_staging() {
TARGET="${1}" local TARGET="${1}"
sudo -l && rsync -vrlptDSH --chown=10004:10005 --progress --human-readable --delete compose/ "${TARGET}" sudo -l && rsync -vrlptDSH --chown=10004:10005 --progress --human-readable --delete compose/ "${TARGET}"
} }
function rsync_delete_prod() { function rsync_delete_prod() {
REV="${1}" local REV="${1}"
TARGET="${2}" local TARGET="${2}"
sudo -l && rsync -vrlptDSH --chown=10004:10005 --progress --human-readable --delete "${REV}/" "${TARGET}" sudo -l && rsync -vrlptDSH --chown=10004:10005 --progress --human-readable --delete "${REV}/" "${TARGET}"
} }
function perform_hardlink() { function perform_hardlink() {
TARGET="${1}" local TARGET="${1}"
hardlink -x '.*\.xml.*' "${TARGET}" hardlink -x '.*\.xml.*' "${TARGET}"
} }
@ -124,6 +130,7 @@ export -f parallel_rsync_no_delete_prod
export -f parallel_rsync_delete_staging export -f parallel_rsync_delete_staging
export -f parallel_rsync_delete_prod export -f parallel_rsync_delete_prod
export -f rsync_no_delete_staging export -f rsync_no_delete_staging
export -f rsync_no_delete_staging_with_excludes
export -f rsync_no_delete_prod export -f rsync_no_delete_prod
export -f rsync_delete_staging export -f rsync_delete_staging
export -f rsync_delete_prod export -f rsync_delete_prod

View File

@ -10,10 +10,16 @@ source $(dirname "$0")/common
# Major Version (eg, 8) # Major Version (eg, 8)
MAJ=${RLVER} MAJ=${RLVER}
if [ "${MAJ}" == "9" ]; then
echo "Does not work for Rocky Linux 9. Please use sync-to-staging"
exit 32
fi
# sync all pieces of a release, including extras, nfv, etc # sync all pieces of a release, including extras, nfv, etc
for COMPOSE in "${NONSIG_COMPOSE[@]}"; do for COMPOSE in "${NONSIG_COMPOSE[@]}"; do
echo "${COMPOSE}: Syncing" echo "${COMPOSE}: Syncing"
pushd "${RELEASE_COMPOSE_ROOT}/compose" || { echo "${COMPOSE}: Failed to change directory"; break; } SYNCSRC="/mnt/compose/${MAJ}/latest-${COMPOSE}-${MAJ}"
pushd "${SYNCSRC}/compose" || { echo "${COMPOSE}: Failed to change directory"; break; }
if [[ "${COMPOSE}" == "Rocky" ]]; then if [[ "${COMPOSE}" == "Rocky" ]]; then
# ISO Work before syncing # ISO Work before syncing
@ -39,30 +45,20 @@ for COMPOSE in "${NONSIG_COMPOSE[@]}"; do
done done
popd || { echo "Could not change directory"; break; } popd || { echo "Could not change directory"; break; }
done done
mkdir -p live/x86_64
ln -s live Live
fi fi
popd || { echo "${COMPOSE}: Failed to change directory"; break; }
TARGET="${STAGING_ROOT}/${CATEGORY_STUB}/${REV}" TARGET="${STAGING_ROOT}/${CATEGORY_STUB}/${REV}"
mkdir -p "${TARGET}" mkdir -p "${TARGET}"
# disabling because none of our files should be starting with dashes. If they pushd "${SYNCSRC}" || { echo "${COMPOSE}: Failed to change directory"; break; }
# are something is *seriously* wrong here. if [[ "${COMPOSE}" != "Rocky" ]]; then
# shellcheck disable=SC2035 rsync_no_delete_staging_with_excludes "${TARGET}" "metadata"
sudo -l && find **/* -maxdepth 0 -type d | parallel --will-cite -j 18 sudo rsync -av --chown=10004:10005 --progress --relative --human-readable \ else
{} "${TARGET}" rsync_no_delete_staging "${TARGET}"
if [[ "${COMPOSE}" == "Rocky" ]]; then
cp COMPOSE_ID "${TARGET}"
chown 10004:10005 "${TARGET}/COMPOSE_ID"
rsync -av --chown=10004:10005 --progress --relative --human-readable metadata "${TARGET}"
fi fi
popd || { echo "${COMPOSE}: Failed to change directory"; break; }
# Return back to where we started
popd || { echo "${COMPOSE}: Failed to change back"; break; }
# Create extra stuff
pushd "${TARGET}" || { echo "${COMPOSE}: Failed to change directory"; break; }
mkdir -p Live/x86_64
ln -s Live live
popd || { echo "${COMPOSE}: Failed to change back"; break; }
done done

View File

@ -23,6 +23,6 @@ if [ $ret_val -eq "0" ]; then
TARGET="${STAGING_ROOT}/${CATEGORY_STUB}/${REV}" TARGET="${STAGING_ROOT}/${CATEGORY_STUB}/${REV}"
mkdir -p "${TARGET}" mkdir -p "${TARGET}"
rsync_no_delete_staging "${TARGET}" rsync_no_delete_staging "${TARGET}"
echo "Hardlinking staging directory" echo "Hardlinking staging directory (${TARGET})"
perform_hardlink "${TARGET}" perform_hardlink "${TARGET}"
fi fi