blob: 600e9957a99e0b5fc86ca20038e8e3a0cec52a16 [file] [log] [blame]
Joey Armstrongf128de82023-09-08 17:05:18 -04001#!/bin/bash
Joey Armstrong0003f1a2023-10-18 16:40:23 -04002# -----------------------------------------------------------------------
Joey Armstrongf22de9d2024-04-26 11:37:52 -04003# Copyright 2023-2024 Open Networking Foundation Contributors
Joey Armstrong0003f1a2023-10-18 16:40:23 -04004#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16# -----------------------------------------------------------------------
Joey Armstrongf22de9d2024-04-26 11:37:52 -040017# SPDX-FileCopyrightText: 2023-2024 Open Networking Foundation Contributors
Joey Armstrong0003f1a2023-10-18 16:40:23 -040018# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------
20## Intent: This script will update a repository makefiles/ directory
21## by creating a hierarchy that will allow using library makefiles
22## and per-repository makefiles.
Joey Armstrongfedf45e2023-09-20 11:40:01 -040023## -----------------------------------------------------------------------
Joey Armstrongf128de82023-09-08 17:05:18 -040024
Joey Armstrong0003f1a2023-10-18 16:40:23 -040025##-------------------##
26##---] GLOBALS [---##
27##-------------------##
Joey Armstrongf128de82023-09-08 17:05:18 -040028set -euo pipefail
Joey Armstronga2db6cd2023-11-30 12:16:18 -050029# declare -g -i debug=1
Joey Armstrongf128de82023-09-08 17:05:18 -040030
Joey Armstrong0003f1a2023-10-18 16:40:23 -040031## -----------------------------------------------------------------------
Joey Armstrongf22de9d2024-04-26 11:37:52 -040032## Intent: Parse command line paths
33## -----------------------------------------------------------------------
34function program_paths()
35{
36 declare -g pgm="$(readlink --canonicalize-existing "$0")"
37 declare -g pgmbin="${pgm%/*}"
38 declare -g pgmroot="${pgmbin%/*}"
39 declare -g pgmname="${pgm%%*/}"
40
41 readonly pgm
42 readonly pgmbin
43 readonly pgmroot
44 readonly pgmname
45
46 return
47}
48program_paths
49
50## -----------------------------------------------------------------------
Joey Armstrong0003f1a2023-10-18 16:40:23 -040051## Intent: Display a message with formatting
52## -----------------------------------------------------------------------
53function banner()
54{
55 cat <<EOM
Joey Armstrongfedf45e2023-09-20 11:40:01 -040056
Joey Armstrong0003f1a2023-10-18 16:40:23 -040057** -----------------------------------------------------------------------
58** $*
59** -----------------------------------------------------------------------
60EOM
61 return
62}
63
64## -----------------------------------------------------------------------
65## Intent: Display an error mesage then exit with status
66## -----------------------------------------------------------------------
67function error()
68{
69 echo "ERROR: $*"
70 exit 1
71}
72
Joey Armstronga2db6cd2023-11-30 12:16:18 -050073##----------------##
74##---] MAIN [---##
75##----------------##
Joey Armstrongf22de9d2024-04-26 11:37:52 -040076
77# shellcheck disable=SC2034
Joey Armstronga2db6cd2023-11-30 12:16:18 -050078while [[ $# -gt 0 ]]; do
Joey Armstrongf22de9d2024-04-26 11:37:52 -040079 arg=$1; shift
80 case "$arg" in
81 debug) declare -g -i debug=1 ;;
82 *) error "Detected invalid switch [$arg]" ;;
83 esac
Joey Armstronga2db6cd2023-11-30 12:16:18 -050084done
85
Joey Armstrongf22de9d2024-04-26 11:37:52 -040086cp "$pgmroot/.pre-commit-config.yaml" .
Joey Armstronga2db6cd2023-11-30 12:16:18 -050087
Joey Armstrongf22de9d2024-04-26 11:37:52 -040088mkdir -p lf
89pushd lf || { error 'pushd makefiles failed'; }
Joey Armstrongf128de82023-09-08 17:05:18 -040090
Joey Armstrong0003f1a2023-10-18 16:40:23 -040091banner 'Adding repo:onf-make (library makefiles) as a submodule'
Joey Armstrongf22de9d2024-04-26 11:37:52 -040092git submodule add 'https://github.com/opencord/onf-make.git' onf-make
93# git checkout 1.0.0
94# git submodule update --remote --merge
95git submodule update --remote --recursive
Joey Armstrongf128de82023-09-08 17:05:18 -040096
Joey Armstrong0003f1a2023-10-18 16:40:23 -040097banner 'Install library/local loader include.mk'
Joey Armstrongf22de9d2024-04-26 11:37:52 -040098rsync -v --checksum "${pgmroot}/install/"* .
99
Joey Armstrongf128de82023-09-08 17:05:18 -0400100
Joey Armstrong0003f1a2023-10-18 16:40:23 -0400101banner 'Create project specific directory makefiles/local'
Joey Armstrongf128de82023-09-08 17:05:18 -0400102mkdir -p local
103touch local/include.mk
Joey Armstrongf128de82023-09-08 17:05:18 -0400104
Joey Armstrongf22de9d2024-04-26 11:37:52 -0400105popd || { error 'popd lf makefiles failed'; }
Joey Armstrongf128de82023-09-08 17:05:18 -0400106
Joey Armstrong0003f1a2023-10-18 16:40:23 -0400107banner 'Prep work for pending checkin'
Joey Armstrongf22de9d2024-04-26 11:37:52 -0400108git add lf
109
110[[ -f 'config.mk' ]] && { git mv 'config.mk' 'lf'; }
111git add lf
Joey Armstronga2db6cd2023-11-30 12:16:18 -0500112git status
Joey Armstrongfedf45e2023-09-20 11:40:01 -0400113
Joey Armstrongf128de82023-09-08 17:05:18 -0400114# [EOF]