Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 1 | # -*- makefile -*- |
| 2 | # ----------------------------------------------------------------------- |
Joey Armstrong | 8388b7f | 2023-01-23 11:20:04 -0500 | [diff] [blame] | 3 | # Copyright 2022-2023 Open Networking Foundation (ONF) and the ONF Contributors |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [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 | # ----------------------------------------------------------------------- |
| 17 | |
Joey Armstrong | 449ce7a | 2023-07-18 18:32:24 -0400 | [diff] [blame] | 18 | include $(ONF_MAKEDIR)/patches/help.mk |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 19 | |
| 20 | patch-gather-args += --exclude=Makefile |
| 21 | patch-gather-args += --exclude-dir=vault |
| 22 | patch-gather-args += --exclude-dir=makefiles |
| 23 | patch-gather-args += --exclude-dir=staging |
| 24 | patch-gather-args += --exclude-dir=patches |
| 25 | |
| 26 | # patch-gather-args += -e 'from collections import' |
| 27 | patch-gather-args += '-e' 'from collections import Mapping' |
| 28 | patch-gather-args += '-e' 'from collections import MutableMapping' |
| 29 | |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 30 | # Defined by [Mm]akefile or makefiles/virtualenv.mk |
| 31 | venv-name ?= $(error $(MAKE) venv-name= is required) |
| 32 | |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 33 | PATCH_PATH ?= $(error $(MAKE) PATCH_PATH= is required) |
| 34 | |
| 35 | ## ----------------------------------------------------------------------- |
| 36 | ## ----------------------------------------------------------------------- |
| 37 | patch-gather: |
| 38 | grep -r $(patch-gather-args) |
| 39 | |
| 40 | ## ----------------------------------------------------------------------- |
| 41 | ## ----------------------------------------------------------------------- |
| 42 | patch-diff: |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 43 | $(HIDE)diff -qr staging $(venv-name) \ |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 44 | | awk '{print "# diff -Naur "$$2" "$$4}' \ |
| 45 | | tee $@.log |
| 46 | |
| 47 | ## ----------------------------------------------------------------------- |
| 48 | ## ----------------------------------------------------------------------- |
| 49 | patch-create: |
| 50 | mkdir -p patches/$(PATCH_PATH) |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 51 | diff -Naur staging/$(PATCH_PATH) $(venv-name)/$(PATCH_PATH) | tee patches/$(PATCH_PATH)/patch |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 52 | exit 1 |
| 53 | |
| 54 | ## ----------------------------------------------------------------------- |
| 55 | ## ----------------------------------------------------------------------- |
| 56 | patch-init: |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 57 | find "$(venv-name)" -name '__pycache__' -type d -print0 \ |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 58 | | xargs -I'{}' --null --no-run-if-empty $(RM) -r {} |
| 59 | mkdir -p staging |
Joey Armstrong | 4de98b7 | 2023-02-09 14:51:38 -0500 | [diff] [blame] | 60 | rsync -rv --checksum "$(venv-name)/." "staging/." |
Joey Armstrong | 36592e3 | 2022-11-28 09:00:28 -0500 | [diff] [blame] | 61 | @echo "Modify files beneath staging/ to create a patch source" |
| 62 | |
| 63 | # [SEE ALSO] |
| 64 | # --------------------------------------------------------------------------- |
| 65 | # https://bobbyhadz.com/blog/python-importerror-cannot-import-name-mapping-from-collections |
| 66 | # --------------------------------------------------------------------------- |
| 67 | # [EOF] |