summaryrefslogtreecommitdiff
path: root/freetype.sh
blob: 48171d54dba2584f1ccf01f9b1c59f86d680c792 (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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
. $(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 V="v$V1.$V2.$V3"
	echo -n $V
}


replaceover () {
	local VERSIONID=$1
	local V=$(echo "$VERSIONID" | sed 's/\./-/g')
	echo -n VER-$V
}


cd $SRC/platform/external
if [ -d freetype-upstream ]; then
        cd freetype-upstream
	git checkout master
        git pull
else
        git clone git://git.savannah.gnu.org/freetype/freetype2.git freetype-upstream
        cd freetype-upstream
fi

NEW_VERSION=$(latest $(git tag | grep -E 'VER-[0-9]+\-'|sed -e 's,^VER-,,' |grep -v '[A-Z]' |grep -v '[a-z]'|sed -e "s/-/./g"))
echo "NEW_VERSION = $NEW_VERSION"

checkout platform/external/freetype

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

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

AOSPVER_A=$(grep "define FREETYPE_MAJOR" include/freetype/freetype.h |sed -e 's,.* ,,')
echo "AOSPVER_A = $AOSPVER_A"

AOSPVER_B=$(grep "define FREETYPE_MINOR" include/freetype/freetype.h |sed -e 's,.* ,,')
echo "AOSPVER_B = $AOSPVER_B"

AOSPVER_C=$(grep "define FREETYPE_PATCH" include/freetype/freetype.h |sed -e 's,.* ,,')
echo "AOSPVER_C = $AOSPVER_C"

AOSPVER=$AOSPVER_A.$AOSPVER_B.$AOSPVER_C
echo "AOSPVER = $AOSPVER"

# Let's see if AOSP uses a git snapshot instead of a release right now...
AOSPGIT="$(grep Version: README.version |sed -e 's,.* ,,')"
# If there's a . in there, it's a version number -- otherwise it's a git commit ID
echo $AOSPGIT |grep -q '\.' && AOSPGIT=""

CHECK_VERSION=$(latest $NEW_VERSION $AOSPVER)
echo "CHECK_VERSION = $CHECK_VERSION"

if [ "$CHECK_VERSION" = "$AOSPVER" ]; then
    notice "freetype 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 freetype to $NEW_VERSION"
	
	
	rm -f Android.patch
	cd $SRC/platform/external/freetype-upstream
	if test -n "$AOSPGIT"; then
		echo git checkout -b linaro-upstream-work-$TIMESTAMP $AOSPGIT
		git checkout -b linaro-upstream-work-$TIMESTAMP $AOSPGIT
	else
		echo git checkout -b linaro-upstream-work-$TIMESTAMP $(replaceover $AOSPVER)
		git checkout -b linaro-upstream-work-$TIMESTAMP $(replaceover $AOSPVER)
	fi
	cd $SRC/platform/external/freetype/src
	for i in *; do
		if [ -e ../../freetype-upstream/src/$i ]; then
			diff -ruN -x 'module.mk' -x 'rules.mk' -x 'Jamfile' ../../freetype-upstream/src/$i $i >>$SRC/platform/external/freetype/src/Android.patch
		fi
	done
	
	cd $SRC/platform/external/freetype/include
	for i in *; do
		if [ -e ../../freetype-upstream/include/$i ]; then
			diff -ruN -x 'module.mk' -x 'rules.mk' -x 'Jamfile' ../../freetype-upstream/include/$i $i >>$SRC/platform/external/freetype/include/Android.patch
		fi
	done
	
	
	cd $SRC/platform/external/freetype-upstream
	git checkout master
	git branch -D linaro-upstream-work-$TIMESTAMP
	git checkout -b linaro-upstream-work-$TIMESTAMP $(replaceover $NEW_VERSION)
	cd $SRC/platform/external/freetype/src
	for i in *; do
		if [ -e ../../freetype-upstream/src/$i ]; then
			cp -rf ../../freetype-upstream/src/$i .
		fi
	done
	
	cd $SRC/platform/external/freetype/include
	for i in *; do
		if [ -e ../../freetype-upstream/include/$i ]; then
			cp -rf ../../freetype-upstream/include/$i .
		fi
	done
	
	cd $SRC/platform/external/freetype/src
	if patch -p0 < Android.patch; then
		rm Android.patch
		cd $SRC/platform/external/freetype/include
		if patch -p0 < Android.patch; then
		    rm Android.patch
		    notice "Auto-updated freetype to $NEW_VERSION."
		    cd $SRC/platform/external/freetype
		    sed -i -e 's/'$AOSPVER'/'$NEW_VERSION'/g' README.version
		    git commit -asm "Update to freetype $NEW_VERSION"
		    git clean -d -f -x
		else
		    error "Couldn't auto-update freetype - patch failed to apply."
		    error "Please fix manually and commit to a branch called"
		    error "linaro-upstream-$NEW_VERSION."
		    exit 1
		    
		fi
		    
        else
                error "Couldn't auto-update freetype - patch failed to apply."
                error "Please fix manually and commit to a branch called"
                error "linaro-upstream-$NEW_VERSION."
                exit 1
        fi
        cd $SRC/platform/external/freetype-upstream
        git checkout master
        git branch -D linaro-upstream-work-$TIMESTAMP
        cd $SRC/platform/external/freetype

fi


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