annotate tools/patch-tool-mxe @ 2334:0ac3f45e790f

Improve indentation
author Volker Grabsch <vog@notjusthosting.com>
date Wed, 28 Mar 2012 15:48:13 +0200
parents f653602a0500
children 99516e73b368
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2333
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
1 #!/bin/bash
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
2
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
3 # Tool for converting between MXE patch files and git repos
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
4 # Imports and exports patch files in "git format-patch" format.
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
5
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
6 cmd=$1
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
7 pkg=$2
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
8
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
9 # MXE directory
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
10 mxedir=~/mxe
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
11
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
12 # directory for unpacked tarballs/git repos
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
13 gitsdir=~/gits
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
14
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
15
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
16 # John Doe <John Doe@acme.org>
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
17 author=`git var GIT_AUTHOR_IDENT | sed 's/^\(.* [<].*[>]\).*$/\1/'`
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
18
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
19 pkg_version=`grep '^$(PKG)_VERSION' $mxedir/src/$pkg.mk | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
20 sed 's/.*:= \(.*\)/\1/'`
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
21
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
22 pkg_short_version=`echo $pkg_version | sed s/'\(.*\)\.[^.]*$'/'\1'/`
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
23
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
24 pkg_subdir=`grep '^$(PKG)_SUBDIR' $mxedir/src/$pkg.mk | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
25 sed 's/.*:= \(.*\)/\1/' | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
26 sed s/'$($(PKG)_VERSION)'/$pkg_version/ | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
27 sed s/'$(call SHORT_PKG_VERSION,$(PKG))'/$pkg_short_version/ | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
28 sed s/'$(PKG)'/$pkg/;`
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
29
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
30 pkg_file=`grep '^$(PKG)_FILE' $mxedir/src/$pkg.mk | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
31 sed 's/.*:= \(.*\)/\1/' | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
32 sed s/'$($(PKG)_VERSION)'/$pkg_version/ | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
33 sed s/'$(call SHORT_PKG_VERSION,$(PKG))'/$pkg_short_version/ | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
34 sed s/'$($(PKG)_SUBDIR)'/$pkg_subdir/ | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
35 sed s/'$(PKG)'/$pkg/;`
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
36
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
37 #echo $pkg
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
38 #echo $pkg_version
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
39 #echo $pkg_subdir
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
40 #echo $pkg_file
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
41
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
42 # init
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
43 function init_git {
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
44 cd $gitsdir
2334
0ac3f45e790f Improve indentation
Volker Grabsch <vog@notjusthosting.com>
parents: 2333
diff changeset
45 echo $pkg_file | grep "\.tar\.gz" >> /dev/null && tar xf $mxedir/pkg/$pkg_file
2333
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
46 echo $pkg_file | grep "\.tar\.bz2" >> /dev/null && tar xf $mxedir/pkg/$pkg_file
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
47 echo $pkg_file | grep "\.tar\.xz" >> /dev/null && xz -dc $mxedir/pkg/$pkg_file | tar xf -
2334
0ac3f45e790f Improve indentation
Volker Grabsch <vog@notjusthosting.com>
parents: 2333
diff changeset
48 echo $pkg_file | grep "\.zip" >> /dev/null && unzip $mxedir/pkg/$pkg_file >> /dev/null
2333
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
49 cd $gitsdir/$pkg_subdir && \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
50 (git init; git add -A; git commit -m "init") > /dev/null
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
51 git tag dist
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
52 }
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
53
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
54 function export_patch {
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
55 cd $gitsdir/$pkg_subdir && \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
56 (
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
57 echo 'This file is part of MXE.'
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
58 echo 'See doc/index.html for further information.'
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
59 echo ''
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
60 echo 'Contains ad hoc patches for cross building.'
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
61 echo ''
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
62 git format-patch -p --stdout dist..HEAD | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
63 sed 's/^From: .*/From: MXE/g;'
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
64 ) > $mxedir/src/$pkg-1-fixes.patch
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
65 }
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
66
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
67 function import_patch {
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
68 cd $gitsdir/$pkg_subdir && \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
69 cat $mxedir/src/$pkg-1-fixes.patch | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
70 sed '/^From/,$ !d' | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
71 sed s/'^From: .*'/"From: $author"/'g;' | \
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
72 git am --keep-cr
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
73 }
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
74
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
75 if [ "$cmd" == "init" ]; then
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
76 init_git $pkg
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
77 elif [ "$cmd" == "import" ]; then
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
78 import_patch $pkg
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
79 elif [ "$cmd" == "export" ]; then
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
80 export_patch $pkg
f653602a0500 Rebrand to new project name MXE
Volker Grabsch <vog@notjusthosting.com>
parents:
diff changeset
81 fi