new tool: patch-tool-mingw

This commit is contained in:
Mark Brand 2010-10-01 20:13:45 +02:00
parent a9cae873d9
commit bfeeb82a62
1 changed files with 80 additions and 0 deletions

80
tools/patch-tool-mingw Executable file
View File

@ -0,0 +1,80 @@
#!/bin/bash
# Tool for converting between mingw-cross-env patch files and git repos
# Imports and exports patch files in "git format-patch" format.
cmd=$1
pkg=$2
# mingw-cross-env directory
mcedir=~/mingw-cross-env
# directory for unpacked tarballs/git repos
gitsdir=~/gits
# John Doe <John Doe@acme.org>
author=`git var GIT_AUTHOR_IDENT | sed 's/^\(.* [<].*[>]\).*$/\1/'`
pkg_version=`grep '^$(PKG)_VERSION' $mcedir/src/$pkg.mk | \
sed 's/.*:= \(.*\)/\1/'`
pkg_short_version=`echo $pkg_version | sed s/'\(.*\)\.[^.]*$'/'\1'/`
pkg_subdir=`grep '^$(PKG)_SUBDIR' $mcedir/src/$pkg.mk | \
sed 's/.*:= \(.*\)/\1/' | \
sed s/'$($(PKG)_VERSION)'/$pkg_version/ | \
sed s/'$(call SHORT_PKG_VERSION,$(PKG))'/$pkg_short_version/ | \
sed s/'$(PKG)'/$pkg/;`
pkg_file=`grep '^$(PKG)_FILE' $mcedir/src/$pkg.mk | \
sed 's/.*:= \(.*\)/\1/' | \
sed s/'$($(PKG)_VERSION)'/$pkg_version/ | \
sed s/'$(call SHORT_PKG_VERSION,$(PKG))'/$pkg_short_version/ | \
sed s/'$($(PKG)_SUBDIR)'/$pkg_subdir/ | \
sed s/'$(PKG)'/$pkg/;`
#echo $pkg
#echo $pkg_version
#echo $pkg_subdir
#echo $pkg_file
# init
function init_git {
cd $gitsdir
echo $pkg_file | grep "\.tar\.gz" >> /dev/null && tar xf $mcedir/pkg/$pkg_file
echo $pkg_file | grep "\.tar\.bz2" >> /dev/null && tar xf $mcedir/pkg/$pkg_file
echo $pkg_file | grep "\.zip" >> /dev/null && unzip $mcedir/pkg/$pkg_file >> /dev/null
cd $gitsdir/$pkg_subdir && \
(git init; git add -A; git commit -m "init") > /dev/null
git tag dist
}
function export_patch {
cd $gitsdir/$pkg_subdir && \
(
echo 'This file is part of mingw-cross-env.'
echo 'See doc/index.html for further information.'
echo ''
echo 'Contains ad hoc patches for cross building.'
echo ''
git format-patch -p --stdout dist..HEAD | \
sed 's/^From: .*/From: mingw-cross-env/g;'
) > $mcedir/src/$pkg-1-fixes.patch
}
function import_patch {
cd $gitsdir/$pkg_subdir && \
cat $mcedir/src/$pkg-1-fixes.patch | \
sed '/^From/,$ !d' | \
sed s/'^From: .*'/"From: $author"/'g;' | \
git am --keep-cr
}
if [ "$cmd" == "init" ]; then
init_git $pkg
elif [ "$cmd" == "import" ]; then
import_patch $pkg
elif [ "$cmd" == "export" ]; then
export_patch $pkg
fi