-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.sh
executable file
·117 lines (97 loc) · 3.41 KB
/
setup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash
# -----------------------------------------------------------------------
# Copyright 2023-2024 Open Networking Foundation Contributors
#
# 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.
# -----------------------------------------------------------------------
# SPDX-FileCopyrightText: 2023-2024 Open Networking Foundation Contributors
# SPDX-License-Identifier: Apache-2.0
# -----------------------------------------------------------------------
## Intent: This script will update a repository makefiles/ directory
## by creating a hierarchy that will allow using library makefiles
## and per-repository makefiles.
## -----------------------------------------------------------------------
##-------------------##
##---] GLOBALS [---##
##-------------------##
set -euo pipefail
# declare -g -i debug=1
## -----------------------------------------------------------------------
## Intent: Parse command line paths
## -----------------------------------------------------------------------
function program_paths()
{
declare -g pgm
pgm="$(readlink --canonicalize-existing "$0")"
declare -g pgmbin="${pgm%/*}"
declare -g pgmroot="${pgmbin%/*}"
declare -g pgmname="${pgm%%*/}"
readonly pgm
readonly pgmbin
readonly pgmroot
# shellcheck disable=SC2034
readonly pgmname
return
}
program_paths
## -----------------------------------------------------------------------
## Intent: Display a message with formatting
## -----------------------------------------------------------------------
function banner()
{
cat <<EOM
** -----------------------------------------------------------------------
** $*
** -----------------------------------------------------------------------
EOM
return
}
## -----------------------------------------------------------------------
## Intent: Display an error mesage then exit with status
## -----------------------------------------------------------------------
function error()
{
echo "ERROR: $*"
exit 1
}
##----------------##
##---] MAIN [---##
##----------------##
# shellcheck disable=SC2034
while [[ $# -gt 0 ]]; do
arg=$1; shift
case "$arg" in
debug) declare -g -i debug=1 ;;
*) error "Detected invalid switch [$arg]" ;;
esac
done
cp "$pgmroot/.pre-commit-config.yaml" .
mkdir -p lf
pushd lf || { error 'pushd makefiles failed'; }
banner 'Adding repo:onf-make (library makefiles) as a submodule'
git submodule add 'https://github.com/opencord/onf-make.git' onf-make
# git checkout 1.0.0
# git submodule update --remote --merge
git submodule update --remote --recursive
banner 'Install library/local loader include.mk'
rsync -v --checksum "${pgmroot}/install/"* .
banner 'Create project specific directory makefiles/local'
mkdir -p local
touch local/include.mk
popd || { error 'popd lf makefiles failed'; }
banner 'Prep work for pending checkin'
git add lf
[[ -f 'config.mk' ]] && { git mv 'config.mk' 'lf'; }
git add lf
git status
# [EOF]