OLD | NEW |
1 #! /bin/sh | 1 #! /bin/sh |
2 | 2 |
3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2009 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 # This script contains the set of commands to build a kernel package. | 7 # This script contains the set of commands to build a kernel package. |
8 # | 8 # |
9 # If successful, a new linux-image-*.deb file will appear in the specified | 9 # If successful, a new linux-image-*.deb file will appear in the specified |
10 # output directory. | 10 # output directory. |
11 # | 11 # |
12 # The user-provided kernel config file is parsed to obtain information about | 12 # The user-provided kernel config file is parsed to obtain information about |
13 # the desired kernel version and target platform. Here are the requirements: | 13 # the desired kernel version and target platform. Here are the requirements: |
14 # 1) Kernel version string in the header, e.g. "Linux kernel version: 2.6.30" | 14 # 1) Kernel version string in the header, e.g. "Linux kernel version: 2.6.30" |
15 # 2) Target architecture variables set up, e.g. CONFIG_X86, CONFIG_ARM, etc. | 15 # 2) Target architecture variables set up, e.g. CONFIG_X86, CONFIG_ARM, etc. |
16 # 3) LOCALVERSION set to describe target platform (e.g. intel-menlow). This is | 16 # 3) LOCALVERSION set to describe target platform (e.g. intel-menlow). This is |
17 # used for package naming. | 17 # used for package naming. |
18 SRC_ROOT=$(dirname $(readlink -f $(dirname "$0"))) | 18 SRC_ROOT=$(dirname $(readlink -f $(dirname "$0"))) |
19 . "${SRC_ROOT}/third_party/shflags/files/src/shflags" | 19 . "${SRC_ROOT}/third_party/shflags/files/src/shflags" |
20 | 20 |
21 KERNEL_DIR="$SRC_ROOT/third_party/kernel" | 21 KERNEL_DIR="$SRC_ROOT/third_party/kernel" |
22 DEFAULT_KCONFIG="${KERNEL_DIR}/files/chromeos/config/chromeos-intel-menlow" | 22 DEFAULT_KFLAVOUR="chromeos-intel-menlow" |
23 | 23 |
24 # Flags | 24 # Flags |
25 DEFAULT_BUILD_ROOT=${BUILD_ROOT:-"${SRC_ROOT}/build"} | 25 DEFAULT_BUILD_ROOT=${BUILD_ROOT:-"${SRC_ROOT}/build"} |
26 DEFINE_string config "${DEFAULT_KCONFIG}" \ | 26 DEFINE_string flavour "${DEFAULT_KFLAVOUR}" \ |
27 "The kernel configuration file to use." | 27 "The kernel flavour to use." |
28 DEFINE_integer revision 002 \ | 28 DEFINE_integer revision 002 \ |
29 "The package revision to use" | 29 "The package revision to use" |
30 DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/x86/local_packages" \ | 30 DEFINE_string output_root "${DEFAULT_BUILD_ROOT}/x86/local_packages" \ |
31 "Directory in which to place the resulting .deb package" | 31 "Directory in which to place the resulting .deb package" |
32 DEFINE_string build_root "$DEFAULT_BUILD_ROOT" \ | 32 DEFINE_string build_root "$DEFAULT_BUILD_ROOT" \ |
33 "Root of build output" | 33 "Root of build output" |
34 FLAGS_HELP="Usage: $0 [flags]" | 34 FLAGS_HELP="Usage: $0 [flags]" |
35 | 35 |
36 # Parse command line | 36 # Parse command line |
37 FLAGS "$@" || exit 1 | 37 FLAGS "$@" || exit 1 |
38 eval set -- "${FLAGS_ARGV}" | 38 eval set -- "${FLAGS_ARGV}" |
39 | 39 |
40 # Die on any errors. | 40 # Die on any errors. |
41 set -e | 41 set -e |
42 | 42 |
43 # TODO: We detect the ARCH below. We can sed the FLAGS_output_root to replace | 43 # TODO: We detect the ARCH below. We can sed the FLAGS_output_root to replace |
44 # an ARCH placeholder with the proper architecture rather than assuming x86. | 44 # an ARCH placeholder with the proper architecture rather than assuming x86. |
45 mkdir -p "$FLAGS_output_root" | 45 mkdir -p "$FLAGS_output_root" |
46 | 46 |
47 # Get kernel package configuration from repo. | 47 # Get kernel package configuration from repo. |
48 # TODO: Find a workaround for needing sudo for this. Maybe create a symlink | 48 # TODO: Find a workaround for needing sudo for this. Maybe create a symlink |
49 # to /tmp/kernel-pkg.conf when setting up the chroot env? | 49 # to /tmp/kernel-pkg.conf when setting up the chroot env? |
50 sudo cp "$KERNEL_DIR"/package/kernel-pkg.conf /etc/kernel-pkg.conf | 50 sudo cp "$KERNEL_DIR"/package/kernel-pkg.conf /etc/kernel-pkg.conf |
51 | 51 |
| 52 # |
| 53 # Generate the flavour config file. |
| 54 # |
| 55 flavour=$FLAGS_flavour |
| 56 (cd ${KERNEL_DIR}/files; debian/rules prepare-${flavour}) |
| 57 |
52 # Parse kernel config file for target architecture information. This is needed | 58 # Parse kernel config file for target architecture information. This is needed |
53 # to determine the full package name and also to setup the environment for | 59 # to determine the full package name and also to setup the environment for |
54 # kernel build scripts which use "uname -m" to autodetect architecture. | 60 # kernel build scripts which use "uname -m" to autodetect architecture. |
55 KCONFIG="$FLAGS_config" | 61 KCONFIG="${KERNEL_DIR}/files/debian/build/build-${flavour}/.config" |
56 if [ ! -f "$KCONFIG" ]; then | 62 if [ ! -f "$KCONFIG" ]; then |
57 KCONFIG="$KERNEL_DIR"/files/chromeos/config/"$KCONFIG" | 63 echo Major bummer. Could not find kernel config. |
| 64 exit 1 |
58 fi | 65 fi |
59 if [ -n $(grep 'CONFIG_X86=y' "$KCONFIG") ] | 66 if [ -n $(grep 'CONFIG_X86=y' "$KCONFIG") ] |
60 then | 67 then |
61 ARCH="i386" | 68 ARCH="i386" |
62 elif [ -n $(grep 'CONFIG_X86_64=y' "$KCONFIG") ] | 69 elif [ -n $(grep 'CONFIG_X86_64=y' "$KCONFIG") ] |
63 then | 70 then |
64 ARCH="x86_64" | 71 ARCH="x86_64" |
65 elif [ -n $(grep 'CONFIG_ARM=y' "$KCONFIG") ] | 72 elif [ -n $(grep 'CONFIG_ARM=y' "$KCONFIG") ] |
66 then | 73 then |
67 ARCH="arm" | 74 ARCH="arm" |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 | 150 |
144 # make-kpkg dumps the newly created package in the parent directory | 151 # make-kpkg dumps the newly created package in the parent directory |
145 if [ -e "../${PACKAGE}" ] | 152 if [ -e "../${PACKAGE}" ] |
146 then | 153 then |
147 mv "../${PACKAGE}" "${FLAGS_output_root}" | 154 mv "../${PACKAGE}" "${FLAGS_output_root}" |
148 echo "Kernel build successful, check ${FLAGS_output_root}/${PACKAGE}" | 155 echo "Kernel build successful, check ${FLAGS_output_root}/${PACKAGE}" |
149 else | 156 else |
150 echo "Kernel build failed" | 157 echo "Kernel build failed" |
151 exit 1 | 158 exit 1 |
152 fi | 159 fi |
OLD | NEW |