diff options
Diffstat (limited to 'libs')
-rwxr-xr-x | libs/common | 20 | ||||
-rwxr-xr-x | libs/git | 4 | ||||
-rwxr-xr-x | libs/project | 102 | ||||
-rwxr-xr-x | libs/tool | 36 |
4 files changed, 81 insertions, 81 deletions
diff --git a/libs/common b/libs/common index 513d697c..bcae2a9d 100755 --- a/libs/common +++ b/libs/common @@ -60,7 +60,7 @@ arguments_list() { for argument in "$@" do - echo "$argument" + env printf '%s\n' "$argument" done } @@ -85,7 +85,7 @@ path_wildcard_expand() { local path=$@ # Evaluation fails with unescaped whitespaces. - path=$( echo "$path" | sed "s/ /\\\ /g" ) + path=$( env printf '%s\n' "$path" | sed "s/ /\\\ /g" ) eval "arguments_list "$path"" } @@ -112,7 +112,7 @@ file_checksum_check() { if ! [ -f "$checksum_path" ] then - printf "Could not verify file checksum!\n" >&2 + env printf '%s\n' 'Could not verify file checksum!' >&2 return 1 fi @@ -142,7 +142,7 @@ file_signature_check() { if ! [ -f "$signature_path" ] then - printf "Could not verify file signature!\n" >&2 + env printf '%s\n' 'Could not verify file signature!' >&2 return 1 fi @@ -336,7 +336,7 @@ requirements() { if [ -z "$requirement_path" ] then - printf "Missing requirement: $requirement\n" >&2 + env printf '%s\n' "Missing requirement: $requirement" >&2 exit 1 fi done @@ -353,7 +353,7 @@ requirements_root() { if [ -z "$requirement_path" ] then - printf "Missing requirement: $requirement\n" >&2 + env printf '%s\n' "Missing requirement: $requirement" >&2 exit 1 fi done @@ -375,22 +375,22 @@ arguments_concat() { fi done - echo "$concat" + env printf '%s\n' "$concat" } execute_root() { local sudo=$( which sudo 2> /dev/null || true ) local arguments - printf "Running command as root: " >&2 - echo "$@" >&2 + env printf '%s' 'Running command as root: ' >&2 + env printf '%b\n' "$*" >&2 if ! [ -z "$sudo" ] then sudo "$@" else # Quote arguments for eval through su. - arguments=$( printf "%q " "$@" ) + arguments=$( env printf '%q ' "$@" ) su -c "$arguments" fi } @@ -214,7 +214,7 @@ git_files() { git_project_repository_path() { local repository=$1 - echo "$root/$SOURCES/$repository" + env printf '%s\n' "$root/$SOURCES/$repository" } git_project_check() { @@ -582,7 +582,7 @@ git_project_release() { 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" + env printf '%s\n' "Releasing sources archive for $project (with ${arguments:-no argument}) from "$repository" git" git_branch_checkout "$repository_path" "$release_branch" git_submodule_update "$repository_path" diff --git a/libs/project b/libs/project index 20a6fe77..b8d7862b 100755 --- a/libs/project +++ b/libs/project @@ -17,7 +17,7 @@ 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" ) +PROJECT_FUNCTIONS=$( for action in $PROJECT_ACTIONS_GENERIC ; do env printf '%s\n' "$action" "$action""_check" ; done ; env printf '%s\n' "$PROJECT_ACTIONS_HELPERS" ) INSTALL_REGEX="\([^:]*\):\(.*\)" @@ -81,7 +81,7 @@ project_action() { if ! project_check "$project" then - printf "Project $project check failed\n" >&2 + env printf '%s\n' "Project $project check failed" >&2 return 1 fi @@ -100,7 +100,7 @@ project_action() { return 0 fi - printf "Project $project $action (with ${arguments:-no argument})\n" >&2 + env printf '%s\n' "Project $project $action (with ${arguments:-no argument})" >&2 ( set -e @@ -109,10 +109,10 @@ project_action() { if [ $? -ne 0 ] then - printf "\nProject $project $action (with ${arguments:-no argument}) failed\n" >&2 + env printf '\n%s\n' "Project $project $action (with ${arguments:-no argument}) failed" >&2 return 1 else - printf "\nProject $project $action (with ${arguments:-no argument}) completed\n" >&2 + env printf '\n%s\n' "Project $project $action (with ${arguments:-no argument}) completed" >&2 fi ) } @@ -128,7 +128,7 @@ project_action_check() { if ! project_check "$project" then - printf "Project $project check failed\n" >&2 + env printf '%s\n' "Project $project check failed" >&2 return 1 fi @@ -165,7 +165,7 @@ project_action_helper() { if ! project_check "$project" then - printf "Project $project check failed\n" >&2 + env printf '%s\n' "Project $project check failed" >&2 return 1 fi @@ -221,11 +221,11 @@ project_action_arguments_verify_recursive() { if ! [ -z "$action_helper_arguments" ] then - test=$( echo "$action_helper_arguments" | grep -P "^$argument$" || true ) + test=$( env printf '%s\n' "$action_helper_arguments" | grep -P "^$argument$" || true ) if [ -z "$test" ] then - printf "Invalid argument $argument for project $project action $action\n" >&2 + env printf '%s\n' "Invalid argument $argument for project $project action $action" >&2 return 1 fi fi @@ -253,7 +253,7 @@ project_action_arguments_recursive() { ifs_save=$IFS IFS=$'\n' - for argument in $( echo "$action_helper_arguments" ) + for argument in $( env printf '%s\n' "$action_helper_arguments" ) do ( IFS=$ifs_save @@ -298,7 +298,7 @@ project_path() { local project_path="$root/$PROJECTS/$project" - echo "$project_path" + env printf '%s\n' "$project_path" } project_sources_path() { @@ -331,7 +331,7 @@ project_sources_path() { if ! [ -z "$sources_path" ] then - echo "$sources_path" + env printf '%s\n' "$sources_path" return fi @@ -340,7 +340,7 @@ project_sources_path() { if directory_filled_check "$path" then - echo "$path" + env printf '%s\n' "$path" return fi @@ -364,7 +364,7 @@ project_sources_path() { if ! [ -z "$sources_path" ] then - echo "$sources_path" + env printf '%s\n' "$sources_path" return fi } @@ -387,7 +387,7 @@ project_sources_directory_filled_error() { if ! [ -z "$sources_path" ] then - printf "Sources directory for project $project (with ${arguments:-no argument}) already exists\n" >&2 + env printf '%s\n' "Sources directory for project $project (with ${arguments:-no argument}) already exists" >&2 return 1 else return 0 @@ -403,7 +403,7 @@ project_sources_directory_missing_empty_error() { if [ -z "$sources_path" ] then - printf "Sources directory for project $project (with ${arguments:-no argument}) missing or empty\n" >&2 + env printf '%s\n' "Sources directory for project $project (with ${arguments:-no argument}) missing or empty" >&2 return 1 else return 0 @@ -437,7 +437,7 @@ project_sources_archive() { if ! [ -z "$sources_archive" ] then - echo "$sources_archive" + env printf '%s\n' "$sources_archive" fi } @@ -449,7 +449,7 @@ project_sources_archive_extract() { local archive=$( project_sources_archive "$project" "$@" ) local destination=$( dirname "$archive" ) - printf "Extracting source archive for $project (with ${arguments:-no argument})\n" + env printf '%s\n' "Extracting source archive for $project (with ${arguments:-no argument})" file_verification_check "$archive" archive_extract "$archive" "$destination" @@ -470,7 +470,7 @@ project_sources_archive_update() { rm -rf "$sources_path" fi - printf "Extracting source archive for $project (with ${arguments:-no argument})\n" + env printf '%s\n' "Extracting source archive for $project (with ${arguments:-no argument})" file_verification_check "$archive" archive_extract "$archive" "$destination" @@ -484,7 +484,7 @@ project_sources_archive_missing_error() { local archive=$( project_sources_archive "$project" "$@" ) if [ -z "$archive" ] || ! [ -f "$archive" ] then - printf "Missing sources archive for $project (with ${arguments:-no argument})\n" >&2 + env printf '%s\n' "Missing sources archive for $project (with ${arguments:-no argument})" >&2 return 1 else return 0 @@ -529,12 +529,12 @@ project_blobs_path() { if [ -f "$blobs_path" ] then - echo "$blobs_path" + env printf '%s\n' "$blobs_path" return fi done - echo "$blobs_path" + env printf '%s\n' "$blobs_path" } project_blobs_ignore_path() { @@ -562,7 +562,7 @@ project_blobs_ignore_path() { if [ -f "$blobs_ignore_path" ] then - echo "$blobs_ignore_path" + env printf '%s\n' "$blobs_ignore_path" return fi done @@ -593,23 +593,23 @@ project_usage_actions() { local project=$1 shift - printf "\nGeneric actions:\n" + env printf '\n%s\n' 'Generic actions:' for action in $PROJECT_ACTIONS_GENERIC do if function_check "$action" then - printf " $action\n" + env printf '%s\n' " $action" fi done if [ $# -gt 0 ] then - printf "\nSpecific actions:\n" + env printf '\n%s\n' 'Specific actions:' for action in "$@" do - printf " $action\n" + env printf '%s\n' " $action" done fi } @@ -618,7 +618,7 @@ project_usage_arguments() { local project=$1 shift - printf "\nArguments:\n" + env printf '\n%s\n' 'Arguments:' project_usage_arguments_recursive "$project" " " "$@" } @@ -636,9 +636,9 @@ project_usage_arguments_recursive() { if ! [ -z "$action_helper_arguments" ] then - echo "$action_helper_arguments" | while read argument + env printf '%s\n' "$action_helper_arguments" | while read argument do - printf "$spacing$argument\n" + env printf '%s\n' "$spacing$argument" project_usage_arguments_recursive "$project" " $spacing" "$@" "$argument" done fi @@ -769,7 +769,7 @@ project_build_check() { while read rule do - source=$( echo "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) + source=$( env printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) source_path="$build_path/$source" # Source may contain a wildcard. @@ -796,7 +796,7 @@ project_build_path() { build_path="$build_path-$argument" done - echo "$build_path" + env printf '%s\n' "$build_path" } project_build_directory_missing_empty_error() { @@ -808,7 +808,7 @@ project_build_directory_missing_empty_error() { if ! directory_filled_check "$build_path" then - printf "Build directory for project $project (with ${arguments:-no argument}) missing or empty\n" >&2 + env printf '%s\n' "Build directory for project $project (with ${arguments:-no argument}) missing or empty" >&2 return 1 else return 0 @@ -851,10 +851,10 @@ project_install() { while read rule do - source=$( echo "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) + source=$( env printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) source_path="$build_path/$source" - destination=$( echo "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) + destination=$( env printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) destination_path="$install_path/$destination" destination_directory_path=$( dirname "$destination_path" ) @@ -892,10 +892,10 @@ project_install() { while read rule do - source=$( echo "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) + source=$( env printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\1/g" ) source_path="$project_path/$INSTALL/$path/$source" - destination=$( echo "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) + destination=$( env printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) destination_path="$install_path/$destination" destination_directory_path=$( dirname "$destination_path" ) @@ -945,7 +945,7 @@ project_install_check() { while read rule do - destination=$( echo "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) + destination=$( env printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) destination_path="$install_path/$destination" if ! [ -f "$destination_path" ] && ! [ -d "$destination_path" ] @@ -979,7 +979,7 @@ project_install_check() { while read rule do - destination=$( echo "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) + destination=$( env printf '%s\n' "$rule" | sed "s/$INSTALL_REGEX/\2/g" ) destination_path="$install_path/$destination" if ! [ -f "$destination_path" ] && ! [ -d "$destination_path" ] @@ -1002,7 +1002,7 @@ project_install_path() { install_path="$install_path-$argument" done - echo "$install_path" + env printf '%s\n' "$install_path" } project_install_directory_missing_empty_error() { @@ -1014,7 +1014,7 @@ project_install_directory_missing_empty_error() { if ! directory_filled_check "$install_path" then - printf "Install directory for project $project (with ${arguments:-no argument}) missing or empty\n" >&2 + env printf '%s\n' "Install directory for project $project (with ${arguments:-no argument}) missing or empty" >&2 return 1 else return 0 @@ -1038,7 +1038,7 @@ project_release_path() { release_path="$release_path/$project" fi - echo "$release_path" + env printf '%s\n' "$release_path" } project_release_archive_path() { @@ -1058,7 +1058,7 @@ project_release_archive_path() { local archive_path="$release_path/$path.$TAR_XZ" - echo "$archive_path" + env printf '%s\n' "$archive_path" } project_release_rootfs_path() { @@ -1078,7 +1078,7 @@ project_release_rootfs_path() { local rootfs_path="$release_path/$path.$TAR_XZ" - echo "$rootfs_path" + env printf '%s\n' "$rootfs_path" } project_release_sources_archive_path() { @@ -1111,7 +1111,7 @@ project_release_sources_archive_path() { then local archive_path="$root/$RELEASE/$SOURCES/$project/$release_path.$TAR_XZ" - echo "$archive_path" + env printf '%s\n' "$archive_path" fi } @@ -1124,7 +1124,7 @@ project_release_sources_archive_create() { 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" + env printf '%s\n' "Releasing sources archive for $project (with ${arguments:-no argument})" archive_create "$archive_path" "$sources_path" file_verification_create "$archive_path" @@ -1199,7 +1199,7 @@ project_release_install() { local files=$( cd "$install_path" && find -type f || true ) local file - echo "$files" | while read file + env printf '%s\n' "$files" | while read file do path="$release_path/$file" directory_path=$( dirname "$path" ) @@ -1226,7 +1226,7 @@ project_release_install_check() { local files=$( cd "$install_path" && find -type f || true ) local file - echo "$files" | while read file + env printf '%s\n' "$files" | while read file do path="$release_path/$file" @@ -1262,7 +1262,7 @@ project_release_install_archive_create() { 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" + env printf '%s\n' "Releasing $prefix archive for $project (with ${arguments:-no argument})" archive_create "$archive_path" "$install_path" file_verification_create "$archive_path" @@ -1310,7 +1310,7 @@ project_release_install_rootfs_create() { 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" + env printf '%s\n' "Releasing $prefix rootfs for $project (with ${arguments:-no argument})" rootfs_create "$rootfs_path" "$install_path" file_verification_create "$rootfs_path" @@ -1421,7 +1421,7 @@ project_file_path() { return 1 fi - echo "$file_path" + env printf '%s\n' "$file_path" } project_file_test() { @@ -17,7 +17,7 @@ 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_FUNCTIONS=$( for action in $TOOL_ACTIONS_GENERIC ; do env printf '%s\n' "$action" "$action""_check" ; done ; env printf '%s\n' "$TOOL_ACTIONS_HELPERS" ) tool_include() { local tool=$1 @@ -79,7 +79,7 @@ tool_action() { if ! tool_check "$tool" then - printf "Tool $tool check failed\n" >&2 + env printf '%s\n' "Tool $tool check failed" >&2 return 1 fi @@ -97,7 +97,7 @@ tool_action() { return 0 fi - printf "Tool $tool $action (with ${arguments:-no argument})\n" >&2 + env printf '%s\n' "Tool $tool $action (with ${arguments:-no argument})" >&2 ( set -e @@ -106,10 +106,10 @@ tool_action() { if [ $? -ne 0 ] then - printf "\nTool $tool $action (with ${arguments:-no argument}) failed\n" >&2 + env printf '\n%s\n' "Tool $tool $action (with ${arguments:-no argument}) failed" >&2 return 1 else - printf "\nTool $tool $action (with ${arguments:-no argument}) completed\n" >&2 + env printf '\n%s\n' "Tool $tool $action (with ${arguments:-no argument}) completed" >&2 fi ) } @@ -125,7 +125,7 @@ tool_action_check() { if ! tool_check "$tool" then - printf "Tool $tool check failed\n" >&2 + env printf '%s\n' "Tool $tool check failed" >&2 return 1 fi @@ -162,7 +162,7 @@ tool_action_helper() { if ! tool_check "$tool" then - printf "Tool $tool check failed\n" >&2 + env printf '%s\n' "Tool $tool check failed" >&2 return 1 fi @@ -193,7 +193,7 @@ tool_action_arguments_recursive() { then tool_action "$action" "$tool" "$@" else - echo "$action_helper_arguments" | while read argument + env printf '%s\n' "$action_helper_arguments" | while read argument do tool_action_arguments_recursive "$action" "$tool" "$@" "$argument" done @@ -205,7 +205,7 @@ tool_path() { local tool_path="$root/$TOOLS/$tool" - echo "$tool_path" + env printf '%s\n' "$tool_path" } tool_sources_path() { @@ -224,7 +224,7 @@ tool_sources_path() { if directory_filled_check "$path" then - echo "$path" + env printf '%s\n' "$path" return fi done @@ -234,23 +234,23 @@ tool_usage_actions() { local tool=$1 shift - printf "\nGeneric actions:\n" + env printf '\n%s\n' 'Generic actions:' for action in $TOOL_ACTIONS_GENERIC do if function_check "$action" then - printf " $action\n" + env printf '%s\n' " $action" fi done if [ $# -gt 0 ] then - printf "\nSpecific actions:\n" + env printf '\n%s\n' 'Specific actions:' for action in "$@" do - printf " $action\n" + env printf '%s\n' " $action" done fi } @@ -259,7 +259,7 @@ tool_usage_arguments() { local tool=$1 shift - printf "\nArguments:\n" + env printf '\n%s\n' 'Arguments:' tool_usage_arguments_recursive "$tool" " " "$@" } @@ -275,9 +275,9 @@ tool_usage_arguments_recursive() { if ! [ -z "$action_helper_arguments" ] then - echo "$action_helper_arguments" | while read argument + env printf '%s\n' "$action_helper_arguments" | while read argument do - printf "$spacing$argument\n" + env printf '%s\n' "$spacing$argument" tool_usage_arguments_recursive "$tool" " $spacing" "$@" "$argument" done fi @@ -316,7 +316,7 @@ tool_file_path() { return 1 fi - echo "$file_path" + env printf '%s\n' "$file_path" } tool_file_test() { |