Skip to content

Commit

Permalink
rootfs-builder: Support building centos-rootfs on Arm64
Browse files Browse the repository at this point in the history
For now, mirrorlist doesn't support non-x86_64 arch, so we need
create baseurl for arm64. Furthermore, we also need to offer
arm64-specific gpg keys along with the regular key.

Fixes: kata-containers#111

Signed-off-by: Penny Zheng <[email protected]>
  • Loading branch information
Pennyzct committed Jun 13, 2018
1 parent 3375e73 commit 0451db9
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 34 deletions.
30 changes: 0 additions & 30 deletions rootfs-builder/centos/RPM-GPG-KEY-CentOS-7

This file was deleted.

8 changes: 5 additions & 3 deletions rootfs-builder/centos/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ LOG_FILE="/var/log/yum-centos.log"
MIRROR_LIST="http://mirrorlist.centos.org/?release=${OS_VERSION}&arch=${ARCH}&repo=os&container=container"

# Aditional Repos
CENTOS_UPDATES_URL="http://mirrorlist.centos.org/?release=${OS_VERSION}&arch=${ARCH}&repo=updates&container=container"
CENTOS_UPDATES_MIRROR_LIST="http://mirrorlist.centos.org/?release=${OS_VERSION}&arch=${ARCH}&repo=updates&container=container"

CENTOS_EXTRAS_URL="http://mirrorlist.centos.org/?release=${OS_VERSION}&arch=${ARCH}&repo=extras&container=container"
CENTOS_EXTRAS_MIRROR_LIST="http://mirrorlist.centos.org/?release=${OS_VERSION}&arch=${ARCH}&repo=extras&container=container"

CENTOS_PLUS_URL="http://mirrorlist.centos.org/?release=${OS_VERSION}&arch=${ARCH}&repo=centosplus&container=container"
CENTOS_PLUS_MIRROR_LIST="http://mirrorlist.centos.org/?release=${OS_VERSION}&arch=${ARCH}&repo=centosplus&container=container"

GPG_KEY_URL="https://www.centos.org/keys/RPM-GPG-KEY-CentOS-7"

GPG_KEY_FILE="RPM-GPG-KEY-CentOS-7"

Expand Down
18 changes: 18 additions & 0 deletions rootfs-builder/centos/config_aarch64.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright (c) 2018 ARM Limited
#
# SPDX-License-Identifier: Apache-2.0

# Base Repos
BASE_URL="http://mirror.centos.org/altarch/${OS_VERSION}/os/${ARCH}/"

# Additional Repos
CENTOS_UPDATES_URL="http://mirror.centos.org/altarch/${OS_VERSION}/updates/${ARCH}/"

CENTOS_EXTRAS_URL="http://mirror.centos.org/altarch/${OS_VERSION}/extras/${ARCH}/"

CENTOS_PLUS_URL="http://mirror.centos.org/altarch/${OS_VERSION}/centosplus/${ARCH}/"

GPG_KEY_ARCH_URL="http://mirror.centos.org/altarch/7/os/aarch64/RPM-GPG-KEY-CentOS-7-aarch64"

GPG_KEY_ARCH_FILE="RPM-GPG-KEY-CentOS-7-aarch64"
9 changes: 9 additions & 0 deletions rootfs-builder/rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ source "${script_dir}/versions.txt"
# distro-specific config file
typeset -r CONFIG_SH="config.sh"

# optional arch-specific config file
typeset -r CONFIG_ARCH_SH="config_${ARCH}.sh"

# Name of an optional distro-specific file which, if it exists, must implement the
# build_rootfs() function.
typeset -r LIB_SH="rootfs_lib.sh"
Expand Down Expand Up @@ -179,6 +182,12 @@ distro_config_dir="${script_dir}/${distro}"
rootfs_config="${distro_config_dir}/${CONFIG_SH}"
source "${rootfs_config}"

# Source arch-specific config file
rootfs_arch_config="${distro_config_dir}/${CONFIG_ARCH_SH}"
if [ -f "${rootfs_arch_config}" ]; then
source "${rootfs_arch_config}"
fi

[ -d "${distro_config_dir}" ] || die "Not found configuration directory ${distro_config_dir}"

if [ -z "$ROOTFS_DIR" ]; then
Expand Down
14 changes: 13 additions & 1 deletion scripts/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,25 @@ enabled=1
EOF
fi

if [ "$GPG_KEY_FILE" != "" ]; then
if [ -n "$GPG_KEY_URL" ]; then
if [ ! -f "${CONFIG_DIR}/${GPG_KEY_FILE}" ]; then
curl -L ${GPG_KEY_URL} -o ${CONFIG_DIR}/${GPG_KEY_FILE}
fi
cat >> "${DNF_CONF}" << EOF
gpgcheck=1
gpgkey=file://${CONFIG_DIR}/${GPG_KEY_FILE}
EOF
fi

if [ -n "$GPG_KEY_ARCH_URL" ]; then
if [ ! -f "${CONFIG_DIR}/${GPG_KEY_ARCH_FILE}" ]; then
curl -L ${GPG_KEY_ARCH_URL} -o ${CONFIG_DIR}/${GPG_KEY_ARCH_FILE}
fi
cat >> "${DNF_CONF}" << EOF
file://${CONFIG_DIR}/${GPG_KEY_ARCH_FILE}
EOF
fi

}

build_rootfs()
Expand Down

0 comments on commit 0451db9

Please sign in to comment.