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

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

Issue 527015: Changes to install_packages.sh so that we can master an image without (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 | « src/scripts/dpkg_no_scripts.sh ('k') | 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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 cat <<EOF > "$APT_SOURCE" 97 cat <<EOF > "$APT_SOURCE"
98 deb file:"$SETUP_DIR" local_packages/ 98 deb file:"$SETUP_DIR" local_packages/
99 deb $FLAGS_server $FLAGS_suite main restricted multiverse universe 99 deb $FLAGS_server $FLAGS_suite main restricted multiverse universe
100 EOF 100 EOF
101 101
102 # Cache directory for APT to use. 102 # Cache directory for APT to use.
103 APT_CACHE_DIR="${OUTPUT_DIR}/tmp/cache/" 103 APT_CACHE_DIR="${OUTPUT_DIR}/tmp/cache/"
104 mkdir -p "${APT_CACHE_DIR}/archives/partial" 104 mkdir -p "${APT_CACHE_DIR}/archives/partial"
105 105
106 # Create the apt configuration file. See "man apt.conf" 106 # Create the apt configuration file. See "man apt.conf"
107 NO_MAINTAINER_SCRIPTS=""
108 if [ -n "$EXPERIMENTAL_NO_MAINTAINER_SCRIPTS" ]; then
109 NO_MAINTAINER_SCRIPTS="Bin { dpkg \"${SCRIPTS_DIR}/dpkg_no_scripts.sh\"; };"
110 fi
107 APT_PARTS="${OUTPUT_DIR}/apt.conf.d" 111 APT_PARTS="${OUTPUT_DIR}/apt.conf.d"
108 mkdir -p "$APT_PARTS" # An empty apt.conf.d to avoid other configs. 112 mkdir -p "$APT_PARTS" # An empty apt.conf.d to avoid other configs.
109 export APT_CONFIG="${OUTPUT_DIR}/apt.conf" 113 export APT_CONFIG="${OUTPUT_DIR}/apt.conf"
110 cat <<EOF > "$APT_CONFIG" 114 cat <<EOF > "$APT_CONFIG"
111 APT 115 APT
112 { 116 {
113 Install-Recommends "0"; 117 Install-Recommends "0";
114 Install-Suggests "0"; 118 Install-Suggests "0";
115 Get 119 Get
116 { 120 {
117 Assume-Yes "1"; 121 Assume-Yes "1";
118 }; 122 };
119 }; 123 };
120 Dir 124 Dir
121 { 125 {
126 $NO_MAINTAINER_SCRIPTS
122 Cache "$APT_CACHE_DIR"; 127 Cache "$APT_CACHE_DIR";
123 Cache { 128 Cache {
124 archives "${APT_CACHE_DIR}/archives"; 129 archives "${APT_CACHE_DIR}/archives";
125 }; 130 };
126 Etc 131 Etc
127 { 132 {
128 sourcelist "$APT_SOURCE"; 133 sourcelist "$APT_SOURCE";
129 parts "$APT_PARTS"; 134 parts "$APT_PARTS";
130 }; 135 };
131 State "${ROOT_FS_DIR}/var/lib/apt/"; 136 State "${ROOT_FS_DIR}/var/lib/apt/";
(...skipping 11 matching lines...) Expand all
143 # TODO: Full audit of the apt conf dump to make sure things are ok. 148 # TODO: Full audit of the apt conf dump to make sure things are ok.
144 apt-config dump > "${OUTPUT_DIR}/apt.conf.dump" 149 apt-config dump > "${OUTPUT_DIR}/apt.conf.dump"
145 150
146 # Add debootstrap link for the suite, if it doesn't exist. 151 # Add debootstrap link for the suite, if it doesn't exist.
147 if [ ! -e "/usr/share/debootstrap/scripts/$FLAGS_suite" ] 152 if [ ! -e "/usr/share/debootstrap/scripts/$FLAGS_suite" ]
148 then 153 then
149 sudo ln -s /usr/share/debootstrap/scripts/jaunty \ 154 sudo ln -s /usr/share/debootstrap/scripts/jaunty \
150 "/usr/share/debootstrap/scripts/$FLAGS_suite" 155 "/usr/share/debootstrap/scripts/$FLAGS_suite"
151 fi 156 fi
152 157
153 # Bootstrap the base debian file system 158 if [ -z "$EXPERIMENTAL_NO_DEBOOTSTRAP" -a \
154 # TODO: Switch to --variant=minbase 159 -z "$EXPERIMENTAL_NO_MAINTAINER_SCRIPTS" ]; then
155 sudo debootstrap --arch=i386 $FLAGS_suite "$ROOT_FS_DIR" "${FLAGS_server}" 160 # Use debootstrap, which runs maintainer scripts.
161 sudo debootstrap --arch=i386 $FLAGS_suite "$ROOT_FS_DIR" "${FLAGS_server}"
162 else
163 # A hack-in-progress that does our own debootstrap equivalent and skips
164 # maintainer scripts.
165
166 # 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"
168
169 # 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.
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"
172
173 # Prep the rootfs to work with dpgk and apt
174 sudo mkdir -p "${ROOT_FS_DIR}/var/lib/dpkg/info"
175 sudo touch "${ROOT_FS_DIR}/var/lib/dpkg/available" \
176 "${ROOT_FS_DIR}/var/lib/dpkg/diversions" \
177 "${ROOT_FS_DIR}/var/lib/dpkg/status"
178 sudo mkdir -p "${ROOT_FS_DIR}/var/lib/apt/lists/partial" \
179 "${ROOT_FS_DIR}/var/lib/dpkg/updates"
180
181 i=0
182 for p in $PACKAGES; do
183 set +e
184 PKG=$(ls "${REPO}"/${p}*_i386.deb)
185 set -e
186 if [ -z "$PKG" ]; then
187 PKG=$(ls "${REPO}"/${p}*_all.deb)
188 fi
189 echo "Installing package: $PKG [$i]"
190 sudo "${SCRIPTS_DIR}"/dpkg_no_scripts.sh \
191 --root="$ROOT_FS_DIR" --unpack "$PKG"
192 i=$((i + 1))
193 done
194
195 # TODO: Remove when we stop having maintainer scripts altogether.
196 sudo cp -a /dev/* "${ROOT_FS_DIR}/dev"
197
198 # ----- MAINTAINER SCRIPT FIXUPS -----
199
200 # base-passwd
201 sudo cp "${ROOT_FS_DIR}/usr/share/base-passwd/passwd.master" \
202 "${ROOT_FS_DIR}/etc/passwd"
203 sudo cp "${ROOT_FS_DIR}/usr/share/base-passwd/group.master" \
204 "${ROOT_FS_DIR}/etc/group"
205
206 # libpam-runtime
207 # 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
209 # from the build chroot.
210 sudo cp -a /etc/pam.d/common-* \
211 /etc/pam.d/login \
212 /etc/pam.d/newusers \
213 /etc/pam.d/su \
214 /etc/pam.d/sudo \
215 "${ROOT_FS_DIR}/etc/pam.d/"
216
217 # mawk
218 sudo ln -s mawk "${ROOT_FS_DIR}/usr/bin/awk"
219
220 # base-files?
221 sudo touch "${ROOT_FS_DIR}/etc/fstab"
222 fi # EXPERIMENTAL_NO_DEBOOTSTRAP
223
156 224
157 # Set up mounts for working within the rootfs. We copy some basic 225 # Set up mounts for working within the rootfs. We copy some basic
158 # network information from the host so that maintainer scripts can 226 # network information from the host so that maintainer scripts can
159 # access the network as needed. 227 # access the network as needed.
160 # TODO: All of this rootfs mount stuff can be removed as soon as we stop 228 # TODO: All of this rootfs mount stuff can be removed as soon as we stop
161 # running the maintainer scripts on install. 229 # running the maintainer scripts on install.
162 sudo mount -t proc proc "${ROOT_FS_DIR}/proc" 230 sudo mount -t proc proc "${ROOT_FS_DIR}/proc"
163 sudo mount -t sysfs sysfs "${ROOT_FS_DIR}/sys" # TODO: Do we need sysfs? 231 sudo mount -t sysfs sysfs "${ROOT_FS_DIR}/sys" # TODO: Do we need sysfs?
164 sudo cp /etc/hosts "${ROOT_FS_DIR}/etc" 232 sudo cp /etc/hosts "${ROOT_FS_DIR}/etc"
165 trap cleanup_rootfs_mounts EXIT 233 trap cleanup_rootfs_mounts EXIT
166 234
235 # Make sure that apt is ready to work.
236 sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive apt-get update
237
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 \
242 apt-get $TMP_FORCE_DPKG --force-yes -f install
243
167 # Install prod packages 244 # Install prod packages
168 COMPONENTS=`cat $FLAGS_package_list | grep -v ' *#' | grep -v '^ *$' | sed '/$/{ N;s/\n/ /;}'` 245 COMPONENTS=`cat $FLAGS_package_list | grep -v ' *#' | grep -v '^ *$' | sed '/$/{ N;s/\n/ /;}'`
169 sudo APT_CONFIG="$APT_CONFIG" apt-get update 246 sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \
170 sudo APT_CONFIG="$APT_CONFIG" apt-get --force-yes \ 247 apt-get --force-yes install $COMPONENTS
171 install $COMPONENTS
172 248
173 # Create kernel installation configuration to suppress warnings, 249 # Create kernel installation configuration to suppress warnings,
174 # install the kernel in /boot, and manage symlinks. 250 # install the kernel in /boot, and manage symlinks.
175 cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/kernel-img.conf" 251 cat <<EOF | sudo dd of="${ROOT_FS_DIR}/etc/kernel-img.conf"
176 link_in_boot = yes 252 link_in_boot = yes
177 do_symlinks = yes 253 do_symlinks = yes
178 minimal_swap = yes 254 minimal_swap = yes
179 clobber_modules = yes 255 clobber_modules = yes
180 warn_reboot = no 256 warn_reboot = no
181 do_bootloader = no 257 do_bootloader = no
182 do_initrd = yes 258 do_initrd = yes
183 warn_initrd = no 259 warn_initrd = no
184 EOF 260 EOF
185 261
186 # Install the kernel. 262 # Install the kernel.
187 sudo APT_CONFIG="$APT_CONFIG" apt-get --force-yes \ 263 sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \
188 install "linux-image-${KERNEL_VERSION}" 264 apt-get --force-yes install "linux-image-${KERNEL_VERSION}"
189 265
190 # Clean up the apt cache. 266 # Clean up the apt cache.
191 # TODO: The cache was populated by debootstrap, not these installs. Remove 267 # TODO: The cache was populated by debootstrap, not these installs. Remove
192 # this line when we can get debootstrap to stop doing this. 268 # this line when we can get debootstrap to stop doing this.
193 sudo rm -f "${ROOT_FS_DIR}"/var/cache/apt/archives/*.deb 269 sudo rm -f "${ROOT_FS_DIR}"/var/cache/apt/archives/*.deb
194 # Need to rm read-only created lock files in order for archiving step to work 270 # Need to rm read-only created lock files in order for archiving step to work
195 sudo rm -rf "$APT_CACHE_DIR" 271 sudo rm -rf "$APT_CACHE_DIR"
196 272
197 # List all packages installed so far, since these are what the local 273 # List all packages installed so far, since these are what the local
198 # repository needs to contain. 274 # repository needs to contain.
199 # TODO: Replace with list_installed_packages.sh when it is fixed up. 275 # TODO: Replace with list_installed_packages.sh when it is fixed up.
200 dpkg --root="${ROOT_FS_DIR}" -l > \ 276 dpkg --root="${ROOT_FS_DIR}" -l > \
201 "${OUTPUT_DIR}/package_list_installed.txt" 277 "${OUTPUT_DIR}/package_list_installed.txt"
202 278
203 cleanup_rootfs_mounts 279 cleanup_rootfs_mounts
204 trap - EXIT 280 trap - EXIT
OLDNEW
« no previous file with comments | « src/scripts/dpkg_no_scripts.sh ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698