Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # Author: Pali Rohár
- # License: GPLv3+
- # Description: Shell script for importing Debian source packages to git (using git import-dsc)
- set -e
- test ! -d .git && git init
- while test "$#" != "0"; do
- last="$(git show-branch --sha1-name master | sed -n 's/^\[\(.*\)\] .*/\1/p' || true)"
- git branch -D upstream || true
- git branch upstream || true
- git import-dsc "$1"
- again=0
- c1="$(git show-branch --sha1-name master | sed -n 's/^\[\(.*\)\] .*/\1/p')"
- if test "$c1" = "$last"; then
- git merge upstream || true
- fi
- DATE="$(dpkg-parsechangelog | sed -n 's/Date: //p')"
- AUTHOR="$(dpkg-parsechangelog | sed -n 's/Maintainer: //p')"
- if git show-branch upstream; then
- c2="$(git show-branch --sha1-name upstream | sed -n 's/^\[\(.*\)\] .*/\1/p')"
- if test "$c1" != "$last" -a "$c2" != "$last" -a "$c1" != "$c2"; then
- again=1
- git tag -d $(git tag --contains master)
- git reset --hard upstream
- fi
- git branch -d upstream
- fi
- if git show-branch HEAD^ && ! test -d debian; then
- git checkout HEAD^ -- debian || true
- git add debian || true
- TAGS="$(git tag --contains master)"
- git tag -d $TAGS
- EDITOR=true git commit --amend
- for tag in $TAGS; do git tag $tag; done
- fi
- if ! test -z "$DATE" -o -z "$AUTHOR"; then
- TAGS="$(git tag --contains master)"
- git tag -d $TAGS
- EDITOR=true git commit --amend --date="$DATE" --author="$AUTHOR"
- for tag in $TAGS; do git tag $tag; done
- fi
- if test "$again" = "1"; then
- git branch upstream
- git clean -f
- git import-dsc "$1"
- git branch -d upstream
- fi
- shift
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement