containerized-rpmbuild: switch up strategy for defaults and return command exit codes (#10061)

This change simplifies the containerized-rpmbuild scripts in a few ways, which makes it easier to maintain and simpler to use.

Completely remove azl-3_repo and the associated settings. It ends up being the same as the "real" repo, so it only added complexity.
Switched from using a MACROS environment variable that wrapper functions like rpmspec and rpm had to use in favor of a macros.with-check file that gets copied to the appropriate place and does the same thing without the need to use the environment variable. This allowed me to completely remove the rpmspec wrapper function.
Similar with TDNF_ARGS. Since we no longer need to point to azl-3_repo, all it had was --releasever=3.0. So instead, we install azurelinux-release, which sets that up properly. This allowed me to completely remove the tdnf wrapper function.
Changed the remaining wrapper functions rpm and rpmbuild to return the exit code from the function they wrap, to allow scripts to use the exit code properly.
This commit is contained in:
Tobias Brick 2024-08-09 08:31:00 -07:00 коммит произвёл GitHub
Родитель 717cb7d2e9
Коммит f028b4d828
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
5 изменённых файлов: 10 добавлений и 58 удалений

Просмотреть файл

@ -230,16 +230,6 @@ sed -i "s~<REPO_BRANCH>~${repo_branch}~" $tmp_dir/welcome.txt
sed -i "s~<AARCH>~$(uname -m)~" $tmp_dir/welcome.txt
cp resources/setup_functions.sh $tmp_dir/setup_functions.sh
sed -i "s~<TOPDIR>~${topdir}~" $tmp_dir/setup_functions.sh
# TODO: Remove when PMC is available for 3.0
if [[ "${version}" == "3.0" ]]; then # Add 3.0 DailyBuild repo
cp resources/azl-3_repo $tmp_dir/azl-3_repo
sed -i "s~<DAILY_BUILD_ID>~${DAILY_BUILD_ID}~" $tmp_dir/azl-3_repo
if [[ $(uname -m) == "x86_64" ]]; then
sed -i "s~<ARCH>~x86-64~" $tmp_dir/azl-3_repo
else
sed -i "s~<ARCH>~aarch64~" $tmp_dir/azl-3_repo
fi
fi
# ============ Build the image ============
dockerfile="${script_dir}/resources/azl.Dockerfile"

Просмотреть файл

@ -1,9 +0,0 @@
[azl-3.0-daily-build]
name=Azure Linux 3.0 Daily Build Repo
baseurl=https://mariner3dailydevrepo.blob.core.windows.net/daily-repo-<DAILY_BUILD_ID>-<ARCH>
gpgkey=file:///etc/pki/rpm-gpg/MICROSOFT-RPM-GPG-KEY
gpgcheck=0
repo_gpgcheck=0
enabled=1
skip_if_unavailable=True
sslverify=0

Просмотреть файл

@ -8,9 +8,7 @@ ARG extra_packages
LABEL containerized-rpmbuild=$azl_repo/build
COPY resources/local_repo /etc/yum.repos.d/local_repo.disabled_repo
# This is used by setup_functions.sh to determine tdnf default arguments
ENV CONTAINERIZED_RPMBUILD_AZL_VERSION=${version}
COPY resources/macros.with-check /usr/lib/rpm/macros.d
RUN echo "source /azl_setup_dir/setup_functions.sh" >> /root/.bashrc && \
echo "if [[ ! -L /repo ]]; then ln -s /mnt/RPMS/ /repo; fi" >> /root/.bashrc
@ -25,5 +23,5 @@ RUN if [[ "${mode}" == "build" ]]; then echo "cd /usr/src/azl || { echo \"ERROR:
RUN if [[ "${mode}" == "test" ]]; then echo "cd /mnt || { echo \"ERROR: Could not change directory to /mnt \"; exit 1; }" >> /root/.bashrc; fi
# Install packages from bashrc so we can use the previously setup tdnf defaults.
RUN echo "echo installing packages vim git ${extra_packages}" >> /root/.bashrc && \
echo "tdnf install -qy vim git ${extra_packages}" >> /root/.bashrc
RUN echo "echo installing packages azurelinux-release vim git ${extra_packages}" >> /root/.bashrc && \
echo "tdnf install --releasever=${version} -qy azurelinux-release vim git ${extra_packages}" >> /root/.bashrc

Просмотреть файл

@ -0,0 +1 @@
%with_check 1

Просмотреть файл

@ -12,25 +12,6 @@ IS_REPO_ENABLED=false
# General setup
## Azure Linux macro files used during spec parsing (as defined in toolkit/scripts/rpmops.sh)
DEFINES=(-D "with_check 1")
MACROS=()
for macro_file in "$SPECS_DIR"/azurelinux-rpm-macros/macros* "$SPECS_DIR"/pyproject-rpm-macros/macros.pyproject "$SPECS_DIR"/perl/macros.perl
do
MACROS+=("--load=$macro_file")
done
# Extra arguments for tdnf
TDNF_ARGS=(--releasever=$CONTAINERIZED_RPMBUILD_AZL_VERSION)
# TODO Remove when dailybuild is discontinued for 3.0
if [[ $CONTAINERIZED_RPMBUILD_AZL_VERSION == "3.0" ]]; then
repo_file_src="/azl_setup_dir/azl-3_repo"
repo_name=$(awk -F'[][]' '/^\[/{print $2}' "${repo_file_src}")
TDNF_ARGS+=("--enablerepo=${repo_name}")
mv "${repo_file_src}" /etc/yum.repos.d/azl-3.repo
fi
## Create $SOURCES_DIR
mkdir -p $SOURCES_DIR
@ -38,6 +19,7 @@ mkdir -p $SOURCES_DIR
rpm() {
local args=("$@")
command "$FUNCNAME" "${args[@]}"
local command_return=$?
if [[ ${args} = *"i"* ]]; then
for ((i = 0; i < ${#args[@]}; ++i)); do
if [[ ${args[$i]} = *".src.rpm"* ]]; then
@ -53,6 +35,7 @@ rpm() {
rm -f $SPECS_DIR/*.spec
rm -f $SOURCES_DIR/*.spec
rm -f $SOURCES_DIR/*.signatures.json
return $command_return
}
# Installs srpm, pkg dependencies and builds pkg
@ -77,14 +60,16 @@ show_help() {
echo "******************************************************************************************"
}
# Refresh repo cache with newly built RPM, use Azure Linux specific DEFINES
# Refresh repo cache with newly built RPM
rpmbuild() {
local args=("$@")
command "$FUNCNAME" "${DEFINES[@]}" "${args[@]}"
command "$FUNCNAME" "${args[@]}"
local command_return=$?
if [[ ${IS_REPO_ENABLED} = true ]] ; then
refresh_local_repo
tdnf makecache
fi
return $command_return
}
# Refresh metadata for local RPMs' repo
@ -179,16 +164,3 @@ install_dependencies() {
return $exit_code
}
# use Azure Linux specific DEFINES
rpmspec() {
local args=("$@")
command "$FUNCNAME" "${DEFINES[@]}" "${args[@]}"
}
# use proper tdnf arguments
tdnf() {
local args=("$@")
command "$FUNCNAME" "${TDNF_ARGS[@]}" "${args[@]}"
}