Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Side by Side Diff: src/scripts/install_packages.sh

Issue 519075: Decrease the number of bootstrap packages in install_packages.sh. (Closed)
Patch Set: Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 local cmdline=`cat /proc/$pid/cmdline` 70 local cmdline=`cat /proc/$pid/cmdline`
71 echo "Killing process that has open file on our rootfs: $cmdline" 71 echo "Killing process that has open file on our rootfs: $cmdline"
72 ! sudo kill $pid # Preceded by ! to disable ERR trap. 72 ! sudo kill $pid # Preceded by ! to disable ERR trap.
73 done 73 done
74 74
75 # Sometimes the volatile directory is left mounted and sometimes it is not, 75 # Sometimes the volatile directory is left mounted and sometimes it is not,
76 # so we precede by '!' to disable the ERR trap. 76 # so we precede by '!' to disable the ERR trap.
77 ! sudo umount "$ROOT_FS_DIR"/lib/modules/2.6.*/volatile/ > /dev/null 2>&1 77 ! sudo umount "$ROOT_FS_DIR"/lib/modules/2.6.*/volatile/ > /dev/null 2>&1
78 78
79 sudo umount "${ROOT_FS_DIR}/proc" 79 sudo umount "${ROOT_FS_DIR}/proc"
80 sudo umount "${ROOT_FS_DIR}/sys"
81 } 80 }
82 81
83 # Create setup directory and copy over scripts, config files, and locally 82 # Create setup directory and copy over scripts, config files, and locally
84 # built packages. 83 # built packages.
85 mkdir -p "${SETUP_DIR}/local_packages" 84 mkdir -p "${SETUP_DIR}/local_packages"
86 cp "${FLAGS_build_root}/${FLAGS_target}/local_packages"/* \ 85 cp "${FLAGS_build_root}/${FLAGS_target}/local_packages"/* \
87 "${SETUP_DIR}/local_packages" 86 "${SETUP_DIR}/local_packages"
88 87
89 # Set up repository for local packages to install in the rootfs via apt-get. 88 # Set up repository for local packages to install in the rootfs via apt-get.
90 cd "$SETUP_DIR" 89 cd "$SETUP_DIR"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 # Use debootstrap, which runs maintainer scripts. 159 # Use debootstrap, which runs maintainer scripts.
161 sudo debootstrap --arch=i386 $FLAGS_suite "$ROOT_FS_DIR" "${FLAGS_server}" 160 sudo debootstrap --arch=i386 $FLAGS_suite "$ROOT_FS_DIR" "${FLAGS_server}"
162 else 161 else
163 # A hack-in-progress that does our own debootstrap equivalent and skips 162 # A hack-in-progress that does our own debootstrap equivalent and skips
164 # maintainer scripts. 163 # maintainer scripts.
165 164
166 # TODO: Replace with a pointer to lool's repo or maybe apt-get --download-only ? 165 # TODO: Replace with a pointer to lool's repo or maybe apt-get --download-only ?
167 REPO="${GCLIENT_ROOT}/repo/var/cache/make_local_repo" 166 REPO="${GCLIENT_ROOT}/repo/var/cache/make_local_repo"
168 167
169 # The set of required packages before apt can take over. 168 # The set of required packages before apt can take over.
170 # TODO: Trim this as much as possible. It is *very* picky, so be careful. 169 PACKAGES="debconf libacl1 libattr1 libc6 libgcc1 libselinux1"
171 PACKAGES="base-files base-passwd bash bsdutils coreutils dash debconf debconf- i18n debianutils diff dpkg e2fslibs e2fsprogs findutils gcc-4.4-base grep gzip h ostname initscripts insserv libacl1 libattr1 libblkid1 libc-bin libc6 libcomerr2 libdb4.7 libdbus-1-3 libgcc1 liblocale-gettext-perl libncurses5 libpam-modules libpam-runtime libpam0g libselinux1 libsepol1 libslang2 libss2 libssl0.9.8 libst dc++6 libtext-charwidth-perl libtext-iconv-perl libtext-wrapi18n-perl libudev0 l ibuuid1 locales login lsb-base lzma makedev mawk mount mountall ncurses-base ncu rses-bin passwd perl-base procps python-minimal python2.6-minimal sed sysv-rc sy svinit-utils tar tzdata upstart util-linux zlib1g apt" 170
171 # Set of packages that we need to install early so that other packages
172 # maintainer scripts can still basically run.
173 #
174 # login - So that groupadd will work
175 # base-passwd/passwd - So that chmod and useradd/groupadd will work
176 # bash - So that scripts can run
177 # libpam-runtim/libuuid1 - Not exactly sure why
178 EXTRA_PACKAGES="base-files base-passwd bash libpam-runtime libuuid1 login pass wd"
172 179
173 # Prep the rootfs to work with dpgk and apt 180 # Prep the rootfs to work with dpgk and apt
174 sudo mkdir -p "${ROOT_FS_DIR}/var/lib/dpkg/info" 181 sudo mkdir -p "${ROOT_FS_DIR}/var/lib/dpkg/info"
175 sudo touch "${ROOT_FS_DIR}/var/lib/dpkg/available" \ 182 sudo touch "${ROOT_FS_DIR}/var/lib/dpkg/available" \
176 "${ROOT_FS_DIR}/var/lib/dpkg/diversions" \ 183 "${ROOT_FS_DIR}/var/lib/dpkg/diversions" \
177 "${ROOT_FS_DIR}/var/lib/dpkg/status" 184 "${ROOT_FS_DIR}/var/lib/dpkg/status"
178 sudo mkdir -p "${ROOT_FS_DIR}/var/lib/apt/lists/partial" \ 185 sudo mkdir -p "${ROOT_FS_DIR}/var/lib/apt/lists/partial" \
179 "${ROOT_FS_DIR}/var/lib/dpkg/updates" 186 "${ROOT_FS_DIR}/var/lib/dpkg/updates"
180 187
181 i=0 188 i=0
182 for p in $PACKAGES; do 189 for p in $PACKAGES $EXTRA_PACKAGES; do
183 set +e 190 set +e
184 PKG=$(ls "${REPO}"/${p}*_i386.deb) 191 PKG=$(ls "${REPO}"/${p}_*_i386.deb)
Bill Richardson 2010/01/07 18:25:40 This is for the target filesystem, not the chroot,
185 set -e 192 set -e
186 if [ -z "$PKG" ]; then 193 if [ -z "$PKG" ]; then
187 PKG=$(ls "${REPO}"/${p}*_all.deb) 194 PKG=$(ls "${REPO}"/${p}_*_all.deb)
188 fi 195 fi
189 echo "Installing package: $PKG [$i]" 196 echo "Installing package: $PKG [$i]"
190 sudo "${SCRIPTS_DIR}"/dpkg_no_scripts.sh \ 197 sudo "${SCRIPTS_DIR}"/dpkg_no_scripts.sh \
191 --root="$ROOT_FS_DIR" --unpack "$PKG" 198 --root="$ROOT_FS_DIR" --unpack "$PKG"
192 i=$((i + 1)) 199 i=$((i + 1))
193 done 200 done
194 201
202 # ----- MAINTAINER SCRIPT FIXUPS -----
203
195 # TODO: Remove when we stop having maintainer scripts altogether. 204 # TODO: Remove when we stop having maintainer scripts altogether.
196 sudo cp -a /dev/* "${ROOT_FS_DIR}/dev" 205 sudo cp -a /dev/* "${ROOT_FS_DIR}/dev"
197 206
198 # ----- MAINTAINER SCRIPT FIXUPS -----
199
200 # base-passwd 207 # base-passwd
201 sudo cp "${ROOT_FS_DIR}/usr/share/base-passwd/passwd.master" \ 208 sudo cp "${ROOT_FS_DIR}/usr/share/base-passwd/passwd.master" \
202 "${ROOT_FS_DIR}/etc/passwd" 209 "${ROOT_FS_DIR}/etc/passwd"
203 sudo cp "${ROOT_FS_DIR}/usr/share/base-passwd/group.master" \ 210 sudo cp "${ROOT_FS_DIR}/usr/share/base-passwd/group.master" \
204 "${ROOT_FS_DIR}/etc/group" 211 "${ROOT_FS_DIR}/etc/group"
205 212
206 # libpam-runtime 213 # libpam-runtime
207 # The postinst script calls pam-auth-update, which is a perl script that 214 # The postinst script calls pam-auth-update, which is a perl script that
208 # expects to run within the targetfs. Until we fix this, we just copy 215 # expects to run within the targetfs. Until we fix this, we just copy
209 # from the build chroot. 216 # from the build chroot.
210 sudo cp -a /etc/pam.d/common-* \ 217 sudo cp -a /etc/pam.d/common-* \
211 /etc/pam.d/login \ 218 /etc/pam.d/login \
212 /etc/pam.d/newusers \ 219 /etc/pam.d/newusers \
213 /etc/pam.d/su \ 220 /etc/pam.d/su \
214 /etc/pam.d/sudo \ 221 /etc/pam.d/sudo \
215 "${ROOT_FS_DIR}/etc/pam.d/" 222 "${ROOT_FS_DIR}/etc/pam.d/"
216 223
217 # mawk 224 # mawk
218 sudo ln -s mawk "${ROOT_FS_DIR}/usr/bin/awk" 225 sudo ln -s mawk "${ROOT_FS_DIR}/usr/bin/awk"
219 226
220 # base-files? 227 # base-files?
221 sudo touch "${ROOT_FS_DIR}/etc/fstab" 228 sudo touch "${ROOT_FS_DIR}/etc/fstab"
229
230 # sysv-rc needs this
231 sudo mkdir -p "${ROOT_FS_DIR}/etc/init.d"
222 fi # EXPERIMENTAL_NO_DEBOOTSTRAP 232 fi # EXPERIMENTAL_NO_DEBOOTSTRAP
223 233
224 234
225 # Set up mounts for working within the rootfs. We copy some basic 235 # Set up mounts for working within the rootfs. We copy some basic
226 # network information from the host so that maintainer scripts can 236 # network information from the host so that maintainer scripts can
227 # access the network as needed. 237 # access the network as needed.
228 # TODO: All of this rootfs mount stuff can be removed as soon as we stop 238 # TODO: All of this rootfs mount stuff can be removed as soon as we stop
229 # running the maintainer scripts on install. 239 # running the maintainer scripts on install.
230 sudo mount -t proc proc "${ROOT_FS_DIR}/proc" 240 sudo mount -t proc proc "${ROOT_FS_DIR}/proc"
231 sudo mount -t sysfs sysfs "${ROOT_FS_DIR}/sys" # TODO: Do we need sysfs?
232 sudo cp /etc/hosts "${ROOT_FS_DIR}/etc" 241 sudo cp /etc/hosts "${ROOT_FS_DIR}/etc"
233 trap cleanup_rootfs_mounts EXIT 242 trap cleanup_rootfs_mounts EXIT
234 243
235 # Make sure that apt is ready to work. 244 # Make sure that apt is ready to work. We use --fix-broken to trigger apt
245 # to install additional critical packages. If there are any of these, we
246 # disable the maintainer scripts so they install ok.
236 sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive apt-get update 247 sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive apt-get update
237 248 TMP_FORCE_NO_SCRIPTS="-o=Dir::Bin::dpkg=${SCRIPTS_DIR}/dpkg_no_scripts.sh"
238 # TODO: We found that apt-get install --fix-broken is needed. It removes some
239 # -dev packages and we need to allow it to run maintainer scripts for now.
240 TMP_FORCE_DPKG="-o=Dir::Bin::dpkg=/usr/bin/dpkg"
241 sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \ 249 sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \
242 apt-get $TMP_FORCE_DPKG --force-yes -f install 250 apt-get $TMP_FORCE_NO_SCRIPTS --force-yes --fix-broken install
243 251
244 # Install prod packages 252 # Install prod packages
245 COMPONENTS=`cat $FLAGS_package_list | grep -v ' *#' | grep -v '^ *$' | sed '/$/{ N;s/\n/ /;}'` 253 COMPONENTS=`cat $FLAGS_package_list | grep -v ' *#' | grep -v '^ *$' | sed '/$/{ N;s/\n/ /;}'`
246 sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \ 254 sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \
247 apt-get --force-yes install $COMPONENTS 255 apt-get --force-yes install $COMPONENTS
248 256
249 # Create kernel installation configuration to suppress warnings, 257 # Create kernel installation configuration to suppress warnings,
250 # install the kernel in /boot, and manage symlinks. 258 # install the kernel in /boot, and manage symlinks.
251 cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/kernel-img.conf" 259 cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/kernel-img.conf"
252 link_in_boot = yes 260 link_in_boot = yes
(...skipping 18 matching lines...) Expand all
271 sudo rm -rf "$APT_CACHE_DIR" 279 sudo rm -rf "$APT_CACHE_DIR"
272 280
273 # List all packages installed so far, since these are what the local 281 # List all packages installed so far, since these are what the local
274 # repository needs to contain. 282 # repository needs to contain.
275 # TODO: Replace with list_installed_packages.sh when it is fixed up. 283 # TODO: Replace with list_installed_packages.sh when it is fixed up.
276 dpkg --root="${ROOT_FS_DIR}" -l > \ 284 dpkg --root="${ROOT_FS_DIR}" -l > \
277 "${OUTPUT_DIR}/package_list_installed.txt" 285 "${OUTPUT_DIR}/package_list_installed.txt"
278 286
279 cleanup_rootfs_mounts 287 cleanup_rootfs_mounts
280 trap - EXIT 288 trap - EXIT
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698