blob: 156caceaed37195af34a6f7777136e91da5690ee [file] [log] [blame]
Joey Armstrong7ad5c362023-07-09 19:10:16 -04001#!/bin/bash
2# -----------------------------------------------------------------------
3# Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
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#
17# SPDX-FileCopyrightText: 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors
18# SPDX-License-Identifier: Apache-2.0
19# -----------------------------------------------------------------------
20# https://gerrit.opencord.org/plugins/gitiles/onf-make
21# ONF.makefile.version = 1.0
22# -----------------------------------------------------------------------
23# Intent: This script is used to bulk refactor and merge makefile changes
24## between development repositories and repo:onf-make.
25## -----------------------------------------------------------------------
26
27## -----------------------------------------------------------------------
28## Intent:
29## -----------------------------------------------------------------------
30function error
31{
32 echo "$*"
33 exit 1
34}
35
36##----------------##
37##---] MAIN [---##
38##----------------##
Joey Armstrong1e07f882023-07-08 19:28:49 -040039src="$HOME/projects/sandbox/onf-make/makefiles"
Joey Armstrong7ad5c362023-07-09 19:10:16 -040040
41dst="$(realpath .)"
42
43[[ $# -eq 0 ]] && error "At least one directory or file is required"
44
45while [ $# -gt 0 ]; do
46 fyl=$1; shift
47
48 echo "FYL: $fyl"
49 if [ -d "$fyl" ]; then
50 readarray -t fyls < <(find "$fyl" -type f -print)
51 [[ ${#@} -gt 0 ]] && fyls+=("$@")
52 # declare -p fyls
53 [[ ${#fyls} -gt 0 ]] && set -- "${fyls[@]}"
54 continue
55 fi
56
57 case "$fyl" in
58 *~) continue ;;
59 '#*#') continue ;;
60 '\.#*') continue ;;
61 esac
62
63 src0="$src/$fyl"
64 dst0="$dst/$fyl"
65
66 [[ ! -e "$src0" ]] && error "File does not exist in src= $src0"
67 [[ ! -e "$dst0" ]] && error "File does not exist in dst= $dst0"
68
69 if ! diff -qr "$src0" "$dst0"; then
70 emacs "$src0" "$dst0"
71 fi
72done
73
74# [EOF]