From aaedee7f361e9ffbc5ed644822ad4e71db1c9f0b Mon Sep 17 00:00:00 2001 From: Colin Watson Date: Fri, 22 Jan 2010 17:57:28 +0000 Subject: [PATCH] Various image build improvements for ARM Add an --arch option to build_image.sh, passed to install_packages.sh. Use it to set APT::Architecture. Add --mirror2/--suite2 options to build_image.sh, and --server2/--suite2 options to install_packages.sh (differing option names to match options that were there already). This allows some of the packages to be pulled from ports.ubuntu.com rather than from local_packages, like this: ./build_image.sh --arch armel --mirror2 http://ports.ubuntu.com/ubuntu-ports --suite2 karmic Copy only .debs from local_packages, not whatever other junk might be lying around there. Use copy: rather than file: for local_packages, so that the files will be copied into the apt cache directory for the benefit of dpkg_no_scripts.sh. Review URL: http://codereview.chromium.org/554031 --- build_image.sh | 9 ++++++++- install_packages.sh | 18 ++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/build_image.sh b/build_image.sh index d2773d67a7..6c6f9bc2be 100755 --- a/build_image.sh +++ b/build_image.sh @@ -33,8 +33,12 @@ DEFINE_boolean replace $FLAGS_FALSE "Overwrite existing output, if any." DEFINE_boolean increment $FLAGS_FALSE \ "Picks the latest build and increments the minor version by one." +DEFINE_string arch "x86" \ + "The target architecture to build for. One of { x86, armel }." DEFINE_string mirror "$DEFAULT_IMG_MIRROR" "Repository mirror to use." DEFINE_string suite "$DEFAULT_IMG_SUITE" "Repository suite to base image on." +DEFINE_string mirror2 "" "Additional repository mirror to use (URL only)." +DEFINE_string suite2 "" "Repository suite for additional mirror." DEFINE_string pkglist "$DEFAULT_PKGLIST" \ "Name of file listing packages to install from repository." DEFINE_boolean with_dev_pkgs $FLAGS_TRUE \ @@ -128,8 +132,11 @@ fi --root="$ROOT_FS_DIR" \ --output_dir="${OUTPUT_DIR}" \ --package_list="$PKGLIST" \ + --arch="$FLAGS_arch" \ --mirror="$FLAGS_mirror" \ - --suite="$FLAGS_suite" + --suite="$FLAGS_suite" \ + --mirror2="$FLAGS_mirror2" \ + --suite2="$FLAGS_suite2" "${SCRIPTS_DIR}/customize_rootfs.sh" --root="${ROOT_FS_DIR}" diff --git a/install_packages.sh b/install_packages.sh index 3043b57793..2c7cefaf4d 100755 --- a/install_packages.sh +++ b/install_packages.sh @@ -34,6 +34,8 @@ DEFINE_string mirror "$DEFAULT_IMG_MIRROR" \ "The upstream package mirror to use." DEFINE_string suite "$DEFAULT_IMG_SUITE" \ "The upstream package suite to use." +DEFINE_string mirror2 "" "Additional package mirror to use (URL only)." +DEFINE_string suite2 "" "Package suite for additional mirror." # Parse command line FLAGS "$@" || exit 1 @@ -81,7 +83,7 @@ cleanup_rootfs_mounts() { # Set up repository for locally built packages; these take highest precedence. mkdir -p "${SETUP_DIR}/local_packages" -cp "${FLAGS_build_root}/${FLAGS_arch}/local_packages"/* \ +cp "${FLAGS_build_root}/${FLAGS_arch}/local_packages"/*.deb \ "${SETUP_DIR}/local_packages" cd "$SETUP_DIR" dpkg-scanpackages local_packages/ /dev/null | \ @@ -91,15 +93,26 @@ cd - # Create the temporary apt source.list used to install packages. APT_SOURCE="${OUTPUT_DIR}/sources.list" cat < "$APT_SOURCE" -deb file:"$SETUP_DIR" local_packages/ +deb copy:"$SETUP_DIR" local_packages/ deb $FLAGS_mirror $FLAGS_suite main restricted multiverse universe EOF +if [ -n "$FLAGS_mirror2" ] && [ -n "$FLAGS_suite2" ]; then + cat <> "$APT_SOURCE" +deb $FLAGS_mirror2 $FLAGS_suite2 main restricted multiverse universe +EOF +fi # Cache directory for APT to use. This cache is re-used across builds. We # rely on the cache to reduce traffic to the hosted repositories. APT_CACHE_DIR="${FLAGS_build_root}/apt_cache-${FLAGS_arch}/" mkdir -p "${APT_CACHE_DIR}/archives/partial" +if [ "${FLAGS_arch}" = x86 ]; then + APT_ARCH=i386 +else + APT_ARCH="${FLAGS_arch}" +fi + # Create the apt configuration file. See "man apt.conf" APT_PARTS="${OUTPUT_DIR}/apt.conf.d" mkdir -p "$APT_PARTS" # An empty apt.conf.d to avoid other configs. @@ -114,6 +127,7 @@ APT Assume-Yes "1"; AllowUnauthenticated "1"; }; + Architecture "${APT_ARCH}"; }; Dir {