Created
October 22, 2013 19:12
-
-
Save hfs/7106433 to your computer and use it in GitHub Desktop.
Create a git repository for the AFD [ http://www.dwd.de/AFD/ ] from a series of downloaded tarballs. Use `wget -N` to download to keep the original file timestamps, which are used as commit timestamps. This script was used to do the initial import of http://github.com/hfs/afd .
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
export GIT_AUTHOR_NAME="Firstname Lastname" | |
export GIT_AUTHOR_EMAIL="[email protected]" | |
export GIT_COMMITTER_NAME="Firstname Lastname" | |
export GIT_COMMITTER_EMAIL="[email protected]" | |
mkdir afd | |
cd afd | |
git init | |
first=true | |
for srcfile in $(ls -1 ../src-*.tar.bz2 | sort -V) $(ls -1 ../afd-*.tar.bz2 | sort -V); do | |
version=$(echo "$srcfile" | perl -pe 's/^.*?-(.*)\.tar\.bz2/\1/') | |
rm -rf * | |
case $version in | |
1.1.*) | |
echo "Extracting ../doc-1.1.x.tar.bz2" | |
tar xjf ../doc-1.1.x.tar.bz2 | |
;; | |
1.2.*) | |
echo "Extracting ../doc-1.2.x.tar.bz2" | |
tar xjf ../doc-1.2.x.tar.bz2 | |
;; | |
*) | |
# No extra doc archive | |
;; | |
esac | |
echo "Extracting $srcfile" | |
tar xjf "$srcfile" --strip=1 | |
date=$(stat --format %y "$srcfile") | |
export GIT_AUTHOR_DATE="$date" | |
export GIT_COMMITTER_DATE="$date" | |
commitmessage=$(mktemp) | |
shortversion=${version%%-*} | |
if [ -e Changelog ]; then | |
changelog=Changelog | |
else | |
changelog=CHANGES | |
fi | |
if [ "$first" ]; then | |
first= | |
echo "First public release version $version" >> $commitmessage | |
echo >> $commitmessage | |
iconv --from iso8859-1 --to utf8 $changelog >> $commitmessage | |
else | |
echo "Version $version" >> $commitmessage | |
echo >> $commitmessage | |
iconv --from iso8859-1 --to utf8 $changelog \ | |
| perl -ne "print if /^-*> Version $shortversion/ .. /^-*> Released:/ and not /^\\s*-+/" >> $commitmessage | |
fi | |
if [ $(wc -l < $commitmessage) -le 2 ]; then | |
interactive=-e | |
else | |
interactive= | |
fi | |
git add . | |
git add -u | |
git commit $interactive -F $commitmessage | |
git tag "$version" | |
rm $commitmessage | |
done | |
git gc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment