Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- project="$1"
- merge_version="$2"
- if [ -z "$project" ]; then
- echo "Provide project name to import"
- echo " $(basename $0) <project> [debian_merge_version]"
- exit 1
- fi
- set -xe
- gbp clone git@salsa.debian.org:gnome-team/$project.git --postclone="git remote rename origin salsa"
- cd $project
- git remote add -f gnome git@gitlab.gnome.org:GNOME/$project.git
- git remote add origin lp:~ubuntu-desktop/ubuntu/+source/$project
- git config push.followTags true
- if [ -z "$merge_version" ]; then
- apt-get changelog "$project=3.28.1-0ubuntu2" > "$project.changelog"
- for ((i = 0; ; i += 1)); do
- version="$(dpkg-parsechangelog -l "$project.changelog" -S Version -o $i -c 1)";
- if [[ "$version" =~ -[0-9]+ubuntu[0-9]+ ]]; then
- continue
- elif [[ "$version" =~ -[0-9]+$ ]]; then
- merge_version=$version
- echo "Last debian version found at $version (salsa tag is debian/${version/:/%})"
- break
- elif [ -z "$version" ]; then
- break;
- fi
- done
- rm -f "$project.changelog"
- if [ -z "$merge_version" ]; then
- echo "Impossible to find debian fork, please provide it as script parameter"
- exit 1
- fi
- fi
- # checkout to the latest debian merge and move as ubuntu/master
- merge_tag=${merge_version/:/%}
- git checkout -b ubuntu/master debian/$merge_tag
- git remote add ubuntu-bzr "bzr::lp:~ubuntu-desktop/$project/ubuntu"
- git fetch ubuntu-bzr
- # for t in $(git tag -l '[0-9]*[0-9]ubuntu[0-9]*'); do git tag "ubuntu/$t" "$t"; git tag -d "$t"; done
- while read -r line; do
- tag="$(echo "${line/:/%}" | sed -n "s,\([a-f0-9]\+\) releasing package $project version \(.*[0-9]\+ubuntu[0-9]\+.*\),\2 \1,p")"
- [ -n "$tag" ] && !git show-ref $tag &> /dev/null && git tag $tag
- done < <(git log ubuntu-bzr/master --oneline)
- for t in $(git tag --merged ubuntu-bzr/master); do git tag "ubuntu/$t" "$t"; git tag -d "$t"; done
- git merge -s ours --no-commit ubuntu-bzr/master --allow-unrelated-histories
- git rm -rf debian
- git read-tree --prefix=/ -u ubuntu-bzr/master
- git rm -rf .bzr*
- git commit -m "Importing lp:~ubuntu-desktop/$project/ubuntu"
- git gc --aggressive
- # Since we want to import a dsc now, we need to remove the tag it already provides or gbp will complain
- last_tag=$(git describe --tags --abbrev=0 ubuntu-bzr/master)
- last_version="$(echo "${last_tag//%/:}" | cut -f2 -d/)"
- git tag ubuntu/bzr-last-release "$last_tag"
- git tag -d "$last_tag"
- if [ -z "$last_version" ]; then
- echo "Now manually get last version version of $project source and continue with .dsc"
- git remote remove ubuntu-bzr
- exit $?
- fi
- dsc_file="../${project}_$(echo "$last_version" | sed "s,^[0-9]\+:,,").dsc"
- if ! [ -e "$dsc_file" ]; then
- echo "No $dsc_file found, please download it"
- exit 1
- fi
- gbp import-dsc --debian-branch=ubuntu/master --debian-tag='ubuntu/%(version)s' "$dsc_file"
- git remote remove ubuntu-bzr
- cat << EOF > debian/gbp.conf
- [DEFAULT]
- debian-branch=ubuntu/master
- upstream-branch=upstream/latest
- debian-tag=ubuntu/%(version)s
- upstream-vcs-tag=%(version)s
- pristine-tar=True
- EOF
- # you might want to `git commit --amend`` now to remove the extra lines added to the changelog, but in that case you should update the last tag (ubuntu/3.28.1-0ubuntu2 in this example) to HEAD
- # and `git gc --aggressive` as per git bzr usage.
- # Set gbp.conf
- ### Importing upstream revision to ubuntu branch
- # gbp import-orig --uscan
- \
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement