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 | { |
| 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 | } |
| 48 | program_paths |
| 49 | |
| 50 | ## ----------------------------------------------------------------------- |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 51 | ## Intent: Display a message with formatting |
| 52 | ## ----------------------------------------------------------------------- |
| 53 | function banner() |
| 54 | { |
| 55 | cat <<EOM |
Joey Armstrong | fedf45e | 2023-09-20 11:40:01 -0400 | [diff] [blame] | 56 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 57 | ** ----------------------------------------------------------------------- |
| 58 | ** $* |
| 59 | ** ----------------------------------------------------------------------- |
| 60 | EOM |
| 61 | return |
| 62 | } |
| 63 | |
| 64 | ## ----------------------------------------------------------------------- |
| 65 | ## Intent: Display an error mesage then exit with status |
| 66 | ## ----------------------------------------------------------------------- |
| 67 | function error() |
| 68 | { |
| 69 | echo "ERROR: $*" |
| 70 | exit 1 |
| 71 | } |
| 72 | |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 73 | ##----------------## |
| 74 | ##---] MAIN [---## |
| 75 | ##----------------## |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame^] | 76 | |
| 77 | # shellcheck disable=SC2034 |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 78 | while [[ $# -gt 0 ]]; do |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame^] | 79 | arg=$1; shift |
| 80 | case "$arg" in |
| 81 | debug) declare -g -i debug=1 ;; |
| 82 | *) error "Detected invalid switch [$arg]" ;; |
| 83 | esac |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 84 | done |
| 85 | |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame^] | 86 | cp "$pgmroot/.pre-commit-config.yaml" . |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 87 | |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame^] | 88 | mkdir -p lf |
| 89 | pushd lf || { error 'pushd makefiles failed'; } |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 90 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 91 | banner 'Adding repo:onf-make (library makefiles) as a submodule' |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame^] | 92 | git submodule add 'https://github.com/opencord/onf-make.git' onf-make |
| 93 | # git checkout 1.0.0 |
| 94 | # git submodule update --remote --merge |
| 95 | git submodule update --remote --recursive |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 96 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 97 | banner 'Install library/local loader include.mk' |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame^] | 98 | rsync -v --checksum "${pgmroot}/install/"* . |
| 99 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 100 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 101 | banner 'Create project specific directory makefiles/local' |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 102 | mkdir -p local |
| 103 | touch local/include.mk |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 104 | |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame^] | 105 | popd || { error 'popd lf makefiles failed'; } |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 106 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 107 | banner 'Prep work for pending checkin' |
Joey Armstrong | f22de9d | 2024-04-26 11:37:52 -0400 | [diff] [blame^] | 108 | git add lf |
| 109 | |
| 110 | [[ -f 'config.mk' ]] && { git mv 'config.mk' 'lf'; } |
| 111 | git add lf |
Joey Armstrong | a2db6cd | 2023-11-30 12:16:18 -0500 | [diff] [blame] | 112 | git status |
Joey Armstrong | fedf45e | 2023-09-20 11:40:01 -0400 | [diff] [blame] | 113 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 114 | # [EOF] |