wrider | 3280e62 | 2019-11-05 12:13:28 -0500 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | # ----------------------------------------------------------------------------- |
| 4 | # |
| 5 | # Copyright (C) 2019 AT&T Intellectual Property and Nokia |
| 6 | # |
| 7 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | # you may not use this file except in compliance with the License. |
| 9 | # You may obtain a copy of the License at |
| 10 | # |
| 11 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | # |
| 13 | # Unless required by applicable law or agreed to in writing, software |
| 14 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | # See the License for the specific language governing permissions and |
| 17 | # limitations under the License. |
| 18 | # |
| 19 | # ----------------------------------------------------------------------------- |
| 20 | |
| 21 | # Mnemonic: publish |
| 22 | # Abstract: Simple script which copies files that the build script left |
| 23 | # for export (packages, but could be anything). This expects |
| 24 | # that all files in /tmp/exportd are to be copied to the |
| 25 | # export directory /export The export directory is assumed to be |
| 26 | # mounted from the outside world as /export, though we will use $1 |
| 27 | # as an override so this can be changed if needed. |
| 28 | # |
| 29 | # Date: 30 July 2019 |
| 30 | # |
| 31 | # ----------------------------------------------------------------------------- |
| 32 | |
| 33 | # This file is copied from ric-plt/lib/rmr ci/publish.sh. |
| 34 | # |
| 35 | |
| 36 | echo "$0 starting" >&2 |
| 37 | argv0=${0##*/} |
| 38 | |
| 39 | target=${1:-/export} |
| 40 | exportd=/tmp/exported # build script dumps here |
| 41 | |
| 42 | if ! cd $target |
| 43 | then |
| 44 | echo "$argv0: abort: cannot find or switch to: $target" >&2 |
| 45 | exit 1 |
| 46 | fi |
| 47 | |
| 48 | if [[ ! -w ./ ]] |
| 49 | then |
| 50 | echo "$argv0: abort: cannot write to target directory: $target" |
| 51 | exit 1 |
| 52 | fi |
| 53 | |
| 54 | if [[ ! -d $exportd ]] |
| 55 | then |
| 56 | echo "$argv0: abort: unable to find the exported directory: $exportd" >&2 |
| 57 | exit 1 |
| 58 | fi |
| 59 | |
| 60 | errors=0 |
| 61 | echo "$argv0: copy: $exportd/* --> $target" >&2 |
| 62 | if ! cp -v $exportd/* $target/ |
| 63 | then |
| 64 | errors=1 |
| 65 | fi |
| 66 | |
| 67 | echo "$argv0: finshed, $errors errors" |
| 68 | exit $errors |