Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: get MacOS build working #318

Merged
merged 3 commits into from
Jun 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 45 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# umoci: Umoci Modifies Open Containers' Images
# Copyright (C) 2016-2020 SUSE LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version: ~> 1.0
os: linux
dist: bionic

Expand All @@ -8,8 +24,17 @@ go:
services:
- docker

notifications:
email: false

before_install:
- sudo sh -c "apt-get -qq update && apt-get install -y gcc-multilib"
- |-
case "$TRAVIS_OS_NAME" in
linux)
sudo apt-get -qq update
sudo apt-get install -y gcc-multilib
;;
esac
# Need to set GO111MODULE=off here because Travis runs inside our source repo
# (which is a Go module) and thus 'go get' will actually add dependencies to
# our go.mod file. Annoyingly this means we cannot require v2 of go-md2man
Expand All @@ -23,18 +48,6 @@ env:
- DOCKER_IMAGE="ubuntu:latest"
- DOCKER_IMAGE="fedora:latest"

matrix:
fast_finish: true
allow_failures:
# The Fedora image has caused us plenty of pain in the past, so don't let
# it kill PRs. This is made more annoying by the fact that the Fedora
# image's size makes this test stage take much longer than any other image
# (~40 minutes on some days).
- env: DOCKER_IMAGE="fedora:latest"

notifications:
email: false

script:
# Necessary to make Travis co-operate with Docker.
- chmod a+rwx .
Expand All @@ -43,3 +56,22 @@ script:
- make GO111MODULE=off GOARCH=386 local-validate-build
# Run the actual CI.
- make DOCKER_IMAGE=$DOCKER_IMAGE ci

matrix:
fast_finish: true
allow_failures:
# The Fedora image has caused us plenty of pain in the past, so don't let
# it kill PRs. This is made more annoying by the fact that the Fedora
# image's size makes this test stage take much longer than any other image
# (~40 minutes on some days).
- env: DOCKER_IMAGE="fedora:latest"
include:
- os: osx
env:
# Clear DOCKER_IMAGE since we don't use it.
- DOCKER_IMAGE=""
script:
# TODO: Run the integration tests and rest of the CI, so we don't need
# to special-case MacOS here.
- make local-validate-build
- make local-test-unit
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,29 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased] ##
umoci has been adopted by the Open Container Initative as a reference
implementation of the OCI Image Specification. This will have little impact on
the roadmap or scope of umoci, but it does further solidify umoci as a useful
piece of "boring container infrastructure" that can be used to build larger
systems.

### Changed ###
* As part of the adoption procedure, the import path and module name of umoci
has changed from `github.com/openSUSE/umoci` to
`github.com/opencontainers/umoci`. This means that users of our (still
unstable) Go API will have to change their import paths in order to update to
newer versions of umoci.

The old GitHub project will contain a snapshot of `v0.4.5` with a few minor
changes to the readme that explain the situation. Go projects which import
the archived project will receive build warnings that explain the need to
update their import paths.

### Added ###
- umoci now builds on MacOS, and we currently run the unit tests on MacOS to
hopefully catch core regressions (in the future we will get the integration
tests running to catch more possible regressions). opencontainers/umoci#318

### Fixed ###
- Suppress repeated xattr warnings on destination filesystems that do not
support xattrs. opencontainers/umoci#311
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ umociimage:
docker build -t $(UMOCI_IMAGE) --build-arg DOCKER_IMAGE=$(DOCKER_IMAGE) .

ifndef COVERAGE
COVERAGE := $(shell mktemp --dry-run umoci.cov.XXXXXX)
COVERAGE := $(notdir $(shell mktemp -u umoci.cov.XXXXXX))
export COVERAGE
endif

.PHONY: test-unit
Expand Down
3 changes: 2 additions & 1 deletion hack/publish-site.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,10 @@
# limitations under the License.

set -Eeuo pipefail
source "$(dirname "$BASH_SOURCE")/readlinkf.sh"

# Change to site root.
site_root="$(readlink -f "$(dirname "${BASH_SOURCE}")/../.site")"
site_root="$(readlinkf_posix "$(dirname "${BASH_SOURCE}")/../.site")"
cd "$site_root"

# Make sure that we've checked out submodules.
Expand Down
43 changes: 43 additions & 0 deletions hack/readlinkf.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash
# readlinkf: POSIX-compliant implementation of readlink -f.
# Author: Koichi Nakashima <koichi@nksm.name>
# Licensed under the Creative Commons Zero v1.0 Universal license.
# <https://creativecommons.org/publicdomain/zero/1.0/>

# Copied verbatim from v1.1.0 of <https://github.com/ko1nksm/readlinkf>.

# POSIX compliant version
readlinkf_posix() {
[ "${1:-}" ] || return 1
max_symlinks=40
CDPATH='' # to avoid changing to an unexpected directory

target=$1
[ -e "${target%/}" ] || target=${1%"${1##*[!/]}"} # trim trailing slashes
[ -d "${target:-/}" ] && target="$target/"

cd -P . 2>/dev/null || return 1
while [ "$max_symlinks" -ge 0 ] && max_symlinks=$((max_symlinks - 1)); do
if [ ! "$target" = "${target%/*}" ]; then
case $target in
/*) cd -P "${target%/*}/" 2>/dev/null || break ;;
*) cd -P "./${target%/*}" 2>/dev/null || break ;;
esac
target=${target##*/}
fi

if [ ! -L "$target" ]; then
target="${PWD%/}${target:+/}${target}"
printf '%s\n' "${target:-/}"
return 0
fi

# `ls -dl` format: "%s %u %s %s %u %s %s -> %s\n",
# <file mode>, <number of links>, <owner name>, <group name>,
# <size>, <date and time>, <pathname of link>, <contents of link>
# https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html
link=$(ls -dl -- "$target" 2>/dev/null) || break
target=${link#*" $target -> "}
done
return 1
}
5 changes: 3 additions & 2 deletions hack/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

set -Eeuo pipefail
source "$(dirname "$BASH_SOURCE")/readlinkf.sh"

## --->
# Project-specific options and functions. In *theory* you shouldn't need to
# touch anything else in this script in order to use this elsewhere.
project="umoci"
root="$(readlink -f "$(dirname "${BASH_SOURCE}")/..")"
root="$(readlinkf_posix "$(dirname "${BASH_SOURCE}")/..")"

# These functions allow you to configure how the defaults are computed.
function get_arch() { go env GOARCH || uname -m; }
Expand All @@ -24,7 +25,7 @@ function setup_project() { true ; }
# This function takes an output path as an argument, where the built
# (preferably static) binary should be placed.
function build_project() {
tmprootfs="$(mktemp -d --tmpdir "$project-build.XXXXXX")"
tmprootfs="$(mktemp -dt "$project-build.XXXXXX")"

make -C "$root" BUILD_DIR="$tmprootfs" COMMIT_NO= "$project.static"
mv "$tmprootfs/$project.static" "$1"
Expand Down
12 changes: 7 additions & 5 deletions hack/test-integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@
# limitations under the License.

set -Eeuxo pipefail
source "$(dirname "$BASH_SOURCE")/readlinkf.sh"

export COVER="${COVER:-0}"
export ROOT="$(readlinkf_posix "$(dirname "$BASH_SOURCE")/..")"

# Set up the root and coverage directories.
export ROOT="$(readlink -f "$(dirname "$(readlink -f "$BASH_SOURCE")")/..")"
# Set up the coverage directory.
COVERAGE="${COVERAGE:-}"
export COVER="${COVER:-0}"
if [ "$COVER" -eq 1 ]; then
export COVERAGE_DIR=$(mktemp --tmpdir -d umoci-coverage.XXXXXX)
export COVERAGE_DIR=$(mktemp -dt umoci-coverage.XXXXXX)
fi

if [ "$COVER" -eq 1 ]; then
# Create a temporary symlink for umoci, since the --help tests require the
# binary have the name "umoci". This is all just to make the Makefile nicer.
UMOCI_DIR="$(mktemp --tmpdir -d umoci.XXXXXX)"
UMOCI_DIR="$(mktemp -dt umoci.XXXXXX)"
export UMOCI="$UMOCI_DIR/umoci"
ln -s "$ROOT/umoci.cover" "$UMOCI"
fi
Expand Down
7 changes: 4 additions & 3 deletions hack/test-unit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,14 @@
# limitations under the License.

set -Eeuxo pipefail
source "$(dirname "$BASH_SOURCE")/readlinkf.sh"

export ROOT="$(readlinkf_posix "$(dirname "$BASH_SOURCE")/..")"

GO="${GO:-go}"
COVERAGE="${COVERAGE:-}"
PROJECT="${PROJECT:-github.com/opencontainers/umoci}"

# Set up the root and coverage directories.
export ROOT="$(readlink -f "$(dirname "$(readlink -f "$BASH_SOURCE")")/..")"

# Run the tests.
extra_args=()
if [ -n "$COVERAGE" ]
Expand Down
5 changes: 3 additions & 2 deletions hack/test-vendor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.

set -Eeuxo pipefail
source "$(dirname "$BASH_SOURCE")/readlinkf.sh"

# Generate a hash-of-hashes for the entire vendor/ tree.
function gethash() {
Expand All @@ -26,8 +27,8 @@ function gethash() {
}

# Figure out root directory.
ROOT="$(readlink -f "$(dirname "$(readlink -f "$BASH_SOURCE")")/..")"
STASHED_ROOT="$(mktemp --tmpdir -d umoci-vendor.XXXXXX)"
ROOT="$(readlinkf_posix "$(dirname "$BASH_SOURCE")/..")"
STASHED_ROOT="$(mktemp -dt umoci-vendor.XXXXXX)"

# Stash away old vendor tree, and restore it on-exit.
mv "$ROOT/vendor" "$STASHED_ROOT/vendor"
Expand Down
Loading