tool/ports: add tool to check source availability

The 'check_port_source' checks whether all remote sources defined for a given
port are currently available. It returns zero, when all remote resources are
available.

Fix #1430
This commit is contained in:
Stefan Kalkowski 2015-03-04 14:46:43 +01:00 committed by Christian Helmuth
parent ebfe3d8ff0
commit 684ce272e6
2 changed files with 88 additions and 0 deletions

27
tool/ports/check_port_source Executable file
View File

@ -0,0 +1,27 @@
#!/usr/bin/make -f
#
# \brief Tool for checking remote 3rd-party sources
# \author Stefan Kalkowski
# \date 2015-03-04
#
#
# Determine Genode base directory based on the known location of the
# 'create_builddir' tool within the Genode source tree
#
export GENODE_DIR := $(realpath $(dir $(MAKEFILE_LIST))/../..)
include $(GENODE_DIR)/tool/ports/mk/front_end.inc
include $(GENODE_DIR)/tool/ports/mk/check_port_arg.inc
usage:
@$(ECHO)
@$(ECHO) "--- check remote sources of port ---"
@$(ECHO) "usage: check_port_source <port-name>"
@$(ECHO)
$(TARGET):
$(VERBOSE)$(MAKE) --no-print-directory \
-f $(GENODE_DIR)/tool/ports/mk/check.mk \
PORT=$(PORT) VERBOSE=$(VERBOSE)

61
tool/ports/mk/check.mk Normal file
View File

@ -0,0 +1,61 @@
#
# \brief Check for remote 3rd-party source code
# \author Stefan Kalkowski
# \date 2015-03-04
#
# This makefile must be invoked from the port directory.
#
# Arguments:
#
# PORT - port description file
#
check:
#
# Utility to check if a tool is installed
#
check_tool = $(if $(shell which $(1)),,$(error Need to have '$(1)' installed.))
$(call check_tool,curl)
$(call check_tool,git)
$(call check_tool,svn)
# repository that contains the port description, used to look up patch files
REP_DIR := $(realpath $(dir $(PORT))/..)
#
# Include definitions provided by the port description file
#
include $(PORT)
#
# Include common definitions
#
include $(GENODE_DIR)/tool/ports/mk/common.inc
#
# Default rule that triggers the actual check steps
#
check: $(DOWNLOADS)
#
# Check source codes from a Git repository
#
%.git:
$(VERBOSE)git ls-remote --exit-code $(URL($*)) >/dev/null 2>&1
#
# Check source codes from Subversion repository
#
%.svn:
$(VERBOSE)svn info -r $(REV($*)) $(URL($*)) >/dev/null 2>&1
#
# Check plain remote file
#
%.file:
$(VERBOSE)curl -f -L -k -r -2 $(URL($*)) > /dev/null 2>&1
%.archive: %.file
$(VERBOSE)true