Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 1 | #!/bin/bash |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame] | 3 | # Copyright 2023-2024 Open Networking Foundation Contributors |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 4 | # |
| 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 Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame] | 17 | # SPDX-FileCopyrightText: 2023-2024 Open Networking Foundation Contributors |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 18 | # 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 Armstrong | fedf45e | 2023-09-20 11:40:01 -0400 | [diff] [blame] | 23 | ## ----------------------------------------------------------------------- |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 24 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 25 | ##-------------------## |
| 26 | ##---] GLOBALS [---## |
| 27 | ##-------------------## |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 28 | set -euo pipefail |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 29 | # declare -g -i debug=1 |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 30 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 31 | ## ----------------------------------------------------------------------- |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame] | 32 | ## Intent: Parse command line paths |
| 33 | ## ----------------------------------------------------------------------- |
| 34 | function program_paths() |
| 35 | { |
Joey Armstrong | 95a5243 | 2024-04-29 15:26:18 -0400 | [diff] [blame] | 36 | declare -g pgm |
| 37 | pgm="$(readlink --canonicalize-existing "$0")" |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame] | 38 | declare -g pgmbin="${pgm%/*}" |
| 39 | declare -g pgmroot="${pgmbin%/*}" |
| 40 | declare -g pgmname="${pgm%%*/}" |
| 41 | |
| 42 | readonly pgm |
| 43 | readonly pgmbin |
| 44 | readonly pgmroot |
Joey Armstrong | 95a5243 | 2024-04-29 15:26:18 -0400 | [diff] [blame] | 45 | |
| 46 | # shellcheck disable=SC2034 |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame] | 47 | readonly pgmname |
| 48 | |
| 49 | return |
| 50 | } |
| 51 | program_paths |
| 52 | |
| 53 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 54 | ## Intent: Display a message with formatting |
| 55 | ## ----------------------------------------------------------------------- |
| 56 | function banner() |
| 57 | { |
| 58 | cat <<EOM |
Joey Armstrong | fedf45e | 2023-09-20 11:40:01 -0400 | [diff] [blame] | 59 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 60 | ** ----------------------------------------------------------------------- |
| 61 | ** $* |
| 62 | ** ----------------------------------------------------------------------- |
| 63 | EOM |
| 64 | return |
| 65 | } |
| 66 | |
| 67 | ## ----------------------------------------------------------------------- |
Eric Ball | f05a295 | 2024-10-21 16:56:09 -0700 | [diff] [blame^] | 68 | ## Intent: Display an error message then exit with status |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 69 | ## ----------------------------------------------------------------------- |
| 70 | function error() |
| 71 | { |
| 72 | echo "ERROR: $*" |
| 73 | exit 1 |
| 74 | } |
| 75 | |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 76 | ##----------------## |
| 77 | ##---] MAIN [---## |
| 78 | ##----------------## |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame] | 79 | |
| 80 | # shellcheck disable=SC2034 |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 81 | while [[ $# -gt 0 ]]; do |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame] | 82 | arg=$1; shift |
| 83 | case "$arg" in |
| 84 | debug) declare -g -i debug=1 ;; |
| 85 | *) error "Detected invalid switch [$arg]" ;; |
| 86 | esac |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 87 | done |
| 88 | |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame] | 89 | cp "$pgmroot/.pre-commit-config.yaml" . |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 90 | |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame] | 91 | mkdir -p lf |
| 92 | pushd lf || { error 'pushd makefiles failed'; } |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 93 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 94 | banner 'Adding repo:onf-make (library makefiles) as a submodule' |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame] | 95 | git submodule add 'https://github.com/opencord/onf-make.git' onf-make |
| 96 | # git checkout 1.0.0 |
| 97 | # git submodule update --remote --merge |
| 98 | git submodule update --remote --recursive |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 99 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 100 | banner 'Install library/local loader include.mk' |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame] | 101 | rsync -v --checksum "${pgmroot}/install/"* . |
| 102 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 103 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 104 | banner 'Create project specific directory makefiles/local' |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 105 | mkdir -p local |
| 106 | touch local/include.mk |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 107 | |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame] | 108 | popd || { error 'popd lf makefiles failed'; } |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 109 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 110 | banner 'Prep work for pending checkin' |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame] | 111 | git add lf |
| 112 | |
| 113 | [[ -f 'config.mk' ]] && { git mv 'config.mk' 'lf'; } |
| 114 | git add lf |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 115 | git status |
Joey Armstrong | fedf45e | 2023-09-20 11:40:01 -0400 | [diff] [blame] | 116 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 117 | # [EOF] |