mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-22 22:21:10 +02:00
Switch install_packages.sh to re-use the apt cache across runs.
This change also switches us to pre-populate the apt cache with the set of packages needed to run apt and install them from there rather than referring to the soon-to-be-defunct local repo. Review URL: http://codereview.chromium.org/523146
This commit is contained in:
parent
1fda17446e
commit
5a9457f2f8
@ -79,13 +79,10 @@ cleanup_rootfs_mounts() {
|
||||
sudo umount "${ROOT_FS_DIR}/proc"
|
||||
}
|
||||
|
||||
# Create setup directory and copy over scripts, config files, and locally
|
||||
# built packages.
|
||||
# Set up repository for locally built packages; these take highest precedence.
|
||||
mkdir -p "${SETUP_DIR}/local_packages"
|
||||
cp "${FLAGS_build_root}/${FLAGS_target}/local_packages"/* \
|
||||
"${SETUP_DIR}/local_packages"
|
||||
|
||||
# Set up repository for local packages to install in the rootfs via apt-get.
|
||||
cd "$SETUP_DIR"
|
||||
dpkg-scanpackages local_packages/ /dev/null | \
|
||||
gzip > local_packages/Packages.gz
|
||||
@ -98,8 +95,9 @@ deb file:"$SETUP_DIR" local_packages/
|
||||
deb $FLAGS_server $FLAGS_suite main restricted multiverse universe
|
||||
EOF
|
||||
|
||||
# Cache directory for APT to use.
|
||||
APT_CACHE_DIR="${OUTPUT_DIR}/tmp/cache/"
|
||||
# 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_target}/"
|
||||
mkdir -p "${APT_CACHE_DIR}/archives/partial"
|
||||
|
||||
# Create the apt configuration file. See "man apt.conf"
|
||||
@ -118,6 +116,7 @@ APT
|
||||
Get
|
||||
{
|
||||
Assume-Yes "1";
|
||||
AllowUnauthenticated "1";
|
||||
};
|
||||
};
|
||||
Dir
|
||||
@ -158,12 +157,12 @@ 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
|
||||
# A hack-in-progress that does our own debootstrap equivalent and skips
|
||||
# maintainer scripts.
|
||||
|
||||
# TODO: Replace with a pointer to lool's repo or maybe apt-get --download-only?
|
||||
REPO="${GCLIENT_ROOT}/repo/var/cache/make_local_repo"
|
||||
# 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
|
||||
# use debootstrap since it is geared toward having a second stage that
|
||||
# needs to run package maintainer scripts. This is also simpler.
|
||||
|
||||
# The set of required packages before apt can take over.
|
||||
PACKAGES="debconf libacl1 libattr1 libc6 libgcc1 libselinux1"
|
||||
@ -185,6 +184,12 @@ else
|
||||
sudo mkdir -p "${ROOT_FS_DIR}/var/lib/apt/lists/partial" \
|
||||
"${ROOT_FS_DIR}/var/lib/dpkg/updates"
|
||||
|
||||
# Download the initial packages into the apt cache if necessary.
|
||||
REPO="${APT_CACHE_DIR}/archives"
|
||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive apt-get update
|
||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \
|
||||
apt-get --download-only install $PACKAGES $EXTRA_PACKAGES
|
||||
|
||||
i=0
|
||||
for p in $PACKAGES $EXTRA_PACKAGES; do
|
||||
set +e
|
||||
@ -199,6 +204,13 @@ else
|
||||
i=$((i + 1))
|
||||
done
|
||||
|
||||
# Make sure that apt is ready to work. We use --fix-broken to trigger apt
|
||||
# to install additional critical packages. If there are any of these, we
|
||||
# disable the maintainer scripts so they install ok.
|
||||
TMP_FORCE_NO_SCRIPTS="-o=Dir::Bin::dpkg=${SCRIPTS_DIR}/dpkg_no_scripts.sh"
|
||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \
|
||||
apt-get $TMP_FORCE_NO_SCRIPTS --force-yes --fix-broken install
|
||||
|
||||
# ----- MAINTAINER SCRIPT FIXUPS -----
|
||||
|
||||
# TODO: Remove when we stop having maintainer scripts altogether.
|
||||
@ -231,7 +243,6 @@ else
|
||||
sudo mkdir -p "${ROOT_FS_DIR}/etc/init.d"
|
||||
fi # EXPERIMENTAL_NO_DEBOOTSTRAP
|
||||
|
||||
|
||||
# Set up mounts for working within the rootfs. We copy some basic
|
||||
# network information from the host so that maintainer scripts can
|
||||
# access the network as needed.
|
||||
@ -241,14 +252,6 @@ sudo mount -t proc proc "${ROOT_FS_DIR}/proc"
|
||||
sudo cp /etc/hosts "${ROOT_FS_DIR}/etc"
|
||||
trap cleanup_rootfs_mounts EXIT
|
||||
|
||||
# Make sure that apt is ready to work. We use --fix-broken to trigger apt
|
||||
# to install additional critical packages. If there are any of these, we
|
||||
# disable the maintainer scripts so they install ok.
|
||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive apt-get update
|
||||
TMP_FORCE_NO_SCRIPTS="-o=Dir::Bin::dpkg=${SCRIPTS_DIR}/dpkg_no_scripts.sh"
|
||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \
|
||||
apt-get $TMP_FORCE_NO_SCRIPTS --force-yes --fix-broken install
|
||||
|
||||
# Install prod packages
|
||||
COMPONENTS=`cat $FLAGS_package_list | grep -v ' *#' | grep -v '^ *$' | sed '/$/{N;s/\n/ /;}'`
|
||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \
|
||||
@ -271,13 +274,6 @@ EOF
|
||||
sudo APT_CONFIG="$APT_CONFIG" DEBIAN_FRONTEND=noninteractive \
|
||||
apt-get --force-yes install "linux-image-${KERNEL_VERSION}"
|
||||
|
||||
# Clean up the apt cache.
|
||||
# TODO: The cache was populated by debootstrap, not these installs. Remove
|
||||
# this line when we can get debootstrap to stop doing this.
|
||||
sudo rm -f "${ROOT_FS_DIR}"/var/cache/apt/archives/*.deb
|
||||
# Need to rm read-only created lock files in order for archiving step to work
|
||||
sudo rm -rf "$APT_CACHE_DIR"
|
||||
|
||||
# List all packages installed so far, since these are what the local
|
||||
# repository needs to contain.
|
||||
# TODO: Replace with list_installed_packages.sh when it is fixed up.
|
||||
|
Loading…
x
Reference in New Issue
Block a user