Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

snap: cross-build snap images #99

Merged
merged 2 commits into from
Aug 9, 2018

Conversation

devimc
Copy link

@devimc devimc commented Jul 13, 2018

Build snap images for all supported architectures

# SPDX-License-Identifier: Apache-2.0
#

set -x
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do these scripts also need set -e?

exit 1
}

get_ip() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For clarity these functions might be better named as make_random_ip_addr() and make_random_port()?

setup_image() {
img_url=$1
img=$2
[ -f "${img}" ] && return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is going to be fragile - if the download fails and the script is re-run, the full image will never be downloaded.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

Copy link
Author

@devimc devimc Jul 31, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if download fails, output file is removed

(build_arch arm64 &> ${WORKDIR}/arm64/log) &
# FIXME: support PPC: https://github.com/kata-containers/packaging/issues/97
#sleep 1
# (build_arch ppc64 &> ${WORKDIR}/ppc64/log) &
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this PR still WIP? If not, can you remove these commented-out lines.

mkfs.vfat -n cidata "${seed_img}" &> /dev/null

if [ -n "${http_proxy}" ]; then
apt_proxy="apt:\n https_proxy: http://proxy-chain.intel.com:911\n proxy: http://proxy-chain.intel.com:911"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't have these named proxies here.


set -x
sudo apt-get update -y
sudo apt-get install -y snapd snapcraft golang-go gcc g++ libcap-ng-dev pkg-config make libz-dev libssl-dev openssl cpio libelf-dev libnewt-dev \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you reformat this list so each package is on a separate line (with a backslash)? Also, you might be able to simplify the list by replacing some of these packages with the build-essential package I think.

set -x
sudo apt-get update -y
sudo apt-get install -y snapd snapcraft golang-go gcc g++ libcap-ng-dev pkg-config make libz-dev libssl-dev openssl cpio libelf-dev libnewt-dev \
libiberty-dev libdw-dev libpci-dev libpixman-1-dev libglib2.0-dev librbd-dev libcap-dev libattr1-dev autoconf flex bison python docker.io
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will docker.io clash with docker-ce which gets installed when you install a Kata system?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, but I'm not installing Kata, I'm building Kata, and I use docker.io for osbuilder

.gitignore Outdated
@@ -9,3 +9,13 @@ prime/
stage/
snap/.snapcraft/
snap/snapcraft.yaml
snap-build/amd64/log
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you simplify to something like the following to avoid hard-coding the list of architectures?

snap-build/*/log
snap-build/*/*.img

@@ -0,0 +1,31 @@
#!/bin/bash
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be simpler to use the osbuilder approach and create a single snap-build/run_qemu.sh script and then have a snap-build/${arch}/config.sh file that defines some variables for the particular architecture that snap-build/run_qemu.sh will use. That will minimise duplication and make it easier to add support for additional architectures.


ip="${1}"
port="${2}"
arch_dir="${WORKDIR}/amd64"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are lots of variables here that can be shared between the different scripts - see comment above about config.sh.

@jodh-intel
Copy link
Contributor

@devimc - a reminder that this PR needs an update.

@devimc devimc force-pushed the snap/multiArch branch 2 times, most recently from 1d4206b to b608b69 Compare August 2, 2018 14:48
@devimc
Copy link
Author

devimc commented Aug 2, 2018

@jodh-intel changes applied, thanks

# SPDX-License-Identifier: Apache-2.0
#

local arch_qemu="x86_64"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you can use local here as these are globals and local is for functions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can if you source it inside a function 😄

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooooh - that's clever! I hadn't spotted that ;)

@@ -0,0 +1,21 @@
#cloud-config
@APT_PROXY@
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.


sudo apt-get update -y
sudo apt-get install -y \
snapd \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Might be clearer to sort this list.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, I agree


source lib.sh

readonly supported_archs=(all amd64 ppc64 arm64)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be arm to match the change in .ci/lib.sh?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nop, arm64 is correct, the change in .ci/lib.sh is to match with yq releases

img=$2
[ -f "${img}" ] && return
download "${img_url}" "$(dirname ${img})"
[ $? != 0 ] && rm -f "${img}" && return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this going to work? The files which source .ci/lib.sh call set -e so if curl fails, the script will immediately exit.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed set -e since I have to check exit codes and poweroff the VM

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you can do this:

set -e

{ download "${img_url}" "$(dirname ${img})"; ret=$?; } || true
[ $ret != 0 ] && rm -f "${img}" && return

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it, thanks

@devimc devimc force-pushed the snap/multiArch branch 4 times, most recently from 511f936 to 6ba2325 Compare August 3, 2018 15:36
@devimc
Copy link
Author

devimc commented Aug 3, 2018

@jodh-intel changes applied, thanks

@jodh-intel
Copy link
Contributor

jodh-intel commented Aug 3, 2018

Thanks @devimc.

lgtm

Approved with PullApprove Approved with PullApprove

@GabyCT
Copy link
Contributor

GabyCT commented Aug 8, 2018

lgtm

Approved with PullApprove

Julio Montes added 2 commits August 9, 2018 09:14
Use `arch` to identify qemu architecture instead of hardcoding it.

fixes kata-containers#91

Signed-off-by: Julio Montes <julio.montes@intel.com>
Add scripts to cross-build snap images for all supported
architectures using virtual machines

fixes kata-containers#98

Signed-off-by: Julio Montes <julio.montes@intel.com>
@egernst egernst merged commit 7705d68 into kata-containers:master Aug 9, 2018
@devimc devimc deleted the snap/multiArch branch November 6, 2018 11:56
jcvenegas pushed a commit that referenced this pull request Jul 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants