summaryrefslogtreecommitdiff
path: root/src/mirror.sh
blob: 7a2a67221827e74ab689b96a69285b4b8a28b06e (plain)
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
#!/bin/sh

create_deps_graph () {
    for f in $DEP_DIR/*; do
        printf "${f#$DEP_DIR/}:"
        local deps=""
        [ -f "$f" ] && while read line; do
            for dep in $line; do
                case "$deps" in
                    *"$dep"*);;
                    *) deps="$deps $dep";;
                esac
            done
        done < $f 
        printf "%s\n" "$deps"
    done
}

mirror () {
    local MIRROR_DIR=${SYSROOT}${1:-$MIRROR_DIR}
    mkdir -p $MIRROR_DIR
    create_deps_graph > $MIRROR_DIR/deps.graph

    local packages=$(list)

    cd $MIRROR_DIR
    fetch $packages
    cd -
}