E. Scott Daniels | 9535930 | 2019-07-30 12:37:48 -0400 | [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 | echo "$0 starting" >&2 |
| 34 | argv0=${0##*/} |
| 35 | |
| 36 | target=${1:-/export} |
| 37 | exportd=/tmp/exported # build script dumps here |
| 38 | |
| 39 | if ! cd $target |
| 40 | then |
| 41 | echo "$argv0: abort: cannot find or switch to: $target" >&2 |
| 42 | exit 1 |
| 43 | fi |
| 44 | |
| 45 | if [[ ! -w ./ ]] |
| 46 | then |
| 47 | echo "$argv0: abort: cannot write to target directory: $target" |
| 48 | exit 1 |
| 49 | fi |
| 50 | |
| 51 | if [[ ! -d $exportd ]] |
| 52 | then |
| 53 | echo "$argv0: abort: unable to find the exported directory: $exportd" >&2 |
| 54 | exit 1 |
| 55 | fi |
| 56 | |
| 57 | errors=0 |
| 58 | echo "$argv0: copy: $exportd/* --> $target" >&2 |
| 59 | if ! cp -v $exportd/* $target/ |
| 60 | then |
| 61 | errors=1 |
| 62 | fi |
| 63 | |
| 64 | echo "$argv0: finshed, $errors errors" |
| 65 | exit $errors |