mirror of
https://github.com/tuna/tunasync-scripts.git
synced 2025-12-25 16:32:47 +00:00
Replace hardcoded versions passed to yum-sync.py with templates [ci skip]
Signed-off-by: Shengqi Chen <harry-chen@outlook.com>
This commit is contained in:
parent
962acd7959
commit
501553bf55
|
|
@ -118,7 +118,7 @@ if __name__ == "__main__":
|
||||||
sp.run([str(here/"yum-sync.py"),
|
sp.run([str(here/"yum-sync.py"),
|
||||||
BASE_URL+'/rpm/rhel/@{os_ver}/@{arch}',
|
BASE_URL+'/rpm/rhel/@{os_ver}/@{arch}',
|
||||||
"--download-repodata",
|
"--download-repodata",
|
||||||
'9,10',
|
'@rhel-current',
|
||||||
'Adoptium',
|
'Adoptium',
|
||||||
'x86_64,aarch64',
|
'x86_64,aarch64',
|
||||||
"rhel@{os_ver}-@{arch}",
|
"rhel@{os_ver}-@{arch}",
|
||||||
|
|
@ -128,7 +128,7 @@ if __name__ == "__main__":
|
||||||
sp.run([str(here/"yum-sync.py"),
|
sp.run([str(here/"yum-sync.py"),
|
||||||
BASE_URL+'/rpm/fedora/@{os_ver}/@{arch}',
|
BASE_URL+'/rpm/fedora/@{os_ver}/@{arch}',
|
||||||
"--download-repodata",
|
"--download-repodata",
|
||||||
'42',
|
'@fedora-current',
|
||||||
'Adoptium',
|
'Adoptium',
|
||||||
'x86_64,aarch64',
|
'x86_64,aarch64',
|
||||||
"fedora@{os_ver}-@{arch}",
|
"fedora@{os_ver}-@{arch}",
|
||||||
|
|
|
||||||
2
chef.sh
2
chef.sh
|
|
@ -13,7 +13,7 @@ YUM_PATH="${BASE_PATH}/yum/stable"
|
||||||
APT_PATH="${BASE_PATH}/apt/stable"
|
APT_PATH="${BASE_PATH}/apt/stable"
|
||||||
export REPO_SIZE_FILE=/tmp/reposize.$RANDOM
|
export REPO_SIZE_FILE=/tmp/reposize.$RANDOM
|
||||||
|
|
||||||
"$yum_sync" "${UPSTREAM}/yum/stable/el/@{os_ver}/@{arch}" 9 chef x86_64 "stable-el@{os_ver}-@{arch}" "$YUM_PATH"
|
"$yum_sync" "${UPSTREAM}/yum/stable/el/@{os_ver}/@{arch}" @rhel-current chef x86_64 "stable-el@{os_ver}-@{arch}" "$YUM_PATH"
|
||||||
echo "YUM finished"
|
echo "YUM finished"
|
||||||
|
|
||||||
"$apt_sync" --delete "${UPSTREAM}/apt/stable" @ubuntu-lts,@debian-current main amd64,i386,aarch64 "$APT_PATH"
|
"$apt_sync" --delete "${UPSTREAM}/apt/stable" @ubuntu-lts,@debian-current main amd64,i386,aarch64 "$APT_PATH"
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ UBUNTU_PATH="${BASE_PATH}/ubuntu/"
|
||||||
DEBIAN_PATH="${BASE_PATH}/debian/"
|
DEBIAN_PATH="${BASE_PATH}/debian/"
|
||||||
export REPO_SIZE_FILE=/tmp/reposize.$RANDOM
|
export REPO_SIZE_FILE=/tmp/reposize.$RANDOM
|
||||||
|
|
||||||
"$yum_sync" "${UPSTREAM}/el/@{os_ver}/@{arch}/" 9 "gitlab" x86_64 "el@{os_ver}" "$YUM_PATH"
|
"$yum_sync" "${UPSTREAM}/el/@{os_ver}/@{arch}/" @rhel-current "gitlab" x86_64 "el@{os_ver}" "$YUM_PATH"
|
||||||
echo "YUM finished"
|
echo "YUM finished"
|
||||||
|
|
||||||
"$apt_sync" --delete "${UPSTREAM}/ubuntu" @ubuntu-lts main amd64,i386 "$UBUNTU_PATH"
|
"$apt_sync" --delete "${UPSTREAM}/ubuntu" @ubuntu-lts main amd64,i386 "$UBUNTU_PATH"
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ UBUNTU_PATH="${BASE_PATH}/ubuntu/"
|
||||||
DEBIAN_PATH="${BASE_PATH}/debian/"
|
DEBIAN_PATH="${BASE_PATH}/debian/"
|
||||||
export REPO_SIZE_FILE=/tmp/reposize.$RANDOM
|
export REPO_SIZE_FILE=/tmp/reposize.$RANDOM
|
||||||
|
|
||||||
"$yum_sync" "${UPSTREAM}/el/@{os_ver}/@{arch}" 9 gitlab-runner x86_64,aarch64 "el@{os_ver}-@{arch}" "$YUM_PATH"
|
"$yum_sync" "${UPSTREAM}/el/@{os_ver}/@{arch}" @rhel-current gitlab-runner x86_64,aarch64 "el@{os_ver}-@{arch}" "$YUM_PATH"
|
||||||
echo "YUM finished"
|
echo "YUM finished"
|
||||||
|
|
||||||
"$apt_sync" --delete "${UPSTREAM}/ubuntu" @ubuntu-lts main amd64,i386,arm64 "$UBUNTU_PATH"
|
"$apt_sync" --delete "${UPSTREAM}/ubuntu" @ubuntu-lts main amd64,i386,arm64 "$UBUNTU_PATH"
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ echo "Debian/Ubuntu finished"
|
||||||
|
|
||||||
|
|
||||||
# =================== YUM/DNF repos ==========================
|
# =================== YUM/DNF repos ==========================
|
||||||
"$yum_sync" "${BASE_URL}/rhel/@{os_ver}/@{arch}/stable/" 9 influxdata x86_64 "el@{os_ver}-@{arch}" "$YUM_PATH"
|
"$yum_sync" "${BASE_URL}/rhel/@{os_ver}/@{arch}/stable/" @rhel-current influxdata x86_64 "el@{os_ver}-@{arch}" "$YUM_PATH"
|
||||||
echo "YUM finished"
|
echo "YUM finished"
|
||||||
|
|
||||||
"${_here}/helpers/size-sum.sh" $REPO_SIZE_FILE --rm
|
"${_here}/helpers/size-sum.sh" $REPO_SIZE_FILE --rm
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export REPO_SIZE_FILE=/tmp/reposize.$RANDOM
|
||||||
|
|
||||||
components=$(printf ",%s" "${MONGO_VERSIONS[@]}")
|
components=$(printf ",%s" "${MONGO_VERSIONS[@]}")
|
||||||
components=${components:1}
|
components=${components:1}
|
||||||
"$yum_sync" "${BASE_URL}/yum/redhat/@{os_ver}/mongodb-org/@{comp}/@{arch}/" 9 "$components" x86_64 "el@{os_ver}-@{comp}" "$YUM_PATH"
|
"$yum_sync" "${BASE_URL}/yum/redhat/@{os_ver}/mongodb-org/@{comp}/@{arch}/" @rhel-current "$components" x86_64 "el@{os_ver}-@{comp}" "$YUM_PATH"
|
||||||
pushd "${YUM_PATH}"
|
pushd "${YUM_PATH}"
|
||||||
for stable in el*-${STABLE_VERSION}; do
|
for stable in el*-${STABLE_VERSION}; do
|
||||||
# e.g. "el8" -> "el8-4.2"
|
# e.g. "el8" -> "el8-4.2"
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ export REPO_SIZE_FILE=/tmp/reposize.$RANDOM
|
||||||
|
|
||||||
components=$(printf ",%s" "${RUDDER_VERS[@]}")
|
components=$(printf ",%s" "${RUDDER_VERS[@]}")
|
||||||
components=${components:1}
|
components=${components:1}
|
||||||
"$yum_sync" "${UPSTREAM}/rpm/@{comp}/RHEL_@{os_ver}/" 9,10 $components x86_64 "rudder@{comp}-RHEL_@{os_ver}" "$YUM_PATH"
|
"$yum_sync" "${UPSTREAM}/rpm/@{comp}/RHEL_@{os_ver}/" @rhel-current $components x86_64 "rudder@{comp}-RHEL_@{os_ver}" "$YUM_PATH"
|
||||||
echo "YUM finished"
|
echo "YUM finished"
|
||||||
|
|
||||||
for ver in ${RUDDER_VERS[@]}; do
|
for ver in ${RUDDER_VERS[@]}; do
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ export REPO_SIZE_FILE=/tmp/reposize.$RANDOM
|
||||||
|
|
||||||
# === download rhel packages ====
|
# === download rhel packages ====
|
||||||
|
|
||||||
"$yum_sync" "${BASE_URL}/rpm/el/@{os_ver}/@{arch}" 9 VirtualBox x86_64 "el@{os_ver}" "$YUM_PATH"
|
"$yum_sync" "${BASE_URL}/rpm/el/@{os_ver}/@{arch}" @rhel-current VirtualBox x86_64 "el@{os_ver}" "$YUM_PATH"
|
||||||
echo "YUM finished"
|
echo "YUM finished"
|
||||||
|
|
||||||
# === download deb packages ====
|
# === download deb packages ====
|
||||||
|
|
|
||||||
25
yum-sync.py
25
yum-sync.py
|
|
@ -10,6 +10,7 @@ import shutil
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import traceback
|
import traceback
|
||||||
import time
|
import time
|
||||||
|
import re
|
||||||
from email.utils import parsedate_to_datetime
|
from email.utils import parsedate_to_datetime
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
@ -21,6 +22,26 @@ DOWNLOAD_TIMEOUT = int(os.getenv("DOWNLOAD_TIMEOUT", "1800"))
|
||||||
REPO_STAT = {}
|
REPO_STAT = {}
|
||||||
|
|
||||||
|
|
||||||
|
OS_TEMPLATE = {
|
||||||
|
"rhel-current": ["9", "10"],
|
||||||
|
"fedora-current": ["41", "42"],
|
||||||
|
}
|
||||||
|
|
||||||
|
pattern_os_template = re.compile(r"@\{(.+)\}")
|
||||||
|
|
||||||
|
def replace_os_template(os_list: List[str]) -> List[str]:
|
||||||
|
ret = []
|
||||||
|
for i in os_list:
|
||||||
|
matched = pattern_os_template.search(i)
|
||||||
|
if matched:
|
||||||
|
for os in OS_TEMPLATE[matched.group(1)]:
|
||||||
|
ret.append(pattern_os_template.sub(os, i))
|
||||||
|
elif i.startswith("@"):
|
||||||
|
ret.extend(OS_TEMPLATE[i[1:]])
|
||||||
|
else:
|
||||||
|
ret.append(i)
|
||||||
|
return ret
|
||||||
|
|
||||||
def calc_repo_size(path: Path):
|
def calc_repo_size(path: Path):
|
||||||
dbfiles = path.glob("repodata/*primary.*")
|
dbfiles = path.glob("repodata/*primary.*")
|
||||||
with tempfile.NamedTemporaryFile() as tmp:
|
with tempfile.NamedTemporaryFile() as tmp:
|
||||||
|
|
@ -175,7 +196,9 @@ def main():
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
os_list = []
|
os_list = []
|
||||||
for os_version in args.os_version.split(","):
|
raw_os_list = args.os_version.split(",")
|
||||||
|
raw_os_list = replace_os_template(raw_os_list)
|
||||||
|
for os_version in raw_os_list.split(","):
|
||||||
if "-" in os_version and "-stream" not in os_version:
|
if "-" in os_version and "-stream" not in os_version:
|
||||||
dash = os_version.index("-")
|
dash = os_version.index("-")
|
||||||
os_list = os_list + [
|
os_list = os_list + [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue