osbuilder: Revert to using apk.static for Alpine

#2399 partially reverted #418, missing on returning to bootstrapping a
rootfs with `apk.static` instead of copying the entire root, which can
result in drastically larger (more than 10x) images. Revert this as well
(requires some updates to URL building).

Fixes: #3216
Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
This commit is contained in:
Jakob Naucke 2021-12-07 12:00:54 +01:00
parent 7522109abc
commit dfd0732ff9
No known key found for this signature in database
GPG Key ID: 45FA1C7D310C0EBE
2 changed files with 14 additions and 5 deletions

View File

@ -11,7 +11,7 @@ BASE_PACKAGES="alpine-base"
# Alpine mirror to use
# See a list of mirrors at http://nl.alpinelinux.org/alpine/MIRRORS.txt
MIRROR=http://dl-5.alpinelinux.org/alpine
MIRROR=https://dl-5.alpinelinux.org/alpine
PACKAGES=""

View File

@ -9,6 +9,8 @@
#
# - Optional environment variables
#
# EXTRA_PKGS: Variable to add extra PKGS provided by the user
#
# BIN_AGENT: Name of the Kata-Agent binary
#
# Any other configuration variable for a specific distro must be added
@ -22,13 +24,20 @@ build_rootfs() {
# Mandatory
local ROOTFS_DIR=$1
# Add extra packages to the rootfs when specified
local EXTRA_PKGS=${EXTRA_PKGS:-}
# Populate ROOTFS_DIR
check_root
mkdir -p "${ROOTFS_DIR}"
rm -rf ${ROOTFS_DIR}/var/tmp
cp -a -r -f /bin /etc /lib /sbin /usr /var ${ROOTFS_DIR}
mkdir -p ${ROOTFS_DIR}{/root,/proc,/dev,/home,/media,/mnt,/opt,/run,/srv,/sys,/tmp}
/sbin/apk.static \
-X ${MIRROR}/v${OS_VERSION}/main \
-U \
--allow-untrusted \
--root ${ROOTFS_DIR} \
--initdb add ${BASE_PACKAGES} ${EXTRA_PKGS} ${PACKAGES}
echo "${MIRROR}/${OS_VERSION}/main" > ${ROOTFS_DIR}/etc/apk/repositories
mkdir -p ${ROOTFS_DIR}{/root,/etc/apk,/proc}
echo "${MIRROR}/v${OS_VERSION}/main" > ${ROOTFS_DIR}/etc/apk/repositories
}