File: __install__

package info (click to toggle)
zplug 2.4.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,068 kB
  • sloc: sh: 1,504; awk: 235; makefile: 26
file content (77 lines) | stat: -rw-r--r-- 1,988 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#!/usr/bin/env zsh
# Description:
#   Install packages in parallel

local     repo arg
local -A  repo_pids proc_states hook_build hook_finished hook_pids status_codes
local -A  tags
local -F  SECONDS=0
local -aU repos
local -i  status_code=0

while (( $# > 0 ))
do
    arg="$1"
    case "$arg" in
        -*|--*)
            __zplug::core::options::unknown "$arg"
            return $status
            ;;
        "")
            # Invalid
            return 1
            ;;
        */*)
            repos+=( "${arg:gs:@::}" )
            ;;
        *)
            return 1
            ;;
    esac
    shift
done

if ! __zplug::job::parallel::init "$repos[@]"; then
    # Since the initialization has failed, this command is terminated.
    # The error message etc. should be done within that function.
    return 1
fi
repos=( "$reply[@]" )

for repo in "$repos[@]"
do
    __zplug::core::tags::parse "$repo"
    tags=( "${reply[@]}" )

    # Run the installation in background
    {
        if [[ -n $tags[if] ]] && ! eval "${tags[if]}" 2> >(__zplug::log::capture::error) >/dev/null; then
            status_code=$_zplug_status[skip_if]
        else
            if __zplug::core::sources::is_handler_defined "install" "$tags[from]"; then
                __zplug::core::sources::use_handler \
                    "install" \
                    "$tags[from]" \
                    "$repo"
                status_code=$status
            fi
        fi

        # Manage the status codes in a file
        # to lock the file in order to write asynchronously
        __zplug::job::handle::flock \
            "$_zplug_log[install]" \
            "repo:$repo\tstatus:$status_code"
    } &

    repo_pids[$repo]=$(builtin printf $!) # for zsh 5.3
    hook_build[$repo]="$tags[hook-build]"
    hook_finished[$repo]=false
    proc_states[$repo]="created"
    status_codes[$repo]=""

    __zplug::job::handle::wait
done

__zplug::job::handle::elapsed_time $SECONDS
__zplug::job::parallel::deinit