From 57e15e8678bcb50468d406ae468d9f33991c2c9b Mon Sep 17 00:00:00 2001 From: ronit Date: Mon, 27 Jan 2020 15:16:05 +0200 Subject: [PATCH] build and publish to PackageCloud.io on merge to master branch Change-Id: I158a76532f439472a6f4c0ac4b8bbc87637f28f5 Signed-off-by: ronit --- ci/Dockerfile | 37 ++++++++++++++++++++++++++++++ ci/README.md | 7 ++++++ ci/build.sh | 41 +++++++++++++++++++++++++++++++++ ci/control | 9 ++++++++ ci/package-tag.yaml | 3 +++ ci/publish.sh | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 162 insertions(+) create mode 100755 ci/Dockerfile create mode 100644 ci/README.md create mode 100755 ci/build.sh create mode 100644 ci/control create mode 100644 ci/package-tag.yaml create mode 100755 ci/publish.sh diff --git a/ci/Dockerfile b/ci/Dockerfile new file mode 100755 index 0000000..92172eb --- /dev/null +++ b/ci/Dockerfile @@ -0,0 +1,37 @@ +# O-RAN-SC +# +# 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. + +# CI to verify the RMR library and build run-time and dev packages +# Inherits C toolchain from buildpack-deps:stretch +# Adds cmake ksh and alien for RMR + +FROM buildpack-deps:stretch +RUN apt-get update && apt-get -q -y install cmake ksh alien +ADD . /tmp +WORKDIR /tmp + +# build RMr, run unit tests, and generate packages and package lists +RUN sh ci/build.sh + +# 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/README.md b/ci/README.md new file mode 100644 index 0000000..e04f067 --- /dev/null +++ b/ci/README.md @@ -0,0 +1,7 @@ +# Continuous Integration + +This directory contains configuration for the Jenkins CI system to +build a docker image with the software in this repository. + +Additional files required to build a Docker image, for example a +script for the CMD or ENTRYPOINT, might also be stored here. diff --git a/ci/build.sh b/ci/build.sh new file mode 100755 index 0000000..b5d300b --- /dev/null +++ b/ci/build.sh @@ -0,0 +1,41 @@ +#!/bin/sh +output_dir="/reader" + +cd ./creader +if [ -d $output_dir ] +then + rm -r -f $output_dir +fi + +make +ls -la .$output_dir +cd .. +pwd +target_dir="packages" +project_name="rnib" +if [ ! -d $target_dir ] +then + echo "$target_dir will be created" + if ! mkdir -p $target_dir + then + echo "[FAIL] cannot find or create target directory: $target_dir" + exit 1 + fi +fi + rm -f ./$target_dir/*.* + mkdir -p $target_dir/DEBIAN + mkdir -p $target_dir/user/local/include/$project_name/ + echo "cp -f -r .$output_dir/* $target_dir/user/local/include/$project_name" + cp -f -r .$output_dir/* $target_dir/user/local/include/$project_name + cp ./ci/control $target_dir/DEBIAN + + ver=$(cat ./ci/package-tag.yaml | grep tag: |awk '{split($0,ver,":"); print ver[2]}'| tr -d " \t\n\r") + echo $project_name + new_name=${project_name}_$ver + echo $new_names + dpkg-deb --build $target_dir + echo "mv *.deb $new_name.deb" + mv *.deb $new_name.deb + echo "deb package is: $project_name_$ver.deb" + ls -al *.deb + \ No newline at end of file diff --git a/ci/control b/ci/control new file mode 100644 index 0000000..93b3c3f --- /dev/null +++ b/ci/control @@ -0,0 +1,9 @@ +Package: rnib +Version: 1.0 +Section: custom +Priority: optional +Architecture: all +Essential: no +Installed-Size: 1024 +Maintainer: oran +Description: new oran module diff --git a/ci/package-tag.yaml b/ci/package-tag.yaml new file mode 100644 index 0000000..582fc9b --- /dev/null +++ b/ci/package-tag.yaml @@ -0,0 +1,3 @@ + +--- +tag: 3.0.4.4 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 -- 2.16.6