aboutsummaryrefslogtreecommitdiffstats
path: root/gen-download-page.sh
blob: e37a4cb24ee3fd7abdf172d1b0af9ca8decbe63d (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#!/bin/sh

project='librb'
out='www/downloads.html'
remote="https://distfiles.kurwinet.pl/test/${project}"
gpg="https://distfiles.kurwinet.pl/bofc-signing.pub.gpg"
asc="https://distfiles.kurwinet.pl/bofc-signing.pub.asc"

get_files_from_remote()
{
    remote="${1}"

    curl "${remote}/" -A "${project}-generator" 2>/dev/null | grep "a href=" | \
        grep -v 'a href=".."' | cut -f2 -d\" | cut -f1 -d/
}

# extract links to files
links="$(curl "${remote}/" -A "${project}-generator" 2>/dev/null \
    | grep "${project}-[0-9]*\.[0-9]*\.[0-9]*\." | sort -r)"

exec 6>&1
exec 1<>"${out}"

echo > "${out}"
echo "<h1>downloads</h1>"
echo "<p>"
echo "Below you can find source files and binary packages for various systems."
echo "<b>(s)</b> right of package name is a gpg signature. You can download"
echo "<a href=\"${gpg}\">gpg file</a> or"
echo "<a href=\"${asc}\">armored asc file</a> to verify files. You can also"
echo "look for key on public keyservers, fingerprint is<br><br>"
echo "&nbsp;&nbsp;&nbsp;&nbsp;63D0 C3DB 42AF 3B4F CF6E  7880 E84A 7E61 C785 0C62<br><br>"
echo "You can download key directly from keyserver with<br><br>"
echo "&nbsp;&nbsp;&nbsp;&nbsp;gpg --recv-keys 63D0C3DB42AF3B4FCF6E7880E84A7E61C7850C62<br><br>"
echo "Then you can verify downloaded image with command<br><br>"
echo "&nbsp;&nbsp;&nbsp;&nbsp;gpg --verify &lt;sig-file&gt; &lt;package-file&gt;"
echo "</p><p>"
echo "All files can also be downloaded from: <a href=\"${remote}/\">${remote}</a><br>"
echo "</p>"
echo "<h1>git</h1>"
echo "<p>"
echo "git clone git@kurwinet.pl:${project}<br>"
echo "git clone git://kurwinet.pl/${project}<br>"
echo "git clone http://git.kurwinet.pl/${project}<br>"
echo "</p>"

echo "<h1>tarballs (source code)</h1>"
echo "<pre>"

files="$(get_files_from_remote "${remote}/" | \
    grep "${project}-[0-9]*\.[0-9]*\.[0-9]*\.")"
versions="$(echo "${files}" | tr ' ' '\n' | rev | \
    cut -f1 -d- | rev | cut -f1-3 -d. | sort -Vur)"

for v in ${versions}
do
    printf "%-10s%s(%s)  %s(%s)  %s(%s)" "${v}" \
        "<a href=\"${remote}/${project}-${v}.tar.gz\">tar.gz</a>" \
        "<a href=\"${remote}/${project}-${v}.tar.gz.sig\">s</a>" \
        "<a href=\"${remote}/${project}-${v}.tar.bz2\">tar.bz2</a>" \
        "<a href=\"${remote}/${project}-${v}.tar.bz2.sig\">s</a>" \
        "<a href=\"${remote}/${project}-${v}.tar.xz\">tar.xz</a>" \
        "<a href=\"${remote}/${project}-${v}.tar.xz.sig\">s</a>"
done

echo "</pre>"

distros="$(get_files_from_remote "${remote}/" | \
    grep -v "${project}-[0-9]*\.[0-9]*\.[0-9]*\." | \
    sort -t'-' -k1,1 -k2,2Vr)"

for d in ${distros}
do
    dname="$(echo ${d} | cut -f1 -d-)"
    dvers="$(echo ${d} | cut -f2 -d-)"
    archs="$(get_files_from_remote "${remote}/${d}/")"

    echo "<h1>${dname} ${dvers}</h1>"

    for a in ${archs}
    do
        files="$(get_files_from_remote "${remote}/${d}/${a}/")"
        echo "<h2>${a}</h2>"

        case "${dname}" in

        debian|ubuntu)
            versions="$(echo ${files} | tr ' ' '\n' | \
                cut -f2 -d_ | cut -f1-3 -d. | sort -Vur)"
            ;;

        centos|rhel|opensuse|fedora)
            versions="$(echo ${files} | tr ' ' '\n' | rev | \
                cut -f2 -d- | rev | cut -f1-3 -d. | sort -Vur)"
            ;;

        slackware)
            versions="$(echo ${files} | tr ' ' '\n' | rev | \
                cut -f3 -d- | rev | cut -f1-3 -d. | sort -Vur)"
            ;;
        esac

        echo "<pre>"
        for v in ${versions}
        do
            case "${dname}" in

            debian)
                ABI="$(echo "${v}" | cut -f1 -d.)"
                printf "%-10s%s(%s)  %s(%s)  %s(%s)  %s(%s)  %s(%s)  %s(%s)\n" "${v}" \
                    "<a href=\"${remote}/${d}/${a}/${project}${ABI}_${v}_${a}.deb\">deb</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}${ABI}_${v}_${a}.deb.sig\">s</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}${ABI}-dbgsym_${v}_${a}.deb\">dbgsym</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}${ABI}-dbgsym_${v}_${a}.deb.sig\">s</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}-dev_${v}_${a}.deb\">dev</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}-dev_${v}_${a}.deb.sig\">s</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}_${v}.dsc\">dsc</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}_${v}.dsc.sig\">s</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}_${v}_${a}.build\">build</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}_${v}_${a}.build.sig\">s</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}_${v}_${a}.buildinfo\">buildinfo</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}_${v}_${a}.buildinfo.sig\">s</a>"
                ;;

            ubuntu)
                ABI="$(echo "${v}" | cut -f1 -d.)"
                printf "%-10s%s(%s)  %s(%s)  %s(%s)  %s(%s)  %s(%s)  %s(%s)\n" "${v}" \
                    "<a href=\"${remote}/${d}/${a}/${project}${ABI}_${v}_${a}.deb\">deb</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}${ABI}_${v}_${a}.deb.sig\">s</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}${ABI}-dbgsym_${v}_${a}.ddeb\">dbgsym</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}${ABI}-dbgsym_${v}_${a}.ddeb.sig\">s</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}-dev_${v}_${a}.deb\">dev</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}-dev_${v}_${a}.deb.sig\">s</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}_${v}.dsc\">dsc</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}_${v}.dsc.sig\">s</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}_${v}_${a}.build\">build</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}_${v}_${a}.build.sig\">s</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}_${v}_${a}.buildinfo\">buildinfo</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}_${v}_${a}.buildinfo.sig\">s</a>"
                ;;

            rhel|centos|opensuse|fedora)
                printf "%-10s%s(%s)  %s(%s)  %s(%s)\n" "${v}" \
                    "<a href=\"${remote}/${d}/${a}/${project}-${v}-1.${a}.rpm\">rpm</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}-${v}-1.${a}.rpm.sig\">s</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}-debuginfo-${v}-1.${a}.rpm\">dbginfo</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}-debuginfo-${v}-1.${a}.rpm.sig\">s</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}-devel-${v}-1.${a}.rpm\">devel</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}-devel-${v}-1.${a}.rpm.sig\">s</a>"
                ;;

            slackware)
                printf "%-10s%s(%s)\n" "${v}" \
                    "<a href=\"${remote}/${d}/${a}/${project}-${v}.${a}-1.tgz\">tgz</a>" \
                    "<a href=\"${remote}/${d}/${a}/${project}-${v}.${a}-1.tgz.sig\">s</a>"
                ;;
            esac
        done
        echo "</pre>"
    done
done

exec 1>&6 6>&-

for l in $(lynx -listonly -nonumbers -dump "${out}" | grep "https://distfiles")
do
    echo -n "checking ${l}... "
    curl -sSfl -A "${project}-generator" "${l}" >/dev/null

    if [ ${?} -eq 0 ]
    then
        echo "ok"
    fi
done