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 # Sets up the chromeos distribution from inside a chroot of the root fs. | 7 # Customizes the root file system of a chromium-based os. |
8 # NOTE: This script should be called by build_image.sh. Do not run this | 8 # NOTE: This script should be called by build_image.sh. Do not run this |
9 # on your own unless you know what you are doing. | 9 # on your own unless you know what you are doing. |
10 | 10 |
11 set -e | 11 set -e |
12 | 12 |
13 # Read options from the config file created by build_image.sh. | 13 # Read options from the config file created by build_image.sh. |
14 echo "Reading options..." | 14 echo "Reading options..." |
15 cat "$(dirname $0)/customize_opts.sh" | 15 cat "$(dirname $0)/customize_opts.sh" |
16 . "$(dirname $0)/customize_opts.sh" | 16 . "$(dirname $0)/customize_opts.sh" |
17 | 17 |
18 PACKAGE_LIST_FILE="${SETUP_DIR}/package-list-prod.txt" | |
19 PACKAGE_LIST_FILE2="${SETUP_DIR}/package-list-2.txt" | |
20 COMPONENTS=`cat $PACKAGE_LIST_FILE | grep -v ' *#' | grep -v '^ *$' | sed '/$/{N
;s/\n/ /;}'` | |
21 FULLNAME="ChromeOS User" | 18 FULLNAME="ChromeOS User" |
22 USERNAME="chronos" | 19 USERNAME="chronos" |
23 ADMIN_GROUP="admin" | 20 ADMIN_GROUP="admin" |
24 DEFGROUPS="adm,dialout,cdrom,floppy,audio,dip,video" | 21 DEFGROUPS="adm,dialout,cdrom,floppy,audio,dip,video" |
25 ADMIN_USERNAME="chronosdev" | 22 ADMIN_USERNAME="chronosdev" |
26 | 23 |
27 CRYPTED_PASSWD_FILE="/trunk/src/scripts/shared_user_passwd.txt" | 24 CRYPTED_PASSWD_FILE="/trunk/src/scripts/shared_user_passwd.txt" |
28 if [ -f $CRYPTED_PASSWD_FILE ] | 25 if [ -f $CRYPTED_PASSWD_FILE ] |
29 then | 26 then |
30 echo "Using password from $CRYPTED_PASSWD_FILE" | 27 echo "Using password from $CRYPTED_PASSWD_FILE" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 if [ ${CHROMEOS_OFFICIAL:-0} -eq 1 ]; then | 75 if [ ${CHROMEOS_OFFICIAL:-0} -eq 1 ]; then |
79 touch /etc/send_metrics | 76 touch /etc/send_metrics |
80 fi | 77 fi |
81 | 78 |
82 # Create the admin group and a chronos user that can act as admin. | 79 # Create the admin group and a chronos user that can act as admin. |
83 groupadd ${ADMIN_GROUP} | 80 groupadd ${ADMIN_GROUP} |
84 echo "%admin ALL=(ALL) ALL" >> /etc/sudoers | 81 echo "%admin ALL=(ALL) ALL" >> /etc/sudoers |
85 useradd -G "${ADMIN_GROUP},${DEFGROUPS}" -g ${ADMIN_GROUP} -s /bin/bash -m \ | 82 useradd -G "${ADMIN_GROUP},${DEFGROUPS}" -g ${ADMIN_GROUP} -s /bin/bash -m \ |
86 -c "${FULLNAME}" -p ${CRYPTED_PASSWD} ${USERNAME} | 83 -c "${FULLNAME}" -p ${CRYPTED_PASSWD} ${USERNAME} |
87 | 84 |
88 # Create apt source.list | |
89 cat <<EOF > /etc/apt/sources.list | |
90 deb file:"$SETUP_DIR" local_packages/ | |
91 deb $SERVER $SUITE main restricted multiverse universe | |
92 EOF | |
93 | |
94 # Install prod packages | |
95 apt-get update | |
96 apt-get --yes --force-yes install $COMPONENTS | |
97 | |
98 # Create kernel installation configuration to suppress warnings, | |
99 # install the kernel in /boot, and manage symlinks. | |
100 cat <<EOF > /etc/kernel-img.conf | |
101 link_in_boot = yes | |
102 do_symlinks = yes | |
103 minimal_swap = yes | |
104 clobber_modules = yes | |
105 warn_reboot = no | |
106 do_bootloader = no | |
107 do_initrd = yes | |
108 warn_initrd = no | |
109 EOF | |
110 | |
111 # NB: KERNEL_VERSION comes from customize_opts.sh | |
112 apt-get --yes --force-yes --no-install-recommends \ | |
113 install "linux-image-${KERNEL_VERSION}" | |
114 | |
115 # Set timezone symlink | 85 # Set timezone symlink |
116 rm -f /etc/localtime | 86 rm -f /etc/localtime |
117 ln -s /mnt/stateful_partition/etc/localtime /etc/localtime | 87 ln -s /mnt/stateful_partition/etc/localtime /etc/localtime |
118 | 88 |
119 # make a mountpoint for stateful partition | 89 # make a mountpoint for stateful partition |
120 sudo mkdir -p "$ROOTFS_DIR"/mnt/stateful_partition | 90 sudo mkdir -p "$ROOTFS_DIR"/mnt/stateful_partition |
121 sudo chmod 0755 "$ROOTFS_DIR"/mnt | 91 sudo chmod 0755 "$ROOTFS_DIR"/mnt |
122 sudo chmod 0755 "$ROOTFS_DIR"/mnt/stateful_partition | 92 sudo chmod 0755 "$ROOTFS_DIR"/mnt/stateful_partition |
123 | 93 |
124 # If we don't create generic udev rules, then udev will try to save the | 94 # If we don't create generic udev rules, then udev will try to save the |
125 # history of various devices (i.e. always associate a given device and MAC | 95 # history of various devices (i.e. always associate a given device and MAC |
126 # address with the same wlan number). As we use a keyfob across different | 96 # address with the same wlan number). As we use a keyfob across different |
127 # machines the ethN and wlanN keep changing. | 97 # machines the ethN and wlanN keep changing. |
128 cat <<EOF >> /etc/udev/rules.d/70-persistent-net.rules | 98 cat <<EOF >> /etc/udev/rules.d/70-persistent-net.rules |
129 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{type}=="1", KERNEL=="eth*",
NAME="eth0" | 99 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{type}=="1", KERNEL=="eth*",
NAME="eth0" |
130 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{type}=="1", KERNEL=="wlan*"
, NAME="wlan0" | 100 SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{type}=="1", KERNEL=="wlan*"
, NAME="wlan0" |
131 EOF | 101 EOF |
132 | 102 |
133 # Setup bootchart. Due to dependencies, this adds about 180MB! | |
134 apt-get --yes --force-yes --no-install-recommends install bootchart | |
135 # TODO: Replace this with pybootchartgui, or remove it entirely. | |
136 apt-get --yes --force-yes --no-install-recommends install bootchart-java | |
137 | |
138 # Install additional packages from a second mirror, if necessary. This must | |
139 # be done after all packages from the first repository are installed; after | |
140 # the apt-get update, apt-get and debootstrap will prefer the newest package | |
141 # versions (which are probably on this second mirror). | |
142 if [ -f "$PACKAGE_LIST_FILE2" ] | |
143 then | |
144 COMPONENTS2=`cat $PACKAGE_LIST_FILE2 | grep -v ' *#' | grep -v '^ *$' | sed '/
$/{N;s/\n/ /;}'` | |
145 | |
146 echo "deb $SERVER2 $SUITE2 main restricted multiverse universe" \ | |
147 >> /etc/apt/sources.list | |
148 apt-get update | |
149 apt-get --yes --force-yes --no-install-recommends \ | |
150 install $COMPONENTS2 | |
151 fi | |
152 | |
153 # List all packages installed so far, since these are what the local | |
154 # repository needs to contain. | |
155 # TODO: better place to put the list. Must still exist after the chroot | |
156 # is dismounted, so build_image.sh can get it. That rules out /tmp and | |
157 # $SETUP_DIR (which is under /tmp). | |
158 sudo sh -c "/trunk/src/scripts/list_installed_packages.sh \ | |
159 > /etc/package_list_installed.txt" | |
160 | |
161 # Remove unused packages. | |
162 # TODO: How are these getting on our image, anyway? | |
163 set +e | |
164 dpkg -l | grep pulseaudio | awk '{ print $2 }' | xargs dpkg --purge | |
165 dpkg -l | grep conkeror | awk '{ print $2 }' | xargs dpkg --purge | |
166 # TODO(rspangler): fix uninstall steps which fail at tip | |
167 #dpkg -l | grep xulrunner | awk '{ print $2 }' | xargs dpkg --purge | |
168 set -e | |
169 | |
170 # Clean up other useless stuff created as part of the install process. | |
171 rm -f /var/cache/apt/archives/*.deb | |
172 rm -rf "$SETUP_DIR" | |
173 | |
174 # Fix issue where alsa-base (dependency of alsa-utils) is messing up our sound | 103 # Fix issue where alsa-base (dependency of alsa-utils) is messing up our sound |
175 # drivers. The stock modprobe settings worked fine. | 104 # drivers. The stock modprobe settings worked fine. |
176 # TODO: Revisit when we have decided on how sound will work on chromeos. | 105 # TODO: Revisit when we have decided on how sound will work on chromeos. |
177 rm /etc/modprobe.d/alsa-base.conf | 106 rm /etc/modprobe.d/alsa-base.conf |
178 | 107 |
179 # -- Remove unneeded fonts and set default gtk font -- | 108 # -- Remove unneeded fonts and set default gtk font -- |
180 UNNEEDED_FONTS_TYPES=$(ls -d /usr/share/fonts/* | grep -v truetype) | 109 UNNEEDED_FONTS_TYPES=$(ls -d /usr/share/fonts/* | grep -v truetype) |
181 UNNEEDED_TRUETYPE_FONTS=$(ls -d /usr/share/fonts/truetype/* | grep -v ttf-droid) | 110 UNNEEDED_TRUETYPE_FONTS=$(ls -d /usr/share/fonts/truetype/* | grep -v ttf-droid) |
182 for i in $UNNEEDED_FONTS_TYPES $UNNEEDED_TRUETYPE_FONTS | 111 for i in $UNNEEDED_FONTS_TYPES $UNNEEDED_TRUETYPE_FONTS |
183 do | 112 do |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 cat <<EOF > /etc/network/interfaces | 262 cat <<EOF > /etc/network/interfaces |
334 auto lo | 263 auto lo |
335 iface lo inet loopback | 264 iface lo inet loopback |
336 EOF | 265 EOF |
337 | 266 |
338 cat <<EOF > /etc/resolv.conf | 267 cat <<EOF > /etc/resolv.conf |
339 # Use the connman dns proxy. | 268 # Use the connman dns proxy. |
340 nameserver 127.0.0.1 | 269 nameserver 127.0.0.1 |
341 EOF | 270 EOF |
342 chmod a-wx /etc/resolv.conf | 271 chmod a-wx /etc/resolv.conf |
OLD | NEW |