From: E. Scott Daniels Date: Tue, 30 Jul 2019 16:37:48 +0000 (-0400) Subject: Add publish script to the CI environment X-Git-Tag: 1.0.44~4 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=95359300395bf91683a15e4b66547b04d16be0e7;p=ric-plt%2Flib%2Frmr.git Add publish script to the CI environment The docker file will now set an entrypoint such that when the container is run the ci/publish.ksh script is executed. The purpose of the script is to copy the packages built into the image to a mounted volume (/export by default). This eliminated the need for an external process to extract files from the container. Change-Id: I45ce98143bb84d2a802e1823ff003396bda6c9fe Signed-off-by: E. Scott Daniels --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c79b44..65db51c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,7 @@ cmake_minimum_required( VERSION 3.5 ) set( major_version "1" ) # should be automatically populated from git tag later, but until CI process sets a tag we use this set( minor_version "0" ) -set( patch_level "42" ) +set( patch_level "43" ) set( install_root "${CMAKE_INSTALL_PREFIX}" ) set( install_lib "lib" ) diff --git a/ci/Dockerfile b/ci/Dockerfile index 579adfa..0f6d871 100755 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -23,6 +23,15 @@ RUN apt-get update && apt-get -q -y install cmake ksh alien ADD . /tmp WORKDIR /tmp -# build RMr, run unit tests, and generate packages +# build RMr, run unit tests, and generate packages and package lists RUN ksh ci/ci_build.ksh +# Executing the container "as a binary" will cause the CI publish +# script to execute. This will take the simple package list generated +# by the ci_build script and copy the list of packages to the target +# directory. The target directory is /export by default, but can be +# overridden from the docker run command line. In either case, the +# assumption is that the target directory is mounted as a volume. +# +ENTRYPOINT [ "ci/publish.sh" ] + diff --git a/ci/ci_build.ksh b/ci/ci_build.ksh index 40aa1f5..8c3f699 100644 --- a/ci/ci_build.ksh +++ b/ci/ci_build.ksh @@ -42,15 +42,19 @@ # Date: 14 June 2019 # -------------------------------------------------------------------------------- -# stash a set of packages for a particular flavour ($1) +# stash a set of packages for a particular flavour ($1). Records what was kept +# in a yaml file for an external process to grab, and in a simple publication +# list for our internal publish script to gobble up. # function stash_pkgs { + mkdir -p $target_dir/exported + for pkg in deb rpm do ls .build/*.$pkg 2>/dev/null | while read f do - cp $f $target_dir/${f##*/} - echo " - $target_dir/${f##*/}" >>$yaml_file + cp $f $target_dir/exported/${f##*/} + echo " - $target_dir/exported/${f##*/}" >>$yaml_file done done @@ -70,6 +74,7 @@ do *) echo "$1 is not recognised" echo "" echo "usage: $0 [-t target-dir]" + echo " target dir defaults to /tmp and is where packages and lists are placed." exit 1 ;; esac @@ -79,8 +84,11 @@ done if [[ ! -d $target_dir ]] then - echo "[FAIL] cannot find directory: $target_dir" - exit 1 + if ! -mkdir -p $target_dir + then + echo "[FAIL] cannot find or create target directory: $target_dir" + exit 1 + fi fi if [[ ! -d ./ci ]] # verify we are in the root of the RMr repo filesystem, abort if not diff --git a/ci/publish.sh b/ci/publish.sh new file mode 100755 index 0000000..bb4f804 --- /dev/null +++ b/ci/publish.sh @@ -0,0 +1,65 @@ +#!/usr/bin/env bash + +# ----------------------------------------------------------------------------- +# +# Copyright (C) 2019 AT&T Intellectual Property and Nokia +# +# 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. +# +# ----------------------------------------------------------------------------- + +# Mnemonic: publish +# Abstract: Simple script which copies files that the build script left +# for export (packages, but could be anything). This expects +# that all files in /tmp/exportd are to be copied to the +# export directory /export The export directory is assumed to be +# mounted from the outside world as /export, though we will use $1 +# as an override so this can be changed if needed. +# +# Date: 30 July 2019 +# +# ----------------------------------------------------------------------------- + +echo "$0 starting" >&2 +argv0=${0##*/} + +target=${1:-/export} +exportd=/tmp/exported # build script dumps here + +if ! cd $target +then + echo "$argv0: abort: cannot find or switch to: $target" >&2 + exit 1 +fi + +if [[ ! -w ./ ]] +then + echo "$argv0: abort: cannot write to target directory: $target" + exit 1 +fi + +if [[ ! -d $exportd ]] +then + echo "$argv0: abort: unable to find the exported directory: $exportd" >&2 + exit 1 +fi + +errors=0 +echo "$argv0: copy: $exportd/* --> $target" >&2 +if ! cp -v $exportd/* $target/ +then + errors=1 +fi + +echo "$argv0: finshed, $errors errors" +exit $errors