Skip to content

Commit d35cbba

Browse files
committed
tar_git: Allow to generate changelog with supplied executable
Allow packages to provide rpm/NAME.changes.run executable in order to customize their changelog generation.
1 parent 622f1ab commit d35cbba

1 file changed

Lines changed: 26 additions & 1 deletion

File tree

src/service/tar_git

Lines changed: 26 additions & 1 deletion
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=1
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=(git-change-log --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 -z "$ALLOW_CHANGES_RUN"; 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

@@ -979,6 +1002,7 @@ rpm_pkg () {
9791002
expand_spec_file "$SPECFILE"
9801003
cp -v "$SPECFILE" ..
9811004
find_changes_file rpm
1005+
find_changes_run_file rpm
9821006
find_yaml_file
9831007
find_other_files
9841008
find_compression "$SPECFILE"
@@ -1029,6 +1053,7 @@ run_android_repo_service () {
10291053
$REPOCMD
10301054
find_spec_file "$MYOUTDIR"
10311055
find_changes_file "$MYOUTDIR"
1056+
find_changes_run_file "$MYOUTDIR"
10321057
find_package_name "$SPECFILE"
10331058
echo "package name is $PACKAGE_NAME"
10341059
set_versha

0 commit comments

Comments
 (0)