code:
#!/bin/bash

#  download script: Download the programs used in libreboot, that
#                   aren't distributed in the git repository.
#
#	Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
#	Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e

download="resources/scripts/helpers/download"

# echo "${programs##*/}" ; echo "${programs%/*}"
programs="$(for program in ${download}/*; do printf "%s\n" "${program##*/}"; done)"

noconfirm="0"

help () {
	printf "%s\n\n" "./download program(s) # programs are space separated, if specifing multiple programs"
	printf "possible values for 'programs':\nall:\n%s\n\n" "${programs}"
	printf "Example (download everything): ./download all\n"
	printf "Example (download flashrom): ./download flashrom\n"
	printf "Example (download coreboot): ./download coreboot\n"
	printf "Example (download coreboot and flashrom): ./download coreboot flashrom\n"
	printf "Example (lists all available downloadable components): ./download list\n"
}

if [ $# -lt 1 ]; then
	printf "ERROR: download script: no argument given.\n"
	help
	exit 1
fi

if [ "${1}" = "--noconfirm" ] || [ "${1}" = "-y" ]; then
	noconfirm="1"
	shift 1
fi

case "${1}" in
	all)
		;;
	list)
		printf "possible values for 'programs':\nall\n%s\n\n" "${programs}"
		exit
		;;
	help)
		help
		exit
		;;
	*)
		for program in "${@}"; do
			printf "%s" "${programs}\n" | grep -wq "${program}" || (printf "ERROR: Invalid program '%s'. See ./download help.\n" "${program}"; exit 1)
		done
		programs="${*}"
		;;
esac

for program in ${programs}; do

	if [ "${noconfirm}" = "0" ]; then
		printf "Use \"./download --noconfirm\" or \"./download -y\" if you want to be rid of these confirmation dialogues.\n\n"
		if [ -d "${program}/" ]; then
            if [ "${program}" = "seabios" ]; then
                # temporary hack. download grub also downloads seabios,
                # which breaks automated build when running ./download all
                # Later on, we'll delete the seabios download script
                # and grub download script and replace both with
                # a download seagrub script

			    rm -Rf "${program:?}" && printf "Old %s directory deleted.\n\n" "${program}"
            else
			    printf "A %s/ directory already exists, delete it? [yN]: " "${program}"
		    	read -r answer
		    	if [ "${answer}" = "y" ]; then
			    	rm -Rf "${program:?}" && printf "Old %s directory deleted.\n\n" "${program}"
    			else
	    			printf "%s directory not deleted, and therefore not replaced.\n" "${program}"
		    		continue
		    	fi
            fi
		fi
	fi

	"${download}/${program}"
done

path: download


code:
#!/bin/bash

#  flash script: uses flashrom to flash a libreboot ROM image
#
#	Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# So that I one day find it again
# http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_06_02

## Don't add here. errors are expected.
[ "x${DEBUG+set}" = 'xset' ] && set -v
# set -u -e

if [ ${EUID} -ne 0 ]; then
   printf "This script must be run as root\n"
   exit 1
fi

arch="unknown"
if [ "$(uname -i)" = "i686" ] || [ "$(uname -m)" = "i686" ]; then
	arch="i686"
elif [ "$(uname -i)" = "x86_64" ] || [ "$(uname -m)" = "x86_64" ]; then
	arch="x86_64"
else
	printf "This script must be run on an i686 or x86_64 host. x86_64 is recommended.\n"
	exit 1
fi

usage="usage: ./flash mode path/to/yourrom.rom"
availablemodes="update, forceupdate, i945lenovo_firstflash, i945lenovo_secondflash, i945apple_firstflash"

mode="unknown"
rompath="unknown"

# User specified no or too few/many parameters
if [ $# -lt 2 ]; then
	printf "%s\n" "${usage}"
	printf "You need to specify exactly one mode, and one file\n"
	printf "%s\n" "${availablemodes}"
	exit 1
fi

mode="${1}"
rompath="${2}"

# User specified an invalid mode of operation
if [ "${mode}" != "update" ] && [ "${mode}" != "forceupdate" ] && [ "${mode}" != "i945lenovo_firstflash" ] && [ "${mode}" != "i945lenovo_secondflash" ] && [ "${mode}" != "i945apple_firstflash" ]; then
	printf "%s\n" "${usage}"
	printf "Invalid mode. Modes available: %s\n" "${availablemodes}"
	exit 1
else
	printf "Mode selected: %s\n" "${mode}"
fi

# The specified file does not exist
if [ ! -f "${rompath}" ]; then
	printf "File not found!\n"
	exit 1
fi

flashrom="unknown"
if [ -f "build" ]; then
	# git or libreboot_src
	flashrom="./flashrom/flashrom"
else
	# libreboot_util
	flashrom="./flashrom/${arch}/flashrom"
fi
if [ ! -f "${flashrom}" ]; then
	printf "flashrom binary not present\n"
	exit 1
fi

# i945 lenovobios
bucts="unknown"
flashrom_lenovobios_sst="unknown"
flashrom_lenovobios_macronix="unknown"
if [ "${mode}" = "i945lenovo_firstflash" ] || [ "${mode}" = "i945lenovo_secondflash" ]; then
	if [ -f "build" ]; then
		# git or libreboot_src
		bucts="./bucts/bucts"
		flashrom_lenovobios_sst="./flashrom/flashrom_lenovobios_sst"
		flashrom_lenovobios_macronix="./flashrom/flashrom_lenovobios_macronix"
	else
		# libreboot_util
		bucts="./bucts/${arch}/bucts"
		flashrom_lenovobios_sst="./flashrom/${arch}/flashrom_lenovobios_sst"
		flashrom_lenovobios_macronix="./flashrom/${arch}/flashrom_lenovobios_macronix"
	fi

	# anti-bricking precaution
	if [ ! -f "${bucts}" ]; then
		printf "bucts binary not present. ABORTING so as to protect against bricking the system.\n"
		exit 1
	fi

	# fail if flashrom is not present
	if [ ! -f "${flashrom_lenovobios_sst}" ] || [ ! -f "${flashrom_lenovobios_macronix}" ]; then
		printf "Flashrom binaries not present.\n"
		exit 1
	fi
fi

if [ "${mode}" = "update" ]; then
	${flashrom} -p internal -w "${rompath}"
elif [ "${mode}" = "forceupdate" ]; then
	${flashrom} -p internal:boardmismatch=force,laptop=force_I_want_a_brick -w "${rompath}"
elif [ "${mode}" = "i945apple_firstflash" ]; then
	${flashrom} -p internal:laptop=force_I_want_a_brick -w "${rompath}"
elif [ "${mode}" = "i945lenovo_firstflash" ]; then
	${bucts} 1 # needed to prevent bricks.
	# One will fail (this is harmless), and the other will succeed.
	${flashrom_lenovobios_sst} -p internal -w "${rompath}"
	${flashrom_lenovobios_macronix} -p internal -w "${rompath}"
elif [ "${mode}" = "i945lenovo_secondflash" ]; then
	${flashrom} -p internal:laptop=force_I_want_a_brick -w "${rompath}"
	${bucts} 0
fi

repo_name: ctag/libreboot

path: flash

license: mit


code:
#!/bin/bash

# Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

libreboot_usage() {
	local action
	local target

	printf "$executable [action] [target] [arguments]\n" >&2

	printf "\nGeneric project actions:\n" >&2

	for action in $PROJECT_ACTIONS_GENERIC
	do
		printf "  $action\n" >&2
	done

	printf "\nVirtual project actions:\n" >&2

	printf "  sources\n"
	printf "  produce\n"
	printf "  test\n"

	printf "\nProject targets:\n" >&2

	ls -A "$root/$PROJECTS/" | while read target
	do
		if project_check "$target"
		then
			printf "  $target\n" >&2
		fi
	done

	printf "\nGeneric tool actions:\n" >&2

	for action in $TOOL_ACTIONS_GENERIC
	do
		printf "  $action\n" >&2
	done

	printf "\nTool targets:\n" >&2

	ls -A "$root/$TOOLS/" | while read target
	do
		if tool_check "$target"
		then
			printf "  $target\n" >&2
		fi
	done

	printf "\nEnvironment variables:\n" >&2
	printf "  PROJECTS_FORCE - Projects to always perform actions for\n" >&2
	printf "  TOOLS_FORCE - Tools to always perform actions for\n" >&2
	printf "  RELEASE_KEY - GPG key to use for release\n" >&2
	printf "  VBOOT_KEYS_PATH - Path to the vboot keys\n" >&2
	printf "  TASKS - Number of simultaneous tasks to run\n" >&2
	printf "  VERSION - Version string to use\n" >&2

	printf "\nConfiguration files:\n" >&2
	printf "  $BUILD_SYSTEM.conf - Environment variables configuration\n" >&2
}

libreboot_project() {
	action=$1
	shift
	project=$1
	shift

	case $action in
		"sources")
			(
				set +e

				project_action_arguments "extract" "$project" "$@"
				if [ $? -eq 0 ]
				then
					return 0
				fi

				project_action_arguments "download" "$project" "$@"
				if [ $? -eq 0 ]
				then
					return 0
				fi
			)
			;;
		"produce")
			for action in "build" "install" "release"
			do
				project_action_arguments "$action" "$project" "$@"
			done
			;;
		"test")
			for action in $PROJECT_ACTIONS
			do
				project_action_arguments "$action" "$project" "$@"
			done
			;;
		*)
			if ! project_function_check "$project" "$action"
			then
				libreboot_usage
				exit 1
			fi

			if [ "$action" = "usage" ]
			then
				project_action "$action" "$project" "$@"
			else
				project_action_arguments "$action" "$project" "$@"
			fi
			;;
	esac
}

libreboot_tool() {
	action=$1
	shift
	tool=$1
	shift

	case $action in
		*)
			if ! tool_function_check "$tool" "$action"
			then
				libreboot_usage
				exit 1
			fi

			if [ "$action" = "usage" ]
			then
				tool_action "$action" "$tool" "$@"
			else
				tool_action_arguments_recursive "$action" "$tool" "$@"
			fi
			;;
	esac
}

libreboot_setup() {
	root=$( realpath "$( dirname "$0" )" )
	executable=$( basename "$0" )

	local requirements="git"
	local requirement_path

	libreboot_setup_include
	libreboot_setup_variables

	for requirement in $requirements
	do
		requirement_path=$( which "$requirement" || true )

		if [ -z "$requirement_path" ]
		then
			printf "Missing requirement: $requirement\n" >&2
			exit 1
		fi
	done
}

libreboot_setup_include() {
	local libs_path="$root/libs"
	local conf_path

	. "$libs_path/project"
	. "$libs_path/tool"
	. "$libs_path/common"
	. "$libs_path/git"

	conf_path="$root/$BUILD_SYSTEM.conf"

	if [ -f "$conf_path" ]
	then
		. "$conf_path"
	fi
}

libreboot_setup_variables() {
	local vboot_tools_path=$( project_install_path "vboot" "tools" )
	local version_path="$root/$DOTVERSION"
	local epoch_path="$root/$DOTEPOCH"

	if [ -z "$TASKS" ]
	then
		TASKS=1
	fi

	if [ -z "$VERSION" ]
	then
		if git_check "$root"
		then
			VERSION="$BUILD_SYSTEM-"$( git_describe "$root" 2> /dev/null || echo "git" )
		elif [ -f "$version_path" ]
		then
			VERSION=$( cat "$version_path" )
		else
			VERSION=$BUILD_SYSTEM
		fi
	fi

	if [ -z "$SOURCE_DATE_EPOCH" ]
	then
		if git_check "$root"
		then
			SOURCE_DATE_EPOCH=$( git log -1 --format=%ct )
		elif [ -f "$epoch_path" ]
		then
			SOURCE_DATE_EPOCH=$( cat "$epoch_path" )
		else
			SOURCE_DATE_EPOCH=$( date +%s )
		fi
	fi

	if [ -z "$VBOOT_KEYS_PATH" ] && [ -d "$vboot_tools_path/devkeys/" ]
	then
		VBOOT_KEYS_PATH="$vboot_tools_path/devkeys/"
	fi

	if [ -z "$EDITOR" ]
	then
		EDITOR="vi"
	fi
}

libreboot() {
	action=$1
	shift
	target=$1
	shift

	set -e

	libreboot_setup "$@"

	if [ -z "$action" ] || [ -z "$target" ]
	then
		libreboot_usage
		exit 1
	fi

	requirements "tar" "sed" "gpg" "sha256sum"

	if project_check "$target"
	then
		libreboot_project "$action" "$target" "$@"
	elif tool_check "$target"
	then
		libreboot_tool "$action" "$target" "$@"
	else
		libreboot_usage
		exit 1
	fi
}

libreboot "$@"

path: libreboot


code:
#!/bin/bash

# Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

BUILD_SYSTEM="libreboot"

PROJECTS="projects"
SOURCES="sources"
BUILD="build"
INSTALL="install"
RELEASE="release"
SYSTEMS="systems"
IMAGES="images"
TOOLS="tools"

CONFIGS="configs"
PATCHES="patches"
TARGETS="targets"
REVISION="revision"
BLOBS="blobs"
BLOBS_IGNORE="blobs-ignore"
BLOBS_DISCOVER="blobs-discover"

DOTEPOCH=".epoch"
DOTVERSION=".version"
DOTREVISION=".revision"
DOTTARFILES=".tarfiles"
TAR_XZ="tar.xz"
SHA256SUM="sha256sum"
ASC="asc"

function_check() {
	local function=$1

	declare -f -F "$function" > /dev/null
}

variable_check() {
	local variable=$1

	test ! -z "${!variable}"
}

arguments_list() {
	local argument

	for argument in "$@"
	do
		echo "$argument"
	done
}

path_wildcard_expand() {
	local path=$@

	# Evaluation fails with unescaped whitespaces.
	path=$( echo "$path" | sed "s/ /\\\ /g" )

	eval "arguments_list "$path""
}

file_checksum_create() {
	local path=$1

	local checksum_path="$path.$SHA256SUM"
	local name=$( basename "$path" )
	local directory_path=$( dirname "$path" )

	(
		cd "$directory_path"
		sha256sum "$name" > "$checksum_path"
	)
}

file_checksum_check() {
	local path=$1

	local checksum_path="$path.$SHA256SUM"
	local name=$( basename "$path" )
	local directory_path=$( dirname "$path" )

	if ! [ -f "$checksum_path" ]
	then
		printf "Could not verify file checksum!\n" >&2
		return 1
	fi

	(
		cd "$directory_path"
		sha256sum -c "$checksum_path"
	)
}

file_signature_create() {
	local path=$1

	local signature_path="$path.$ASC"

	if [ -z "$RELEASE_KEY" ]
	then
		return 0
	fi

	gpg --default-key "$RELEASE_KEY" --armor --output "$signature_path" --detach-sign --yes "$path"
}

file_signature_check() {
	local path=$1

	local signature_path="$path.$ASC"

	if ! [ -f "$signature_path" ]
	then
		printf "Could not verify file signature!\n" >&2
		return 1
	fi

	gpg --armor --verify "$signature_path" "$path"
}

file_verification_create() {
	local path=$1

	file_checksum_create "$path"
	file_signature_create "$path"
}

file_verification_check() {
	local path=$1

	file_checksum_check "$path"
	file_signature_check "$path"
}

file_exists_check() {
	local path=$1

	test -f "$path"
}

directory_filled_check() {
	local path=$1

	if [ -z "$( ls -A "$path" 2> /dev/null )" ]
	then
		return 1
	else
		return 0
	fi
}

archive_files_create() {
	local source_path=$1

	local directory=$( basename "$source_path" )
	local tarfiles_path="$source_path/$DOTTARFILES"
	local revision_path="$source_path/$DOTREVISION"
	local version_path="$source_path/$DOTVERSION"

	if git_check "$source_path"
	then
		git_files "$source_path" | tr -d '\0' > "$tarfiles_path"
		echo "$DOTTARFILES" | tr -d '\0' >> "$tarfiles_path"
	else
		touch "$tarfiles_path"

		(
			cd "$source_path"
			find
		) | LC_ALL=C sort | sed "s,^./,," | grep -vP "^\.$" > "$tarfiles_path"
	fi

	if [ -f "$revision_path" ]
	then
		echo "$DOTREVISION" | tr -d '\0' >> "$tarfiles_path"
	fi

	if [ -f "$version_path" ]
	then
		echo "$DOTVERSION" | tr -d '\0' >> "$tarfiles_path"
	fi

	if [ -f "$epoch_path" ]
	then
		echo "$DOTEPOCH" | tr -d '\0' >> "$tarfiles_path"
	fi
}

archive_files_date() {
	local source_path=$1

	local epoch_path="$source_path/$DOTEPOCH"

	if ! [ -z "$SOURCE_DATE_EPOCH" ]
	then
		(
			cd "$source_path"
			find -exec touch --no-dereference --date="@$SOURCE_DATE_EPOCH" {} \;
		)
	fi
}

archive_create() {
	local archive_path=$1
	local source_path=$2
	local directory=$3

	local tarfiles_path="$source_path/$DOTTARFILES"
	local directory_path=$( dirname "$archive_path" )

	mkdir -p "$directory_path"

	if [ -z "$directory" ]
	then
		directory=$( basename "$source_path" )
	fi

	archive_files_create "$source_path"
	archive_files_date "$source_path"

	(
		cd "$source_path"
		tar -cJf "$archive_path" --no-recursion -T "$tarfiles_path" --transform="s,^,$directory/,S" --owner=root --group=root --numeric-owner
	)
}

archive_extract() {
	local archive_path=$1
	local destination_path=$2

	if [ -z "$destination_path" ]
	then
		destination_path=$( dirname "$archive_path" )
	fi

	tar -xf "$archive_path" -ps -C "$destination_path"
}

rootfs_files_create() {
	local source_path=$1

	local directory=$( basename "$source_path" )
	local tarfiles_path="$source_path/$DOTTARFILES"

	touch "$tarfiles_path"

	(
		cd "$source_path"
		execute_root find
	) | LC_ALL=C sort | sed "s,^./,," | grep -vP "^$DOTTARFILES|^\.$" > "$tarfiles_path"
}

rootfs_files_date() {
	local source_path=$1

	local epoch_path="$source_path/$DOTEPOCH"

	if ! [ -z "$SOURCE_DATE_EPOCH" ]
	then
		(
			cd "$source_path"
			execute_root find -exec touch --no-dereference --date="@$SOURCE_DATE_EPOCH" {} \;
		)
	fi
}

rootfs_create() {
	local rootfs_path=$1
	local source_path=$2
	local directory=$3

	local tarfiles_path="$source_path/$DOTTARFILES"
	local directory_path=$( dirname "$rootfs_path" )

	mkdir -p "$directory_path"

	if [ -z "$directory" ]
	then
		directory=$( basename "$source_path" )
	fi

	rootfs_files_create "$source_path"
	rootfs_files_date "$source_path"

	(
		cd "$source_path"
		execute_root tar -cJf "$rootfs_path" --no-recursion -T "$tarfiles_path" --numeric-owner
	)

	execute_root chmod 644 "$rootfs_path"
	execute_root chown $USER:$USER "$rootfs_path"
}

requirements() {
	local requirement
	local requirement_path

	for requirement in "$@"
	do
		requirement_path=$( which "$requirement" || true )

		if [ -z "$requirement_path" ]
		then
			printf "Missing requirement: $requirement\n" >&2
			exit 1
		fi
	done
}

requirements_root() {
	local requirement
	local requirement_path

	for requirement in "$@"
	do
		# We need to keep stdout output to show the command.
		requirement_path=$( execute_root which "$requirement" || true )

		if [ -z "$requirement_path" ]
		then
			printf "Missing requirement: $requirement\n" >&2
			exit 1
		fi
	done
}

arguments_concat() {
	local delimiter=$1
	shift

	local concat

	for argument in "$@"
	do
		if ! [ -z "$concat" ]
		then
			concat="$concat""$delimiter""$argument"
		else
			concat="$argument"
		fi
	done

	echo "$concat"
}

execute_root() {
	local sudo=$( which sudo 2> /dev/null || true )
	local arguments

	printf "Running command as root: " >&2
	echo "$@" >&2

	if ! [ -z "$sudo" ]
	then
		sudo "$@"
	else
		# Quote arguments for eval through su.
		arguments=$( printf "%q " "$@" )
		su -c "$arguments"
	fi
}

path: libs/common


code:
#!/bin/bash

# Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

DOTGIT=".git"
HEAD="HEAD"
ORIGIN_HEAD="origin/HEAD"
WILDDOTPATCH="*.patch"
GIT_NAME="Libreboot"
GIT_EMAIL="libreboot@libreboot.org"

git_check() {
	local repository_path=$1

	directory_filled_check "$repository_path/$DOTGIT"
}

git_clone() {
	local repository_path=$1
	local url=$2

	git clone "$url" "$repository_path"
}

git_submodule_update() {
	local repository_path=$1

	(
		cd "$repository_path"
		git submodule update --init
	)
}

git_merge() {
	local repository_path=$1
	local revision=$2

	(
		cd "$repository_path"
		git merge "$revision"
	)
}

git_branch_create() {
	local repository_path=$1
	local branch=$2
	local revision=$3

	(
		cd "$repository_path"
		git checkout -B "$branch"

		if ! [ -z "$revision" ]
		then
			git reset --hard "$revision"
		fi
	)
}

git_branch_delete() {
	local repository_path=$1
	local branch=$2

	(
		cd "$repository_path"
		git branch -D "$branch"
	)
}

git_branch_checkout() {
	local repository_path=$1
	local branch=$2

	(
		cd "$repository_path"
		git checkout "$branch" > /dev/null
	)
}

git_branch_check() {
	local repository_path=$1
	local branch=$2

	(
		cd "$repository_path" 2> /dev/null > /dev/null
		if [ $? -ne 0 ]
		then
			return 1
		fi

		git rev-parse --verify "$branch" 2> /dev/null > /dev/null
		if [ $? -ne 0 ]
		then
			return 1
		fi
	)
}

git_fetch() {
	local repository_path=$1

	(
		cd "$repository_path"
		git fetch origin
	)
}

git_fetch_check() {
	local repository_path=$1

	(
		cd "$repository_path" 2> /dev/null > /dev/null
		if [ $? -ne 0 ]
		then
			return 1
		fi

		local output=$( git fetch --dry-run origin 2>&1 )
		if ! [ -z "$output" ]
		then
			return 1
		fi
	)
}

git_clean() {
	local repository_path=$1

	(
		cd "$repository_path"
		git clean -df
	)
}

git_remove() {
	local repository_path=$1
	local path=$2

	(
		cd "$repository_path"
		git rm -rf "$path"
	)
}

git_commit() {
	local repository_path=$1
	local message=$2

	(
		export GIT_COMMITTER_NAME=$GIT_NAME
		export GIT_COMMITTER_EMAIL=$GIT_EMAIL

		cd "$repository_path"
		git commit --author="$GIT_NAME <$GIT_EMAIL>" -m "$message"
	)
}

git_patch() {
	local repository_path=$1
	local branch=$2
	local patch=$3

	(
		export GIT_COMMITTER_NAME=$GIT_NAME
		export GIT_COMMITTER_EMAIL=$GIT_EMAIL

		cd "$repository_path"
		git checkout "$branch" 2> /dev/null > /dev/null
		git am "$patch"
	)
}

git_revision() {
	local repository_path=$1

	(
		cd "$repository_path"
		git rev-parse "$HEAD"
	)
}

git_describe() {
	local repository_path=$1

	(
		cd "$repository_path"
		git describe --tags
	)
}

git_files() {
	local repository_path=$1

	(
		cd "$repository_path"
		# Reproducible sorting.
		git ls-files | LC_ALL=C sort -z
	)
}

git_project_repository_path() {
	local repository=$1

	echo "$root/$SOURCES/$repository"
}

git_project_check() {
	local repository=$1

	local repository_path=$( git_project_repository_path "$repository" )

	git_check "$repository_path"
}

git_project_patch_recursive() {
	local project=$1
	local repository=$2
	local branch=$3
	local path=$4

	local repository_path=$( git_project_repository_path "$repository" )
	local project_path=$( project_path "$project" )
	local patches_path="$project_path/$PATCHES/$path/$WILDDOTPATCH"
	local patch_path

	if ! [ -z "$path" ] && [ "$path" != "." ]
	then
		git_project_patch_recursive "$project" "$repository" "$branch" "$( dirname "$path" )"
	fi

	path_wildcard_expand "$patches_path" | while read patch_path
	do
		if ! [ -f "$patch_path" ]
		then
			continue
		fi

		git_patch "$repository_path" "$branch" "$patch_path"
	done
}

git_project_clone() {
	local repository=$1
	shift
	local urls=$@

	local repository_path=$( git_project_repository_path "$repository" )
	local directory_path=$( dirname "$repository_path" )
	local url

	mkdir -p "$directory_path"

	(
		set +e

		for url in $urls
		do
			git_clone "$repository_path" "$url"

			if [ $? -eq 0 ]
			then
				return 0
			fi
		done

		return 1
	)
}

git_project_prepare() {
	local project=$1
	shift
	local repository=$1
	shift

	git_project_prepare_revision "$project" "$repository" "$@"
	git_project_prepare_blobs "$project" "$repository" "$@"
	git_project_prepare_patch "$project" "$repository" "$@"
}

git_project_prepare_blobs() {
	local project=$1
	shift
	local repository=$1
	shift

	local repository_path=$( git_project_repository_path "$repository" )
	local blobs_path=$( project_blobs_path "$project" "$@" )
	local blob

	if ! [ -f "$blobs_path" ]
	then
		return
	fi

	while read blob
	do
		git_remove "$repository_path" "$blob"
	done < "$blobs_path"

	git_commit "$repository_path" "Removed blobs"
}

git_project_prepare_patch() {
	local project=$1
	shift
	local repository=$1
	shift

	local project_path=$( project_path "$project" )
	local configs_path="$project_path/$CONFIGS"
	local prepare_branch
	local prepare_path
	local branch=$project
	local argument
	local path

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			if [ -z "$path" ]
			then
				path="$argument"
			else
				path="$path/$argument"
			fi

			branch="$branch-$argument"
		fi

		local revision_path="$configs_path/$path/$REVISION"

		if ! [ -f "$revision_path" ]
		then
			continue
		fi

		prepare_branch=$branch
		prepare_path=$path
	done

	if ! [ -z "$prepare_branch" ]
	then
		git_project_patch_recursive "$project" "$repository" "$prepare_branch" "$prepare_path"
	fi
}

git_project_prepare_revision() {
	local project=$1
	shift
	local repository=$1
	shift

	local repository_path=$( git_project_repository_path "$repository" )
	local project_path=$( project_path "$project" )
	local configs_path="$project_path/$CONFIGS"
	local prepare_branch
	local prepare_revision
	local branch=$project
	local argument
	local path

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			if [ -z "$path" ]
			then
				path="$argument"
			else
				path="$path/$argument"
			fi

			branch="$branch-$argument"
		fi

		local revision_path="$configs_path/$path/$REVISION"

		if ! [ -f "$revision_path" ]
		then
			continue
		fi

		prepare_branch=$branch
		prepare_revision=$( cat "$revision_path" )
	done

	if ! [ -z "$prepare_branch" ]
	then
		git_branch_create "$repository_path" "$prepare_branch" "$prepare_revision"
	fi
}

git_project_prepare_check() {
	local project=$1
	shift
	local repository=$1
	shift

	local repository_path=$( git_project_repository_path "$repository" )
	local project_path=$( project_path "$project" )
	local configs_path="$project_path/$CONFIGS"
	local prepare_branch
	local branch=$project
	local argument
	local path

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			if [ -z "$path" ]
			then
				path="$argument"
			else
				path="$path/$argument"
			fi

			branch="$branch-$argument"
		fi

		local revision_path="$configs_path/$path/$REVISION"

		if ! [ -f "$revision_path" ]
		then
			continue
		fi

		prepare_branch=$branch
	done

	if ! [ -z "$prepare_branch" ]
	then
		git_branch_check "$repository_path" "$prepare_branch"
	fi
}

git_project_prepare_clean() {
	local project=$1
	shift
	local repository=$1
	shift

	local repository_path=$( git_project_repository_path "$repository" )
	local prepare_branch
	local branch=$project
	local argument

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			branch="$branch-$argument"
		fi

		if ! git_branch_check "$repository_path" "$branch"
		then
			continue
		fi

		prepare_branch=$branch
	done

	if ! [ -z "$prepare_branch" ]
	then
		# Let's not worry about missing branches.
		(
			set +e

			git_branch_delete "$repository_path" "$prepare_branch"

			if [ $? -ne 0 ]
			then
				return 0
			fi
		)
	fi
}

git_project_checkout() {
	local project=$1
	shift
	local repository=$1
	shift

	local repository_path=$( git_project_repository_path "$repository" )
	local checkout_branch
	local branch=$project
	local argument

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			branch="$branch-$argument"
		fi

		if ! git_branch_check "$repository_path" "$branch"
		then
			continue
		fi

		checkout_branch=$branch
	done

	if ! [ -z "$checkout_branch" ]
	then
		git_branch_checkout "$repository_path" "$checkout_branch"
		git_submodule_update "$repository_path"
	fi
}

git_project_update() {
	local project=$1
	shift
	local repository=$1
	shift

	local repository_path=$( git_project_repository_path "$repository" )

	git_fetch "$repository_path"
	git_branch_checkout "$repository_path" "$ORIGIN_HEAD"

	git_project_prepare_clean "$project" "$repository" "$@"
	git_project_prepare "$project" "$repository" "$@"
}

git_project_update_check() {
	local project=$1
	shift
	local repository=$1
	shift

	git_project_prepare_check "$project" "$repository" "$@"

	git_fetch_check "$repository_path"
}

git_project_release() {
	local project=$1
	shift
	local repository=$1
	shift
	local arguments=$@

	local repository_path=$( git_project_repository_path "$repository" )
	local release_branch
	local branch=$project
	local argument

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			branch="$branch-$argument"
		fi

		if ! git_branch_check "$repository_path" "$branch"
		then
			continue
		fi

		release_branch=$branch
	done

	if ! [ -z "$release_branch" ]
	then
		local archive_path="$root/$RELEASE/$SOURCES/$project/$release_branch.$TAR_XZ"
		local sources_path="$root/$SOURCES/$repository"

		printf "Releasing sources archive for $project (with ${arguments:-no argument}) from "$repository" git\n"

		git_branch_checkout "$repository_path" "$release_branch"
		git_submodule_update "$repository_path"
		git_clean "$repository_path"
		archive_create "$archive_path" "$sources_path" "$release_branch"
		file_verification_create "$archive_path"
	fi
}

git_project_release_check() {
	local project=$1
	shift
	local repository=$1
	shift

	local repository_path=$( git_project_repository_path "$repository" )
	local release_branch
	local branch=$project
	local argument

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			branch="$branch-$argument"
		fi

		if ! git_branch_check "$repository_path" "$branch"
		then
			continue
		fi

		release_branch=$branch
	done

	if ! [ -z "$release_branch" ]
	then
		local archive_path="$root/$RELEASE/$SOURCES/$project/$release_branch.$TAR_XZ"

		file_exists_check "$archive_path"

		if [ $? -ne 0 ]
		then
			return 1
		else
			return 0
		fi
	fi
}

path: libs/git


code:
#!/bin/bash

# Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

PROJECT_ACTIONS_GENERIC="usage download extract update build install release clean"
PROJECT_ACTIONS_HELPERS="arguments"
PROJECT_FUNCTIONS=$( for action in $PROJECT_ACTIONS_GENERIC ; do echo "$action" "$action""_check" ; done ; echo "$PROJECT_ACTIONS_HELPERS" )

INSTALL_REGEX="\([^:]*\):\(.*\)"

project_include() {
	local project=$1

	local project_path=$( project_path "$project" )

	unset -f $PROJECT_FUNCTIONS

	. "$project_path/$project"

	project_helper_include "$project"
}

project_helper_include() {
	local project=$1

	local project_path=$( project_path "$project" )
	local include="$project_path/$project-helper"

	if [ -f "$include" ]
	then
		. "$include"
	fi
}

project_check() {
	local project=$1

	local project_path=$( project_path "$project" )

	if ! [ -f "$project_path/$project" ]
	then
		return 1
	fi

	return 0
}

project_function_check() {
	local project=$1
	local function=$2

	project_include "$project"

	if ! function_check "$function"
	then
		return 1
	fi

	return 0
}

project_action() {
	local action=$1
	shift
	local project=$1
	shift
	local arguments=$@

	(
		set +e

		if ! project_check "$project"
		then
			printf "Project $project check failed\n" >&2
			return 1
		fi

		project_action_check "$action" "$project" "$@"

		if [ $? -eq 0 ]
		then
			return 0
		fi

		project_include "$project"

		if ! function_check "$action"
		then
			return 0
		fi

		printf "Project $project $action (with ${arguments:-no argument})\n" >&2

		(
			set -e
			"$action" "$@"
		)

		if [ $? -ne 0 ]
		then
			printf "\nProject $project $action (with ${arguments:-no argument}) failed\n" >&2
			return 1
		else
			printf "\nProject $project $action (with ${arguments:-no argument}) completed\n" >&2
		fi
	)
}

project_action_check() {
	local action=$1
	shift
	local project=$1
	shift

	(
		set +e

		if ! project_check "$project"
		then
			printf "Project $project check failed\n" >&2
			return 1
		fi

		project_include "$project"

		if ! function_check "$action""_check"
		then
			return 1
		fi

		for project_force in $PROJECTS_FORCE
		do
			if [ "$project_force" = "$project" ]
			then
				return 1
			fi
		done

		(
			set -e
			"$action""_check" "$@"
		)
	)
}

project_action_helper() {
	local helper=$1
	shift
	local project=$1
	shift

	(
		set +e

		if ! project_check "$project"
		then
			printf "Project $project check failed\n" >&2
			return 1
		fi

		project_include "$project"

		if ! function_check "$helper"
		then
			return 0
		fi

		(
			set -e
			"$helper" "$@"
		)
	)
}

project_action_arguments() {
	local action=$1
	shift
	local project=$1
	shift

	project_action_arguments_verify_recursive "$action" "$project" "$@"
	project_action_arguments_recursive "$action" "$project" "$@"
}

project_action_arguments_verify_recursive() {
	local action=$1
	shift
	local project=$1
	shift

	local action_helper_arguments

	# Store final argument.
	local argument=${@:$#}

	local test

	if [ $# -gt 1 ]
	then
		# Set previous arguments.
		set "${@:1:$#-1}"
	elif [ $# -eq 1 ]
	then
		shift
	else
		return 0
	fi

	action_helper_arguments=$( project_action_helper "arguments" "$project" "$@" )

	if ! [ -z "$action_helper_arguments" ]
	then
		test=$( echo "$action_helper_arguments" | grep -P "^$argument$" || true )

		if [ -z "$test" ]
		then
			printf "Invalid argument $argument for project $project action $action\n" >&2
			return 1
		fi
	fi

	project_action_arguments_verify_recursive "$action" "$project" "$@"
}

project_action_arguments_recursive() {
	local action=$1
	shift
	local project=$1
	shift

	local action_helper_arguments
	local argument
	local ifs_save

	action_helper_arguments=$( project_action_helper "arguments" "$project" "$@" )

	if [ $? -ne 0 ] || [ -z "$action_helper_arguments" ]
	then
		project_action "$action" "$project" "$@"
	else
		# This it to allow space characters in arguments.
		ifs_save=$IFS
		IFS=$'\n'

		for argument in $( echo "$action_helper_arguments" )
		do
			(
				IFS=$ifs_save

				# Only a single argument at a time is returned by the helper.
				project_action_arguments_recursive "$action" "$project" "$@" "$argument"
			)
		done

		IFS=$ifs_save
	fi
}

project_action_projects() {
	local action=$1
	shift
	local project=$1
	shift

	local project_path=$( project_path "$project" )
	local project_projects_path="$project_path/$CONFIGS/$PROJECTS"
	local project_projects_action_path="$project_path/$CONFIGS/$PROJECTS-$action"
	local arguments
	local path

	if [ -f "$project_projects_action_path" ]
	then
		path=$project_projects_action_path
	else
		path=$project_projects_path
	fi

	# Multiple arguments can be read from the file.
	while read arguments
	do
		eval "project_action_arguments "$action" $arguments"
	done < "$path"
}

project_path() {
	local project=$1

	local project_path="$root/$PROJECTS/$project"

	echo "$project_path"
}

project_sources_path() {
	local project=$1
	shift
	local repository=$1
	shift

	local sources_path
	local argument
	local path

	# Check downloaded and extracted sources first, using "$project."
	path="$root/$SOURCES/$project"

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			path="$path-$argument"
		fi

		if ! directory_filled_check "$path"
		then
			continue
		fi

		sources_path=$path
	done

	if ! [ -z "$sources_path" ]
	then
		echo "$sources_path"
		return
	fi

	# Check downloaded sources then, using "$repository."
	path="$root/$SOURCES/$repository"

	if directory_filled_check "$path"
	then
		echo "$path"
		return
	fi

	# Check project sources finally, using "$project."
	path="$root/$PROJECTS/$project/$SOURCES"

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			path="$path/$argument"
		fi

		if ! directory_filled_check "$path"
		then
			continue
		fi

		sources_path=$path
	done

	if ! [ -z "$sources_path" ]
	then
		echo "$sources_path"
		return
	fi
}

project_sources_directory_filled_check() {
	local project=$1
	shift

	local sources_path=$( project_sources_path "$project" "$@" )

	test ! -z "$sources_path"
}

project_sources_directory_filled_error() {
	local project=$1
	shift
	local arguments=$@

	local sources_path=$( project_sources_path "$project" "$@" )

	if ! [ -z "$sources_path" ]
	then
		printf "Sources directory for project $project (with ${arguments:-no argument}) already exists\n" >&2
		return 1
	else
		return 0
	fi
}

project_sources_directory_missing_empty_error() {
	local project=$1
	shift
	local arguments=$@

	local sources_path=$( project_sources_path "$project" "$@" )

	if [ -z "$sources_path" ]
	then
		printf "Sources directory for project $project (with ${arguments:-no argument}) missing or empty\n" >&2
		return 1
	else
		return 0
	fi
}

project_sources_archive() {
	local project=$1
	shift

	local sources_archive
	local argument
	local path="$root/$SOURCES/$project"

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			path="$path-$argument"
		fi

		local archive="$path.$TAR_XZ"

		if ! [ -f "$archive" ]
		then
			continue
		fi

		sources_archive=$archive
	done

	if ! [ -z "$sources_archive" ]
	then
		echo "$sources_archive"
	fi
}

project_sources_archive_extract() {
	local project=$1
	shift
	local arguments=$@

	local archive=$( project_sources_archive "$project" "$@" )
	local destination=$( dirname "$archive" )

	printf "Extracting source archive for $project (with ${arguments:-no argument})\n"

	file_verification_check "$archive"
	archive_extract "$archive" "$destination"
}

project_sources_archive_update() {
	local project=$1
	shift
	local arguments=$@

	local repository=$project
	local sources_path=$( project_sources_path "$project" "$repository" "$@" )
	local archive=$( project_sources_archive "$project" "$@" )
	local destination=$( dirname "$archive" )

	if [ -d "$sources_path" ]
	then
		rm -rf "$sources_path"
	fi

	printf "Extracting source archive for $project (with ${arguments:-no argument})\n"

	file_verification_check "$archive"
	archive_extract "$archive" "$destination"
}

project_sources_archive_missing_error() {
	local project=$1
	shift
	local arguments=$@

	local archive=$( project_sources_archive "$project" "$@" )
	if [ -z "$archive" ] || ! [ -f "$archive" ]
	then
		printf "Missing sources archive for $project (with ${arguments:-no argument})\n" >&2
		return 1
	else
		return 0
	fi
}

project_sources_archive_missing_check() {
	local project=$1
	shift

	local archive=$( project_sources_archive "$project" "$@" )
	if [ -z "$archive" ] || ! [ -f "$archive" ]
	then
		return 0
	else
		return 1
	fi
}

project_blobs_path() {
	local project=$1
	shift

	local project_path=$( project_path "$project" )
	local configs_path="$project_path/$CONFIGS"
	local argument
	local path

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			if [ -z "$path" ]
			then
				path="$argument"
			else
				path="$path/$argument"
			fi
		fi

		local blobs_path="$configs_path/$path/$BLOBS"

		if [ -f "$blobs_path" ]
		then
			echo "$blobs_path"
			return
		fi
	done

	echo "$blobs_path"
}

project_blobs_ignore_path() {
	local project=$1
	shift

	local project_path=$( project_path "$project" )
	local configs_path="$project_path/$CONFIGS"
	local argument
	local path

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			if [ -z "$path" ]
			then
				path="$argument"
			else
				path="$path/$argument"
			fi
		fi

		blobs_ignore_path="$configs_path/$path/$BLOBS_IGNORE"

		if [ -f "$blobs_ignore_path" ]
		then
			echo "$blobs_ignore_path"
			return
		fi
	done
}

project_arguments_targets() {
	local project=$1
	shift

	local project_path=$( project_path "$project" )
	local targets_path="$project_path/$CONFIGS"
	local argument

	for argument in "$@"
	do
		targets_path="$targets_path/$argument"
	done

	targets_path="$targets_path/$TARGETS"

	if [ -f "$targets_path" ]
	then
		cat "$targets_path"
	fi
}

project_usage_actions() {
	local project=$1
	shift

	printf "\nGeneric actions:\n"

	for action in $PROJECT_ACTIONS_GENERIC
	do
		if function_check "$action"
		then
			printf "  $action\n"
		fi
	done

	if [ $# -gt 0 ]
	then
		printf "\nSpecific actions:\n"

		for action in "$@"
		do
			printf "  $action\n"
		done
	fi
}

project_usage_arguments() {
	local project=$1
	shift

	printf "\nArguments:\n"

	project_usage_arguments_recursive "$project" "  " "$@"
}

project_usage_arguments_recursive() {
	local project=$1
	shift
	local spacing=$1
	shift

	local action_helper_arguments
	local argument

	action_helper_arguments=$( project_action_helper "arguments" "$project" "$@" )

	if ! [ -z "$action_helper_arguments" ]
	then
		echo "$action_helper_arguments" | while read argument
		do
			printf "$spacing$argument\n"
			project_usage_arguments_recursive "$project" "  $spacing" "$@" "$argument"
		done
	fi
}

project_download_git() {
	local project=$1
	shift
	local repository=$1
	shift
	local urls=$1
	shift

	requirements "git"

	if ! git_project_check "$repository"
	then
		project_sources_directory_filled_error "$project" "$repository" "$@"

		git_project_clone "$repository" "$urls"
	fi

	git_project_prepare "$project" "$repository" "$@"
}

project_download_check_git() {
	local project=$1
	shift
	local repository=$1
	shift

	requirements "git"

	git_project_check "$repository"
	git_project_prepare_check "$project" "$repository" "$@"
}

project_extract() {
	local project=$1
	shift

	local repository=$project

	if ! project_sources_directory_filled_check "$project" "$repository" "$@"
	then
		project_sources_archive_missing_error "$project" "$@"
		project_sources_archive_extract "$project" "$@"
	fi
}

project_extract_check() {
	local project=$1
	shift

	local repository=$project

	project_sources_directory_filled_check "$project" "$repository" "$@"
}

project_update_git() {
	local project=$1
	shift
	local repository=$1
	shift

	requirements "git"

	project_sources_directory_missing_empty_error "$project" "$repository" "$@"

	if git_project_check "$repository"
	then
		git_project_update "$project" "$repository" "$@"
	else
		if ! project_sources_archive_missing_check "$project" "$@"
		then
			project_sources_archive_update "$project" "$@"
		fi
	fi
}

project_update_check_git() {
	local project=$1
	shift
	local repository=$1
	shift

	requirements "git"

	if git_project_check "$repository"
	then
		# Git repository should always be updated (even if upstream didn't progress).
		# For instance, this is useful for testing new versions of patches without changing revision.
		return 1
	else
		project_sources_archive_missing_check "$project" "$@"
	fi
}

project_build_check() {
	local project=$1
	shift

	local project_path=$( project_path "$project" )
	local build_path=$( project_build_path "$project" "$@" )
	local source_file_path
	local argument
	local rule
	local path

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			if [ -z "$path" ]
			then
				path="$argument"
			else
				path="$path/$argument"
			fi
		fi

		configs_install_path="$project_path/$CONFIGS/$path/$INSTALL"

		if ! [ -f "$configs_install_path" ]
		then
			continue
		fi

		while read rule
		do
			source=$( echo "$rule" | sed "s/$INSTALL_REGEX/\1/g" )
			source_path="$build_path/$source"

			# Source may contain a wildcard.
			path_wildcard_expand "$source_path" | while read source_file_path
			do
				if ! [ -f "$source_file_path" ] && ! [ -d "$source_file_path" ]
				then
					false
				fi
			done
		done < "$configs_install_path"
	done
}

project_build_path() {
	local project=$1
	shift

	local build_path="$root/$BUILD/$project"
	local argument

	for argument in "$@"
	do
		build_path="$build_path-$argument"
	done

	echo "$build_path"
}

project_build_directory_missing_empty_error() {
	local project=$1
	shift
	local arguments=$@

	local build_path=$( project_build_path "$project" "$@" )

	if ! directory_filled_check "$build_path"
	then
		printf "Build directory for project $project (with ${arguments:-no argument}) missing or empty\n" >&2
		return 1
	else
		return 0
	fi
}

project_install() {
	local project=$1
	shift

	local project_path=$( project_path "$project" )
	local build_path=$( project_build_path "$project" "$@" )
	local install_path=$( project_install_path "$project" "$@" )
	local source_file_path
	local argument
	local rule
	local path

	# Install built files first.
	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			if [ -z "$path" ]
			then
				path="$argument"
			else
				path="$path/$argument"
			fi
		fi

		configs_install_path="$project_path/$CONFIGS/$path/$INSTALL"

		if ! [ -f "$configs_install_path" ]
		then
			continue
		fi

		project_build_directory_missing_empty_error "$project" "$@"

		while read rule
		do
			source=$( echo "$rule" | sed "s/$INSTALL_REGEX/\1/g" )
			source_path="$build_path/$source"

			destination=$( echo "$rule" | sed "s/$INSTALL_REGEX/\2/g" )
			destination_path="$install_path/$destination"
			destination_directory_path=$( dirname "$destination_path" )

			mkdir -p "$destination_directory_path"

			# Source may contain a wildcard.
			path_wildcard_expand "$source_path" | while read source_file_path
			do
				cp -rT "$source_file_path" "$destination_path"
			done
		done < "$configs_install_path"
	done

	path=""

	# Install install files then.
	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			if [ -z "$path" ]
			then
				path="$argument"
			else
				path="$path/$argument"
			fi
		fi

		install_install_path="$project_path/$INSTALL/$path/$INSTALL"

		if ! [ -f "$install_install_path" ]
		then
			continue
		fi

		while read rule
		do
			source=$( echo "$rule" | sed "s/$INSTALL_REGEX/\1/g" )
			source_path="$project_path/$INSTALL/$path/$source"

			destination=$( echo "$rule" | sed "s/$INSTALL_REGEX/\2/g" )
			destination_path="$install_path/$destination"
			destination_directory_path=$( dirname "$destination_path" )

			mkdir -p "$destination_directory_path"

			# Source may contain a wildcard.
			path_wildcard_expand "$source_path" | while read source_file_path
			do
				cp -rT "$source_file_path" "$destination_path"
			done
		done < "$install_install_path"
	done
}

project_install_check() {
	local project=$1
	shift

	local project_path=$( project_path "$project" )
	local build_path=$( project_build_path "$project" "$@" )
	local install_path=$( project_install_path "$project" "$@" )
	local argument
	local rule
	local path

	# Install built files first.
	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			if [ -z "$path" ]
			then
				path="$argument"
			else
				path="$path/$argument"
			fi
		fi

		configs_install_path="$project_path/$CONFIGS/$path/$INSTALL"

		if ! [ -f "$configs_install_path" ]
		then
			continue
		fi

		project_build_directory_missing_empty_error "$project" "$@"

		while read rule
		do
			destination=$( echo "$rule" | sed "s/$INSTALL_REGEX/\2/g" )
			destination_path="$install_path/$destination"

			if ! [ -f "$destination_path" ] && ! [ -d "$destination_path" ]
			then
				false
			fi
		done < "$configs_install_path"
	done

	path=""

	# Install install files then.
	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			if [ -z "$path" ]
			then
				path="$argument"
			else
				path="$path/$argument"
			fi
		fi

		install_install_path="$project_path/$INSTALL/$path/$INSTALL"

		if ! [ -f "$install_install_path" ]
		then
			continue
		fi

		while read rule
		do
			destination=$( echo "$rule" | sed "s/$INSTALL_REGEX/\2/g" )
			destination_path="$install_path/$destination"

			if ! [ -f "$destination_path" ] && ! [ -d "$destination_path" ]
			then
				false
			fi
		done < "$install_install_path"
	done
}

project_install_path() {
	local project=$1
	shift

	local install_path="$root/$INSTALL/$project"
	local argument

	for argument in "$@"
	do
		install_path="$install_path-$argument"
	done

	echo "$install_path"
}

project_install_directory_missing_empty_error() {
	local project=$1
	shift
	local arguments=$@

	local install_path=$( project_install_path "$project" "$@" )

	if ! directory_filled_check "$install_path"
	then
		printf "Install directory for project $project (with ${arguments:-no argument}) missing or empty\n" >&2
		return 1
	else
		return 0
	fi
}

project_release_path() {
	local project=$1
	shift
	local prefix=$1

	local release_path="$root/$RELEASE/$prefix"

	# Special care for tools and systems, that depend on the host arch.
	if [ "$prefix" = "$SYSTEMS" ] || [ "$prefix" = "$TOOLS" ]
	then
		local machine=$( uname -m )

		release_path="$release_path/$machine/$project"
	else
		release_path="$release_path/$project"
	fi

	echo "$release_path"
}

project_release_archive_path() {
	local project=$1
	shift
	local prefix=$1
	shift

	local release_path=$( project_release_path "$project" "$prefix" )
	local argument
	local path="$project"

	for argument in "$@"
	do
		path="$path-$argument"
	done

	local archive_path="$release_path/$path.$TAR_XZ"

	echo "$archive_path"
}

project_release_rootfs_path() {
	local project=$1
	shift
	local prefix=$1
	shift

	local release_path=$( project_release_path "$project" "$prefix" )
	local argument
	local path="$project"

	for argument in "$@"
	do
		path="$path-$argument"
	done

	local rootfs_path="$release_path/$path.$TAR_XZ"

	echo "$rootfs_path"
}

project_release_sources_archive_path() {
	local project=$1
	shift

	local sources_path="$root/$SOURCES/"
	local release_path
	local argument
	local path="$project"

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			path="$path-$argument"
		fi

		local directory_path="$sources_path/$path"

		if ! directory_filled_check "$directory_path"
		then
			continue
		fi

		release_path=$path
	done

	if ! [ -z "$release_path" ]
	then
		local archive_path="$root/$RELEASE/$SOURCES/$project/$release_path.$TAR_XZ"

		echo "$archive_path"
	fi
}

project_release_sources_archive_create() {
	local project=$1
	shift
	local arguments=$@

	local repository=$project
	local archive_path=$( project_release_sources_archive_path "$project" "$@" )
	local sources_path=$( project_sources_path "$project" "$repository" "$@" )

	printf "Releasing sources archive for $project (with ${arguments:-no argument})\n"

	archive_create "$archive_path" "$sources_path"
	file_verification_create "$archive_path"
}

project_release_sources_archive_exists_check() {
	local project=$1
	shift

	local archive_path=$( project_release_sources_archive_path "$project" "$@" )
	if [ -z "$archive_path" ] || ! [ -f "$archive_path" ]
	then
		return 1
	else
		return 0
	fi
}

project_release_sources_git() {
	local project=$1
	shift
	local repository=$1
	shift

	requirements "git"

	project_sources_directory_missing_empty_error "$project" "$repository" "$@"

	if git_project_check "$repository"
	then
		if ! git_project_release_check "$project" "$repository" "$@"
		then
			git_project_release "$project" "$repository" "$@"
		fi
	else
		if ! project_release_sources_archive_exists_check "$project" "$@"
		then
			project_release_sources_archive_create "$project" "$@"
		fi
	fi
}

project_release_check_sources_git() {
	local project=$1
	shift
	local repository=$1
	shift

	requirements "git"

	if git_project_check "$repository"
	then
		git_project_release_check "$project" "$repository" "$@"
	else
		project_release_sources_archive_exists_check "$project" "$@"
	fi
}

project_release_install() {
	local project=$1
	shift
	local prefix=$1
	shift

	local install_path=$( project_install_path "$project" "$@" )
	local release_path=$( project_release_path "$project" "$prefix" )
	local directory_path
	local path

	project_install_directory_missing_empty_error "$project" "$@"

	local files=$( cd "$install_path" && find -type f || true )
	local file

	echo "$files" | while read file
	do
		path="$release_path/$file"
		directory_path=$( dirname "$path" )

		mkdir -p "$directory_path"

		cp "$install_path/$file" "$path"
		file_verification_create "$path"
	done
}

project_release_install_check() {
	local project=$1
	shift
	local prefix=$1
	shift

	local install_path=$( project_install_path "$project" "$@" )
	local release_path=$( project_release_path "$project" "$prefix" )
	local path

	project_install_directory_missing_empty_error "$project" "$@"

	local files=$( cd "$install_path" && find -type f || true )
	local file

	echo "$files" | while read file
	do
		path="$release_path/$file"

		file_exists_check "$path"
	done
}

project_release_install_archive() {
	local project=$1
	shift
	local prefix=$1
	shift

	project_install_directory_missing_empty_error "$project" "$@"

	project_release_install_archive_create "$project" "$prefix" "$@"
}

project_release_install_archive_check() {
	local project=$1
	shift

	project_release_install_archive_exists_check "$project" "$@"
}

project_release_install_archive_create() {
	local project=$1
	shift
	local prefix=$1
	shift
	local arguments=$@

	local install_path=$( project_install_path "$project" "$@" )
	local archive_path=$( project_release_archive_path "$project" "$prefix" "$@" )

	printf "Releasing $prefix archive for $project (with ${arguments:-no argument})\n"

	archive_create "$archive_path" "$install_path"
	file_verification_create "$archive_path"
}

project_release_install_archive_exists_check() {
	local project=$1
	shift
	local prefix=$1
	shift

	local archive_path=$( project_release_archive_path "$project" "$prefix" "$@" )

	file_exists_check "$archive_path"
}

project_release_install_rootfs() {
	local project=$1
	shift
	local prefix=$1
	shift

	project_install_directory_missing_empty_error "$project" "$@"

	if ! project_release_install_rootfs_exists_check "$project" "$prefix" "$@"
	then
		project_release_install_rootfs_create "$project" "$prefix" "$@"
	fi
}

project_release_install_rootfs_check() {
	local project=$1
	shift

	project_release_install_rootfs_exists_check "$project" "$@"
}

project_release_install_rootfs_create() {
	local project=$1
	shift
	local prefix=$1
	shift
	local arguments=$@

	local install_path=$( project_install_path "$project" "$@" )
	local rootfs_path=$( project_release_rootfs_path "$project" "$prefix" "$@" )

	printf "Releasing $prefix rootfs for $project (with ${arguments:-no argument})\n"

	rootfs_create "$rootfs_path" "$install_path"
	file_verification_create "$rootfs_path"
}

project_release_install_rootfs_exists_check() {
	local project=$1
	shift
	local prefix=$1
	shift

	local rootfs_path=$( project_release_rootfs_path "$project" "$prefix" "$@" )

	file_exists_check "$rootfs_path"
}

project_clean() {
	local project=$1
	shift

	project_clean_build "$project" "$@"
	project_clean_install "$project" "$@"
	project_clean_release "$project" "$@"
}

project_clean_build() {
	local project=$1
	shift

	local build_path=$( project_build_path "$project" "$@" )

	rm -rf "$build_path"
}

project_clean_install() {
	local project=$1
	shift

	local install_path=$( project_install_path "$project" "$@" )

	rm -rf "$install_path"
}

project_clean_release() {
	local project=$1
	shift

	local prefix

	for prefix in "$SOURCES" "$SYSTEMS" "$IMAGES" "$TOOLS" "$DOCS"
	do
		local release_path=$( project_release_path "$project" "$prefix" )

		rm -rf "$release_path"
	done
}

project_clean_rootfs() {
	local project=$1
	shift

	project_clean_build "$project" "$@"
	project_clean_rootfs_install "$project" "$@"
	project_clean_release "$project" "$@"

}

project_clean_rootfs_install() {
	local project=$1
	shift

	local install_path=$( project_install_path "$project" "$@" )

	execute_root rm -rf "$install_path"

}

project_file_path() {
	local project=$1
	shift
	local directory=$1
	shift
	local file=$1
	shift

	local project_path=$( project_path "$project" )
	local path="$project_path/$directory"
	local argument
	local file_path

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			path="$path/$argument"
		fi

		if ! [ -f "$path/$file" ]
		then
			continue
		fi

		file_path="$path/$file"
	done

	if [ -z "$file_path" ]
	then
		return 1
	fi

	echo "$file_path"
}

project_file_test() {
	local file_path=$( project_file_path "$@" )

	test -f "$file_path"
}

project_file_contents() {
	local file_path=$( project_file_path "$@" )

	if [ -f "$file_path" ]
	then
		cat "$file_path"
	fi
}

project_file_contents_herit() {
	local project=$1
	shift
	local directory=$1
	shift
	local file=$1
	shift

	local project_path=$( project_path "$project" )
	local path="$project_path/$directory"
	local argument
	local file_path

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			path="$path/$argument"
		fi

		file_path="$path/$file"

		if ! [ -f "$file_path" ]
		then
			continue
		fi

		cat "$file_path"
	done
}

path: libs/project


code:
#!/bin/bash

# Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

TOOL_ACTIONS_GENERIC="usage update execute"
TOOL_ACTIONS_HELPERS="arguments"
TOOL_FUNCTIONS=$( for action in $TOOL_ACTIONS_GENERIC ; do echo "$action" "$action""_check" ; done ; echo "$TOOL_ACTIONS_HELPERS" )

tool_include() {
	local tool=$1

	local tool_path=$( tool_path "$tool" )

	unset -f $TOOL_FUNCTIONS

	. "$tool_path/$tool"

	tool_helper_include "$tool"
}

tool_helper_include() {
	local tool=$1

	local tool_path=$( tool_path "$tool" )
	local include="$tool_path/$tool-helper"

	if [ -f "$include" ]
	then
		. "$include"
	fi
}

tool_check() {
	local tool=$1

	local tool_path=$( tool_path "$tool" )

	if ! [ -f "$tool_path/$tool" ]
	then
		return 1
	fi

	return 0
}

tool_function_check() {
	local tool=$1
	local function=$2

	tool_include "$tool"

	if ! function_check "$function"
	then
		return 1
	fi

	return 0
}

tool_action() {
	local action=$1
	shift
	local tool=$1
	shift
	local arguments=$@

	(
		set +e

		if ! tool_check "$tool"
		then
			printf "Tool $tool check failed\n" >&2
			return 1
		fi

		tool_action_check "$action" "$tool" "$@"

		if [ $? -eq 0 ]
		then
			return 0
		fi

		tool_include "$tool"

		if ! function_check "$action"
		then
			return 0
		fi

		printf "Tool $tool $action (with ${arguments:-no argument})\n" >&2

		(
			set -e
			"$action" "$@"
		)

		if [ $? -ne 0 ]
		then
			printf "\nTool $tool $action (with ${arguments:-no argument}) failed\n" >&2
			return 1
		else
			printf "\nTool $tool $action (with ${arguments:-no argument}) completed\n" >&2
		fi
	)
}

tool_action_check() {
	local action=$1
	shift
	local tool=$1
	shift

	(
		set +e

		if ! tool_check "$tool"
		then
			printf "Tool $tool check failed\n" >&2
			return 1
		fi

		tool_include "$tool"

		if ! function_check "$action""_check"
		then
			return 1
		fi

		for tool_force in $TOOLS_FORCE
		do
			if [ "$tool_force" = "$tool" ]
			then
				return 1
			fi
		done

		(
			set -e
			"$action""_check" "$@"
		)
	)
}

tool_action_helper() {
	local helper=$1
	shift
	local tool=$1
	shift

	(
		set +e

		if ! tool_check "$tool"
		then
			printf "Tool $tool check failed\n" >&2
			return 1
		fi

		tool_include "$tool"

		if ! function_check "$helper"
		then
			return 0
		fi

		(
			set -e
			"$helper" "$@"
		)
	)
}

tool_action_arguments_recursive() {
	local action=$1
	shift
	local tool=$1
	shift

	local action_helper_arguments=$( tool_action_helper "arguments" "$tool" "$@" )
	local argument

	if [ $? -ne 0 ] || [ -z "$action_helper_arguments" ]
	then
		tool_action "$action" "$tool" "$@"
	else
		echo "$action_helper_arguments" | while read argument
		do
			tool_action_arguments_recursive "$action" "$tool" "$@" "$argument"
		done
	fi
}

tool_path() {
	local tool=$1

	local tool_path="$root/$TOOLS/$tool"

	echo "$tool_path"
}

tool_sources_path() {
	local tool=$1
	shift

	local path="$root/$TOOLS/$tool/$SOURCES"
	local argument

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			path="$path/$argument"
		fi

		if directory_filled_check "$path"
		then
			echo "$path"
			return
		fi
	done
}

tool_usage_actions() {
	local tool=$1
	shift

	printf "\nGeneric actions:\n"

	for action in $TOOL_ACTIONS_GENERIC
	do
		if function_check "$action"
		then
			printf "  $action\n"
		fi
	done

	if [ $# -gt 0 ]
	then
		printf "\nSpecific actions:\n"

		for action in "$@"
		do
			printf "  $action\n"
		done
	fi
}

tool_usage_arguments() {
	local tool=$1
	shift

	printf "\nArguments:\n"

	tool_usage_arguments_recursive "$tool" "  " "$@"
}

tool_usage_arguments_recursive() {
	local tool=$1
	shift
	local spacing=$1
	shift

	local action_helper_arguments=$( tool_action_helper "arguments" "$tool" "$@" )
	local argument

	if ! [ -z "$action_helper_arguments" ]
	then
		echo "$action_helper_arguments" | while read argument
		do
			printf "$spacing$argument\n"
			tool_usage_arguments_recursive "$tool" "  $spacing" "$@" "$argument"
		done
	fi
}

tool_file_path() {
	local tool=$1
	shift
	local directory=$1
	shift
	local file=$1
	shift

	local tool_path=$( tool_path "$tool" )
	local path="$tool_path/$directory"
	local argument
	local file_path

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			path="$path/$argument"
		fi

		if ! [ -f "$path/$file" ]
		then
			continue
		fi

		file_path="$path/$file"
	done

	if [ -z "$file_path" ]
	then
		return 1
	fi

	echo "$file_path"
}

tool_file_test() {
	local file_path=$( tool_file_path "$@" )

	test -f "$file_path"
}

tool_file_contents() {
	local file_path=$( tool_file_path "$@" )

	if [ -f "$file_path" ]
	then
		cat "$file_path"
	fi
}

tool_file_contents_herit() {
	local tool=$1
	shift
	local directory=$1
	shift
	local file=$1
	shift

	local tool_path=$( tool_path "$tool" )
	local path="$tool_path/$directory"
	local argument
	local file_path

	for argument in "" "$@"
	do
		if ! [ -z "$argument" ]
		then
			path="$path/$argument"
		fi

		file_path="$path/$file"

		if ! [ -f "$file_path" ]
		then
			continue
		fi

		cat "$file_path"
	done
}

path: libs/tool


code:
#!/bin/sh

#  generic build script, for building components (all of them)
#
#	Copyright (C) 2014, 2015 Leah Rowe <info@minifree.org>
#	Copyright (C) 2015 Patrick "P. J." McDermott <pj@pehjota.net>
#	Copyright (C) 2015, 2016 Klemens Nanni <contact@autoboot.org>
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e

build=./resources/scripts/helpers/build

listmodes() {
	for mode in "${build}"/*; do
		printf '%s\n' "${mode##*/}"
	done
}

# Takes exactly one mode as parameter
listoptions() {
	for option in "${build}"/"${1}"/*; do
		printf '%s\n' "${option##*/}"
	done
}

help() {
	cat <<- EOF
	USAGE:	./oldbuild <MODE> <OPTION>

	possible values for 'mode':
	$(listmodes)

	Example:	./oldbuild module all
	Example:	./oldbuild module flashrom [static]
	Example:	./oldbuild roms withgrub
	Example:	./oldbuild clean all

	Refer to the libreboot documentation for more information.
	EOF
}

die() {
	printf 'Error: %s\n' "${@}" 1>&2
	exit 1
}

if [ $# -lt 1 ]; then
	die "Wrong number of arguments specified. See './oldbuild help'."
fi

mode="${1}"

[ "${mode}" = help ] && help && exit 0

if [ $# -gt 1 ]; then

    option="${2}"
    shift 2

    case "${option}" in
    	list)
    		printf "Available options for mode '%s':\n\n" "${mode}"
    		listoptions "${mode}"
    		;;
    	all)
    		for option in $(listoptions "${mode}"); do
    			"${build}"/"${mode}"/"${option}" $@
    		done
    		;;
    	*)
    		if [ -d "${build}"/"${mode}"/ ]; then
    			if [ -f "${build}"/"${mode}"/"${option}" ]; then
    				"${build}"/"${mode}"/"${option}" $@
    			else
                    help
    				die "Invalid option for '${mode}'. See './oldbuild ${mode} list'."
    			fi
    		else
                help
    			die "Invalid mode '${mode}'. See './oldbuild help'."
    		fi
    esac
else
    help
    exit 0
fi

path: oldbuild


code:
#!/bin/bash

# Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

download() {
	local repository="coreboot"

	git_project_prepare "$project" "$repository" "$@"
}

download_check() {
	local repository="coreboot"

	git_project_prepare_check "$project" "$repository" "$@"
}

extract() {
	local repository="coreboot"

	project_extract "$project" "$@"
}

extract_check() {
	local repository="coreboot"

	project_extract_check "$project" "$@"
}

update() {
	local repository="coreboot"

	project_update_git "$project" "$repository" "$@"
}

update_check() {
	local repository="coreboot"

	project_update_check_git "$project" "$repository" "$@"
}

build() {
	local repository="coreboot"

	project_sources_directory_missing_empty_error "$project" "$repository" "$@"

	local coreboot_sources_path=$( project_sources_path "$project" "$repository" "$@" )
	local sources_path="$coreboot_sources_path/util/cbfstool/"
	local build_path=$( project_build_path "$project" "$@" )
	local build_util_path=$( dirname "$build_path" )

	local vboot_sources_path=$( project_sources_path "vboot" "vboot" "devices" )

	if git_project_check "$repository"
	then
		git_project_checkout "$project" "$repository" "$@"
	fi

	project_action "checkout" "vboot" "devices"

	mkdir -p "$build_path"

	make -C "$sources_path" objutil="$build_util_path" VBOOT_SOURCE="$vboot_sources_path" -j$TASKS
}

build_check() {
	project_build_check "$project" "$@"
}

install() {
	project_install "$project" "$@"
}

install_check() {
	project_install_check "$project" "$@"
}

release() {
	local repository="coreboot"

	project_release_install_archive "$project" "$TOOLS" "$@"

	project_release_sources_git "$project" "$repository" "$@"
}

release_check() {
	local repository="coreboot"

	project_release_install_archive_check "$project" "$TOOLS" "$@"

	project_release_check_sources_git "$project" "$repository" "$@"
}

clean() {
	project_clean "$project" "$@"
}

path: projects/cbfstool/cbfstool


code:
cbfstool:cbfstool
fmaptool:fmaptool

path: projects/cbfstool/configs/install


code:
#!/bin/bash

# Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

download() {
	local repository="coreboot"

	git_project_prepare "$project" "$repository" "$@"
}

download_check() {
	local repository="coreboot"

	git_project_prepare_check "$project" "$repository" "$@"
}

extract() {
	local repository="coreboot"

	project_extract "$project" "$@"
}

extract_check() {
	local repository="coreboot"

	project_extract_check "$project" "$@"
}

update() {
	local repository="coreboot"

	project_update_git "$project" "$repository" "$@"
}

update_check() {
	local repository="coreboot"

	project_update_check_git "$project" "$repository" "$@"
}

build() {
	local repository="coreboot"

	project_sources_directory_missing_empty_error "$project" "$repository" "$@"

	local coreboot_sources_path=$( project_sources_path "$project" "$repository" "$@" )
	local sources_path="$coreboot_sources_path/util/cbmem/"
	local build_path=$( project_build_path "$project" "$@" )

	if git_project_check "$repository"
	then
		git_project_checkout "$project" "$repository" "$@"
	fi

	mkdir -p "$build_path"

	make -C "$sources_path" -j$TASKS

	cp "$sources_path/cbmem" "$build_path"

	make -C "$sources_path" "clean"
}

build_check() {
	project_build_check "$project" "$@"
}

install() {
	project_install "$project" "$@"
}

install_check() {
	project_install_check "$project" "$@"
}

release() {
	local repository="coreboot"

	project_release_install_archive "$project" "$TOOLS" "$@"

	project_release_sources_git "$project" "$repository" "$@"
}

release_check() {
	local repository="coreboot"

	project_release_install_archive_check "$project" "$TOOLS" "$@"

	project_release_check_sources_git "$project" "$repository" "$@"
}

clean() {
	project_clean "$project" "$@"
}

path: projects/cbmem/cbmem


path: projects/cbmem/configs/install


path: projects/coreboot/configs/blobs


code:
Documentation/codeflow.svg
Documentation/CorebootBuildingGuide.tex
Documentation/hypertransport.svg
payloads/external/depthcharge/Kconfig
payloads/external/FILO/Kconfig
payloads/external/GRUB2/Kconfig
payloads/external/SeaBIOS/Kconfig
payloads/external/U-Boot/Kconfig
payloads/Kconfig
payloads/libpayload/curses/PDCurses-3.4/demos/worm.c
payloads/libpayload/curses/PDCurses-3.4/sdl1/deffont.h
payloads/libpayload/curses/PDCurses-3.4/sdl1/deficon.h
payloads/libpayload/curses/PDCurses-3.4/win32/pdckbd.c
payloads/libpayload/curses/PDCurses-3.4/x11/big_icon.xbm
payloads/libpayload/curses/PDCurses-3.4/x11/little_icon.xbm
payloads/libpayload/curses/pdcurses-backend/pdcdisp.c
payloads/libpayload/curses/PDCurses/demos/worm.c
payloads/libpayload/curses/PDCurses/sdl1/deffont.h
payloads/libpayload/curses/PDCurses/sdl1/deficon.h
payloads/libpayload/curses/PDCurses/win32/pdckbd.c
payloads/libpayload/curses/PDCurses/x11/big_icon.xbm
payloads/libpayload/curses/PDCurses/x11/little_icon.xbm
payloads/libpayload/curses/tinycurses.c
payloads/libpayload/drivers/keyboard.c
payloads/libpayload/drivers/usb/usbmsc.c
payloads/libpayload/tests/cbfs-x86-test.c
payloads/nvramcui/payload.sh
src/cpu/allwinner/a10/raminit.c
src/cpu/amd/family_10h-family_15h/init_cpus.c
src/cpu/amd/family_10h-family_15h/processor_name.c
src/cpu/amd/geode_gx2/Kconfig
src/cpu/amd/geode_lx/cpureginit.c
src/cpu/amd/geode_lx/Kconfig
src/cpu/amd/microcode/microcode.c
src/cpu/amd/model_10xxx/init_cpus.c
src/cpu/amd/model_10xxx/processor_name.c
src/cpu/amd/model_fxx/model_fxx_update_microcode.c
src/cpu/amd/model_fxx/powernow_acpi.c
src/cpu/intel/fsp_model_206ax/acpi.c
src/cpu/intel/fsp_model_406dx/acpi.c
src/cpu/intel/haswell/acpi.c
src/cpu/intel/microcode/microcode.c
src/cpu/intel/model_2065x/acpi.c
src/cpu/intel/model_206ax/acpi.c
src/cpu/Kconfig
src/cpu/samsung/exynos5250/update-bl1.sh
src/cpu/via/nano/update_ucode.c
src/device/dram/spd_cache.c
src/device/Kconfig
src/device/oprom/yabel/interrupt.c
src/drivers/aspeed/common/ast_dram_tables.h
src/drivers/aspeed/common/ast_tables.h
src/drivers/i2c/ww_ring/ww_ring_programs.c
src/drivers/intel/fsp1_1/car.c
src/drivers/intel/fsp1_1/fsp_gop.c
src/drivers/intel/fsp1_1/Kconfig
src/drivers/intel/fsp1_1/ramstage.c
src/drivers/intel/fsp2_0/graphics.c
src/drivers/intel/fsp2_0/Kconfig
src/drivers/pc80/mc146818rtc.c
src/drivers/pc80/rtc/mc146818rtc.c
src/drivers/pc80/vga/vga_palette.c
src/drivers/siemens/nc_fpga/nc_fpga.c
src/drivers/xgi/common/vb_setmode.c
src/drivers/xgi/common/vb_table.h
src/drivers/xgi/common/XGI_main.h
src/Kconfig
src/lib/coreboot_table.c
src/lib/jpeg.c
src/lib/tlcl_structures.h
src/lib/tpm2_tlcl.c
src/mainboard/adi/rcc-dff/Kconfig
src/mainboard/advansus/a785e-i/mptable.c
src/mainboard/amd/bettong/mptable.c
src/mainboard/amd/bimini_fam10/mptable.c
src/mainboard/amd/db-ft3b-lc/Memphis_MEM4G16D3EABG.spd.hex
src/mainboard/amd/dinar/buildOpts.c
src/mainboard/amd/dinar/Kconfig
src/mainboard/amd/gardenia/OemCustomize.c
src/mainboard/amd/inagua/Kconfig
src/mainboard/amd/lamar/Kconfig
src/mainboard/amd/olivehill/mptable.c
src/mainboard/amd/olivehillplus/mptable.c
src/mainboard/amd/parmer/mptable.c
src/mainboard/amd/persimmon/Kconfig
src/mainboard/amd/serengeti_cheetah_fam10/get_bus_conf.c
src/mainboard/amd/south_station/Kconfig
src/mainboard/amd/south_station/mptable.c
src/mainboard/amd/thatcher/mptable.c
src/mainboard/amd/torpedo/Kconfig
src/mainboard/amd/torpedo/mptable.c
src/mainboard/amd/union_station/Kconfig
src/mainboard/amd/union_station/mptable.c
src/mainboard/apple/macbookair4_2/early_southbridge.c
src/mainboard/asrock/e350m1/mptable.c
src/mainboard/asrock/imb-a180/mptable.c
src/mainboard/asus/f2a85-m/mptable.c
src/mainboard/asus/kfsn4-dre/get_bus_conf.c
src/mainboard/asus/m5a88-v/mptable.c
src/mainboard/avalue/eax-785e/mptable.c
src/mainboard/bap/ode_e20XX/BAP_Q7_1066.spd.hex
src/mainboard/bap/ode_e20XX/BAP_Q7_800.spd.hex
src/mainboard/bap/ode_e20XX/BAP_Q7.spd.hex
src/mainboard/bap/ode_e21XX/BAP_Q7_1066.spd.hex
src/mainboard/bap/ode_e21XX/BAP_Q7_1333.spd.hex
src/mainboard/bap/ode_e21XX/BAP_Q7_800.spd.hex
src/mainboard/bap/ode_e21XX/mptable.c
src/mainboard/digitallogic/adl855pc/irq_tables.c
src/mainboard/gigabyte/ga-b75m-d3h/romstage.c
src/mainboard/gigabyte/ga-b75m-d3v/romstage.c
src/mainboard/gizmosphere/gizmo2/Micron_MT41J128M16JT.spd.hex
src/mainboard/gizmosphere/gizmo/mptable.c
src/mainboard/google/auron_paine/spd/spd.c
src/mainboard/google/auron/spd/Elpida_EDJ4216EFBG.spd.hex
src/mainboard/google/auron/spd/empty.spd.hex
src/mainboard/google/auron/spd/Hynix_HMT425S6AFR6A.spd.hex
src/mainboard/google/auron/spd/Micron_4KTF25664HZ.spd.hex
src/mainboard/google/auron/spd/spd.c
src/mainboard/google/bolt/elpida_4Gb_1600_x16.spd.hex
src/mainboard/google/bolt/micron_4Gb_1600_1.35v_x16.spd.hex
src/mainboard/google/bolt/romstage.c
src/mainboard/google/bolt/samsung_4Gb_1600_1.35v_x16.spd.hex
src/mainboard/google/butterfly/hda_verb.c
src/mainboard/google/butterfly/mainboard.c
src/mainboard/google/chell/spd/empty.spd.hex
src/mainboard/google/chell/spd/hynix_dimm_H9CCNNN8GTMLAR.spd.hex
src/mainboard/google/chell/spd/hynix_dimm_H9CCNNNBJTMLAR.spd.hex
src/mainboard/google/chell/spd/hynix_dimm_H9CCNNNCLTMLAR.spd.hex
src/mainboard/google/chell/spd/samsung_dimm_K4E6E304EB-EGCF.spd.hex
src/mainboard/google/chell/spd/samsung_dimm_K4E6E304EE-EGCF.spd.hex
src/mainboard/google/chell/spd/samsung_dimm_K4E8E304EE-EGCF.spd.hex
src/mainboard/google/chell/spd/spd.c
src/mainboard/google/cyan/Kconfig
src/mainboard/google/cyan/spd/hynix_2GiB_dimm_H5TC4G63AFR-PBA.spd.hex
src/mainboard/google/cyan/spd/hynix_2GiB_dimm_HMT425S6CFR6A_H5TC4G63CFR.spd.hex
src/mainboard/google/cyan/spd/samsung_2GiB_dimm_K4B4G1646Q-HYK0.spd.hex
src/mainboard/google/cyan/spd/spd.c
src/mainboard/google/enguarde/spd/hynix_2GiB_dimm_H5TC4G63AFR-PBA.spd.hex
src/mainboard/google/enguarde/spd/samsung_1GiB_dimm_K4B2G1646Q-BYK0.spd.hex
src/mainboard/google/enguarde/spd/micron_1GiB_dimm_MT41K128M16JT-125.spd.hex
src/mainboard/google/enguarde/spd/samsung_2GiB_dimm_K4B4G1646Q-HYK0.spd.hex
src/mainboard/google/enguarde/spd/micron_2GiB_dimm_MT41K256M16HA-125.spd.hex
src/mainboard/google/enguarde/spd/hynix_1GiB_dimm_H5TC2G63FFR-PBA.spd.hex
src/mainboard/google/eve/spd/hynix_dimm_H9CCNNNBJTALAR.spd.hex
src/mainboard/google/eve/spd/hynix_dimm_H9CCNNNCLTMLAR.spd.hex
src/mainboard/google/eve/spd/samsung_dimm_K4E8E324EB.spd.hex
src/mainboard/google/eve/spd/empty.spd.hex
src/mainboard/google/eve/spd/samsung_dimm_K4E6E304EB.spd.hex
src/mainboard/google/eve/spd/samsung_dimm_K4EBE304EB.spd.hex
src/mainboard/google/eve/spd/hynix_dimm_H9CCNNN8GTALAR.spd.hex
src/mainboard/google/falco/Elpida_EDJ4216EFBG.spd.hex
src/mainboard/google/falco/Hynix_HMT425S6AFR6A.spd.hex
src/mainboard/google/falco/Micron_4KTF25664HZ.spd.hex
src/mainboard/google/falco/romstage.c
src/mainboard/google/falco/Samsung_M471B5674QH0.spd.hex
src/mainboard/google/glados/spd/empty.spd.hex
src/mainboard/google/glados/spd/hynix_dimm_H9CCNNN8JTBLAR.spd.hex
src/mainboard/google/glados/spd/hynix_dimm_H9CCNNNBLTALAR.spd.hex
src/mainboard/google/glados/spd/samsung_dimm_K4E6E304EE-EGCF.spd.hex
src/mainboard/google/glados/spd/spd.c
src/mainboard/google/guado/lan.c
src/mainboard/google/jecht/lan.c
src/mainboard/google/lars/spd/empty.spd.hex
src/mainboard/google/lars/spd/hynix_dimm_H9CCNNN8JTBLAR-NUD-1G-1866.spd.hex
src/mainboard/google/lars/spd/hynix_dimm_H9CCNNNBLTBLAR-NUD-2G-1866.spd.hex
src/mainboard/google/lars/spd/samsung_dimm_K4E6E304EB-EGCF-2G-1866.spd.hex
src/mainboard/google/lars/spd/samsung_dimm_K4E8E324EB-EGCF-1G-1866.spd.hex
src/mainboard/google/lars/spd/spd.c
src/mainboard/google/link/elpida_4Gb_1600_x16.spd.hex
src/mainboard/google/link/hda_verb.c
src/mainboard/google/link/i915.c
src/mainboard/google/link/micron_4Gb_1600_1.35v_x16.spd.hex
src/mainboard/google/link/romstage.c
src/mainboard/google/link/samsung_4Gb_1600_1.35v_x16.spd.hex
src/mainboard/google/ninja/lan.c
src/mainboard/google/ninja/romstage.c
src/mainboard/google/ninja/spd/hynix_1GiB_dimm_H5TC2G63FFR-PBA.spd.hex
src/mainboard/google/ninja/spd/hynix_2GiB_dimm_H5TC4G63AFR-PBA.spd.hex
src/mainboard/google/ninja/spd/hynix_2GiB_dimm_H5TC4G63CFR-PBA.spd.hex
src/mainboard/google/ninja/spd/micron_1GiB_dimm_MT41K128M16JT-125.spd.hex
src/mainboard/google/ninja/spd/micron_2GiB_dimm_MT41K256M16HA-125.spd.hex
src/mainboard/google/panther/lan.c
src/mainboard/google/peach_pit/mainboard.c
src/mainboard/google/peppy/Elpida_EDJ4216EFBG.spd.hex
src/mainboard/google/peppy/Hynix_HMT425S6AFR6A.spd.hex
src/mainboard/google/peppy/Micron_4KTF25664HZ.spd.hex
src/mainboard/google/peppy/romstage.c
src/mainboard/google/rambi/romstage.c
src/mainboard/google/rambi/spd/hynix_1GiB_dimm_H5TC2G63FFR-PBA.spd.hex
src/mainboard/google/rambi/spd/hynix_2GiB_dimm_H5TC4G63AFR-PBA.spd.hex
src/mainboard/google/rambi/spd/micron_1GiB_dimm_MT41K128M16JT-125.spd.hex
src/mainboard/google/rambi/spd/micron_2GiB_dimm_MT41K256M16HA-125.spd.hex
src/mainboard/google/rikku/lan.c
src/mainboard/google/rotor/dram_params.c
src/mainboard/google/samus/romstage.c
src/mainboard/google/samus/spd/elpida_16.spd.hex
src/mainboard/google/samus/spd/elpida_4.spd.hex
src/mainboard/google/samus/spd/elpida_8.spd.hex
src/mainboard/google/samus/spd/empty.spd.hex
src/mainboard/google/samus/spd/hynix_16.spd.hex
src/mainboard/google/samus/spd/hynix_4.spd.hex
src/mainboard/google/samus/spd/hynix_8.spd.hex
src/mainboard/google/samus/spd/samsung_4.spd.hex
src/mainboard/google/samus/spd/samsung_8.spd.hex
src/mainboard/google/samus/spd/spd.c
src/mainboard/google/slippy/Hynix_HMT425S6AFR6A.spd.hex
src/mainboard/google/slippy/Micron_4KTF25664HZ.spd.hex
src/mainboard/google/slippy/variants/peppy/spd/Micron_4KTF25664HZ.spd.hex
src/mainboard/google/slippy/variants/peppy/spd/Elpida_EDJ4216EFBG.spd.hex
src/mainboard/google/slippy/variants/peppy/spd/Hynix_HMT425S6AFR6A.spd.hex
src/mainboard/google/slippy/variants/falco/spd/Micron_4KTF25664HZ.spd.hex
src/mainboard/google/slippy/variants/falco/spd/Elpida_EDJ4216EFBG.spd.hex
src/mainboard/google/slippy/variants/falco/spd/Samsung_M471B5674QH0.spd.hex
src/mainboard/google/slippy/variants/falco/spd/Hynix_HMT425S6AFR6A.spd.hex
src/mainboard/google/slippy/variants/leon/spd/Micron_4KTF25664HZ.spd.hex
src/mainboard/google/slippy/variants/leon/spd/Hynix_HMT425S6AFR6A.spd.hex
src/mainboard/google/slippy/variants/leon/spd/Samsung_K4B4G1646Q.spd.hex
src/mainboard/google/slippy/variants/wolf/spd/Micron_4KTF25664HZ.spd.hex
src/mainboard/google/slippy/variants/wolf/spd/Samsung_K4B4G1646B.spd.hex
src/mainboard/google/slippy/variants/wolf/spd/Hynix_HMT425S6AFR6A.spd.hex
src/mainboard/google/slippy/romstage.c
src/mainboard/google/tidus/lan.c
src/mainboard/hp/abm/mptable.c
src/mainboard/hp/dl165_g6_fam10/get_bus_conf.c
src/mainboard/hp/pavilion_m6_1035dx/mptable.c
src/mainboard/ibase/mb899/cmos.layout
src/mainboard/ibase/mb899/superio_hwm.c
src/mainboard/intel/amenia/romstage.c
src/mainboard/intel/apollolake_rvp/romstage.c
src/mainboard/intel/cougar_canyon2/Kconfig
src/mainboard/intel/kblrvp/spd/hynix_dimm_H9CCNNNBJTMLAR.spd.hex
src/mainboard/intel/kblrvp/spd/empty.spd.hex
src/mainboard/intel/kblrvp/spd/rvp3.spd.hex
src/mainboard/intel/kunimitsu/spd/empty.spd.hex
src/mainboard/intel/kunimitsu/spd/hynix_dimm_H9CCNNN8JTALAR-NUD-1G-1866.spd.hex
src/mainboard/intel/kunimitsu/spd/hynix_dimm_H9CCNNN8JTBLAR-NUD-1G-1866.spd.hex
src/mainboard/intel/kunimitsu/spd/hynix_dimm_H9CCNNNBLTALAR-NUD-2G-1866.spd.hex
src/mainboard/intel/kunimitsu/spd/hynix_dimm_H9CCNNNBLTBLAR-NUD-2G-1866.spd.hex
src/mainboard/intel/kunimitsu/spd/mic_dimm_EDF8132A3MA-JD-F-1G-1866.spd.hex
src/mainboard/intel/kunimitsu/spd/samsung_dimm_K4E6E304EE-EGCF-2G-1866.spd.hex
src/mainboard/intel/kunimitsu/spd/samsung_dimm_K4E8E304EE-EGCE.spd.hex
src/mainboard/intel/kunimitsu/spd/samsung_dimm_K4E8E304EE-EGCF-1G-1866.spd.hex
src/mainboard/intel/kunimitsu/spd/spd.c
src/mainboard/intel/minnowmax/Kconfig
src/mainboard/intel/mohonpeak/Kconfig
src/mainboard/intel/sklrvp/spd/empty.spd.hex
src/mainboard/intel/sklrvp/spd/rvp3.spd.hex
src/mainboard/intel/sklrvp/spd/spd.c
src/mainboard/intel/strago/Kconfig
src/mainboard/intel/strago/spd/hynix_2GiB_dimm_H5TC4G63AFR-PBA.spd.hex
src/mainboard/intel/strago/spd/hynix_2GiB_dimm_HMT425S6CFR6A_H5TC4G63CFR.spd.hex
src/mainboard/intel/strago/spd/samsung_2GiB_dimm_K4B4G1646Q-HYK0.spd.hex
src/mainboard/intel/strago/spd/spd.c
src/mainboard/intel/wtm2/i915.c
src/mainboard/jetway/nf81-t56n-lf/Kconfig
src/mainboard/kontron/986lcd-m/cmos.layout
src/mainboard/kontron/986lcd-m/mainboard.c
src/mainboard/lenovo/g505s/mptable.c
src/mainboard/lippert/frontrunner-af/Kconfig
src/mainboard/lippert/frontrunner-af/mptable.c
src/mainboard/lippert/toucan-af/Kconfig
src/mainboard/lippert/toucan-af/mptable.c
src/mainboard/msi/ms7721/mptable.c
src/mainboard/msi/ms9652_fam10/get_bus_conf.c
src/mainboard/packardbell/ms2290/mainboard.c
src/mainboard/pcengines/apu1/Kconfig
src/mainboard/samsung/lumpy/romstage.c
src/mainboard/siemens/mc_bdx1/mainboard.c
src/mainboard/siemens/mc_tcu3/lcd_panel.c
src/mainboard/siemens/mc_tcu3/mainboard.c
src/mainboard/siemens/mc_tcu3/modhwinfo.c
src/mainboard/siemens/mc_tcu3/romstage.c
src/mainboard/siemens/sitemp_g1p1/cmos.layout
src/mainboard/supermicro/h8dmr_fam10/get_bus_conf.c
src/mainboard/supermicro/h8qgi/buildOpts.c
src/mainboard/supermicro/h8qme_fam10/get_bus_conf.c
src/mainboard/supermicro/h8scm/buildOpts.c
src/mainboard/tyan/s2912_fam10/get_bus_conf.c
src/mainboard/tyan/s4880/irq_tables.c
src/mainboard/tyan/s4882/irq_tables.c
src/mainboard/tyan/s8226/buildOpts.c
src/northbridge/amd/agesa/common/common.c
src/northbridge/amd/amdk8/acpi.c
src/northbridge/amd/amdk8/coherent_ht.c
src/northbridge/amd/amdk8/raminit_test.c
src/northbridge/amd/amdmct/mct_ddr3/mcttmrl.c
src/northbridge/amd/amdmct/mct/mctardk3.c
src/northbridge/amd/amdmct/mct/mctardk4.c
src/northbridge/amd/amdmct/mct/mcttmrl.c
src/northbridge/amd/gx2/pll_reset.c
src/northbridge/amd/pi/00630F01/Kconfig
src/northbridge/amd/pi/00660F01/Kconfig
src/northbridge/amd/pi/00730F01/Kconfig
src/northbridge/intel/fsp_rangeley/fsp/Kconfig
src/northbridge/intel/fsp_sandybridge/fsp/Kconfig
src/northbridge/intel/gm45/raminit_rcomp_calibration.c
src/northbridge/intel/gm45/raminit_read_write_training.c
src/northbridge/intel/haswell/Kconfig
src/northbridge/intel/haswell/raminit.c
src/northbridge/intel/i82830/vga.c
src/northbridge/intel/i945/raminit.c
src/northbridge/intel/nehalem/gma.c
src/northbridge/intel/nehalem/raminit.c
src/northbridge/intel/nehalem/raminit_tables.c
src/northbridge/intel/pineview/raminit.c
src/northbridge/intel/sandybridge/gma.c
src/northbridge/intel/sandybridge/Kconfig
src/northbridge/intel/sandybridge/raminit.c
src/northbridge/intel/sandybridge/raminit_mrc.c
src/northbridge/intel/sandybridge/raminit_patterns.h
src/northbridge/intel/x4x/raminit_ddr2.c
src/northbridge/via/cx700/raminit.c
src/northbridge/via/vx800/ide.c
src/northbridge/via/vx800/uma_ram_setting.c
src/northbridge/via/vx900/sata.c
src/soc/broadcom/cygnus/ddr_init.c
src/soc/broadcom/cygnus/ddr_init_table.c
src/soc/intel/apollolake/Kconfig
src/soc/intel/apollolake/nhlt.c
src/soc/intel/baytrail/acpi.c
src/soc/intel/baytrail/Kconfig
src/soc/intel/baytrail/romstage/raminit.c
src/soc/intel/braswell/acpi.c
src/soc/intel/braswell/gpio.c
src/soc/intel/braswell/Kconfig
src/soc/intel/broadwell/acpi.c
src/soc/intel/broadwell/Kconfig
src/soc/intel/broadwell/romstage/raminit.c
src/soc/intel/common/fsp_ramstage.c
src/soc/intel/common/mma.c
src/soc/intel/common/vbt.c
src/soc/intel/fsp_baytrail/acpi.c
src/soc/intel/fsp_baytrail/fsp/Kconfig
src/soc/intel/fsp_baytrail/Kconfig
src/soc/intel/fsp_broadwell_de/fsp/chipset_fsp_util.c
src/soc/intel/fsp_broadwell_de/fsp/Kconfig
src/soc/intel/quark/Kconfig
src/soc/intel/quark/romstage/romstage.c
src/soc/intel/sch/Kconfig
src/soc/intel/skylake/Kconfig
src/soc/intel/skylake/nhlt/dmic.c
src/soc/intel/skylake/nhlt/max98357.c
src/soc/intel/skylake/nhlt/nau88l25.c
src/soc/intel/skylake/nhlt/ssm4567.c
src/soc/nvidia/tegra210/Kconfig
src/soc/nvidia/tegra210/mtc.c
src/soc/qualcomm/ipq40xx/Kconfig
src/soc/qualcomm/ipq40xx/lcc.c
src/soc/qualcomm/ipq806x/Kconfig
src/soc/qualcomm/ipq806x/lcc.c
src/soc/samsung/exynos5250/clock.c
src/soc/samsung/exynos5420/clock.c
src/southbridge/amd/agesa/hudson/Kconfig
src/southbridge/amd/cimx/sb800/Kconfig
src/southbridge/amd/pi/hudson/Kconfig
src/southbridge/intel/bd82x6x/Kconfig
src/southbridge/intel/bd82x6x/lpc.c
src/southbridge/intel/common/firmware/Kconfig
src/southbridge/intel/i82801ix/dmi_setup.c
src/southbridge/intel/ibexpeak/Kconfig
src/southbridge/intel/lynxpoint/Kconfig
src/southbridge/intel/sch/Kconfig
src/southbridge/nvidia/ck804/early_setup_ss.h
src/southbridge/nvidia/mcp55/early_setup_ss.h
src/southbridge/sis/sis966/early_setup_ss.h
src/southbridge/sis/sis966/early_smbus.c
src/southbridge/sis/sis966/ide.c
src/southbridge/sis/sis966/sata.c
src/southbridge/sis/sis966/usb2.c
src/southbridge/sis/sis966/usb.c
src/superio/via/vt1211/vt1211.c
src/vendorcode/amd/agesa/f10/Proc/CPU/Family/0x10/cpuF10Dmi.c
src/vendorcode/amd/agesa/f10/Proc/CPU/Family/0x10/cpuF10WheaInitDataTables.c
src/vendorcode/amd/agesa/f10/Proc/Mem/Main/muc.c
src/vendorcode/amd/agesa/f12/Proc/CPU/Family/0x10/cpuF10Dmi.c
src/vendorcode/amd/agesa/f12/Proc/CPU/Family/0x10/cpuF10WheaInitDataTables.c
src/vendorcode/amd/agesa/f12/Proc/CPU/Family/0x12/cpuF12Dmi.c
src/vendorcode/amd/agesa/f12/Proc/CPU/Family/0x12/cpuF12WheaInitDataTables.c
src/vendorcode/amd/agesa/f12/Proc/Fch/Hwm/Family/Hudson2/Hudson2HwmLateService.c
src/vendorcode/amd/agesa/f12/Proc/GNB/Gfx/Family/LN/F12GfxServices.c
src/vendorcode/amd/agesa/f12/Proc/Mem/Main/muc.c
src/vendorcode/amd/agesa/f14/Proc/CPU/Family/0x10/cpuF10Dmi.c
src/vendorcode/amd/agesa/f14/Proc/CPU/Family/0x10/cpuF10WheaInitDataTables.c
src/vendorcode/amd/agesa/f14/Proc/Mem/Main/muc.c
src/vendorcode/amd/agesa/f15/Proc/CPU/Family/0x10/cpuF10Dmi.c
src/vendorcode/amd/agesa/f15/Proc/CPU/Family/0x10/cpuF10WheaInitDataTables.c
src/vendorcode/amd/agesa/f15/Proc/CPU/Family/0x15/cpuF15WheaInitDataTables.c
src/vendorcode/amd/agesa/f15/Proc/Mem/Main/muc.c
src/vendorcode/amd/agesa/f15/Proc/Mem/Ps/OR/mpor3.c
src/vendorcode/amd/agesa/f15/Proc/Mem/Tech/DDR3/mtlrdimm3.c
src/vendorcode/amd/agesa/f15tn/Proc/CPU/Family/0x15/cpuF15WheaInitDataTables.c
src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbInitTN/GfxIntegratedInfoTableTN.c
src/vendorcode/amd/agesa/f15tn/Proc/GNB/Modules/GnbInitTN/GfxLibTN.c
src/vendorcode/amd/agesa/f15tn/Proc/Mem/Main/muc.c
src/vendorcode/amd/agesa/f15tn/Proc/Mem/Ps/TN/mptn3.c
src/vendorcode/amd/agesa/f15tn/Proc/Mem/Tech/DDR3/mtlrdimm3.c
src/vendorcode/amd/agesa/f16kb/Proc/CPU/Family/0x16/cpuF16WheaInitDataTables.c
src/vendorcode/amd/agesa/f16kb/Proc/GNB/Modules/GnbGfxIntTableV3/GfxLibV3.c
src/vendorcode/amd/agesa/f16kb/Proc/GNB/Modules/GnbInitKB/GnbF1TableKB.c
src/vendorcode/amd/agesa/f16kb/Proc/Mem/Main/muc.c
src/vendorcode/amd/agesa/f16kb/Proc/Mem/Ps/KB/mpkb3.c
src/vendorcode/amd/cimx/sb800/SATA.c
src/vendorcode/amd/pi/Kconfig
src/vendorcode/google/chromeos/build-snow
util/amdtools/example_input/lspci-cb-48G-667MHz-18.2-20090909e
util/amdtools/example_input/lspci-prop-48G-667MHz-18.2
util/autoport/readme.md
util/bimgtool/bimgtool.c
util/cbfstool/fmd_parser.c_shipped
util/cbfstool/fmd_scanner.c_shipped
util/cbfstool/linux_trampoline.c
util/cbfstool/lz4/lib/lz4.c
util/crossgcc/patches/binutils-2.25_riscv.patch
util/crossgcc/patches/gcc-5.2.0_riscv.patch
util/ifdtool/ifdtool.c
util/intelmetool/intelmetool.c
util/ipqheader/createxbl.py
util/kconfig/zconf.hash.c_shipped
util/kconfig/zconf.lex.c_shipped
util/kconfig/zconf.tab.c_shipped
util/mma/mma_automated_test.sh
util/mtkheader/gen-bl-img.py
util/nvidia/cbootimage/src/aes_ref.c
util/nvramtool/accessors/layout-bin.c
util/riscvtools/make-spike-elf.sh
util/rockchip/make_idb.py
util/romcc/do_tests.sh
util/romcc/test.sh
util/romcc/tests/include/linux_console.h
util/romcc/tests/linux_console.h
util/romcc/tests/linux_test5.c
util/romcc/tests/raminit_test6.c
util/romcc/tests/raminit_test7.c
util/romcc/tests/simple_test14.c
util/romcc/tests/simple_test30.c
util/romcc/tests/simple_test38.c
util/romcc/tests/simple_test39.c
util/romcc/tests/simple_test54.c
util/romcc/tests/simple_test59.c
util/romcc/tests/simple_test72.c
util/romcc/tests/simple_test73.c
util/sconfig/lex.yy.c_shipped
util/sconfig/sconfig.tab.c_shipped
util/superiotool/fintek.c
util/superiotool/ite.c
util/superiotool/nuvoton.c
util/superiotool/smsc.c
util/superiotool/winbond.c
util/xcompile/xcompile

path: projects/coreboot/configs/blobs-ignore


code:
.spd.hex files - serial presence detect. These are not blobs
see JEDEC standard or https://en.wikipedia.org/wiki/Serial_presence_detect
These are added to the nonblobs file

src/northbridge/intel/nehalem/raminit_tables.c"
src/northbridge/intel/sandybridge/raminit_patterns.h
These are used by native raminit for the relevant platforms, and are not blobs

"src/southbridge/nvidia/mcp55/early_setup_ss.h" \
"src/southbridge/nvidia/ck804/early_setup_ss.h" \
"src/southbridge/sis/sis966/early_setup_ss.h"
not blobs

The text in this file is CC-BY-SA 4.0 or higher. All contributions to it must
be made under the same license.


code:
jerry
mickey
minnie
speedy


path: projects/coreboot/configs/install


path: projects/coreboot/configs/revision


code: depthcharge

path: projects/coreboot/configs/targets


code:
#!/bin/bash

# Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

arguments() {
	project_arguments_targets "$project" "$@"
}

usage() {
	project_usage_actions "$project"
	project_usage_arguments "$project" "$@"
}

download() {
	local repository=$project

	project_download_git "$project" "$repository" "https://review.coreboot.org/coreboot https://github.com/coreboot/coreboot.git" "$@"
}

download_check() {
	local repository=$project

	project_download_check_git "$project" "$repository" "$@"
}

extract() {
	project_extract "$project" "$@"
}

extract_check() {
	project_extract_check "$project" "$@"
}

update() {
	local repository=$project

	project_update_git "$project" "$repository" "$@"
}

update_check() {
	local repository=$project

	project_update_check_git "$project" "$repository" "$@"
}

build() {
	local payload=$1
	shift

	local repository=$project

	project_sources_directory_missing_empty_error "$project" "$repository" "$payload" "$@"

	local sources_path=$( project_sources_path "$project" "$repository" "$payload" "$@" )
	local build_path=$( project_build_path "$project" "$payload" "$@" )
	local config_path=$( coreboot_config_path "$payload" "$@" )

	local arch=$( coreboot_arch "$payload" "$@" )

	local crossgcc_build_path=$( project_build_path "crossgcc" "$arch" )
	local crossgcc_bin_path="$crossgcc_build_path/bin/"
	local vboot_sources_path=$( project_sources_path "vboot" "vboot" "devices" )

	project_action "build" "crossgcc" "$arch"

	if git_project_check "$repository"
	then
		git_project_checkout "$project" "$repository" "$payload" "$@"
	fi

	project_action "checkout" "vboot" "devices"

	project_action "build" "$payload" "$@"

	if coreboot_ec_check "$payload" "$@"
	then
		ec=$( coreboot_ec "$payload" "$@" )

		project_action "build" "$ec" "$@"
	fi

	rm -f "$sources_path/.xcompile"

	mkdir -p "$build_path"

	make -C "$sources_path" obj="$build_path" DOTCONFIG="$build_path/.config" XGCCPATH="$crossgcc_bin_path" BUILD_TIMELESS=1 KERNELVERSION="$VERSION" KBUILD_DEFCONFIG="$config_path" "defconfig"
	make -C "$sources_path" obj="$build_path" DOTCONFIG="$build_path/.config" XGCCPATH="$crossgcc_bin_path" BUILD_TIMELESS=1 KERNELVERSION="$VERSION" VBOOT_SOURCE="$vboot_sources_path" -j$TASKS

	rm -f "$sources_path/.xcompile"
}

build_check() {
	project_build_check "$project" "$@"
}

install() {
	project_install "$project" "$@"
}

install_check() {
	project_install_check "$project" "$@"
}

release() {
	local repository=$project

	project_release_install_archive "$project" "$IMAGES" "$@"

	project_release_sources_git "$project" "$repository" "$@"
}

release_check() {
	local repository=$project

	project_release_install_archive_check "$project" "$IMAGES" "$@"

	project_release_check_sources_git "$project" "$repository" "$@"
}

clean() {
	project_clean "$project" "$@"
}

path: projects/coreboot/coreboot


code:
#!/bin/bash

# Copyright (C) 2016 Paul Kocialkowski <contact@paulk.fr>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

DEVICES="devices"
PAYLOADS="payloads"
CONFIG="config"
ARCH="arch"
EC="ec"

coreboot_arch() {
	project_file_contents "$project" "$CONFIGS" "$ARCH" "$@"
}

coreboot_config_path() {
	project_file_path "$project" "$CONFIGS" "$CONFIG" "$@"
}

coreboot_ec_check() {
	project_file_test "$project" "$CONFIGS" "$EC" "$@"
}

coreboot_ec() {
	project_file_contents "$project" "$CONFIGS" "$EC" "$@"
}

path: projects/coreboot/coreboot-helper