Skip to content

Commit 4f36e8a

Browse files
committed
Give packages more control over changelog generation
Allow packages to provide a sfdk-changelog script as rpm/NAME.changes.run.
1 parent 92984c8 commit 4f36e8a

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tar_git

+26-1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,11 @@ set_default_params () {
5353
LOCAL_SUBMODULES="N"
5454
LOCAL_GROUPS="mer-core mer-core-attic mer-crosshelpers mer-obs mer-tools"
5555
LOCAL_MIRROR_GROUP="mirror"
56+
# Allow running supplied *.changes.run executable to generate changelog.
57+
ALLOW_CHANGES_RUN="Y"
58+
# Use the given exec wrapper for running *.changes.run to protect against malware.
59+
# The wrapper can be a command with initial list of arguments
60+
CHANGES_RUN_WRAPPER=(sfdk-changelog --script)
5661
}
5762

5863
get_config_options () {
@@ -227,6 +232,13 @@ find_changes_file () {
227232
[[ -z $CHANGESFILE ]] || cp "$CHANGESFILE" ..
228233
}
229234

235+
find_changes_run_file () {
236+
237+
CHANGESRUNFILE="$(find $1 -type f -name '*.changes.run')"
238+
239+
[[ "$(echo $CHANGESRUNFILE | wc -w)" -le 1 ]] || error "Need single changes.run file in rpm"
240+
}
241+
230242
find_yaml_file () {
231243

232244
YAMLFILE="$(basename $SPECFILE .spec).yaml"
@@ -237,7 +249,7 @@ find_yaml_file () {
237249

238250
find_other_files () {
239251

240-
for i in $(find rpm/ -type f -not -name '*.yaml' -not -name '*.changes' -not -name '*.spec'); do
252+
for i in $(find rpm/ -type f -not -name '*.yaml' -not -name '*.changes' -not -name '*.changes.run' -not -name '*.spec'); do
241253

242254
cp -v $i ..
243255

@@ -532,6 +544,17 @@ do_changelog_block () {
532544

533545
generate_changes () {
534546

547+
if test -n "$CHANGESRUNFILE"; then
548+
if test "$ALLOW_CHANGES_RUN" != "Y" ; then
549+
error "Not allowed to run supplied executable to generate changelog"
550+
fi
551+
CHANGESFILE=../$(basename "${CHANGESRUNFILE%.run}")
552+
if ! command "${CHANGES_RUN_WRAPPER[@]}" "$CHANGESRUNFILE" > "$CHANGESFILE"; then
553+
error "Unable to generate changelog entries using '$CHANGESRUNFILE'"
554+
fi
555+
return
556+
fi
557+
535558
CHANGES=""
536559
ENTRIES=""
537560

@@ -1014,6 +1037,7 @@ rpm_pkg () {
10141037
expand_spec_file "$SPECFILE"
10151038
cp -v "$SPECFILE" ..
10161039
find_changes_file rpm
1040+
find_changes_run_file rpm
10171041
find_yaml_file
10181042
find_other_files
10191043
find_compression "$SPECFILE"
@@ -1064,6 +1088,7 @@ run_android_repo_service () {
10641088
$REPOCMD
10651089
find_spec_file "$MYOUTDIR"
10661090
find_changes_file "$MYOUTDIR"
1091+
find_changes_run_file "$MYOUTDIR"
10671092
find_package_name "$SPECFILE"
10681093
echo "package name is $PACKAGE_NAME"
10691094
set_versha

0 commit comments

Comments
 (0)