summaryrefslogtreecommitdiff
path: root/control.sh
blob: e111fbbcc9a29b8ec403e60f2cf79cd5af154b94 (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
#!/bin/bash
shopt -s extglob nullglob

export PKG_NAME=$1
shift

export PKG_BASE=$(realpath "$(dirname "$0")")
. "${PKG_BASE}/helper.sh"

if [[ -n $2 ]]; then
    PKG_VRSN=$2
fi

cat <<EOF
Package: ${PKG_NAME}
EOF

if [[ ${PKG_PRIO} == required || ${PKG_PRIO} == +* ]]; then
    cat <<EOF
Essential: yes
EOF
fi

if [[ $1 == status ]]; then
    cat <<EOF
Status: install ok installed
EOF
fi

cat <<EOF
Priority: ${PKG_PRIO#+}
Section: $(cat "${PKG_DATA}/_metadata/section")
EOF

if [[ $1 == status || $1 == available ]]; then
    cat <<EOF
Installed-Size: $(dpkg -f "${PKG_BASE}/debs/${PKG_NAME}_${PKG_VRSN}-${PKG_RVSN}_darwin-arm.deb" Installed-Size)
EOF
elif [[ $1 == control ]]; then
    cat <<EOF
Installed-Size: $(du -s "${PKG_DEST}" | cut -d $'\t' -f 1)
EOF
fi

cat <<EOF
Maintainer: $(cat "${PKG_DATA}/_metadata/maintainer")
Architecture: darwin-arm
EOF

echo -n "Version: ${PKG_VRSN}"

if [[ $1 == status || $1 == available ]]; then
    echo "-${PKG_RVSN}"
else
    echo
fi

if [[ $1 == available ]]; then
    cat <<EOF
Size: $(find "${PKG_DEST}" -type f -exec cat {} \; | gzip -c | wc -c | cut -d $'\t' -f 1)
EOF
fi

unset comma
for dep in "${PKG_DEPS[@]}"; do
    if [[ ${comma+@} == @ ]]; then
        echo -n ","
    else
        echo -n "Depends:"
        comma=
    fi

    echo -n " $(basename "${dep}" .dep)"
done

if [[ -e ${PKG_DATA}/_metadata/depends ]]; then
    if [[ ${comma+@} == @ ]]; then
        echo -n ","
    else
        echo -n "Depends:"
        comma=
    fi

    echo -n " $(cat "${PKG_DATA}/_metadata/depends")"
fi

if [[ ${comma+@} == @ ]]; then
    echo
fi

cat <<EOF
Description: $(head -n 1 "${PKG_DATA}/_metadata/description")
EOF

if [[ $(wc -l "${PKG_DATA}/_metadata/description" | cut -d ' ' -f 1) -gt 1 ]]; then
    cat <<EOF
$(tail -n +2 "${PKG_DATA}/_metadata/description" | fold -sw 72 | sed -e 's/^/ /')
EOF
fi

if [[ -e ${PKG_DATA}/_metadata/name ]]; then
    cat <<EOF
Name: $(cat "${PKG_DATA}/_metadata/name")
EOF
fi

if [[ -e ${PKG_DATA}/_metadata/website ]]; then
    cat <<EOF
Website: $(cat "${PKG_DATA}/_metadata/website")
EOF
fi

if [[ $1 == status || $1 == available ]]; then
    echo
fi