aboutsummaryrefslogtreecommitdiff
path: root/Functions/DEB
blob: 5d59135cd88d966e5e9b902743b31925fd551336 (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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/bash (source)

# ThirdPartyInstallers DEB backend

function thirdparty_backend() {
    echo "DEB"
}

function thirdparty_arch() {
    local debfile="$1"
    local arch=$(dpkg-deb --field "$debfile" "Architecture")
    if [ "$arch" = "amd64" ]
    then echo "x86_64"
    elif [ "$arch" = "all" ]
    then echo "noarch"
    else echo "$arch"
    fi
}

function thirdparty_distribution_name() {
    local debfile="$1"
    local distro=$(dpkg-deb --field "$debfile" "Distribution")
    if [ -z "$distro" ]
    then echo "Debian based (guessed)"
    else echo "$distro"
    fi
}

function thirdparty_distribution_code() {
    return
}

function thirdparty_dependencies() {
    local debfile="$1"
    local deps=$(dpkg-deb --field "$debfile" "Depends")

    # The Depends fields contains a comma-separated list of dependencies. The range with the required
    # versions, when available, is output between parenthesis. To make the Dependencies output match the
    # format used by GoboLinux, we use a newline separator and remove all parenthesis characters found.

    echo "$deps" | sed 's/, /\n/g' | tr -d "()"
}

function thirdparty_description() {
    local debfile="$1"
    dpkg-deb --field "$debfile" "Description"
}

function thirdparty_filenames() {
    local debfile="$1"
    local contents=$(dpkg-deb --contents "$debfile")

    # The output of --contents looks like this:
    #
    # drwxr-xr-x root/root         0 2016-12-20 12:55 ./
    # drwxr-xr-x root/root         0 2016-12-20 12:55 ./etc/
    # ...
    # lrwxrwxrwx root/root         0 2016-12-20 12:55 ./opt/application/lib/libavfilter.so -> libavfilter.so.3.90.100
    #
    # We only want the path component. The sed below uses ./ as delimiter to account for
    # spaces in file names. Symbolic link targets are filtered out.

    echo "$contents" | sed 's,.*\./\(.*\),/\1,g' | grep -v "^/$" | sed -e 's,/$,,g' -e 's, -> .*,,g'
}

function thirdparty_license() {
    local debfile="$1"
    echo "Please visit the project website for licensing information."
}

function thirdparty_name() {
    local debfile="$1"
    dpkg-deb --field "$debfile" "Package"
}

function thirdparty_version() {
    local debfile="$1"
    local version=$(dpkg-deb --field "$debfile" "Version")
    # The format is: [epoch:]upstream_version[-debian_revision]
    # We want to output the [epoch:]upstream_version part
    echo "$version" | cut -d: -f1-2 | rev | cut -d- -f2- | rev
}

function thirdparty_release() {
    local debfile="$1"
    local version=$(dpkg-deb --field "$debfile" "Version")
    # The format is: [epoch:]upstream_version[-debian_revision]
    # We want to output the [-debian_revision] part
    # The absence of a debian_revision is equivalent to a debian_revision of 0.
    if echo "$version" | grep -q -- "-"
    then echo "$version" | rev | cut -d- -f1 | rev
    else echo "0"
    fi
}

function thirdparty_summary() {
    local debfile="$1"
    dpkg-deb --field "$debfile" "Description"
}

function thirdparty_url() {
    local debfile="$1"
    dpkg-deb --field "$debfile" "Homepage"
}

function thirdparty_search_remotedb() {
    local path="$1"
    local arch="$2"
    local distro="$3"
    false
}

function thirdparty_uncompress() {
    local debfile="$1"
    Log_Normal "Extracting DEB payload."
    dpkg-deb --extract "$debfile" .
}