diff options
Diffstat (limited to 'libs')
-rwxr-xr-x | libs/common | 114 | ||||
-rwxr-xr-x | libs/git | 20 | ||||
-rwxr-xr-x | libs/project | 118 | ||||
-rwxr-xr-x | libs/tool | 16 |
4 files changed, 134 insertions, 134 deletions
diff --git a/libs/common b/libs/common index db72a974..b0cb5867 100755 --- a/libs/common +++ b/libs/common @@ -117,13 +117,13 @@ diff_patch_file() { local source_file_path - if ! ( grep -E '^-{3}.*/' "${patch_file_path}" >/dev/null 2>&1 ); then - source_file_path="${repository_path}/${filename_in_diff}" + if ! ( grep -E '^-{3}.*/' "$patch_file_path" >/dev/null 2>&1 ); then + source_file_path="$repository_path/$filename_in_diff" else - source_file_path="${repository_path}/${filename_in_diff##*/}" + source_file_path="$repository_path/${filename_in_diff##*/}" fi - patch "${source_file_path}" "${patch_file_path}" + patch "$source_file_path" "$patch_file_path" } path_wildcard_expand() { @@ -228,29 +228,29 @@ directory_filled_check() { 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}" - local epoch_path="${source_path}/${DOTEPOCH}" - local rnd_seed_path="${source_path}/${DOTRNDSEED}" + local directory="$(basename "$source_path")" + local tarfiles_path="$source_path/$DOTTARFILES" + local revision_path="$source_path/$DOTREVISION" + local version_path="$source_path/$DOTVERSION" + local epoch_path="$source_path/$DOTEPOCH" + local rnd_seed_path="$source_path/$DOTRNDSEED" - # Files in "${tarfiles_path}" are NUL terminated. + # Files in "$tarfiles_path" are NUL terminated. # `tr '\0' '\n'` for human-readable output. - if git_check "${source_path}"; then - git_files "${source_path}" > "${tarfiles_path}" - printf '%s\0' "${DOTTARFILES}" >> "${tarfiles_path}" + if git_check "$source_path"; then + git_files "$source_path" > "$tarfiles_path" + printf '%s\0' "$DOTTARFILES" >> "$tarfiles_path" else - find "${source_path}" -print0 | env LC_ALL='C.UTF-8' sort -z | sed -z "1d;s,^${source_path}/\\?,,;/^${DOTTARFILES}\$/d" > "${tarfiles_path}" + find "$source_path" -print0 | env LC_ALL='C.UTF-8' sort -z | sed -z "1d;s,^$source_path/\\?,,;/^$DOTTARFILES\$/d" > "$tarfiles_path" fi - for dotfile in "${revision_path}" \ - "${version_path}" \ - "${epoch_path}" \ - "${rnd_seed_path}" + for dotfile in "$revision_path" \ + "$version_path" \ + "$epoch_path" \ + "$rnd_seed_path" do - if [[ -f "${dotfile}" ]]; then - printf '%s\0' ".${dotfile##*.}" >> "${tarfiles_path}" + if [[ -f "$dotfile" ]]; then + printf '%s\0' ".${dotfile##*.}" >> "$tarfiles_path" fi done } @@ -258,10 +258,10 @@ archive_files_create() { archive_files_date() { local source_path="$1" - local epoch_path="${source_path}/${DOTEPOCH}" + local epoch_path="$source_path/$DOTEPOCH" - if [[ -n "${SOURCE_DATE_EPOCH}" ]]; then - find "${source_path}" -execdir touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" {} + + if [[ -n "$SOURCE_DATE_EPOCH" ]]; then + find "$source_path" -execdir touch --no-dereference --date="@$SOURCE_DATE_EPOCH" {} + fi } @@ -270,24 +270,24 @@ archive_create() { local source_path="$2" local directory="$3" - local tarfiles_path="${source_path}/${DOTTARFILES}" - local directory_path="$(dirname "${archive_path}")" + local tarfiles_path="$source_path/$DOTTARFILES" + local directory_path="$(dirname "$archive_path")" - mkdir -p "${directory_path}" + mkdir -p "$directory_path" - if [[ -z "${directory}" ]]; then - directory="$(basename "${source_path}")" + if [[ -z "$directory" ]]; then + directory="$(basename "$source_path")" fi - archive_files_create "${source_path}" - archive_files_date "${source_path}" + archive_files_create "$source_path" + archive_files_date "$source_path" local tar_options=( --create --xz - --file="${archive_path}" - --files-from="${tarfiles_path}" - --transform="s,^,${directory}/,S" + --file="$archive_path" + --files-from="$tarfiles_path" + --transform="s,^,$directory/,S" --no-recursion --warning=no-filename-with-nuls --null @@ -297,7 +297,7 @@ archive_create() { ) ( - cd "${source_path}" + cd "$source_path" tar "${tar_options[@]}" ) } @@ -306,31 +306,31 @@ archive_extract() { local archive_path="$1" local destination_path="$2" - if [[ -z "${destination_path}" ]]; then - destination_path="$(dirname "${archive_path}")" + if [[ -z "$destination_path" ]]; then + destination_path="$(dirname "$archive_path")" fi - tar -xf "${archive_path}" -ps -C "${destination_path}" + 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}" + local directory="$(basename "$source_path")" + local tarfiles_path="$source_path/$DOTTARFILES" - # Files in "${tarfiles_path}" are NUL terminated. + # Files in "$tarfiles_path" are NUL terminated. # `tr '\0' '\n'` for human-readable output. - execute_root find "${source_path}" -print0 | env LC_ALL='C.UTF-8' sort -z | sed -z "1d;s,^${source_path}/\\?,,;/^${DOTTARFILES}\$/d" > "${tarfiles_path}" + execute_root find "$source_path" -print0 | env LC_ALL='C.UTF-8' sort -z | sed -z "1d;s,^$source_path/\\?,,;/^$DOTTARFILES\$/d" > "$tarfiles_path" } rootfs_files_date() { local source_path="$1" - local epoch_path="${source_path}/${DOTEPOCH}" + local epoch_path="$source_path/$DOTEPOCH" - if [[ -n "${SOURCE_DATE_EPOCH}" ]]; then - execute_root find "${source_path}" -execdir touch --no-dereference --date="@${SOURCE_DATE_EPOCH}" {} + + if [[ -n "$SOURCE_DATE_EPOCH" ]]; then + execute_root find "$source_path" -execdir touch --no-dereference --date="@$SOURCE_DATE_EPOCH" {} + fi } @@ -339,23 +339,23 @@ rootfs_create() { local source_path="$2" local directory="$3" - local tarfiles_path="${source_path}/${DOTTARFILES}" - local directory_path="$(dirname "${rootfs_path}")" + local tarfiles_path="$source_path/$DOTTARFILES" + local directory_path="$(dirname "$rootfs_path")" - mkdir -p "${directory_path}" + mkdir -p "$directory_path" - if [[ -z "${directory}" ]]; then - directory="$(basename "${source_path}")" + if [[ -z "$directory" ]]; then + directory="$(basename "$source_path")" fi - rootfs_files_create "${source_path}" - rootfs_files_date "${source_path}" + rootfs_files_create "$source_path" + rootfs_files_date "$source_path" local tar_options=( --create --xz - --file="${rootfs_path}" - --files-from="${tarfiles_path}" + --file="$rootfs_path" + --files-from="$tarfiles_path" --no-recursion --warning=no-filename-with-nuls --null @@ -365,12 +365,12 @@ rootfs_create() { ) ( - cd "${source_path}" + cd "$source_path" execute_root tar "${tar_options[@]}" ) - execute_root chmod 644 "${rootfs_path}" - execute_root chown "${USER}:${USER}" "${rootfs_path}" + execute_root chmod 644 "$rootfs_path" + execute_root chown "$USER:$USER" "$rootfs_path" } requirements() { @@ -205,7 +205,7 @@ git_files() { local repository_path="$1" ( - cd "${repository_path}" + cd "$repository_path" # Reproducible sorting. git ls-files -z | env LC_ALL='C.UTF-8' sort -z ) @@ -231,23 +231,23 @@ git_project_patch_recursive() { 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}" + local repository_path="$(git_project_repository_path "$repository")" + local project_path="$(project_path "$project")" + local patches_path="$project_path/$PATCHES/$path" - if ! [[ -d "${patches_path}" ]]; then + if ! [[ -d "$patches_path" ]]; then return fi - if [[ "${path}" != "." ]]; then - git_project_patch_recursive "${project}" "${repository}" "${branch}" "$(dirname "${path}")" + if [[ "$path" != "." ]]; then + git_project_patch_recursive "$project" "$repository" "$branch" "$(dirname "$path")" fi - for patch in "${patches_path}"/[!.]*.@(patch|diff); do + for patch in "$patches_path"/[!.]*.@(patch|diff); do if [[ "${patch##*.}" == "patch" ]]; then - git_patch "${repository_path}" "${branch}" "${patch}" + git_patch "$repository_path" "$branch" "$patch" else - diff_patch_file "${repository_path}" "${patch}" + diff_patch_file "$repository_path" "$patch" fi done } diff --git a/libs/project b/libs/project index ab56feba..37a5973c 100755 --- a/libs/project +++ b/libs/project @@ -48,9 +48,9 @@ project_helper_include() { project_check() { local project="${1##*/}" - local project_path="$(project_path "${project}")" + local project_path="$(project_path "$project")" - if ! [[ -f "${project_path}/${project}" ]]; then + if ! [[ -f "$project_path/$project" ]]; then return 1 fi } @@ -79,14 +79,14 @@ project_action() { ( set +e - project_action_check "${action}" "${project}" "$@" + project_action_check "$action" "$project" "$@" - printf '%s\n' "Project ${project} ${action} (with ${arguments:-no argument})" >&2 + printf '%s\n' "Project $project $action (with ${arguments:-no argument})" >&2 - if "${action}" "$@"; then - printf '\n%s\n' "Project ${project} ${action} (with ${arguments:-no argument}) completed" >&2 + if "$action" "$@"; then + printf '\n%s\n' "Project $project $action (with ${arguments:-no argument}) completed" >&2 else - printf '\n%s\n' "Project ${project} ${action} (with ${arguments:-no argument}) failed" >&2 + printf '\n%s\n' "Project $project $action (with ${arguments:-no argument}) failed" >&2 return 1 fi ) @@ -105,8 +105,8 @@ project_action_check() { return 1 fi - for project_force in ${PROJECTS_FORCE}; do - if [[ "${project_force}" == "${project}" ]]; then + for project_force in $PROJECTS_FORCE; do + if [[ "$project_force" == "$project" ]]; then return 1 fi done @@ -124,11 +124,11 @@ project_action_helper() { local project="$1" shift - if ! function_check "${helper}"; then + if ! function_check "$helper"; then return 0 fi - "${helper}" "$@" + "$helper" "$@" } project_action_arguments() { @@ -137,10 +137,10 @@ 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() { @@ -165,18 +165,18 @@ project_action_arguments_verify_recursive() { return 0 fi - action_helper_arguments="$(project_action_helper 'arguments' "${project}" "$@")" + action_helper_arguments="$(project_action_helper 'arguments' "$project" "$@")" - if [[ -n "${action_helper_arguments}" ]]; then - test="$(printf '%s\n' "${action_helper_arguments}" | grep -e "^${argument}\$" || true)" + if [[ -n "$action_helper_arguments" ]]; then + test="$(printf '%s\n' "$action_helper_arguments" | grep -e "^$argument\$" || true)" - if [[ -z "${test}" ]]; then - printf '%s\n' "Invalid argument ${argument} for project ${project} action ${action}" >&2 + if [[ -z "$test" ]]; then + printf '%s\n' "Invalid argument $argument for project $project action $action" >&2 return 1 fi fi - project_action_arguments_verify_recursive "${action}" "${project}" "$@" + project_action_arguments_verify_recursive "$action" "$project" "$@" } project_action_arguments_recursive() { @@ -188,21 +188,21 @@ project_action_arguments_recursive() { local action_helper_arguments local argument - action_helper_arguments="$(project_action_helper 'arguments' "${project}" "$@" || true)" + action_helper_arguments="$(project_action_helper 'arguments' "$project" "$@" || true)" - if [[ -z "${action_helper_arguments}" ]]; then - project_action "${action}" "${project}" "$@" + if [[ -z "$action_helper_arguments" ]]; then + project_action "$action" "$project" "$@" else # This is to allow space characters in arguments. - local ifs_save="${IFS}" + local ifs_save="$IFS" local IFS=$'\n' - for argument in $(printf '%s\n' "${action_helper_arguments}") + for argument in $(printf '%s\n' "$action_helper_arguments") do - IFS="${ifs_save}" + IFS="$ifs_save" # Only a single argument at a time is returned by the helper. - project_action_arguments_recursive "${action}" "${project}" "$@" "${argument}" + project_action_arguments_recursive "$action" "$project" "$@" "$argument" done fi } @@ -213,22 +213,22 @@ project_action_projects() { 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 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}" + if [[ -f "$project_projects_action_path" ]]; then + path="$project_projects_action_path" else - path="${project_projects_path}" + path="$project_projects_path" fi # Multiple arguments can be read from the file. while read -r arguments; do - eval "project_action_arguments ${action} ${arguments}" - done < "${path}" + eval "project_action_arguments $action $arguments" + done < "$path" } project_path() { @@ -448,18 +448,18 @@ project_sources_prepare() { # Not implemented yet / May end up not being needed #project_sources_prepare_blobs - project_sources_prepare_patch "${project}" "${sources_path}" "$@" + project_sources_prepare_patch "$project" "$sources_path" "$@" } project_sources_prepare_patch() { local project="$1" local sources_path="$2" - local project_path="$(project_path "${project}")" - local patches_path="${project_path}/${PATCHES}" + local project_path="$(project_path "$project")" + local patches_path="$project_path/$PATCHES" - for patch in "${patches_path}"/[!.]*.@(patch|diff); do - diff_patch_file "${sources_path}" "${patch}" + for patch in "$patches_path"/[!.]*.@(patch|diff); do + diff_patch_file "$sources_path" "$patch" done } @@ -556,8 +556,8 @@ project_usage_actions() { ( for action in "${PROJECT_ACTIONS_GENERIC[@]}"; do - if function_check "${action}"; then - printf '%s\n' " ${action}" + if function_check "$action"; then + printf '%s\n' " $action" fi done ) @@ -567,7 +567,7 @@ project_usage_actions() { ( for action in "$@"; do - printf '%s\n' " ${action}" + printf '%s\n' " $action" done ) fi @@ -579,7 +579,7 @@ project_usage_arguments() { printf '\n%s\n' 'Arguments:' - project_usage_arguments_recursive "${project}" ' ' "$@" + project_usage_arguments_recursive "$project" ' ' "$@" } project_usage_arguments_recursive() { @@ -591,12 +591,12 @@ project_usage_arguments_recursive() { local action_helper_arguments local argument - action_helper_arguments="$(project_action_helper 'arguments' "${project}" "$@")" + action_helper_arguments="$(project_action_helper 'arguments' "$project" "$@")" - if [[ -n "${action_helper_arguments}" ]]; then - for argument in ${action_helper_arguments}; do - printf '%s\n' "${spacing}${argument}" - project_usage_arguments_recursive "${project}" " ${spacing}" "$@" "${argument}" + if [[ -n "$action_helper_arguments" ]]; then + for argument in $action_helper_arguments; do + printf '%s\n' "$spacing$argument" + project_usage_arguments_recursive "$project" " $spacing" "$@" "$argument" done fi } @@ -643,25 +643,25 @@ project_download_archive() { local archive="${archive_uri##*/}" local compress_fmt="${archive##*.tar}" - local directory_prefix="${root}/${SOURCES}" - local archive_path="${root}/${SOURCES}/${archive}" - local sources_path="${root}/${SOURCES}/${project}" + local directory_prefix="$root/$SOURCES" + local archive_path="$root/$SOURCES/$archive" + local sources_path="$root/$SOURCES/$project" if [[ "${compress_fmt#*.}" != "${ARCHIVE#*.}" ]]; then - ARCHIVE="tar${compress_fmt}" + ARCHIVE="tar$compress_fmt" fi # TODO: Split this code block into separate functions # Archive verification will be included at that point in time - if ! project_sources_directory_filled_check "${project}"; then - download_wrapper "${directory_prefix}" "${archive_uri}" "${archive_dsig_uri}" - archive_extract "${archive_path}" "${directory_prefix}" + if ! project_sources_directory_filled_check "$project"; then + download_wrapper "$directory_prefix" "$archive_uri" "$archive_dsig_uri" + archive_extract "$archive_path" "$directory_prefix" - mv "${archive_path%.tar*}" "${sources_path}" + mv "${archive_path%.tar*}" "$sources_path" fi # Patch the source, if necessary - project_sources_prepare "${project}" "${sources_path}" + project_sources_prepare "$project" "$sources_path" } project_download_check_archive() { @@ -669,7 +669,7 @@ project_download_check_archive() { local sources_path="$2" # TODO: Write the following function - #project_sources_archive_extract_check "${project}" "${sources_path}" + #project_sources_archive_extract_check "$project" "$sources_path" } project_extract() { @@ -46,9 +46,9 @@ tool_helper_include() { tool_check() { local tool="${1##*/}" - local tool_path="$(tool_path "${tool}")" + local tool_path="$(tool_path "$tool")" - if ! [[ -f "${tool_path}/${tool}" ]]; then + if ! [[ -f "$tool_path/$tool" ]]; then return 1 fi } @@ -204,18 +204,18 @@ tool_arguments_targets() { local tool="$1" shift - local tool_path="$(tool_path "${tool}")" - local targets_path="${tool_path}/${CONFIGS}" + local tool_path="$(tool_path "$tool")" + local targets_path="$tool_path/$CONFIGS" local argument for argument in "$@"; do - targets_path="${targets_path}/${argument}" + targets_path="$targets_path/$argument" done - targets_path="${targets_path}/${TARGETS}" + targets_path="$targets_path/$TARGETS" - if [[ -f "${targets_path}" ]]; then - cat "${targets_path}" + if [[ -f "$targets_path" ]]; then + cat "$targets_path" fi } |