File: tests.info

package info (click to toggle)
snapd 2.71-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 79,536 kB
  • sloc: ansic: 16,114; sh: 16,105; python: 9,941; makefile: 1,890; exp: 190; awk: 40; xml: 22
file content (62 lines) | stat: -rwxr-xr-x 1,588 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

set -eu

show_help() {
    echo "usage: tests.info <CMD>"
    echo
    echo "Supported commands:"
    echo "    is-snapd-from-archive:  indicates when the snapd package is from the repository"
    echo "    is-reexec-enabled:      indicates re-execution has been explicitly enabled through the env"
    echo "    is-reexec-in-use:       indicates re-execution to the snapd snap is being effectively performed"
}

# ubuntu 14.04: does not support apt download which is used to get the packages from the archive.
# ubuntu-core: it is built based on the snapd.deb file, so it requires the deb is created from current.
is_snapd_from_archive() {
    [ "$SNAPD_DEB_FROM_REPO" = true ] && \
    [ -n "$(command -v apt)" ] && \
    [[ "$SPREAD_SYSTEM" != ubuntu-core-* ]] && \
    not os.query is-trusty
}

is_reexec_enabled() {
    snap debug execution snap | grep -q "is-reexec-enabled: true"
}

is_reexec_in_use() {
    snap debug execution snap | grep -q "is-reexecd: true"
}

main() {
    if [ $# -eq 0 ]; then
        show_help
        exit 0
    fi

    local subcommand="$1"
    local action=
    while [ $# -gt 0 ]; do
        case "$subcommand" in
            -h|--help)
                show_help
                exit 0
                ;;
            *)
                action=$(echo "$subcommand" | tr '-' '_')
                shift
                break
                ;;
        esac
    done

    if [ -z "$(declare -f "$action")" ]; then
        echo "tests.info: no such command: $subcommand"
        show_help
        exit 1
    fi

    "$action" "$@"
}

main "$@"