summaryrefslogtreecommitdiffstats
path: root/scripts/get_linux_config.sh
blob: 0b986ae13011a83917922879682b963246cb4cd9 (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
#!/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`

# parameter #1	BOARD_PATH
# parameter #2  LINUX26_DIR

CONFIGS=`ls -X $1/*linux*.*.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 linux_version()
{
	local KCONFIG
	KCONFIG=`basename $1`
	KERNEL=`echo ${KCONFIG} | sed s/.*-linux-/linux-/g -`
	THIS_MAJOR=${KERNEL:10:2}
	THIS_MINOR=${KERNEL:13}

}

# Try to be careful...

for i in ${CONFIGS} ; do
    linux_version $i
    if [ ${THIS_MAJOR} -le ${LINUX_MAJOR_VERSION} ] ; then
	    echo Copying `basename $i`.config ...
	    cp $i.config ${LINUX26_CONFIG}
    elif [ ${THIS_MAJOR} -eq ${LINUX_MAJOR_VERSION} ] ; then
	if [ ${THIS_MINOR} -le ${LINUX_MINOR_VERSION} ] ; then
	    echo Copying `basename $i`.config ...
	    cp $i.config ${LINUX26_CONFIG}
	fi
    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