aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/get_linux_config.sh
blob: 6c0003685550c8ed614bbda676c4ad448c18da93 (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
#!/bin/bash
#######################################################################
#
# Copy successively all configs from the BSP directory (par #1)
# to the Linux directory (par #2)
# Do not copy config files for later linux versions than the current
# A well-behaved filename is 
# "<name>-linux-2.6.<major>.<minor>.config" or
# "<name>-linux-2.6.<major>.config"
#
#######################################################################

TOPDIR=`pwd`
DEBUG=0
# parameter #1	BOARD_PATH
# parameter #2  LINUX26_DIR

CONFIGS=`ls -X $1/*linux-2.6.*.config | sed s/[.]config// - | sort`
LINUX26_DIR=`basename $2`
LINUX26_CONFIG=${2}/.config
LINUX_MAJOR_VERSION=${LINUX26_DIR:10:2}
LINUX_MINOR_VERSION=${LINUX26_DIR:13}

function DBG_PRINT
{
	if [ ${DEBUG} = 1 ] ; then
		echo $1
	fi
}

function linux_version()
{
	local KCONFIG
	KCONFIG=`basename $1`
	KERNEL=`echo ${KCONFIG} | sed s/.*linux-2.6./linux-2.6./g -`
	THIS_MAJOR=${KERNEL:10:2}
	THIS_MINOR=${KERNEL:13}
	THIS_MINOR=${THIS_MINOR:=0}
}

# Try to be careful...
DBG_PRINT MAJOR=\"${LINUX_MAJOR_VERSION}\"
DBG_PRINT MINOR=\"${LINUX_MINOR_VERSION}\"

for i in ${CONFIGS} ; do
    DBG_PRINT FILE=$i
    linux_version $i
    DBG_PRINT KERNEL=${KERNEL}
    if [ ${THIS_MAJOR} -lt ${LINUX_MAJOR_VERSION} ] ; then
	    echo Copying `basename $i`.config ...
	    cp $i.config ${LINUX26_CONFIG}
    elif [ ${THIS_MAJOR} -eq ${LINUX_MAJOR_VERSION} ] ; then
	if [ "${LINUX_MINOR_VERSION}X" = "X" ] ; then
		if [ "${THIS_MINOR}X" = "X" ] ; then
		    echo Copying `basename $i`.config ...
		    cp $i.config ${LINUX26_CONFIG}
		else		
			return
		fi
	elif [ ${THIS_MINOR} -le ${LINUX_MINOR_VERSION} ] ; then
	    echo Copying `basename $i`.config ...
	    cp $i.config ${LINUX26_CONFIG}
	fi
    else		
	return
    fi
done

# Did not work... - be promisceous

if [ ! -f "${LINUX26_CONFIG}" ] ; then \
	for i in `ls $1/*linux*.config` ; do
		echo Copying `basename $i` ...
		cp $i ${LINUX26_CONFIG}
	done
fi