From a031b83a09a8628435317a03f199cdc18b78262f Mon Sep 17 00:00:00 2001 From: Matthew Heon Date: Wed, 1 Nov 2017 11:24:59 -0400 Subject: Initial checkin from CRI-O repo Signed-off-by: Matthew Heon --- hack/btrfs_installed_tag.sh | 7 +++++++ hack/btrfs_tag.sh | 7 +++++++ hack/find-godeps.sh | 41 +++++++++++++++++++++++++++++++++++++++++ hack/libdm_tag.sh | 15 +++++++++++++++ hack/ostree_tag.sh | 4 ++++ hack/selinux_tag.sh | 4 ++++ hack/verify-gofmt.sh | 21 +++++++++++++++++++++ 7 files changed, 99 insertions(+) create mode 100755 hack/btrfs_installed_tag.sh create mode 100755 hack/btrfs_tag.sh create mode 100755 hack/find-godeps.sh create mode 100755 hack/libdm_tag.sh create mode 100755 hack/ostree_tag.sh create mode 100755 hack/selinux_tag.sh create mode 100755 hack/verify-gofmt.sh (limited to 'hack') diff --git a/hack/btrfs_installed_tag.sh b/hack/btrfs_installed_tag.sh new file mode 100755 index 000000000..357f33b8b --- /dev/null +++ b/hack/btrfs_installed_tag.sh @@ -0,0 +1,7 @@ +#!/bin/bash +cc -E - > /dev/null 2> /dev/null << EOF +#include +EOF +if test $? -ne 0 ; then + echo exclude_graphdriver_btrfs +fi diff --git a/hack/btrfs_tag.sh b/hack/btrfs_tag.sh new file mode 100755 index 000000000..cc48504ab --- /dev/null +++ b/hack/btrfs_tag.sh @@ -0,0 +1,7 @@ +#!/bin/bash +cc -E - > /dev/null 2> /dev/null << EOF +#include +EOF +if test $? -ne 0 ; then + echo btrfs_noversion +fi diff --git a/hack/find-godeps.sh b/hack/find-godeps.sh new file mode 100755 index 000000000..4ce932542 --- /dev/null +++ b/hack/find-godeps.sh @@ -0,0 +1,41 @@ +#!/bin/bash +# +# $1 - base path of the source tree +# $2 - subpath under $1 to find *.go dependencies for +# $3 - package name (eg, github.com/organization/project) + +set -o errexit +set -o nounset +set -o pipefail + +# might be called from makefile before basepath is set up; just return +# empty deps. The make target will then ensure that GOPATH is set up +# correctly, and go build will build everything the first time around +# anyway. Next time we get here everything will be fine. +if [ ! -d "$1/$2" ]; then + exit 0 +fi + +function find-deps() { + local basepath=$1 + local srcdir=$2 + local pkgname=$3 + local deps= + + # gather imports from cri-o + pkgs=$(cd ${basepath}/${srcdir} && go list -f "{{.Imports}}" . | tr ' ' '\n' | tr -d '[]' | grep -v "/vendor/" | grep ${pkgname} | sed -e "s|${pkgname}/||g") + + # add each Go import's sources to the deps list, + # and recursively get that imports's imports too + for dep in ${pkgs}; do + deps+="$(ls ${basepath}/${dep}/*.go | sed -e "s|${basepath}/||g") " + # add deps of this package too + deps+="$(find-deps ${basepath} ${dep} ${pkgname}) " + done + + echo "${deps}" | sort | uniq +} + +# add Go sources from the current package at the end +echo "$(find-deps "$1" "$2" "$3" | xargs) $(cd $1 && ls $2/*.go | xargs)" + diff --git a/hack/libdm_tag.sh b/hack/libdm_tag.sh new file mode 100755 index 000000000..d1f83ba10 --- /dev/null +++ b/hack/libdm_tag.sh @@ -0,0 +1,15 @@ +#!/bin/bash +tmpdir="$PWD/tmp.$RANDOM" +mkdir -p "$tmpdir" +trap 'rm -fr "$tmpdir"' EXIT +cc -o "$tmpdir"/libdm_tag -ldevmapper -x c - > /dev/null 2> /dev/null << EOF +#include +int main() { + struct dm_task *task; + dm_task_deferred_remove(task); + return 0; +} +EOF +if test $? -ne 0 ; then + echo libdm_no_deferred_remove +fi diff --git a/hack/ostree_tag.sh b/hack/ostree_tag.sh new file mode 100755 index 000000000..89499c5e8 --- /dev/null +++ b/hack/ostree_tag.sh @@ -0,0 +1,4 @@ +#!/bin/bash +if ! pkg-config ostree-1 2> /dev/null ; then + echo containers_image_ostree_stub +fi diff --git a/hack/selinux_tag.sh b/hack/selinux_tag.sh new file mode 100755 index 000000000..ff80fda04 --- /dev/null +++ b/hack/selinux_tag.sh @@ -0,0 +1,4 @@ +#!/bin/bash +if pkg-config libselinux 2> /dev/null ; then + echo selinux +fi diff --git a/hack/verify-gofmt.sh b/hack/verify-gofmt.sh new file mode 100755 index 000000000..5577d1b9b --- /dev/null +++ b/hack/verify-gofmt.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +set -o errexit +set -o nounset +set -o pipefail + +find_files() { + find . -not \( \ + \( \ + -wholename '*/vendor/*' \ + \) -prune \ + \) -name '*.go' +} + +GOFMT="gofmt -s" +bad_files=$(find_files | xargs $GOFMT -l) +if [[ -n "${bad_files}" ]]; then + echo "!!! '$GOFMT' needs to be run on the following files: " + echo "${bad_files}" + exit 1 +fi -- cgit v1.2.3-54-g00ecf