jenkins-pipelines/scripts/publish-patch.sh
Dostoievski Batista 0eec407738 Add jenkins pipeline for patch creation
This change adds support for creating a patch on top of specified build
state using Jenkins:
- patch-monolithic: Main job where all the stages are listed and called.
- ostree-pull: Part where we pull the ostree from the remote build home.
- patch-make: Part where "patch-builder" is executed and the patch gets
    created.
- patch-iso: Part where the "create-prepatched-iso" is executed and the
    pre-patched ISO is created.
- publish-patch: Part where the publish directory for the pre-patched
    ISO and patch is created.
We also update the build-packages part to support "reuse_maximum" option
when running build-pkgs.

Test plan:
    PASS: Run full monolithic pipeline
    PASS: Run full patch-monolithic pipeline

Story: 2010226
Task: 50700

Change-Id: I7c7d688f2c568532a0b23844dcfd81349ca96476
Signed-off-by: Dostoievski Batista <dostoievski.albinobatista@windriver.com>
2024-09-11 14:50:05 -03:00

74 lines
2.2 KiB
Bash

#!/bin/bash
#
# Copyright (c) 2024 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
source $(dirname "$0")/lib/job_utils.sh || exit 1
source $(dirname "$0")/lib/publish_utils.sh || exit 1
require_job_env BUILD_HOME
require_job_env SW_VERSION
require_job_env PATCH_NUM
require_job_env PATCH_PREVIOUS
require_job_env PATCH_TAG
load_build_env || exit 1
require_job_env PUBLISH_ROOT
if $DRY_RUN ; then
bail "DRY_RUN=false is not supported, bailing out"
fi
# Create temporary folder
TEMP_DIR="$BUILD_OUTPUT_HOME/tmp"
mkdir -p "$TEMP_DIR" || exit 1
# Add the file checksum to the list
checksum_files_list_file="$TEMP_DIR/published_patch_checksum_files"
find_checksum_files "${PUBLISH_SUBDIR}/outputs/patch" \
>"$checksum_files_list_file" || exit 1
dst_dir="${PUBLISH_DIR}/outputs/patch"
checksum_file="$dst_dir/$CHECKSUMS_FILENAME"
src_dir="$BUILD_OUTPUT_HOME/localdisk/deploy"
abs_src_dir="$(readlink -e "$src_dir")" || continue
# Clean destination folder
rm -rf --one-file-system "$dst_dir" || exit 1
mkdir -p "$dst_dir" || exit 1
# Go to every repo and get the new commits we have added to make the patch
# since the $PATCH_PREVIOUS
(
cd "${REPO_ROOT}"
(
set -e
repo forall -c 'echo $REPO_PATH'
) | while read gitdir ; do
cd ${REPO_ROOT}/$gitdir
commit="$(git tag -l ${PATCH_PREVIOUS} | grep -q ${PATCH_PREVIOUS} && git log --pretty=format:'%ad %an %H %s' --date=short ${PATCH_PREVIOUS}.. | grep -v '.gitreview')"
if [ "$commit" ]; then printf "%b" "$gitdir \n$commit \n\n"; fi
done
) > ${dst_dir}/COMMITS_${PATCH_PREVIOUS}_to_${PATCH_TAG}
# Setup the tag symlink
link_target=$(basename "$BUILD_OUTPUT_HOME")
ln -sfn "$link_target" "${PUBLISH_ROOT}/${PATCH_TAG}"
# Publish patch and pre-patched ISO
DEPLOY_DIR=$BUILD_HOME/localdisk/deploy
patch_file=($DEPLOY_DIR/patch_output/*.patch)
iso_file=$DEPLOY_DIR/prepatched-iso-${SW_VERSION}.${PATCH_NUM}.iso
iso_sig=$DEPLOY_DIR/prepatched-iso-${SW_VERSION}.${PATCH_NUM}.sig
declare -a file_list=( $patch_file $iso_file $iso_sig )
for f in ${file_list[@]}; do
publish_file "$f" "$dst_dir" "$checksum_files_list_file" >>"$checksum_file" || exit 1
done
check_pipe_status || exit 1