2024-01-04 09:54:04 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
2024-06-06 16:43:42 +02:00
|
|
|
SCRIPTDIR=$(readlink -f "$(dirname "$0")")
|
2024-01-04 09:54:04 +01:00
|
|
|
ROOT=$(readlink -f "${SCRIPTDIR}/..")
|
|
|
|
|
GET_LAST_COMMIT="${SCRIPTDIR}/get_last_commit.sh"
|
2024-01-04 13:40:40 +01:00
|
|
|
CHANGELOG_FILE="$ROOT/CHANGELOG.md"
|
|
|
|
|
CHANGELOG_TMP_FILE="$ROOT/CHANGELOG-tmp.md"
|
2024-01-04 09:54:04 +01:00
|
|
|
|
|
|
|
|
die() {
|
|
|
|
|
echo "$@"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
(
|
|
|
|
|
cd "${ROOT}"
|
|
|
|
|
|
2024-01-04 13:40:40 +01:00
|
|
|
#
|
|
|
|
|
# Determine DTS release version
|
|
|
|
|
#
|
|
|
|
|
DTS_VER=v`cat meta-dts-distro/conf/distro/dts-distro.conf | grep DISTRO_VERSION | tr -d "\" [A-Z]_="`
|
|
|
|
|
|
2024-01-04 09:54:04 +01:00
|
|
|
#
|
|
|
|
|
# Arguments
|
|
|
|
|
# 1 - path to recipe
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
get_srcrev() {
|
|
|
|
|
local recipe_path="$1"
|
|
|
|
|
|
|
|
|
|
if [ ! -f "${recipe_path}" ]; then
|
|
|
|
|
die "${recipe_path} does not exist"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
_retval=$(grep -E "SRCREV\s*=\s*[\"']([a-zA-Z0-9]*)[\"']" "${recipe_path}" \
|
|
|
|
|
| sed -E "s/SRCREV\s*=\s*[\"']([a-zA-Z0-9]*)[\"']/\1/"
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
# Arguments
|
|
|
|
|
# 1 - path to recipe to update
|
|
|
|
|
# 2 - srcrev to set
|
|
|
|
|
#
|
|
|
|
|
do_update_srcrev() {
|
|
|
|
|
local recipe_path="$1"
|
|
|
|
|
local new_srcrev="$2"
|
|
|
|
|
|
|
|
|
|
if [ ! -f "${recipe_path}" ]; then
|
|
|
|
|
die "${recipe_path} does not exist"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
sed -Ei "s/SRCREV\s*=\s*[\"']([a-zA-Z0-9]*)[\"']/SRCREV = \"${new_srcrev}\"/g" "${recipe_path}"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
update_failed() {
|
|
|
|
|
echo "Failed to update \"$2\": $1"
|
|
|
|
|
echo " repo: $4"
|
|
|
|
|
echo " branch: $5"
|
|
|
|
|
die
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Determine last commit ID, update recipes and make commits
|
|
|
|
|
#
|
|
|
|
|
# Arguments
|
|
|
|
|
# 1 - component name
|
|
|
|
|
# 2 - path to recipe to update
|
|
|
|
|
# 3 - repository name
|
|
|
|
|
# 4 - branch
|
|
|
|
|
do_update() {
|
|
|
|
|
local component_name="$1"
|
|
|
|
|
local recipe_path="$2"
|
|
|
|
|
local repository="$3"
|
|
|
|
|
local branch="$4"
|
|
|
|
|
|
|
|
|
|
last_commit=$($GET_LAST_COMMIT -r $repository -b $branch)
|
|
|
|
|
[ "$?" -eq 0 ] || update_failed "failed to obtain last commit info: ${last_commit}" "$@"
|
|
|
|
|
|
|
|
|
|
get_srcrev $recipe_path
|
|
|
|
|
old_commit="${_retval}"
|
|
|
|
|
|
|
|
|
|
if [ "${old_commit}" == "${last_commit}" ]; then
|
|
|
|
|
echo "${component_name} is up to date"
|
|
|
|
|
else
|
|
|
|
|
echo "Updating $1 to $last_commit"
|
|
|
|
|
do_update_srcrev "${recipe_path}" "${last_commit}"
|
|
|
|
|
|
2024-01-04 13:40:40 +01:00
|
|
|
# update changelog, determine which line to modify, it should be X-2
|
|
|
|
|
# where X is header of one after latest release, as we want to add new
|
|
|
|
|
# changelog info at the end of latest release
|
|
|
|
|
line_number=$(grep -n '##' CHANGELOG.md | sed -n '2p' | cut -d ":" -f 1)
|
|
|
|
|
result=$((line_number - 2))
|
|
|
|
|
|
2024-06-06 16:43:42 +02:00
|
|
|
sed "$result a\* Updated $1 to revision $last_commit" $CHANGELOG_FILE > $CHANGELOG_TMP_FILE
|
2024-01-04 13:40:40 +01:00
|
|
|
cp $CHANGELOG_TMP_FILE $CHANGELOG_FILE
|
2024-01-04 09:54:04 +01:00
|
|
|
git add "${recipe_path}"
|
|
|
|
|
git commit -F - <<< "${component_name}: update to ${last_commit}"
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
do_update "3mdeb-secpack" \
|
|
|
|
|
"meta-dts-distro/recipes-dasharo/3mdeb-secpack/3mdeb-secpack_git.bb" \
|
|
|
|
|
"3mdeb/3mdeb-secpack" \
|
|
|
|
|
"master"
|
|
|
|
|
|
2024-01-04 13:40:40 +01:00
|
|
|
if [ -f "$CHANGELOG_TMP_FILE" ]; then
|
|
|
|
|
rm -rf $CHANGELOG_TMP_FILE
|
|
|
|
|
git add $CHANGELOG_FILE
|
|
|
|
|
git commit -F - <<< "CHANGELOG.md: fill up after automatic update of components"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
git commit -F - <<< "Release ${DTS_VER}"
|
|
|
|
|
git push --set-upstream origin "main"
|
|
|
|
|
# update tag position, should not trigger new pipeline
|
2024-01-11 12:28:08 +01:00
|
|
|
git tag "${DTS_VER}"
|
|
|
|
|
git push --set-upstream origin "${DTS_VER}"
|
2024-01-04 09:54:04 +01:00
|
|
|
)
|