prepare_port: fix race condition in safety rule

The safe guard Git repository in $(CONTRIB_DIR) may only be initialized
once, regardless of the number of ports to be prepared.

Issue #3235
This commit is contained in:
Roman Iten 2019-03-18 14:33:49 +01:00 committed by Norman Feske
parent ed33cf08c7
commit 1caa2ff3cb
3 changed files with 18 additions and 16 deletions

View File

@ -4,6 +4,9 @@
# \date 2014-05-27
#
# compound directory where all 3rd-party source codes are installed
CONTRIB_DIR ?= $(GENODE_DIR)/contrib
SHELL := bash
VERBOSE ?= @
ECHO := echo -e

View File

@ -17,9 +17,6 @@ $(MAKECMDGOALS) default:
ARGUMENT := $(MAKECMDGOALS)
PORT_NAME := $(firstword $(ARGUMENT))
# compound directory where all 3rd-party source codes are installed
CONTRIB_DIR ?= $(GENODE_DIR)/contrib
# list of all repositories located at '<genode-dir>/repos/'
REPOSITORIES ?= $(shell find $(GENODE_DIR)/repos -follow -mindepth 1 -maxdepth 1 -type d)
@ -45,18 +42,6 @@ _REL_HASH_FILE := $(notdir $(REP_DIR))/ports/$(notdir $(PORT))
# directory where to install the port
PORT_DIR := $(CONTRIB_DIR)/$(PORT_NAME)-$(HASH)
#
# Protect the GENODE_DIR Git repository by creating an
# empty Git repository in CONTRIB_DIR. This is to catch
# Git tools called by port recipes from falling through
# the parent directories of PORT_DIR and affecting other
# Git repositories.
#
$(PORT_DIR): $(CONTRIB_DIR)/.git
$(CONTRIB_DIR)/.git:
$(VERBOSE)mkdir -p $(CONTRIB_DIR)
$(VERBOSE)git init --quiet $(CONTRIB_DIR)
# path to hash file generated during installation
PORT_HASH_FILE := $(PORT_DIR)/$(PORT_NAME).hash

View File

@ -12,6 +12,8 @@ endif
export GENODE_DIR := $(realpath $(dir $(MAKEFILE_LIST))/../..)
include $(GENODE_DIR)/tool/ports/mk/common.inc
usage:
@echo
@echo "Tool for preparing and updating ports"
@ -29,5 +31,17 @@ TARGETS = $(sort $(MAKECMDGOALS))
.PHONY: $(TARGETS)
$(TARGETS):
#
# Protect the GENODE_DIR Git repository by creating an
# empty Git repository in CONTRIB_DIR. This is to catch
# Git tools called by port recipes from falling through
# the parent directories of PORT_DIR and affecting other
# Git repositories.
#
$(PORT_DIR): $(CONTRIB_DIR)/.git/HEAD
$(CONTRIB_DIR)/.git/HEAD:
@$(VERBOSE)mkdir -p $(CONTRIB_DIR)
@$(VERBOSE)git init --quiet $(CONTRIB_DIR)
$(TARGETS): $(CONTRIB_DIR)/.git/HEAD
@$(MAKE) -f $(GENODE_DIR)/tool/ports/mk/prepare_single_port.mk $@