Browse Source

refactoring

main
Nicolas Massé 1 week ago
parent
commit
940a8a1af9
  1. 6
      build.sh
  2. 62
      common.sh
  3. 54
      update.sh

6
build.sh

@ -15,10 +15,8 @@ GIT_REPOSITORY="https://github.com/nmasse-itix/zfs-aarch64.git"
COPR_PROJECT="zfs-aarch64"
COPR_USERNAME="$(copr-cli whoami)"
dists=(centos-9 centos-10)
for v in $(get_fedora_versions); do
dists+=("fedora-$v")
done
echo "Computing a list of currently maintained versions of Fedora and CentOS Stream..."
dists=( $(get_all_remote_dists) )
for dist in "${dists[@]}"; do
copr_release="${dist//centos/epel}"

62
common.sh

@ -2,8 +2,68 @@
# Prints the list of currently maintained Fedora versions (e.g. "42 43 44"),
# based on the Bodhi releases API.
get_fedora_versions () {
function get_fedora_versions () {
curl -fsSL "https://bodhi.fedoraproject.org/releases/?exclude_archived=true&state=current" \
| jq -r '.releases[] | select(.id_prefix=="FEDORA") | .version' \
| grep -E '^[0-9]+$' | sort -n
}
# Prints the list of active CentOS Stream versions (e.g. "9 10"),
# based on the directory listing of the official mirror.
function get_centos_stream_versions () {
curl -fsSL "https://mirror.stream.centos.org/" \
| grep -oP '(?<=href=")[0-9]+-stream(?=/")' \
| sed 's/-stream//' | sort -n
}
# Prints the list of currently maintained Fedora and CentOS Stream versions (e.g. "centos-9 centos-10 fedora-42 fedora-43 fedora-44").
function get_all_remote_dists () {
local dists=()
for v in $(get_centos_stream_versions); do
dists+=("centos-$v")
done
for v in $(get_fedora_versions); do
dists+=("fedora-$v")
done
echo "${dists[@]}"
}
# Installs locally all source RPMs of a given distribution.
function install_all_srpm () {
local dist=$1
echo "Importing source RPMs of $dist..."
rpm -ivh "--define=_topdir $PWD/$dist" "$dist/SRPMS/"*.src.rpm
}
# Applies all patches for a given distribution.
function apply_patches () {
local dist=$1
for patch in "$dist/PATCHES"/*.patch; do
echo "Applying patch $(basename "$patch")..."
patch -d "$dist"* -p1 < "$patch"
done
}
# Downloads the libvirt and zfs source RPMs for a given Fedora distribution.
function download_sources_fedora () {
local dist=$1
local v="${dist#*-}"
echo "Downloading libvirt source for Fedora $v..."
dnf download --repofrompath=$dist,https://dl.fedoraproject.org/pub/fedora/linux/releases/$v/Everything/source/tree/ --repofrompath=$dist-updates,https://dl.fedoraproject.org/pub/fedora/linux/updates/$v/Everything/source/tree/ --repo="$dist" --repo="$dist-updates" --source libvirt --destdir $dist/SRPMS/
echo "Downloading zfs source for Fedora $v..."
if ! dnf download --repofrompath=zfs-$dist,http://download.zfsonlinux.org/fedora/$v/SRPMS/ --repo=zfs-$dist --source zfs zfs-dkms --destdir $dist/SRPMS/; then
echo "ZFS source RPM not found for Fedora $v, skipping..."
fi
}
# Downloads the libvirt and zfs source RPMs for a given CentOS Stream distribution.
function download_sources_centos_stream () {
local dist=$1
local v="${dist#*-}"
echo "Downloading libvirt source for CentOS Stream $v..."
dnf download --repofrompath=$dist,https://mirror.stream.centos.org/$v-stream/AppStream/source/tree/ --repo="$dist" --source libvirt --destdir $dist/SRPMS/
echo "Downloading zfs source for CentOS Stream $v..."
if ! dnf download --repofrompath=zfs-$dist,http://download.zfsonlinux.org/epel/$v/SRPMS/ --repo=zfs-$dist --source zfs zfs-dkms --destdir $dist/SRPMS/; then
echo "ZFS source RPM not found for CentOS Stream $v, skipping..."
fi
}

54
update.sh

@ -6,50 +6,13 @@ source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
find . -name '*.src.rpm' -delete
function install_all_srpm () {
local dist=$1
echo "Importing source RPMs of $dist..."
rpm -ivh "--define=_topdir $PWD/$dist" "$dist/SRPMS/"*.src.rpm
}
function apply_patches () {
local dist=$1
for patch in "$dist/PATCHES"/*.patch; do
echo "Applying patch $(basename "$patch")..."
patch -d "$dist"* -p1 < "$patch"
done
}
function download_sources_fedora () {
local dist=$1
local v="${dist#*-}"
echo "Downloading libvirt source for Fedora $v..."
dnf download --repofrompath=$dist,https://dl.fedoraproject.org/pub/fedora/linux/releases/$v/Everything/source/tree/ --repofrompath=$dist-updates,https://dl.fedoraproject.org/pub/fedora/linux/updates/$v/Everything/source/tree/ --repo="$dist" --repo="$dist-updates" --source libvirt --destdir $dist/SRPMS/
echo "Downloading zfs source for Fedora $v..."
if ! dnf download --repofrompath=zfs-$dist,http://download.zfsonlinux.org/fedora/$v/SRPMS/ --repo=zfs-$dist --source zfs zfs-dkms --destdir $dist/SRPMS/; then
echo "ZFS source RPM not found for Fedora $v, skipping..."
fi
}
function download_sources_centos_stream () {
local dist=$1
local v="${dist#*-}"
echo "Downloading libvirt source for CentOS Stream $v..."
dnf download --repofrompath=$dist,https://mirror.stream.centos.org/$v-stream/AppStream/source/tree/ --repo="$dist" --source libvirt --destdir $dist/SRPMS/
echo "Downloading zfs source for CentOS Stream $v..."
if ! dnf download --repofrompath=zfs-$dist,http://download.zfsonlinux.org/epel/$v/SRPMS/ --repo=zfs-$dist --source zfs zfs-dkms --destdir $dist/SRPMS/; then
echo "ZFS source RPM not found for CentOS Stream $v, skipping..."
fi
}
dists=(centos-9 centos-10)
for v in $(get_fedora_versions); do
dists+=("fedora-$v")
done
echo "Computing a list of currently maintained versions of Fedora and CentOS Stream..."
dists=( $(get_all_remote_dists) )
for dist in "${dists[@]}"; do
mkdir -p "$dist/SRPMS"
rm -rf "$PWD/$dist/SOURCES"
find "$dist/SRPMS" -name '*.src.rpm' -delete
rm -rf "$dist/SOURCES"
if [[ "$dist" == fedora-* ]]; then
download_sources_fedora "$dist"
elif [[ "$dist" == centos-* ]]; then
@ -58,6 +21,15 @@ for dist in "${dists[@]}"; do
echo "Unknown distribution: $dist"
exit 1
fi
mapfile -t srpms < <(find "$dist/SRPMS" -name '*.src.rpm')
if [ ${#srpms[@]} -ne 3 ]; then
echo "Expecting 3 source RPMs for $dist, got only ${#srpms[@]}, skipping..."
continue
fi
echo "Found 3 source RPMs for $dist:"
for srpm in "${srpms[@]}"; do
echo " - $(basename "$srpm")"
done
install_all_srpm "$dist"
apply_patches "$dist"
done

Loading…
Cancel
Save