File: prepare-dep

package info (click to toggle)
scrcpy 1.17-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 1,372 kB
  • sloc: ansic: 7,675; java: 4,310; sh: 262; xml: 107; makefile: 65
file content (58 lines) | stat: -rwxr-xr-x 1,013 bytes parent folder | download
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
#!/usr/bin/env bash
set -e
url="$1"
sum="$2"
dir="$3"

checksum() {
    local file="$1"
    local sum="$2"
    echo "$file: verifying checksum..."
    echo "$sum  $file" | sha256sum -c
}

get_file() {
    local url="$1"
    local file="$2"
    local sum="$3"
    if [[ -f "$file" ]]
    then
        echo "$file: found"
    else
        echo "$file: not found, downloading..."
        wget "$url" -O "$file"
    fi
    checksum "$file" "$sum"
}

extract() {
    local file="$1"
    echo "Extracting $file..."
    if [[ "$file" == *.zip ]]
    then
        unzip -q "$file"
    elif [[ "$file" == *.tar.gz ]]
    then
        tar xf "$file"
    else
        echo "Unsupported file: $file"
        return 1
    fi
}

get_dep() {
    local url="$1"
    local sum="$2"
    local dir="$3"
    local file="${url##*/}"
    if [[ -d "$dir" ]]
    then
        echo "$dir: found"
    else
        echo "$dir: not found"
        get_file "$url" "$file" "$sum"
        extract "$file"
    fi
}

get_dep "$url" "$sum" "$dir"