summaryrefslogtreecommitdiff
path: root/compat/bin/get-compat-trees
blob: d7812457f65fc8e886d2fa1a41a3eba1bb8528dc (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
#!/bin/bash
#
# Copyright (C) 2012, Luis R. Rodriguez <mcgrof@frijolero.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# You can use this script to install all mainline kernels used
# to test compile the Linux kernel compatibility module. You can
# then use ckmake to cross compile against all supported kernels.

# Pretty colors
GREEN="\033[01;32m"
YELLOW="\033[01;33m"
NORMAL="\033[00m"
BLUE="\033[34m"
RED="\033[31m"
PURPLE="\033[35m"
CYAN="\033[36m"
UNDERLINE="\033[02m"

PREFIX=$HOME/

GIT_TREES="git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git"
GIT_TREES="$GIT_TREES git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git"
GIT_TREES="$GIT_TREES git://github.com/mcgrof/compat.git"
GIT_TREES="$GIT_TREES git://github.com/mcgrof/compat-drivers.git"

LINUX_GIT="git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git"

which git 2>&1 > /dev/null
if [[ $? -ne 0 ]]; then
	echo -e "You need to install ${PURPLE}git${NORMAL}"
	exit 1
fi

echo -e "This will typically take ~ ${YELLOW}10 ${CYAN}minutes${NORMAL}, download about "
echo -e "~ ${YELLOW}1 ${CYAN}GiB${NORMAL} of data over your network, and then consume about "
echo -e "~ ${YELLOW}2 ${CYAN}GiB${NORMAL} of hard drive space."

read -p "Do you still want to continue (y/N)? "
if [[ "${REPLY}" != "y" ]]; then
	echo -e "Bailing out !"
	exit 1
fi

mkdir -p $PREFIX
cd $PREFIX

for i in $GIT_TREES; do
	TREE=$(echo ${i} | awk -F"/" '{print $NF}')

	if [[ -d $PREFIX/$TREE ]]; then
		echo "${GREEN}${TREE}${NORMAL} is already present, skipping..."
		continue
	fi

	echo -e "Cloning ${GREEN}${TREE}${NORMAL}..."

	case $TREE in
	"linux-stable.git")
		cd $PREFIX/
		git clone $i

		cd $PREFIX/linux-stable
		# This lets us bake releases off of Linus' RC releases by
		# simply git fetch'ing "linus" and reseting the tree afterwards.
		git remote add linus $LINUX_GIT
		;;
	"linux-next.git")
		cd $PREFIX
		git clone $i --reference $PREFIX/linux-stable/.git/
		;;
	"compat-drivers.git")
		# This is just what scripts are tested for. Probably best to
		# unify all into one place but this will do for now.
		mkdir -p $PREFIX/devel/
		cd $PREFIX/devel/
		git clone $i
		;;
	*)
		cd $PREFIX
		git clone $i
		;;
	esac
done