From a088ceb9520a18011a15d6cfb49b389230ad2b86 Mon Sep 17 00:00:00 2001
From: Walter Lozano <walter.lozano@collabora.com>
Date: Mon, 13 Jan 2025 15:30:12 -0300
Subject: [PATCH 1/2] apertis-pkg-merge-local: Add new tool

Add a tool to help when a package update cannot be done by CI. This tool
should help developers to perform the merge in a similar way as the CI
and also help to run some basic checks.

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
---
 tools/Makefile                |   1 +
 tools/apertis-pkg-merge-local | 102 ++++++++++++++++++++++++++++++++++
 2 files changed, 103 insertions(+)
 create mode 100755 tools/apertis-pkg-merge-local

diff --git a/tools/Makefile b/tools/Makefile
index d300d05..783a110 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -7,6 +7,7 @@ TOOLS = \
 	ade \
 	apertis-abi-compare \
 	apertis-images \
+	apertis-pkg-merge-local \
 	apertis-pkg-merge-updates \
 	apertis-pkg-merge-upstream-to-downstreams \
 	apertis-pkg-pull-updates \
diff --git a/tools/apertis-pkg-merge-local b/tools/apertis-pkg-merge-local
new file mode 100755
index 0000000..5e84ae4
--- /dev/null
+++ b/tools/apertis-pkg-merge-local
@@ -0,0 +1,102 @@
+#!/bin/bash
+
+DOWNSTREAM_BRANCH=${DOWNSTREAM_BRANCH:=apertis/v2026dev0}
+UPSTREAM_BRANCH=${UPSTREAM_BRANCH:="debian/trixie"}
+
+DOWNSTREAM_BRANCH_OLD=${DOWNSTREAM_BRANCH_OLD:="apertis/v2025"}
+UPSTREAM_BRANCH_OLD=${UPSTREAM_BRANCH_OLD:="debian/bookworm"}
+
+echo Using $DOWNSTREAM_BRANCH $UPSTREAM_BRANCH as current branches
+echo Using $DOWNSTREAM_BRANCH_OLD $UPSTREAM_BRANCH_OLD as old branches
+
+merge() {
+    # Configure git merge to use dpkg-mergechangelogs
+    if ! grep -q -v dpkg-mergechangelogs ".git/info/attributes" 2> /dev/null; then
+        echo "debian/changelog merge=dpkg-mergechangelogs" >> ".git/info/attributes"
+    fi
+    git config "merge.dpkg-mergechangelogs.name" "debian/changelog merge driver"
+    git config "merge.dpkg-mergechangelogs.driver" "dpkg-mergechangelogs %O %A %B %A"
+
+    # Get proposed branch
+    proposed_branch=`git branch -a | grep "remotes/origin/proposed-updates/$UPSTREAM_BRANCH"`
+    proposed_branch=`echo $proposed_branch | sed 's;remotes/origin/;;g'`
+
+    if [ "$proposed_branch" = "" ] ; then
+        echo "Unable to find proposed branch"
+        exit
+    fi
+
+    # Checkout proposed updates branch
+    git checkout $proposed_branch
+
+    # Reset proposed updates branch to apertis branch to have it as first ancestor
+    # same as CI does
+    git reset --hard origin/$DOWNSTREAM_BRANCH
+
+    git merge origin/$UPSTREAM_BRANCH -m "Merge $UPSTREAM_BRANCH into $DOWNSTREAM_BRANCH"
+
+    echo Use the following commands to finish the merge
+    echo
+    echo To fix remaining conflicts:
+    echo " git mergetool"
+    echo
+    echo To check the changelog merge:
+    echo " git difftool origin/$UPSTREAM_BRANCH debian/changelog"
+    echo " git difftool origin/$DOWNSTREAM_BRANCH debian/changelog"
+    echo
+    echo To run a final check:
+    echo
+    echo Show new delta against upstream
+    echo " "`basename $0` diff
+    echo " "`basename $0` diff_old
+    echo
+    echo To finish the merge
+    echo " git merge --continue"
+    echo
+    echo To commit the changes
+    echo " "`basename $0` commit
+}
+
+diff() {
+    echo Diff against $UPSTREAM_BRANCH $EXTRA_ARGS
+    git diff $EXTRA_ARGS origin/$UPSTREAM_BRANCH ':(exclude)debian/apertis' ':(exclude)debian/changelog'
+}
+
+diff_old() {
+    echo Diff in previous release $EXTRA_ARGS
+    git diff $EXTRA_ARGS origin/$UPSTREAM_BRANCH_OLD origin/$DOWNSTREAM_BRANCH_OLD ':(exclude)debian/apertis' ':(exclude)debian/changelog'
+}
+
+commit() {
+    dch --force-distribution --distribution apertis --local +apertis --upstream Rebase on top of $UPSTREAM_BRANCH
+    git add debian/changelog
+    git diff --cached
+    DIR=`pwd`
+    PACKAGE=`basename $DIR`
+    VERSION=`dpkg-parsechangelog -S version`
+    echo Release $PACKAGE version $VERSION
+    git commit -sm "Release $PACKAGE version $VERSION"
+}
+
+COMMAND=$1
+shift
+EXTRA_ARGS=$@
+
+case "$COMMAND" in
+merge)
+    merge
+    ;;
+diff)
+    diff
+    ;;
+diff_old)
+    diff_old
+    ;;
+commit)
+    commit
+    ;;
+*)
+    echo Unknown command
+    echo Usage `basename $0` '[merge|diff|diff_old|commit]'
+    ;;
+esac
-- 
GitLab


From 1e68d5c40fad6165c506cb61331579dd98b5873c Mon Sep 17 00:00:00 2001
From: Walter Lozano <walter.lozano@collabora.com>
Date: Tue, 14 Jan 2025 09:34:47 -0300
Subject: [PATCH 2/2] Release apertis-dev-tools version 0.2024.17

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
---
 debian/changelog | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 1fb3513..8d384c1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+apertis-dev-tools (0.2024.17) apertis; urgency=medium
+
+  * apertis-pkg-merge-local: Add new tool.
+    Add a tool to help when a package update cannot be done by CI. This tool
+    should help developers to perform the merge in a similar way as the CI
+    and also help to run some basic checks.
+
+ -- Walter Lozano <walter.lozano@collabora.com>  Tue, 14 Jan 2025 09:34:26 -0300
+
 apertis-dev-tools (0.2024.16) apertis; urgency=medium
 
   * Drop unneeded dependencies.
-- 
GitLab