summaryrefslogtreecommitdiff
path: root/iproute2.sh
blob: d488c7d3af95032e78844079db83ca4f8d850c8f (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
. $(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
}


NEW_VERSION=$(latest $(wget -O - --no-verbose -q https://www.kernel.org/pub/linux/utils/net/iproute2/ | grep -E 'iproute2-[0-9]' | sed -e 's,^<a href="iproute2-,,' | cut -d '"' -f1 | sed -e "s/.tar.*/ /g"))
if [ -z "$NEW_VERSION" ]; then
	echo "Can't determine current version, probably the website has been edited."
	echo "Please fix the $0 script."
	exit 1
fi
echo "NEW_VERSION = $NEW_VERSION"



checkout platform/external/iproute2

cd $SRC/platform/external/iproute2

if git branch -a | grep -q linaro-upstream-$NEW_VERSION; then
	ok "iproute2 is up to date."
	exit 0
fi

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

AOSPVER=$(grep "Version:" README.version | cut -d ' ' -f2)
echo "AOSPVER = $AOSPVER"

if [ "$(vertonumber $NEW_VERSION)" -le "$(vertonumber $AOSPVER)" ]; then
	notice "iproute2 is up to date in AOSP master, copying its work"
else
	notice "Updating iproute2 to $NEW_VERSION"
	
	rm -f Android.patch
	
	cd $SRC/platform/external
	wget https://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-$AOSPVER.tar.gz  
	tar -zxf iproute2-$AOSPVER.tar.gz
	
	cd $SRC/platform/external/iproute2
	
#	for i in *; do
#		if [ -e ../iproute2-$AOSPVER/$i ]; then
#			diff -ruN ../iproute2-$AOSPVER/$i $i >>Android.patch
#		fi
#	done
	
	cd $SRC/platform/external
	wget https://www.kernel.org/pub/linux/utils/net/iproute2/iproute2-$NEW_VERSION.tar.gz
	tar -zxf iproute2-$NEW_VERSION.tar.gz
	
	cd $SRC/platform/external/iproute2
	for i in *; do
		if [ -e ../iproute2-$NEW_VERSION/$i ]; then
			cp -rf ../iproute2-$NEW_VERSION/$i .
		fi
	done
	
	cd $SRC/platform/external
	rm -rf iproute2-$AOSPVER iproute2-$NEW_VERSION.tar.gz iproute2-$AOSPVER.tar.gz iproute2-$NEW_VERSION
	
	
	cd $SRC/platform/external/iproute2
	
	if patch -p0 < Android.patch; then
		rm Android.patch
		notice "Auto-updated iproute2 to $NEW_VERSION."
		sed -i -e 's/'$AOSPVER'/'$NEW_VERSION'/g' README.version
		git commit -asm "Update to iproute2 $NEW_VERSION"
		git clean -d -f -x
	else
		error "Couldn't auto-update iproute2 - patch failed to apply."
		error "Please fix manually and commit to a branch called"
		error "linaro-upstream-$NEW_VERSION."
		sed -i -e 's/'$AOSPVER'/'$NEW_VERSION'/g' README.version
		exit 1
	fi
	
		
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