Advertisement
3v1n0

importer.sh

Jun 22nd, 2018
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. project="$1"
  4. merge_version="$2"
  5.  
  6. if [ -z "$project" ]; then
  7. echo "Provide project name to import"
  8. echo " $(basename $0) <project> [debian_merge_version]"
  9. exit 1
  10. fi
  11.  
  12. set -xe
  13.  
  14. gbp clone git@salsa.debian.org:gnome-team/$project.git --postclone="git remote rename origin salsa"
  15. cd $project
  16.  
  17. git remote add -f gnome git@gitlab.gnome.org:GNOME/$project.git
  18. git remote add origin lp:~ubuntu-desktop/ubuntu/+source/$project
  19. git config push.followTags true
  20.  
  21. if [ -z "$merge_version" ]; then
  22. apt-get changelog "$project=3.28.1-0ubuntu2" > "$project.changelog"
  23.  
  24. for ((i = 0; ; i += 1)); do
  25. version="$(dpkg-parsechangelog -l "$project.changelog" -S Version -o $i -c 1)";
  26.  
  27. if [[ "$version" =~ -[0-9]+ubuntu[0-9]+ ]]; then
  28. continue
  29. elif [[ "$version" =~ -[0-9]+$ ]]; then
  30. merge_version=$version
  31. echo "Last debian version found at $version (salsa tag is debian/${version/:/%})"
  32. break
  33. elif [ -z "$version" ]; then
  34. break;
  35. fi
  36. done
  37.  
  38. rm -f "$project.changelog"
  39.  
  40. if [ -z "$merge_version" ]; then
  41. echo "Impossible to find debian fork, please provide it as script parameter"
  42. exit 1
  43. fi
  44. fi
  45.  
  46. # checkout to the latest debian merge and move as ubuntu/master
  47. merge_tag=${merge_version/:/%}
  48. git checkout -b ubuntu/master debian/$merge_tag
  49.  
  50. git remote add ubuntu-bzr "bzr::lp:~ubuntu-desktop/$project/ubuntu"
  51. git fetch ubuntu-bzr
  52. # for t in $(git tag -l '[0-9]*[0-9]ubuntu[0-9]*'); do git tag "ubuntu/$t" "$t"; git tag -d "$t"; done
  53.  
  54. while read -r line; do
  55. tag="$(echo "${line/:/%}" | sed -n "s,\([a-f0-9]\+\) releasing package $project version \(.*[0-9]\+ubuntu[0-9]\+.*\),\2 \1,p")"
  56. [ -n "$tag" ] && !git show-ref $tag &> /dev/null && git tag $tag
  57. done < <(git log ubuntu-bzr/master --oneline)
  58.  
  59. for t in $(git tag --merged ubuntu-bzr/master); do git tag "ubuntu/$t" "$t"; git tag -d "$t"; done
  60.  
  61. git merge -s ours --no-commit ubuntu-bzr/master --allow-unrelated-histories
  62. git rm -rf debian
  63. git read-tree --prefix=/ -u ubuntu-bzr/master
  64. git rm -rf .bzr*
  65. git commit -m "Importing lp:~ubuntu-desktop/$project/ubuntu"
  66. git gc --aggressive
  67.  
  68. # Since we want to import a dsc now, we need to remove the tag it already provides or gbp will complain
  69. last_tag=$(git describe --tags --abbrev=0 ubuntu-bzr/master)
  70. last_version="$(echo "${last_tag//%/:}" | cut -f2 -d/)"
  71. git tag ubuntu/bzr-last-release "$last_tag"
  72. git tag -d "$last_tag"
  73.  
  74. if [ -z "$last_version" ]; then
  75. echo "Now manually get last version version of $project source and continue with .dsc"
  76. git remote remove ubuntu-bzr
  77. exit $?
  78. fi
  79.  
  80. dsc_file="../${project}_$(echo "$last_version" | sed "s,^[0-9]\+:,,").dsc"
  81.  
  82. if ! [ -e "$dsc_file" ]; then
  83. echo "No $dsc_file found, please download it"
  84. exit 1
  85. fi
  86.  
  87. gbp import-dsc --debian-branch=ubuntu/master --debian-tag='ubuntu/%(version)s' "$dsc_file"
  88.  
  89. git remote remove ubuntu-bzr
  90.  
  91. cat << EOF > debian/gbp.conf
  92. [DEFAULT]
  93. debian-branch=ubuntu/master
  94. upstream-branch=upstream/latest
  95. debian-tag=ubuntu/%(version)s
  96. upstream-vcs-tag=%(version)s
  97. pristine-tar=True
  98. EOF
  99.  
  100. # 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
  101. # and `git gc --aggressive` as per git bzr usage.
  102.  
  103. # Set gbp.conf
  104.  
  105. ### Importing upstream revision to ubuntu branch
  106. # gbp import-orig --uscan
  107. \
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement