mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-12 07:26:58 +02:00
Use local apt cache instead of local_repo when mastering an image.
This change switches to mastering an image without using debootstrap. We turn on the previously experimental bits that install a small set of packages manually before handing things over to apt. In both cases we use apt to download the packages so that it can populate it's local package cache. With this change we will no longer depend on the local_repo when mastering an image. Developers will not have to rebuild their local repo when repo_list_image.txt changes. Instead we will use and lazy-fill the local apt-cache. The first time you build_image.sh it will be slow since it needs to download the packages. Subsequent runs should be as before since it will use the local cache. If packages are added they should be lazily fetched in the next image build. Until we have a fully populated external mirror, developers will still have to add packages to repo_list_image.txt. Also, until make_chroot is switched over to use the external repo then developers will have to redo their local repo when the repo_list_dev.txt changes. Review URL: http://codereview.chromium.org/521073
This commit is contained in:
parent
58e02408a6
commit
4f44d9e104
@ -33,7 +33,7 @@ DEFINE_boolean replace $FLAGS_FALSE "Overwrite existing output, if any."
|
|||||||
DEFINE_boolean increment $FLAGS_FALSE \
|
DEFINE_boolean increment $FLAGS_FALSE \
|
||||||
"Picks the latest build and increments the minor version by one."
|
"Picks the latest build and increments the minor version by one."
|
||||||
|
|
||||||
DEFINE_string mirror "$DEFAULT_IMG_MIRROR" "Repository mirror to use."
|
DEFINE_string mirror "$DEFAULT_EXT_MIRROR" "Repository mirror to use."
|
||||||
DEFINE_string suite "$DEFAULT_IMG_SUITE" "Repository suite to base image on."
|
DEFINE_string suite "$DEFAULT_IMG_SUITE" "Repository suite to base image on."
|
||||||
DEFINE_string pkglist "$DEFAULT_PKGLIST" \
|
DEFINE_string pkglist "$DEFAULT_PKGLIST" \
|
||||||
"Name of file listing packages to install from repository."
|
"Name of file listing packages to install from repository."
|
||||||
|
@ -90,7 +90,7 @@ DEFAULT_IMG_SUITE=${CHROMEOS_IMG_SUITE:-"chromeos"}
|
|||||||
# Package repositories (mirrors)
|
# Package repositories (mirrors)
|
||||||
DEFAULT_EXT_MIRROR=${CHROMEOS_EXT_MIRROR:-"http://build.chromium.org/buildbot/packages"}
|
DEFAULT_EXT_MIRROR=${CHROMEOS_EXT_MIRROR:-"http://build.chromium.org/buildbot/packages"}
|
||||||
DEFAULT_DEV_MIRROR=${CHROMEOS_DEV_MIRROR:-"file://$GCLIENT_ROOT/repo/apt"}
|
DEFAULT_DEV_MIRROR=${CHROMEOS_DEV_MIRROR:-"file://$GCLIENT_ROOT/repo/apt"}
|
||||||
DEFAULT_IMG_MIRROR=${CHROMEOS_IMG_MIRROR:-"file:///home/$USER/trunk/repo/apt"}
|
DEFAULT_IMG_MIRROR=${CHROMEOS_IMG_MIRROR:-"copy:///home/$USER/trunk/repo/apt"}
|
||||||
|
|
||||||
# Default location for chroot
|
# Default location for chroot
|
||||||
DEFAULT_CHROOT_DIR=${CHROMEOS_CHROOT_DIR:-"$GCLIENT_ROOT/chroot"}
|
DEFAULT_CHROOT_DIR=${CHROMEOS_CHROOT_DIR:-"$GCLIENT_ROOT/chroot"}
|
||||||
|
@ -30,7 +30,7 @@ DEFINE_string build_root "$DEFAULT_BUILD_ROOT" \
|
|||||||
"Root of build output"
|
"Root of build output"
|
||||||
DEFINE_string package_list "$DEFAULT_PKGLIST" \
|
DEFINE_string package_list "$DEFAULT_PKGLIST" \
|
||||||
"The package list file to use."
|
"The package list file to use."
|
||||||
DEFINE_string server "$DEFAULT_IMG_MIRROR" \
|
DEFINE_string server "$DEFAULT_EXT_MIRROR" \
|
||||||
"The package server to use."
|
"The package server to use."
|
||||||
DEFINE_string suite "$DEFAULT_IMG_SUITE" \
|
DEFINE_string suite "$DEFAULT_IMG_SUITE" \
|
||||||
"The package suite to use."
|
"The package suite to use."
|
||||||
@ -146,19 +146,6 @@ EOF
|
|||||||
# TODO: Full audit of the apt conf dump to make sure things are ok.
|
# TODO: Full audit of the apt conf dump to make sure things are ok.
|
||||||
apt-config dump > "${OUTPUT_DIR}/apt.conf.dump"
|
apt-config dump > "${OUTPUT_DIR}/apt.conf.dump"
|
||||||
|
|
||||||
# Add debootstrap link for the suite, if it doesn't exist.
|
|
||||||
if [ ! -e "/usr/share/debootstrap/scripts/$FLAGS_suite" ]
|
|
||||||
then
|
|
||||||
sudo ln -s /usr/share/debootstrap/scripts/jaunty \
|
|
||||||
"/usr/share/debootstrap/scripts/$FLAGS_suite"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "$EXPERIMENTAL_NO_DEBOOTSTRAP" -a \
|
|
||||||
-z "$EXPERIMENTAL_NO_MAINTAINER_SCRIPTS" ]; then
|
|
||||||
# Use debootstrap, which runs maintainer scripts.
|
|
||||||
sudo debootstrap --arch=i386 $FLAGS_suite "$ROOT_FS_DIR" "${FLAGS_server}"
|
|
||||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive apt-get update
|
|
||||||
else
|
|
||||||
# We do a rough equivalent to debootstrap that installs the minimal
|
# We do a rough equivalent to debootstrap that installs the minimal
|
||||||
# packages needed to be able to run apt to install the rest. We don't
|
# packages needed to be able to run apt to install the rest. We don't
|
||||||
# use debootstrap since it is geared toward having a second stage that
|
# use debootstrap since it is geared toward having a second stage that
|
||||||
@ -173,7 +160,7 @@ else
|
|||||||
# login - So that groupadd will work
|
# login - So that groupadd will work
|
||||||
# base-passwd/passwd - So that chmod and useradd/groupadd will work
|
# base-passwd/passwd - So that chmod and useradd/groupadd will work
|
||||||
# bash - So that scripts can run
|
# bash - So that scripts can run
|
||||||
# libpam-runtim/libuuid1 - Not exactly sure why
|
# libpam-runtime/libuuid1 - Not exactly sure why
|
||||||
# sysv-rc - So that we can overwrite invoke-rc.d, update-rc.d
|
# sysv-rc - So that we can overwrite invoke-rc.d, update-rc.d
|
||||||
EXTRA_PACKAGES="base-files base-passwd bash libpam-runtime libuuid1 login passwd sysv-rc"
|
EXTRA_PACKAGES="base-files base-passwd bash libpam-runtime libuuid1 login passwd sysv-rc"
|
||||||
|
|
||||||
@ -191,18 +178,14 @@ else
|
|||||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \
|
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \
|
||||||
apt-get --download-only install $PACKAGES $EXTRA_PACKAGES
|
apt-get --download-only install $PACKAGES $EXTRA_PACKAGES
|
||||||
|
|
||||||
i=0
|
# Install initial packages directly with dpkg_no_scripts.sh
|
||||||
for p in $PACKAGES $EXTRA_PACKAGES; do
|
for p in $PACKAGES $EXTRA_PACKAGES; do
|
||||||
set +e
|
PKG=$(ls "${REPO}"/${p}_*_i386.deb || /bin/true)
|
||||||
PKG=$(ls "${REPO}"/${p}_*_i386.deb)
|
|
||||||
set -e
|
|
||||||
if [ -z "$PKG" ]; then
|
if [ -z "$PKG" ]; then
|
||||||
PKG=$(ls "${REPO}"/${p}_*_all.deb)
|
PKG=$(ls "${REPO}"/${p}_*_all.deb)
|
||||||
fi
|
fi
|
||||||
echo "Installing package: $PKG [$i]"
|
|
||||||
sudo "${SCRIPTS_DIR}"/dpkg_no_scripts.sh \
|
sudo "${SCRIPTS_DIR}"/dpkg_no_scripts.sh \
|
||||||
--root="$ROOT_FS_DIR" --unpack "$PKG"
|
--root="$ROOT_FS_DIR" --unpack "$PKG"
|
||||||
i=$((i + 1))
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Make sure that apt is ready to work. We use --fix-broken to trigger apt
|
# Make sure that apt is ready to work. We use --fix-broken to trigger apt
|
||||||
@ -252,7 +235,8 @@ else
|
|||||||
|
|
||||||
# sysv-rc needs this
|
# sysv-rc needs this
|
||||||
sudo mkdir -p "${ROOT_FS_DIR}/etc/init.d"
|
sudo mkdir -p "${ROOT_FS_DIR}/etc/init.d"
|
||||||
fi # EXPERIMENTAL_NO_DEBOOTSTRAP
|
|
||||||
|
# ----- END MAINTAINER SCRIPT FIXUPS -----
|
||||||
|
|
||||||
# Set up mounts for working within the rootfs. We copy some basic
|
# Set up mounts for working within the rootfs. We copy some basic
|
||||||
# network information from the host so that maintainer scripts can
|
# network information from the host so that maintainer scripts can
|
||||||
|
Loading…
Reference in New Issue
Block a user