Created
May 19, 2017 20:02
-
-
Save Orc/2df8763e9007659af3baba04f156e71f to your computer and use it in GitHub Desktop.
create a git repository from a pile of tarballs (one tarball per commit, ordered cronologically, with the git dates forged to match the tarball dates)
This file contains 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/ksh | |
# | |
extractomatic() { | |
tarball=$1 | |
first_in_archive=`tar tzf $tarball | head -1` | |
path=`dirname ${first_in_archive}/thing` | |
when=`dateof $tarball` | |
export GIT_COMMITTER_DATE="$when" | |
export GIT_AUTHOR_DATE="$when" | |
echo "extract $tarball to $path" | |
tar xzf $tarball | |
if [ "$path" != "." ]; then | |
echo "rsync $path to ." | |
rsync -ar $path/. . | |
rm -rf $path | |
fi | |
echo -n "[more]" | |
read me | |
} | |
for x in ` ls -1rt "$@" `;do | |
messagetag=`basename $x` | |
extractomatic "$x" | |
for y in `git status -u | grep '# '`; do | |
if [ -f $y ]; then | |
case "`file $y`" in | |
*ELF*) rm $y ;; | |
esac | |
fi | |
if [ -f $y ]; then | |
case "$y" in | |
*.o) rm $y ;; | |
*.gz) rm $y ;; | |
*) git add $y ;; | |
esac | |
fi | |
done | |
git commit -m "$messagetag" -a | |
git tag "$messagetag" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment