summaryrefslogtreecommitdiff
path: root/imagemagick.sh
blob: a1b33f108e86b77c926dc030afd16e9192eff376 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
. $(dirname $0)/functions

vertonumber () {
        local VERSIONID=$1
        local V1=$(echo $VERSIONID | cut -d. -f1)
        local V2=$(echo $VERSIONID | cut -d. -f2)
        local V3=$(echo $VERSIONID | cut -d. -f3)
        local V="$V1$V2$V3"
        echo -n $V
}

numbertover () {
	local VERSIONID=$1
	local V1=$(echo $VERSIONID | cut -d. -f1)
	local V2=$(echo $VERSIONID | cut -d. -f2)
	local V3=$(echo $VERSIONID | cut -d. -f3)
	local V4=$(echo $VERSIONID | cut -d. -f4)
	local V="$V1.$V2.$V3-$V4"
	echo -n $V
}




cd $SRC/platform/external
if [ -d ImageMagick-upstream ]; then
        cd ImageMagick-upstream
	git checkout master
        git pull
else
        git clone http://git.imagemagick.org/repos/ImageMagick ImageMagick-upstream
        cd ImageMagick-upstream
fi

NEW_VERSION=$(latest $(git tag | grep -E '[0-9]' | sed -e "s/-/./g"))
echo "NEW_VERSION = $NEW_VERSION"



checkout platform/external/ImageMagick

cd $SRC/platform/external/ImageMagick
if git branch -a |grep -q linaro-upstream-$NEW_VERSION; then
	ok "ImageMagick is up to date."
	exit 0
fi


git checkout -b linaro-upstream-work-$TIMESTAMP aosp/master


AOSPVER=$(latest $(grep "Release ImageMagick version" ChangeLog | cut -d' ' -f7 | sed -e "s/,//g" | sed -e "s/-/./g"))
echo "AOSPVER = $AOSPVER"


if [ "$NEW_VERSION" = "$AOSPVER" ]; then
	notice "ImageMagick is up to date in AOSP master, copying its work"
else
	LATEST_LINARO=$(latest $(git branch -a |grep origin/linaro-upstream |sed -e 's,.*-,,'))
	if [ -n "$LATEST_LINARO" ]; then
		if [ "$(latest $LATEST_LINARO $AOSPVER)" != "$AOSPVER" ]; then
			git checkout linaro-upstream-$LATEST_LINARO || git checkout -b linaro-upstream-$LATEST_LINARO origin/linaro-upstream-$LATEST_LINARO
		fi
	fi
	
	notice "Updating ImageMagick to $NEW_VERSION"
	
	rm -f Android.patch
	cd ../ImageMagick-upstream
	git checkout -b linaro-upstream-work-$TIMESTAMP "$(numbertover $AOSPVER)"
	cd ../ImageMagick
	for i in *; do
		if [ -e ../ImageMagick-upstream/$i ]; then
			diff -ruN ../ImageMagick-upstream/$i $i >>Android.patch
		fi
	done
	cd ../ImageMagick-upstream
	git checkout master
	git branch -D linaro-upstream-work-$TIMESTAMP
	git checkout -b linaro-upstream-work-$TIMESTAMP "$(numbertover $NEW_VERSION)"
	cd ../ImageMagick
	for i in *; do
		if [ -e ../ImageMagick-upstream/$i ]; then
			cp -rf ../ImageMagick-upstream/$i .
		fi
	done
	
	
	if patch -p0 <Android.patch; then
		rm Android.patch
		notice "Auto-updated ImageMagick to $(numbertover $NEW_VERSION)."
		git commit -asm "Update to ImageMagick $(numbertover $NEW_VERSION)"
		git clean -d -f -x
	else
		error "Couldn't auto-update ImageMagick - patch failed to apply."
		error "Please fix manually and commit to a branch called"
		error "linaro-upstream-$NEW_VERSION."
		exit 1
	fi
	cd ../ImageMagick-upstream
	git checkout master
	git branch -D linaro-upstream-work-$TIMESTAMP
	cd ../ImageMagick

fi

git push origin linaro-upstream-work-$TIMESTAMP:linaro-upstream-$NEW_VERSION
git pull
git checkout -b linaro-upstream-$NEW_VERSION origin/linaro-upstream-$NEW_VERSION
git branch -D linaro-upstream-work-$TIMESTAMP

pwd