aboutsummaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
Diffstat (limited to 'libs')
-rwxr-xr-xlibs/common7
-rwxr-xr-xlibs/git2
-rwxr-xr-xlibs/project261
3 files changed, 221 insertions, 49 deletions
diff --git a/libs/common b/libs/common
index 06b411e1..b1091e4f 100755
--- a/libs/common
+++ b/libs/common
@@ -117,6 +117,13 @@ diff_patch() {
patch -fd "$sources_path" -r - < "$patch_path"
}
+diff_patch_check() {
+ local sources_path=$1
+ local patch_path=$2
+
+ patch -sfd "$sources_path" --dry-run < "$patch_path" > /dev/null 2>&1
+}
+
path_wildcard_expand() {
local path=$@
diff --git a/libs/git b/libs/git
index 429d4783..2cde3dd3 100755
--- a/libs/git
+++ b/libs/git
@@ -312,7 +312,7 @@ git_project_patch_recursive() {
git_patch "$repository_path" "$branch" "$patch" || return 1
done
- if [[ $path != . ]]; then
+ if [[ -n $path && $path != . ]]; then
git_project_patch_recursive "$project" "$repository" "$branch" "$(dirname "$path")"
fi
}
diff --git a/libs/project b/libs/project
index 8f4ef233..d884556d 100755
--- a/libs/project
+++ b/libs/project
@@ -60,46 +60,114 @@ project_dependencies() {
local project=$1
shift
- local -a dependencies
- mapfile -t dependencies < <(project_file_contents_herit "$project" "$CONFIGS" "$DEPENDENCIES" "$@")
+ if [[ -n "${PROJECTS_FORCE[*]}" ]]; then
+ local expanded
+ local project_force
- if [[ -n ${dependencies[*]} ]]; then
- printf '%s\n' "${dependencies[@]}"
+ for project_force in "${PROJECTS_FORCE[@]}"; do
+ project_arguments_expand_recursive $project_force | while IFS='' read -r expanded; do
+ project_dependencies_sort $expanded
+ done
+ done
fi
+
+ project_dependencies_sort "$project" "$@" | head -n -1
}
-project_dependencies_check() {
+project_dependencies_collect() {
local project=$1
shift
- local -a dependencies
- mapfile -t dependencies < <(project_dependencies "$project" "$@")
+ local argument
+ local path
- local -i missing=0
+ for argument in "" "$@"; do
+ if [[ -z $argument ]]; then
+ path=$CONFIGS
+ else
+ path=$path/$argument
+ fi
+
+ project_file_contents "$project" "$path" "$DEPENDENCIES"
+ done
+
+ project_dependencies_collect_recursive "$project" "$@"
+}
+
+project_dependencies_collect_recursive() {
+ local project=$1
+ shift
+
+ local argument
+ local path
- for ((i = 0, nodeps = ${#dependencies[@]}; i < nodeps; ++i)); do
- local -a dependency=(${dependencies[i]})
+ for argument in "" "$@"; do
+ if [[ -z $argument ]]; then
+ path=$CONFIGS
+ else
+ path=$path/$argument
+ fi
+ done
- project_check "${dependency[0]}" || let ++missing
+ project_action_helper arguments "$project" "$@" | while IFS='' read -r argument; do
+ project_file_contents "$project" "$path/$argument" "$DEPENDENCIES"
+ project_dependencies_collect_recursive "$project" "$@" "$argument"
done
+}
- return $missing
+project_dependencies_encode_recursive() {
+ local project=$1
+ shift
+
+ local project_arguments=$(arguments_concat ' ' "$project" "$@")
+ local project_arguments_encoded=$(base64 -w0 <<< "$project_arguments")
+
+ local dependency
+
+ project_dependencies_collect "$project" "$@" | while IFS='' read -r dependency; do
+ local dependency_arguments=$(arguments_concat ' ' $dependency)
+ local dependency_arguments_encoded=$(base64 -w0 <<< "$dependency_arguments")
+
+ printf '%s\n' "$project_arguments_encoded $dependency_arguments_encoded"
+
+ project_dependencies_encode_recursive $dependency
+ done
}
-project_dependencies_sources_check() {
+project_dependencies_sort() {
local project=$1
shift
- local -a dependencies
- mapfile -t dependencies < <(project_dependencies "$project" "$@")
+ (
+ set -o pipefail
+
+ project_dependencies_encode_recursive "$project" "$@" | tsort | base64 -d -w0 | tac
+ )
+}
+project_dependencies_check() {
+ local project=$1
+ shift
+
+ local dependency
local -i missing=0
- for ((i = 0, nodeps = ${#dependencies[@]}; i < nodeps; ++i)); do
- local -a dependency=(${dependencies[i]})
+ project_dependencies "$project" "$@" | while read -r dependency; do
+ project_check $dependency || let ++missing
+ done
+
+ return $missing
+}
+
+project_dependencies_sources_check() {
+ local project=$1
+ shift
+
+ local dependency
+ local -i missing=0
- project_sources_directory_filled_check "${dependency[0]}" ||
- let ++missing
+ project_dependencies "$project" "$@" | while read -r dependency; do
+ project_sources_directory_filled_check $dependency || let ++missing
done
return $missing
@@ -110,12 +178,9 @@ project_dependencies_action_arguments() {
local project=$2
shift 2
- local -a dependencies
- mapfile -t dependencies < <(project_dependencies "$project" "$@")
-
- for ((i = 0, nodeps = ${#dependencies[@]}; i < nodeps; ++i)); do
- local -a dependency=(${dependencies[i]})
+ local -a dependency
+ project_dependencies "$project" "$@" | while read -ra dependency; do
if project_function_check "${dependency[0]}" "$action"; then
project_action_arguments "$action" "${dependency[@]}"
fi
@@ -126,14 +191,13 @@ project_function_check() {
local project=$1
local function=$2
- project_include "$project"
-
- if ! function_check "$function"
- then
- return 1
- fi
+ (
+ project_include "$project"
- return 0
+ if ! function_check "$function"; then
+ exit 1
+ fi
+ )
}
project_action() {
@@ -153,6 +217,8 @@ project_action() {
printf '%s\n' "Project $project $action (with ${arguments:-no argument})"
(
+ set -e
+
"$action" "$@"
)
@@ -201,11 +267,15 @@ project_action_helper() {
local project="$1"
shift
- if ! function_check "$helper"; then
- return 0
- fi
+ (
+ project_include "$project"
- "$helper" "$@"
+ if ! function_check "$helper"; then
+ exit 0
+ fi
+
+ "$helper" "$@"
+ )
}
project_action_arguments() {
@@ -214,10 +284,12 @@ project_action_arguments() {
local project="$1"
shift
- project_include "$project"
+ (
+ project_include "$project"
- project_action_arguments_verify_recursive "$action" "$project" "$@"
- project_action_arguments_recursive "$action" "$project" "$@"
+ project_action_arguments_verify_recursive "$action" "$project" "$@"
+ project_action_arguments_recursive "$action" "$project" "$@"
+ )
}
project_action_arguments_verify_recursive() {
@@ -308,6 +380,17 @@ project_action_projects() {
done < "$path"
}
+project_action_usage() {
+ local project=$1
+ shift
+
+ (
+ project_include "$project"
+
+ project_action usage "$project" "$@"
+ )
+}
+
project_path() {
local project=$1
@@ -521,23 +604,75 @@ project_sources_archive_missing_check() {
project_sources_prepare() {
local project="$1"
- local sources_path="$2"
+ shift
+
+ project_sources_prepare_blobs "$project" "$@"
+ project_sources_prepare_patch "$project" "$@"
+}
+
+project_sources_prepare_blobs() {
+ local project=$1
+ shift
- # Not implemented yet / May end up not being needed
- #project_sources_prepare_blobs
- project_sources_prepare_patch "$project" "$sources_path" "$@"
+ local sources_path=$(project_sources_path "$project" "$project" "$@")
+
+ (
+ cd "$sources_path" || exit 1
+
+ project_blobs "$project" "$@" | while IFS='' read -r blob; do
+ rm -f -- "$blob"
+ done
+ )
}
project_sources_prepare_patch() {
local project="$1"
- local sources_path="$2"
+ shift
- local project_path="$(project_path "$project")"
- local patches_path="$project_path/$PATCHES"
+ local argument
+ local path
+
+ for argument in "$@"; do
+ if [[ -z $path ]]; then
+ path=$argument
+ else
+ path=$path/$argument
+ fi
+ done
+
+ if [[ -n $project ]]; then
+ project_sources_patch_recursive "$project" "$path"
+ fi
+}
+
+project_sources_prepare_check() {
+ local project=$1
+ shift
+
+ local sources_path=$(project_sources_path "$project" "$project" "$@")
+
+ directory_filled_check "$sources_path"
+}
+
+project_sources_patch_recursive() {
+ local project=$1
+ local path=$2
+
+ local project_path=$(project_path "$project")
+ local sources_path=$(project_sources_path "$project" "$project" "$@")
+ local patches_path=$project_path/$PATCHES/$path
+
+ if ! [[ -d $project_path/$PATCHES ]]; then
+ return 0
+ fi
for patch in "$patches_path"/[!.]*.@(patch|diff); do
- diff_patch "$sources_path" "$patch"
+ project_sources_patch "$sources_path" "$patch" || return 1
done
+
+ if [[ -n $path && $path != . ]]; then
+ project_sources_patch_recursive "$project" "$(dirname "$path")"
+ fi
}
project_blobs() {
@@ -556,6 +691,17 @@ project_blobs() {
fi
}
+project_sources_patch() {
+ local sources_path=$1
+ local patch_path=$2
+
+ if diff_patch_check "$sources_path" "$patch_path"; then
+ diff_patch "$sources_path" "$patch_path"
+ else
+ return 1
+ fi
+}
+
project_blobs_path() {
local project=$1
shift
@@ -639,6 +785,26 @@ project_arguments_targets() {
fi
}
+project_arguments_expand_recursive() {
+ local project=$1
+ shift
+
+ local -a arguments
+ readarray -t arguments < <(project_action_helper arguments "$project" "$@")
+
+ if [[ -z "${arguments[*]}" ]]; then
+ echo "$project" "$@"
+
+ return 0
+ fi
+
+ local argument
+
+ for argument in "${arguments[@]}"; do
+ project_arguments_expand_recursive "$project" "$@" "$argument"
+ done
+}
+
project_usage_actions() {
local project="$1"
shift
@@ -751,8 +917,7 @@ project_download_archive() {
mv "${archive_path%.tar*}" "$sources_path"
fi
- # Patch the source, if necessary
- project_sources_prepare "$project" "$sources_path"
+ project_sources_prepare "$project"
}
project_download_check_archive() {