Skip to content

Commit

Permalink
make install_dependencies work with file dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasb-ms committed Nov 13, 2024
1 parent 4f0ad92 commit 7cb6449
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
5 changes: 3 additions & 2 deletions toolkit/scripts/containerized-build/create_container_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ script_dir=$(realpath $(dirname "${BASH_SOURCE[0]}"))
topdir=/usr/src/azl
enable_local_repo=false
keep_container="--rm"
packages_to_install="azurelinux-release vim git jq"

while (( "$#")); do
case "$1" in
Expand All @@ -92,7 +93,7 @@ while (( "$#")); do
-p ) repo_path="$(realpath $2)"; shift 2 ;;
-mo ) extra_mounts="$2"; shift 2 ;;
-b ) build_mount_dir="$(realpath $2)"; shift 2;;
-ep ) extra_packages="$2"; shift 2;;
-ep ) packages_to_install="${packages_to_install} $2"; shift 2;;
-r ) enable_local_repo=true; shift ;;
-k ) keep_container=""; shift ;;
-q ) STD_OUT_REDIRECT=/dev/null; shift ;;
Expand Down Expand Up @@ -268,7 +269,7 @@ docker build -q \
--build-arg enable_local_repo="$enable_local_repo" \
--build-arg azl_repo="$repo_path" \
--build-arg mode="$mode" \
--build-arg extra_packages="$extra_packages" \
--build-arg packages_to_install="$packages_to_install" \
.

echo "docker_image_tag is ${docker_image_tag}"
Expand Down
6 changes: 3 additions & 3 deletions toolkit/scripts/containerized-build/resources/azl.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ ARG version
ARG enable_local_repo
ARG azl_repo
ARG mode
ARG extra_packages
ARG packages_to_install
LABEL containerized-rpmbuild=$azl_repo/build

COPY resources/local_repo /etc/yum.repos.d/local_repo.disabled_repo
Expand All @@ -23,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 azurelinux-release vim git ${extra_packages}" >> /root/.bashrc && \
echo "tdnf install --releasever=${version} -qy azurelinux-release vim git ${extra_packages}" >> /root/.bashrc
RUN echo "echo installing packages ${packages_to_install}" >> /root/.bashrc && \
echo "tdnf install --releasever=${version} -qy ${packages_to_install}" >> /root/.bashrc
14 changes: 14 additions & 0 deletions toolkit/scripts/containerized-build/resources/setup_functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,20 @@ install_dependencies() {
# Get the list of dependencies from the spec file.
mapfile -t dep_list < <(rpmspec -q --buildrequires $spec_file)

# Replace the dependencies with the package providing them.
for i in "${!dep_list[@]}"
do
# if the dependency is a file, find the package that provides it
if [[ ${dep_list[$i]} == /* ]]; then
package=$(tdnf repoquery --file "${dep_list[$i]}" --json | jq -r 'map(.Name) | unique | .[]')
if [ -z "$package" ]; then
echo "Could not find package providing '${dep_list[$i]}'." >/dev/stderr
return 1
else
dep_list[$i]=$package
fi
fi
done
# Install all the dependencies.
tdnf install -y "${dep_list[@]}" || exit_code=$?
done
Expand Down

0 comments on commit 7cb6449

Please sign in to comment.