upload tizen1.0 source
[kernel/linux-2.6.36.git] / scripts / mkmodimg.sh
1 #!/bin/bash
2
3 # mkmod.sh
4 # Making an image file which contains driver modules(.ko files)
5 # The image file will be in $TMP_DIR/$BIN_NAME (usr/tmp-mod/modules.img)
6 # CAUTION: This script MUST be run in the root directory of linux kernel source.
7 # Author: Wonil Choi (wonil22.choi@samsung.com)
8
9 TMP_DIR="usr/tmp-mod"
10 BIN_NAME="modules.img"
11
12 make modules
13 if [ "$?" != "0" ]; then
14         echo "Failed to make modules"
15         exit 1
16 fi
17 make modules_install ARCH=arm INSTALL_MOD_PATH=${TMP_DIR}
18 if [ "$?" != "0" ]; then
19         echo "Failed to make modules_install"
20         exit 1
21 fi
22
23 # modules image size is dynamically determined
24 BIN_SIZE=`du -s ${TMP_DIR}/lib | awk {'printf $1;'}`
25 let BIN_SIZE=${BIN_SIZE}+1024+512 # 1 MB journal + 512 KB buffer
26
27 cd ${TMP_DIR}/lib
28 mkdir -p tmp
29 dd if=/dev/zero of=${BIN_NAME} count=${BIN_SIZE} bs=1024
30 mkfs.ext4 -q -F -t ext4 -b 1024 ${BIN_NAME}
31 sudo -n mount -t ext4 ${BIN_NAME} ./tmp -o loop
32 if [ "$?" != "0" ]; then
33         echo "Failed to mount (or sudo)"
34         exit 1
35 fi
36 cp modules/* ./tmp -rf
37 sudo -n chown root:root ./tmp -R
38 sync
39 sudo -n umount ./tmp
40 if [ "$?" != "0" ]; then
41         echo "Failed to umount (or sudo)"
42         exit 1
43 fi
44 mv ${BIN_NAME} ../
45 cd ../
46 rm lib -rf
47