[git-buildpackage] Usage inside pipelines / branches

Guido Günther agx at sigxcpu.org
Tue Jun 7 14:15:27 CEST 2022


Hi,
On Tue, Jun 07, 2022 at 01:43:28PM +0200, Denny Fuchs wrote:
> Hello,
> 
> I used GBP a while without any issues as the structure was pretty simple,
> which means, we had only the master branch and one Debian version.
> 
> Now we switched our procedure and working only on a develop branch and merge
> from develop into main/master branch. That was the first part, were I run
> into trouble .. as not all changes where inside the Debian packages.
> The next problem was, that we want to create Debian packages for different
> version, like Stretch / Buster / ....
> 
> Because of the debian/changelog and also some Debian files inside debian/ I
> had always merge conflics ...
> 
> So I started to create for every Debian version a own branch, starting from
> the latest master and added all debian/ files
> 
> So we have have 4 branches:
> -> master
>    - For building releases / packages
>    - Does not contain any Debian files
> -> develop
>   - Develoment. All changes were merged later to master
>   - Does not contain any Debian files
> -> debian/stretch
>   - Does contain Debian files
> -> debian/buster
>   - Does contain Debian files

> 
> Everything is done via Gitlab pipelines and using custom "helper" script,
> which holds most commands and has a switch for snapshots and releases ...
> 
> This script .. works from the build view fine .. but we saw .. that often
> merges / changes are not included ...
> 
> Below is the helper script .. which was extended / changed very often ...
> 
> But it seems .. I'm doing it more or less wrong ..  and tried so many things
> ... :-)
> 
> * What I expecting (example for Debian Stretch)
>   - Clone the master branch (done via Gitlab)
>   - Checkout debian/stretch
>   - Merge **all** changes from origin/master into the debian/branch and
> **overwrite all**, as only debian/ files are maintained inside the branch
>   - Build packages either for release (and than start a new version number,
> or snapshot)
> 
> 
> I tried first git merge .. but the changes from merges like feature/foo ->
> develop -> master was not included
> So switched to rebase .. with -Xtheirs origin/master .. and saw .. that
> again the latest merge from develop -> master was not there ..
> 
> I tried from the console .. like:
> 
> git clone git at foo:/project
> cd project
> git checkout debian/stretch
> git rebase -Xtheirs origin/master
> git pull
> gbp import-ref -uHEAD
> ....
> 
> and also .. my changes (in this case gitlab/build_script.sh) is not on the
> branch debian/stretch/
> 
> So, here comes the point .. where I think .. I'm doing it all wrong :-)
> 
> I have no idea .. how to to get it working right .. to create Debian
> packages for different versions and always include all changes from master
> ...
> 
> I know .. it is maybe a Git usage problem .. than a GBP .. But I think ..
> the origin problem is to use GBP on the correct way and I hope, that someone
> can help me :-)

I have to say that I don't understand your intended workflow but maybe
"gbp import-ref" helps as it allows you to take a branches content 1:1
and replace everything but the debian/ folder (which is kept verbatim).
This makes sure you don't get any  merge conflicts.

Cheers,
 -- Guido


> 
> 
> 
> ================================================
> #!/bin/bash -x
> 
> GIT_VERSION=$(git describe --tags)
> echo "Git version is $GIT_VERSION"
> 
> case $1 in
> 
>   snapshot)
>     echo "Prepare Git repo for ${DEBIAN_VERSION} snapshot"
> 
>     git checkout debian/${DEBIAN_VERSION}
>     git pull origin debian/${DEBIAN_VERSION}
>     #git merge -s ours origin/master
>     git rebase -Xtheirs origin/master
>     gbp import-ref -uHEAD
>     mk-build-deps --install --remove --tool="$TOOL_ARGS" debian/control
>     DEB_VERSION=$(dpkg-parsechangelog --count 1 -S version   | awk -F '+'
> '{print $1}')
>     gbp buildpackage --git-upstream-tag='v%(version)s'
> --git-upstream-branch="$CI_COMMIT_REF_NAME"  --git-ignore-branch
> --git-upstream-tree=BRANCH --git-ignore-new --build=all -us -uc -rfakeroot
> --lintian-opts profile debian
>     gbp tag --debian-tag='v%(version)s' --ignore-new --retag
>     git pull --no-edit
>     gbp dch --commit --snapshot --since=HEAD
>     gbp push --debian-branch=debian/${DEBIAN_VERSION}
> git@$CI_SERVER_HOST:$CI_PROJECT_PATH.git
>     git push --follow-tags git@$CI_SERVER_HOST:$CI_PROJECT_PATH.git
>     ;;
> 
>   release)
>     echo "Prepare Git repo for ${DEBIAN_VERSION} release"
>     git checkout debian/${DEBIAN_VERSION}
>     CHANGELOG_VERSION=$(dpkg-parsechangelog --count 1 -S version   | awk -F
> '+' '{print $1}' | cut -d'~' -f1)
>     TYPE=${2:-2}
> 
>     function increment_version() {
>       local VERSION="$1"
>       local PLACE="$2"
> 
>       IFS='.' read -r -a a <<<"$VERSION"
>       ((a[PLACE]++))
>       echo "${a[0]}.${a[1]}.${a[2]}"
>     }
> 
>     export DEB_VERSION="$(increment_version $CHANGELOG_VERSION $TYPE)"
>     echo "New version is"  $DEB_VERSION
>     git checkout debian/${DEBIAN_VERSION}
>     git pull origin debian/${DEBIAN_VERSION}
>     git rebase -Xtheirs origin/master
>     gbp import-ref -uHEAD
>     mk-build-deps --install --remove --tool="$TOOL_ARGS" debian/control
>     gbp buildpackage --git-upstream-tag='v%(version)s'
> --git-upstream-branch=master  --git-ignore-branch --git-upstream-tree=BRANCH
> --git-ignore-new --build=all -us -uc -rfakeroot --lintian-opts profile
> debian
>     gbp tag --debian-tag="debian/${DEBIAN_VERSION}/%(version)s" --retag
>     git pull --no-edit
>     gbp push --debian-branch=debian/${DEBIAN_VERSION}
> git@$CI_SERVER_HOST:$CI_PROJECT_PATH.git
>     gbp dch -R -N $DEB_VERSION --spawn-editor=never --commit
>     git push --follow-tags git@$CI_SERVER_HOST:$CI_PROJECT_PATH.git
>     ;;
> esac
> 
> =========================================
> 
> 
> cu denny
> _______________________________________________
> git-buildpackage mailing list
> git-buildpackage at lists.sigxcpu.org
> http://lists.sigxcpu.org/mailman/listinfo/git-buildpackage


More information about the git-buildpackage mailing list