- "#!/bin/bash
- set -e
- pkg=$1
- r="repos/$pkg"
- if [ ! -d "$r" ]
- then
- git init -q --bare "$r"
- fi
- firstletter=${pkg:0:1}
- archive=/home/nomeata/mount/packages/$firstletter/$pkg/
- test -d tmp || mkdir tmp
- echo Importing sources...
- for v in $(ls $archive)
- do
- vc="$(echo "$v"|tr '~^:?*[' _)"
- if ! git --git-dir=$r show-ref --quiet --verify -- "refs/trees/$vc"
- then
- echo $v
- tmp=$(mktemp -u -d --tmpdir=tmp/ $pXXXXXXXX)
- # sigh, too verbose and no --quiet
- dpkg-source --no-copy -x $archive/$v/*dsc $tmp >/dev/null 2>/dev/null
- git --git-dir=$r --work-tree=$tmp add .
- tree=$(git --git-dir=$r --work-tree=$tmp write-tree)
- git --git-dir=$r update-ref refs/trees/$vc $tree
- rm -rf $tmp
- fi
- done
- echo Building graph of commits...
- echo > $r/commit-graph
- for v in $(ls $archive)
- do
- vc="$(echo "$v"|tr '~^:?*[' _)"
- for v2 in $(git --git-dir=$r show refs/trees/$vc:debian/changelog|dpkg-parsechangelog --format rfc822 -l- --all -S Version)
- do
- if test -d $archive/$v2
- then
- echo "$v2 $v" >> $r/commit-graph
- fi
- done
- done
- cat $r/commit-graph |head -n 20
- echo Building commits...
- for v in $(tsort < $r/commit-graph)
- do
- vc="$(echo "$v"|tr '~^:?*[' _)"
- if ! git --git-dir=$r show-ref --quiet --verify -- "refs/tags/$vc"
- then
- echo "$v"
- parents="$(grep " $v\$" $r/commit-graph|cut -d\ -f1|fgrep -x -v $v| tr '~^:?*[' _|sed -e 's,^,refs/tags/,'|tr '\n' ' ')"
- #echo $parents
- if test -n "$parents"
- then chosen_parents=$(git --git-dir=$r merge-base --independent $parents|sed -e 's,^,-p ,'|tr '\n' ' ')
- else chosen_parents=""
- fi
- #echo chosen: $chosen_parents
- commit=$(
- git --git-dir=$r show refs/trees/$vc:debian/changelog|dpkg-parsechangelog -Fdebian -l- -c1 -SChanges|sed '1{/^$/d}' | \
- GIT_AUTHOR_NAME="$(git --git-dir=$r show refs/trees/$vc:debian/changelog|dpkg-parsechangelog -Fdebian -l- -c1 -SMaintainer|cut -d\< -f1)" \
- GIT_AUTHOR_EMAIL="$(git --git-dir=$r show refs/trees/$vc:debian/changelog|dpkg-parsechangelog -Fdebian -l- -c1 -SMaintainer|cut -d\< -f2)" \
- GIT_AUTHOR_DATE="$(git --git-dir=$r show refs/trees/$vc:debian/changelog|dpkg-parsechangelog -Fdebian -l- -c1 -SDate)" \
- GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE \
- git --git-dir=$r commit-tree $chosen_parents refs/trees/$vc )
- git --git-dir=$r update-ref refs/tags/$vc $commit
- # assuming the latest commit comes last
- git --git-dir=$r update-ref refs/heads/master $commit
- fi
- done
- git --git-dir=$r gc"
- https://people.debian.org/~nomeata/dscs_to_git.sh#:~:text=%23!/bin/bash%0A%0Aset,dir%3D%24r%20gc