Skip to content

Commit

Permalink
Fixing issue #627 (Validate IMGs for whole set, not ROOTID)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsundermeyer authored and Stefan Knorr committed Feb 3, 2022
1 parent 567abde commit fc02dec
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
1 change: 0 additions & 1 deletion make/selector.mk
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ endif
ifeq "$(MAKECMDGOALS)" "validate"
include $(DAPSROOT)/make/setfiles.mk
include $(DAPSROOT)/make/profiling.mk
include $(DAPSROOT)/make/images.mk
include $(DAPSROOT)/make/validate.mk
endif

Expand Down
29 changes: 24 additions & 5 deletions make/validate.mk
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,25 @@ ifeq "$(strip $(VALIDATE_IDS))" "1"
FAULTY_IDS = $(shell $(XSLTPROC) --xinclude --stylesheet $(DAPSROOT)/daps-xslt/common/get-all-xmlids.xsl --file $(MAIN) $(XSLTPROCESSOR) | grep -P '[^-a-zA-Z0-9]')
endif

# search for missing and duplicated images. Similar code as in images.mk, but
# here we want to look at all images of the set, not only the ones used in the
# current document [also see https://github.com/openSUSE/daps/issues/627]

ifeq "$(strip $(VALIDATE_IMAGES))" "1"
_IMG_USED := $(sort $(shell $(XSLTPROC) --stringparam "filetype=img" \
--file $(SETFILES_TMP) --stylesheet \
$(DAPSROOT)/daps-xslt/common/extract-files-and-images.xsl \
$(XSLTPROCESSOR) 2>/dev/null))
_IMG_DUPES := $(sort $(wildcard $(addprefix $(IMG_SRCDIR)/*/,$(addsuffix .*, \
$(filter \
$(shell echo $(basename $(notdir $(SRC_IMG_ALL)) 2>/dev/null) | \
tr " " "\n" | sort |uniq -d 2>/dev/null),$(basename $(_IMG_USED) \
2>/dev/null)) \
))))
_IMG_MISS := $(sort $(filter-out $(notdir $(basename $(SRC_IMG_ALL))), \
$(basename $(_IMG_USED))))
endif

ifeq "$(suffix $(DOCBOOK5_RNG))" ".rnc"
JING_FLAGS += -c
endif
Expand Down Expand Up @@ -53,13 +72,13 @@ endif
endif
endif
ifeq "$(strip $(VALIDATE_IMAGES))" "1"
ifneq "$(strip $(DOUBLE_IMG))" ""
@ccecho "warn" "Warning: Image names not unique$(COMMA) multiple sources available for the following images::"
@echo -e "$(subst $(SPACE),\n,$(sort $(DOUBLE_IMG)))"
ifneq "$(strip $(_IMG_DUPES))" ""
@ccecho "warn" "Warning: Image names not unique$(COMMA) multiple sources available for the following images:"
@echo -e "$(subst $(SPACE),\n,$(sort $(_IMG_DUPES)))"
endif
ifneq "$(strip $(MISSING_IMG))" ""
ifneq "$(strip $(_IMG_MISS))" ""
@ccecho "error" "Fatal error: The following images are missing:"
@echo -e "$(subst $(SPACE),\n,$(sort $(MISSING_IMG)))"
@echo -e "$(subst $(SPACE),\n,$(sort $(_IMG_MISS)))"
@exit 1
endif
endif
Expand Down

0 comments on commit fc02dec

Please sign in to comment.