Skip to content

Commit

Permalink
Provide a way to apply upstream patches to the image
Browse files Browse the repository at this point in the history
This change allows users to apply patches to the images during build
time directly from gerrit using the new arg PATCH.
At the moment, it's limited to upstream projects with patches on
gerrit; future changes will allow different sources, including
local directories.
  • Loading branch information
elfosardo committed Nov 5, 2020
1 parent a7386dc commit db3f157
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,21 @@ RUN if [ $(uname -m) = "x86_64" ]; then \
FROM docker.io/centos:centos8

ARG PKGS_LIST=main-packages-list.txt
ARG PATCH_LIST=patch-list.txt

COPY ${PKGS_LIST} /tmp/main-packages-list.txt
COPY ${PKGS_LIST} ${PATCH_LIST} /tmp/
COPY patch-image.sh /bin/

RUN dnf install -y python3 python3-requests && \
curl https://raw.githubusercontent.com/openstack/tripleo-repos/master/tripleo_repos/main.py | python3 - -b master current-tripleo && \
dnf upgrade -y && \
dnf --setopt=install_weak_deps=False install -y $(cat /tmp/main-packages-list.txt) && \
dnf clean all && \
rm -rf /var/cache/{yum,dnf}/*
rm -rf /var/cache/{yum,dnf}/* && \
if [ -s "/tmp/${PATCH_LIST}" ]; then \
/bin/patch-image.sh; \
fi && \
rm -f /bin/patch-image.sh

COPY --from=builder /tmp/ipxe/src/bin/undionly.kpxe /tmp/ipxe/src/bin-x86_64-efi/snponly.efi /tmp/ipxe/src/bin-x86_64-efi/ipxe.efi /tftpboot/

Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,14 @@ The ironic configuration can be overridden by various environment variables. The
- OS_CONDUCTOR__INSPECT_TIMEOUT=1800 - timeout (seconds) for waiting for node inspection
- OS_CONDUCTOR__CLEAN_CALLBACK_TIMEOUT=1800 - timeout (seconds) to wait for a callback from the ramdisk doing the cleaning
- OS_PXE__BOOT_RETRY_TIMEOUT=1200 - timeout (seconds) to enable boot retries.

Applying Patches to the image
-----------------------------

When building the image, it is possible to specify one or more patches for an
upstream project to apply to the image, using the file patch-list.txt

Each line of the file is in the form "project_dir refspec" where:
- project is the last part of the project url including the org, for example openstack/ironic
- refspec is the gerrit refspec of the patch we want to test, for example refs/changes/67/759567/1

29 changes: 29 additions & 0 deletions patch-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/bash
set -ex

patch_file="/tmp/${PATCH_LIST}"

while IFS= read -r line
do
# each line is in the form "project_dir refsspec" where:
# - project is the last part of the project url including the org,
# for example openstack/ironic
# - refspec is the gerrit refspec of the patch we want to test,
# for example refs/changes/67/759567/1
PROJECT=$(echo $line | cut -d " " -f1)
PROJ_NAME=$(echo $PROJECT | cut -d "/" -f2)
PROJ_URL="https://opendev.org/$PROJECT"
REFSPEC=$(echo $line | cut -d " " -f2)

cd /tmp
git clone "$PROJ_URL"
cd "$PROJ_NAME"
git fetch "$PROJ_URL" "$REFSPEC"
git checkout FETCH_HEAD

SKIP_GENERATE_AUTHORS=1 SKIP_WRITE_GIT_CHANGELOG=1 python3 setup.py sdist
pip3 install dist/*.tar.gz
done < "$patch_file"

cd /

Empty file added patch-list.txt
Empty file.

0 comments on commit db3f157

Please sign in to comment.