OLD | NEW |
1 #!/bin/bash | 1 #!/bin/bash |
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 # Script to install packages into the target root file system. | 7 # Script to install packages into the target root file system. |
8 # | 8 # |
9 # NOTE: This script should be called by build_image.sh. Do not run this | 9 # NOTE: This script should be called by build_image.sh. Do not run this |
10 # on your own unless you know what you are doing. | 10 # on your own unless you know what you are doing. |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 deb file:"$SETUP_DIR" local_packages/ | 94 deb file:"$SETUP_DIR" local_packages/ |
95 deb $FLAGS_server $FLAGS_suite main restricted multiverse universe | 95 deb $FLAGS_server $FLAGS_suite main restricted multiverse universe |
96 EOF | 96 EOF |
97 | 97 |
98 # Cache directory for APT to use. This cache is re-used across builds. We | 98 # Cache directory for APT to use. This cache is re-used across builds. We |
99 # rely on the cache to reduce traffic to the hosted repositories. | 99 # rely on the cache to reduce traffic to the hosted repositories. |
100 APT_CACHE_DIR="${FLAGS_build_root}/apt_cache-${FLAGS_target}/" | 100 APT_CACHE_DIR="${FLAGS_build_root}/apt_cache-${FLAGS_target}/" |
101 mkdir -p "${APT_CACHE_DIR}/archives/partial" | 101 mkdir -p "${APT_CACHE_DIR}/archives/partial" |
102 | 102 |
103 # Create the apt configuration file. See "man apt.conf" | 103 # Create the apt configuration file. See "man apt.conf" |
104 NO_MAINTAINER_SCRIPTS="" | |
105 if [ -n "$EXPERIMENTAL_NO_MAINTAINER_SCRIPTS" ]; then | |
106 NO_MAINTAINER_SCRIPTS="Bin { dpkg \"${SCRIPTS_DIR}/dpkg_no_scripts.sh\"; };" | |
107 fi | |
108 APT_PARTS="${OUTPUT_DIR}/apt.conf.d" | 104 APT_PARTS="${OUTPUT_DIR}/apt.conf.d" |
109 mkdir -p "$APT_PARTS" # An empty apt.conf.d to avoid other configs. | 105 mkdir -p "$APT_PARTS" # An empty apt.conf.d to avoid other configs. |
110 export APT_CONFIG="${OUTPUT_DIR}/apt.conf" | 106 export APT_CONFIG="${OUTPUT_DIR}/apt.conf" |
111 cat <<EOF > "$APT_CONFIG" | 107 cat <<EOF > "$APT_CONFIG" |
112 APT | 108 APT |
113 { | 109 { |
114 Install-Recommends "0"; | 110 Install-Recommends "0"; |
115 Install-Suggests "0"; | 111 Install-Suggests "0"; |
116 Get | 112 Get |
117 { | 113 { |
118 Assume-Yes "1"; | 114 Assume-Yes "1"; |
119 AllowUnauthenticated "1"; | 115 AllowUnauthenticated "1"; |
120 }; | 116 }; |
121 }; | 117 }; |
122 Dir | 118 Dir |
123 { | 119 { |
124 $NO_MAINTAINER_SCRIPTS | 120 Bin { |
| 121 dpkg "${SCRIPTS_DIR}/dpkg_no_scripts.sh"; |
| 122 }; |
125 Cache "$APT_CACHE_DIR"; | 123 Cache "$APT_CACHE_DIR"; |
126 Cache { | 124 Cache { |
127 archives "${APT_CACHE_DIR}/archives"; | 125 archives "${APT_CACHE_DIR}/archives"; |
128 }; | 126 }; |
129 Etc | 127 Etc |
130 { | 128 { |
131 sourcelist "$APT_SOURCE"; | 129 sourcelist "$APT_SOURCE"; |
132 parts "$APT_PARTS"; | 130 parts "$APT_PARTS"; |
133 }; | 131 }; |
134 State "${ROOT_FS_DIR}/var/lib/apt/"; | 132 State "${ROOT_FS_DIR}/var/lib/apt/"; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \ | 176 sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \ |
179 apt-get --download-only install $PACKAGES $EXTRA_PACKAGES | 177 apt-get --download-only install $PACKAGES $EXTRA_PACKAGES |
180 | 178 |
181 # Install initial packages directly with dpkg_no_scripts.sh | 179 # Install initial packages directly with dpkg_no_scripts.sh |
182 for p in $PACKAGES $EXTRA_PACKAGES; do | 180 for p in $PACKAGES $EXTRA_PACKAGES; do |
183 PKG=$(ls "${REPO}"/${p}_*_i386.deb || /bin/true) | 181 PKG=$(ls "${REPO}"/${p}_*_i386.deb || /bin/true) |
184 if [ -z "$PKG" ]; then | 182 if [ -z "$PKG" ]; then |
185 PKG=$(ls "${REPO}"/${p}_*_all.deb) | 183 PKG=$(ls "${REPO}"/${p}_*_all.deb) |
186 fi | 184 fi |
187 sudo "${SCRIPTS_DIR}"/dpkg_no_scripts.sh \ | 185 sudo "${SCRIPTS_DIR}"/dpkg_no_scripts.sh \ |
188 --root="$ROOT_FS_DIR" --unpack "$PKG" | 186 --root="$ROOT_FS_DIR" --nodpkg_fallback --unpack "$PKG" |
| 187 sudo "${SCRIPTS_DIR}"/dpkg_no_scripts.sh \ |
| 188 --root="$ROOT_FS_DIR" --nodpkg_fallback --configure "$p" |
189 done | 189 done |
190 | 190 |
191 # Make sure that apt is ready to work. We use --fix-broken to trigger apt | 191 # Make sure that apt is ready to work. We use --fix-broken to trigger apt |
192 # to install additional critical packages. If there are any of these, we | 192 # to install additional critical packages. If there are any of these, we |
193 # disable the maintainer scripts so they install ok. | 193 # disable the maintainer scripts so they install ok. |
194 TMP_FORCE_NO_SCRIPTS="-o=Dir::Bin::dpkg=${SCRIPTS_DIR}/dpkg_no_scripts.sh" | 194 TMP_FORCE_NO_SCRIPTS="-o=DPkg::options::=--nodpkg_fallback" |
195 sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \ | 195 sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \ |
196 apt-get $TMP_FORCE_NO_SCRIPTS --force-yes --fix-broken install | 196 apt-get $TMP_FORCE_NO_SCRIPTS --force-yes --fix-broken install |
197 | 197 |
198 # ----- MAINTAINER SCRIPT FIXUPS ----- | 198 # TODO: Remove these hacks when we stop having maintainer scripts altogether. |
199 | |
200 # TODO: Remove when we stop having maintainer scripts altogether. | |
201 sudo cp -a /dev/* "${ROOT_FS_DIR}/dev" | 199 sudo cp -a /dev/* "${ROOT_FS_DIR}/dev" |
202 sudo cp -a /etc/resolv.conf "${ROOT_FS_DIR}/etc/resolv.conf" | 200 sudo cp -a /etc/resolv.conf "${ROOT_FS_DIR}/etc/resolv.conf" |
203 sudo ln -sf /bin/true "${ROOT_FS_DIR}/usr/sbin/invoke-rc.d" | 201 sudo ln -sf /bin/true "${ROOT_FS_DIR}/usr/sbin/invoke-rc.d" |
204 sudo ln -sf /bin/true "${ROOT_FS_DIR}/usr/sbin/update-rc.d" | 202 sudo ln -sf /bin/true "${ROOT_FS_DIR}/usr/sbin/update-rc.d" |
205 | 203 |
206 # base-files | |
207 # TODO: Careful audit of the postinst; this isn't all that is there. | |
208 sudo cp -a "${ROOT_FS_DIR}/usr/share/base-files/networks" \ | |
209 "${ROOT_FS_DIR}/usr/share/base-files/nsswitch.conf" \ | |
210 "${ROOT_FS_DIR}/usr/share/base-files/profile" \ | |
211 "${ROOT_FS_DIR}/etc/" | |
212 | |
213 # base-passwd | |
214 sudo cp "${ROOT_FS_DIR}/usr/share/base-passwd/passwd.master" \ | |
215 "${ROOT_FS_DIR}/etc/passwd" | |
216 sudo cp "${ROOT_FS_DIR}/usr/share/base-passwd/group.master" \ | |
217 "${ROOT_FS_DIR}/etc/group" | |
218 | |
219 # libpam-runtime | |
220 # The postinst script calls pam-auth-update, which is a perl script that | |
221 # expects to run within the targetfs. Until we fix this, we just copy | |
222 # from the build chroot. | |
223 sudo cp -a /etc/pam.d/common-* \ | |
224 /etc/pam.d/login \ | |
225 /etc/pam.d/newusers \ | |
226 /etc/pam.d/su \ | |
227 /etc/pam.d/sudo \ | |
228 "${ROOT_FS_DIR}/etc/pam.d/" | |
229 | |
230 # mawk | |
231 sudo ln -s mawk "${ROOT_FS_DIR}/usr/bin/awk" | |
232 | |
233 # base-files? | |
234 sudo touch "${ROOT_FS_DIR}/etc/fstab" | |
235 | |
236 # sysv-rc needs this | |
237 sudo mkdir -p "${ROOT_FS_DIR}/etc/init.d" | |
238 | |
239 # ----- END MAINTAINER SCRIPT FIXUPS ----- | |
240 | |
241 # Set up mounts for working within the rootfs. We copy some basic | 204 # Set up mounts for working within the rootfs. We copy some basic |
242 # network information from the host so that maintainer scripts can | 205 # network information from the host so that maintainer scripts can |
243 # access the network as needed. | 206 # access the network as needed. |
244 # TODO: All of this rootfs mount stuff can be removed as soon as we stop | 207 # TODO: All of this rootfs mount stuff can be removed as soon as we stop |
245 # running the maintainer scripts on install. | 208 # running the maintainer scripts on install. |
246 sudo mount -t proc proc "${ROOT_FS_DIR}/proc" | 209 sudo mount -t proc proc "${ROOT_FS_DIR}/proc" |
247 sudo cp /etc/hosts "${ROOT_FS_DIR}/etc" | 210 sudo cp /etc/hosts "${ROOT_FS_DIR}/etc" |
248 trap cleanup_rootfs_mounts EXIT | 211 trap cleanup_rootfs_mounts EXIT |
249 | 212 |
250 # Install prod packages | 213 # Install prod packages |
(...skipping 19 matching lines...) Expand all Loading... |
270 apt-get --force-yes install "linux-image-${KERNEL_VERSION}" | 233 apt-get --force-yes install "linux-image-${KERNEL_VERSION}" |
271 | 234 |
272 # List all packages installed so far, since these are what the local | 235 # List all packages installed so far, since these are what the local |
273 # repository needs to contain. | 236 # repository needs to contain. |
274 # TODO: Replace with list_installed_packages.sh when it is fixed up. | 237 # TODO: Replace with list_installed_packages.sh when it is fixed up. |
275 dpkg --root="${ROOT_FS_DIR}" -l > \ | 238 dpkg --root="${ROOT_FS_DIR}" -l > \ |
276 "${OUTPUT_DIR}/package_list_installed.txt" | 239 "${OUTPUT_DIR}/package_list_installed.txt" |
277 | 240 |
278 cleanup_rootfs_mounts | 241 cleanup_rootfs_mounts |
279 trap - EXIT | 242 trap - EXIT |
OLD | NEW |