lib/pvl/hosts/include_cache.sh
author Tero Marttila <tero.marttila@aalto.fi>
Tue, 03 Mar 2015 12:09:22 +0200
changeset 715 76ed62924d50
permissions -rw-r--r--
lib/pvl/hosts: include cache for proper hosts dependencies
715
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
     1
INCLUDE_CACHE='var/include-cache'
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
     2
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
     3
## Normalize a given source path for use in the include-cache
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
     4
function include_cache_path {
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
     5
    local src="$1"
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
     6
    local cache="$src"
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
     7
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
     8
    cache="${cache//_/__}"
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
     9
    cache="${cache//\//_}"
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    10
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    11
    echo "$INCLUDE_CACHE/$cache"
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    12
}
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    13
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    14
## Read the include cache for given path
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    15
function include_cache {
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    16
    local cache="$1"
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    17
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    18
    if [ ! -e "$cache" ]; then
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    19
        debug "missing: $cache"
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    20
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    21
        return 0
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    22
    fi
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    23
    
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    24
    cat $cache
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    25
}
76ed62924d50 lib/pvl/hosts: include cache for proper hosts dependencies
Tero Marttila <tero.marttila@aalto.fi>
parents:
diff changeset
    26