Skip to content

Commit

Permalink
Merge pull request #13 from kba/cleanup-cmd
Browse files Browse the repository at this point in the history
- `ocrd-make -c|-cleanup|-cleanup|cleanup` to remove all makefiles linked/copied to CWD (target directory) last time (but no self-made ones)
- in `ocrd-make` when symlinking/copying makefiles to CWD (target directory), replace `cp -u` (to avoid its redundant error message and retval) with an explicit shell loop checking file existence and time stamps
  • Loading branch information
bertsky authored Jun 3, 2020
2 parents e355d55 + fc521c9 commit db3afad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CONFIGNAME := $(basename $(notdir $(CONFIGURATION)))

WORKSPACES := $(patsubst %/mets.xml,%,$(wildcard */data/mets.xml */mets.xml))

ifeq ($(filter help info repair deps-ubuntu install uninstall %.mk,$(MAKECMDGOALS)),)
ifeq ($(filter help cleanup info repair deps-ubuntu install uninstall %.mk,$(MAKECMDGOALS)),)
ifeq ($(notdir $(MAKEFILE_LIST)),Makefile)
$(error Did you forget to select a workflow configuration makefile?)
else
Expand All @@ -71,6 +71,7 @@ help:
@echo
@echo " Targets (general):"
@echo " * help (this message)"
@echo " * cleanup (remove symlinked/copied Makefiles)"
@echo " * deps-ubuntu (install extra system packages needed here, beyond ocrd and processors)"
@echo " * install (copy 'ocrd-make' script and configuration makefiles to"
@echo " * VIRTUAL_ENV=$(VIRTUAL_ENV))"
Expand Down Expand Up @@ -111,6 +112,9 @@ uninstall:
$(RM) $(BINDIR)/ocrd-make
$(RM) -r $(SHAREDIR)

cleanup:
find $(SHAREDIR) \( -name 'Makefile' -or -name '*.mk' \) -exec basename {} \; |xargs rm -v

.PHONY: deps-ubuntu install uninstall

# spawn a new configuration
Expand Down
13 changes: 11 additions & 2 deletions ocrd-make
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,22 @@ function process {
# we want to have a fall-back for FS without symlink support
# or when some makefile already exists (perhaps with customization)
# but unfortunately, `cp -u` has strange semantics w.r.t. retvalue
ln -t "$CURDIR" -s "$SHAREDIR"/{*.mk,Makefile} 2>/dev/null || cp -fu "$SHAREDIR"/{*.mk,Makefile} "$CURDIR"
for f in *.mk Makefile;do
local src="$SHAREDIR/$f"
local dst="$CURDIR/$f"
if [[ ! -e "$dst" || "$src" -nt "$dst" ]];then
ln -s "$src" "$dst" 2>/dev/null || cp -f "$src" "$dst"
fi
done
make -C "$CURDIR" "$@"
)
}


case ${1:--h} in
-c|-[-]cleanup|cleanup)
process --no-print-directory cleanup
exit
;;
-h|-[-]help|help)
cat <<EOF
(This will merely delegate to \`make\` on the current working directory "$PWD"
Expand Down

0 comments on commit db3afad

Please sign in to comment.