diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-04-20 23:05:42 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-05-04 14:30:02 -0400 |
commit | 7d584af432202470d9d8fefd74a7f7ed044c4ab3 (patch) | |
tree | 0db3e165bd055a5f56c1a8548333b0dc87c27774 /src/dagpkg | |
parent | 2ae5371f347603d34a7ccc33681e612db338d11e (diff) |
random tidy up
Diffstat (limited to 'src/dagpkg')
-rwxr-xr-x | src/dagpkg | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -28,7 +28,6 @@ set -e # Globals: # - temp_dir -# - log # - name (sort of, it's also local to visit_pkgbuild() ) # - prev # - I @@ -77,8 +76,8 @@ source_pkgbuild() { # Visit a PKGBUILD for graph building. visit_pkgbuild() { - # The name of the previous package - prev="${1}" + log=$1 # The file to appund our results to + prev=$2 # The name of the previous package local name source_pkgbuild @@ -114,7 +113,7 @@ visit_pkgbuild() { local d w for d in "${depends[@]}" "${makedepends[@]}" "${checkdepends[@]}"; do # Cleanup dependency versions - d=${d%%<*}; d=${d%%>*}; d=${d%%=*} + d=${d%%[<>=]*} # Where's the pkgbuild? w=$(toru-where "$d") @@ -125,7 +124,7 @@ visit_pkgbuild() { # Go to this dir pushd "$w" &>/dev/null - visit_pkgbuild "$name" + visit_pkgbuild "$log" "$name" popd &>/dev/null done @@ -151,27 +150,28 @@ main() { source_pkgbuild # A temporary work dir and log file - temp_dir="${1:-$(mktemp -dt ${name}-testpkg-XXXX)}" - log="${temp_dir}/buildorder" + temp_dir="${1:-$(mktemp -dt "${name}-testpkg-XXXX")}" + local log="${temp_dir}/buildorder" # Mark array for DFS-based topological sort. See # https://en.wikipedia.org/wiki/Topological_sort for an explanation of # the algorithm. Key: package name, value: 0 for unvisited package, 1 # during visit, 2 after visit. - declare -A marks + declare -gA marks # If we specified a work dir on the cli it means we want to skip # dependency graph creation and jump to build whatever is there if [ -z "${1}" ]; then # Visit the root PKGBUILD to make the graph. - visit_pkgbuild "" + visit_pkgbuild "$log" "" else msg "Resuming build..." fi # enter work dir pushd "${temp_dir}" &>/dev/null - nl ${log} | while read order pkg; do + local w + while read -r order pkg; do # skip if already built if test -f "${pkg}/built_ok"; then warning "tried to build %s twice" "%{pkg}" @@ -179,7 +179,7 @@ main() { fi # where's this package? - local w="$(toru-where "$pkg")" + w="$(toru-where "$pkg")" test -z "$w" && continue # copy to work dir if not already @@ -191,7 +191,7 @@ main() { term_title "%s(%s)" "$pkg" "$order" - msg "Building %s" ${pkg} + msg "Building %s" "${pkg}" # upgrade the system # this would probably have to go on HOOKPREBUILD if you're working @@ -215,11 +215,11 @@ main() { touch built_ok popd &>/dev/null - done + done < <(nl "$log") popd &>/dev/null # cleanup - rm -rf ${log} "${temp_dir}" + rm -rf "${log}" "${temp_dir}" term_title "done" } |