| 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 12 matching lines...) Expand all Loading... |
| 23 DEFINE_string output_dir "" \ | 23 DEFINE_string output_dir "" \ |
| 24 "The location of the output directory to use [REQUIRED]." | 24 "The location of the output directory to use [REQUIRED]." |
| 25 DEFINE_string root "" \ | 25 DEFINE_string root "" \ |
| 26 "The root file system to install packages in." | 26 "The root file system to install packages in." |
| 27 DEFINE_string arch "x86" \ | 27 DEFINE_string arch "x86" \ |
| 28 "The target architecture to build for. One of { x86, armel }." | 28 "The target architecture to build for. One of { x86, armel }." |
| 29 DEFINE_string build_root "$DEFAULT_BUILD_ROOT" \ | 29 DEFINE_string build_root "$DEFAULT_BUILD_ROOT" \ |
| 30 "Root of build output" | 30 "Root of build output" |
| 31 DEFINE_string package_list "$DEFAULT_PKGLIST" \ | 31 DEFINE_string package_list "$DEFAULT_PKGLIST" \ |
| 32 "Comma separated set of package-list files to use." | 32 "Comma separated set of package-list files to use." |
| 33 DEFINE_string server "$DEFAULT_EXT_MIRROR" \ | 33 DEFINE_string mirror "$DEFAULT_IMG_MIRROR" \ |
| 34 "The package server to use." | 34 "The upstream package mirror to use." |
| 35 DEFINE_string suite "$DEFAULT_IMG_SUITE" \ | 35 DEFINE_string suite "$DEFAULT_IMG_SUITE" \ |
| 36 "The package suite to use." | 36 "The upstream package suite to use." |
| 37 | 37 |
| 38 # Parse command line | 38 # Parse command line |
| 39 FLAGS "$@" || exit 1 | 39 FLAGS "$@" || exit 1 |
| 40 eval set -- "${FLAGS_ARGV}" | 40 eval set -- "${FLAGS_ARGV}" |
| 41 | 41 |
| 42 # Die on any errors. | 42 # Die on any errors. |
| 43 set -e | 43 set -e |
| 44 | 44 |
| 45 KERNEL_DEB_PATH=$(find "${FLAGS_build_root}/${FLAGS_arch}/local_packages" \ | 45 KERNEL_DEB_PATH=$(find "${FLAGS_build_root}/${FLAGS_arch}/local_packages" \ |
| 46 -name "linux-image-*.deb") | 46 -name "linux-image-*.deb") |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 "${SETUP_DIR}/local_packages" | 85 "${SETUP_DIR}/local_packages" |
| 86 cd "$SETUP_DIR" | 86 cd "$SETUP_DIR" |
| 87 dpkg-scanpackages local_packages/ /dev/null | \ | 87 dpkg-scanpackages local_packages/ /dev/null | \ |
| 88 gzip > local_packages/Packages.gz | 88 gzip > local_packages/Packages.gz |
| 89 cd - | 89 cd - |
| 90 | 90 |
| 91 # Create the temporary apt source.list used to install packages. | 91 # Create the temporary apt source.list used to install packages. |
| 92 APT_SOURCE="${OUTPUT_DIR}/sources.list" | 92 APT_SOURCE="${OUTPUT_DIR}/sources.list" |
| 93 cat <<EOF > "$APT_SOURCE" | 93 cat <<EOF > "$APT_SOURCE" |
| 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_mirror $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_arch}/" | 100 APT_CACHE_DIR="${FLAGS_build_root}/apt_cache-${FLAGS_arch}/" |
| 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 APT_PARTS="${OUTPUT_DIR}/apt.conf.d" | 104 APT_PARTS="${OUTPUT_DIR}/apt.conf.d" |
| 105 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. |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 PACKAGES="debconf libacl1 libattr1 libc6 libgcc1 libselinux1" | 153 PACKAGES="debconf libacl1 libattr1 libc6 libgcc1 libselinux1" |
| 154 | 154 |
| 155 # Set of packages that we need to install early so that other packages | 155 # Set of packages that we need to install early so that other packages |
| 156 # maintainer scripts can still basically run. | 156 # maintainer scripts can still basically run. |
| 157 # | 157 # |
| 158 # login - So that groupadd will work | 158 # login - So that groupadd will work |
| 159 # base-passwd/passwd - So that chmod and useradd/groupadd will work | 159 # base-passwd/passwd - So that chmod and useradd/groupadd will work |
| 160 # bash - So that scripts can run | 160 # bash - So that scripts can run |
| 161 # libpam-runtime/libuuid1 - Not exactly sure why | 161 # libpam-runtime/libuuid1 - Not exactly sure why |
| 162 # sysv-rc - So that we can overwrite invoke-rc.d, update-rc.d | 162 # sysv-rc - So that we can overwrite invoke-rc.d, update-rc.d |
| 163 EXTRA_PACKAGES="base-files base-passwd bash libpam-runtime libuuid1 login passwd
sysv-rc" | 163 EXTRA_PACKAGES="base-files base-passwd bash libpam-runtime libuuid1 login passwd
sysv-rc mawk" |
| 164 | 164 |
| 165 # Prep the rootfs to work with dpgk and apt | 165 # Prep the rootfs to work with dpgk and apt |
| 166 sudo mkdir -p "${ROOT_FS_DIR}/var/lib/dpkg/info" | 166 sudo mkdir -p "${ROOT_FS_DIR}/var/lib/dpkg/info" |
| 167 sudo touch "${ROOT_FS_DIR}/var/lib/dpkg/available" \ | 167 sudo touch "${ROOT_FS_DIR}/var/lib/dpkg/available" \ |
| 168 "${ROOT_FS_DIR}/var/lib/dpkg/diversions" \ | 168 "${ROOT_FS_DIR}/var/lib/dpkg/diversions" \ |
| 169 "${ROOT_FS_DIR}/var/lib/dpkg/status" | 169 "${ROOT_FS_DIR}/var/lib/dpkg/status" |
| 170 sudo mkdir -p "${ROOT_FS_DIR}/var/lib/apt/lists/partial" \ | 170 sudo mkdir -p "${ROOT_FS_DIR}/var/lib/apt/lists/partial" \ |
| 171 "${ROOT_FS_DIR}/var/lib/dpkg/updates" | 171 "${ROOT_FS_DIR}/var/lib/dpkg/updates" |
| 172 | 172 |
| 173 # Download the initial packages into the apt cache if necessary. | 173 # Download the initial packages into the apt cache if necessary. |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 apt-get --force-yes install "linux-image-${KERNEL_VERSION}" | 242 apt-get --force-yes install "linux-image-${KERNEL_VERSION}" |
| 243 | 243 |
| 244 # List all packages installed so far, since these are what the local | 244 # List all packages installed so far, since these are what the local |
| 245 # repository needs to contain. | 245 # repository needs to contain. |
| 246 # TODO: Replace with list_installed_packages.sh when it is fixed up. | 246 # TODO: Replace with list_installed_packages.sh when it is fixed up. |
| 247 dpkg --root="${ROOT_FS_DIR}" -l > \ | 247 dpkg --root="${ROOT_FS_DIR}" -l > \ |
| 248 "${OUTPUT_DIR}/package_list_installed.txt" | 248 "${OUTPUT_DIR}/package_list_installed.txt" |
| 249 | 249 |
| 250 cleanup_rootfs_mounts | 250 cleanup_rootfs_mounts |
| 251 trap - EXIT | 251 trap - EXIT |
| OLD | NEW |