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 | # -*- makefile -*- |
| 3 | # ----------------------------------------------------------------------- |
| 4 | # Copyright 2023 Open Networking Foundation (ONF) and the ONF Contributors |
| 5 | # |
| 6 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | # you may not use this file except in compliance with the License. |
| 8 | # You may obtain a copy of the License at |
| 9 | # |
| 10 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | # |
| 12 | # Unless required by applicable law or agreed to in writing, software |
| 13 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | # See the License for the specific language governing permissions and |
| 16 | # limitations under the License. |
| 17 | # ----------------------------------------------------------------------- |
| 18 | # SPDX-FileCopyrightText: 2023 Open Networking Foundation (ONF) and the ONF Contributors |
| 19 | # SPDX-License-Identifier: Apache-2.0 |
| 20 | # ----------------------------------------------------------------------- |
| 21 | ## Intent: This script will update a repository makefiles/ directory |
| 22 | ## by creating a hierarchy that will allow using library makefiles |
| 23 | ## and per-repository makefiles. |
Joey Armstrong | fedf45e | 2023-09-20 11:40:01 -0400 | [diff] [blame] | 24 | ## ----------------------------------------------------------------------- |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 25 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 26 | ##-------------------## |
| 27 | ##---] GLOBALS [---## |
| 28 | ##-------------------## |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 29 | set -euo pipefail |
| 30 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 31 | ## ----------------------------------------------------------------------- |
| 32 | ## Intent: Display a message with formatting |
| 33 | ## ----------------------------------------------------------------------- |
| 34 | function banner() |
| 35 | { |
| 36 | cat <<EOM |
Joey Armstrong | fedf45e | 2023-09-20 11:40:01 -0400 | [diff] [blame] | 37 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 38 | ** ----------------------------------------------------------------------- |
| 39 | ** $* |
| 40 | ** ----------------------------------------------------------------------- |
| 41 | EOM |
| 42 | return |
| 43 | } |
| 44 | |
| 45 | ## ----------------------------------------------------------------------- |
| 46 | ## Intent: Display an error mesage then exit with status |
| 47 | ## ----------------------------------------------------------------------- |
| 48 | function error() |
| 49 | { |
| 50 | echo "ERROR: $*" |
| 51 | exit 1 |
| 52 | } |
| 53 | |
| 54 | ##----------------## |
| 55 | ##---] MAIN [---## |
| 56 | ##----------------## |
| 57 | |
| 58 | ## Avoid trashing a work-in-progress |
| 59 | path='makefiles/local/include.mk' |
| 60 | [[ -e "$path" ]] && { error "Detected upgrade path: $path"; } |
| 61 | |
| 62 | banner "Archive current directory" |
| 63 | tar czvf ../backup-setup.tgz . |
| 64 | |
| 65 | ## Migration patches should be simple and plentiful. |
| 66 | if [[ ! -d makefiles-orig ]]; then |
| 67 | cat <<EOM |
| 68 | |
| 69 | * ----------------------------------------------------------------------- |
| 70 | * Replacing a repository makefile directory is deployed |
| 71 | * by creating a few independent patches. |
| 72 | * ----------------------------------------------------------------------- |
| 73 | 1) Rename the repository-specific makefiles directory. |
| 74 | 1a) git mv makefiles makefiles-orig |
| 75 | 1b) Update Makefile to "include makefiles-orig" |
| 76 | |
| 77 | 2) Create makefiles/ |
| 78 | 2a) add repo:onf-make as a submodule. |
| 79 | 2b) create makefiles/local/ |
| 80 | 2c) relocate config files |
| 81 | |
| 82 | 3) Update Makefile to include makefiles/include.mk |
| 83 | |
| 84 | EOM |
| 85 | exit 1 |
| 86 | fi |
Joey Armstrong | fedf45e | 2023-09-20 11:40:01 -0400 | [diff] [blame] | 87 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 88 | mkdir -p makefiles |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 89 | pushd makefiles || { 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 | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 92 | git submodule add 'https://github.com/opencord/onf-make.git' onf-lib |
| 93 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 94 | banner 'Install library/local loader include.mk' |
| 95 | rsync -v --checksum onf-lib/makefiles_include_mk.ex include.mk |
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 'Create project specific directory makefiles/local' |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 98 | mkdir -p local |
| 99 | touch local/include.mk |
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 | popd || { error 'popd makefiles failed'; } |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 102 | |
Joey Armstrong | 0003f1a | 2023-10-18 16:40:23 -0400 | [diff] [blame] | 103 | banner 'Prep work for pending checkin' |
| 104 | git add makefiles/include.mk |
| 105 | git add makefiles/local/include.mk |
| 106 | git mv config.mk makefiles/config.mk |
| 107 | git add makefiles |
Joey Armstrong | fedf45e | 2023-09-20 11:40:01 -0400 | [diff] [blame] | 108 | |
Joey Armstrong | f128de8 | 2023-09-08 17:05:18 -0400 | [diff] [blame] | 109 | # [EOF] |