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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
|
#!/bin/bash
#
# package.sh -- functions to generate a package page
#
# Copyright © 2008-2009 Lionel Le Folgoc <mrpouit@ubuntu.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
function medibuntu_resources {
echo "<h3>Medibuntu resources:</h3>" >> $out
echo "<ul>" >> $out
# Bug report
echo "<li><a href=\"https://bugs.launchpad.net/medibuntu/+bugs\">Bug reports</a></li>" >> $out
dscfile=$(grep-dctrl -s Files -X -P $src Sources-$comp | tail -n+2 | awk '{print $3}' | grep "\.dsc$")
if [ -n "$dscfile" ]; then
# Changelog
changelogfile=$(echo $dscfile | sed -e 's/\.dsc$/\.changelog/')
echo "<li><a href=\"$BASE_URL/$dir/$changelogfile\">Changelog</a></li>" >> $out
# License file
copyrightfile=$(echo $dscfile | sed -e 's/\.dsc$/\.copyright/')
echo "<li><a href=\"$BASE_URL/$dir/$copyrightfile\">License file</a></li>" >> $out
fi
echo "</ul>" >> $out
}
function external_resources {
homepage=$(grep-dctrl -n -s Homepage -X -P $pkg Packages-$ar)
# If the Homepage field is empty, do not display
if [ -n "$homepage" ]; then
echo "<h3>External resources:</h3>" >> $out
echo "<ul>" >> $out
echo "<li><a href=\"$homepage\">Homepage</a></li>" >> $out
echo "</ul>" >> $out
fi
}
function source_package {
dscfile=$(grep-dctrl -s Files -X -P $src Sources-$comp | tail -n+2 | awk '{print $3}' | grep '\.dsc$')
difffile=$(grep-dctrl -s Files -X -P $src Sources-$comp | tail -n+2 | awk '{print $3}' |grep '\.debian\.tar\.*\|\.diff\.gz$')
if [ -n "$difffile" ]; then
origfile=$(grep-dctrl -s Files -X -P $src Sources-$comp | tail -n+2 | awk '{print $3}' | grep '\.orig\.tar\.*')
else
origfile=$(grep-dctrl -s Files -X -P $src Sources-$comp | tail -n+2 | awk '{print $3}' | grep '\.tar\.*')
fi
echo "<h3>Source package ($src):</h3>" >> $out
echo "<ul>" >> $out
echo "<li><a href=\"$BASE_URL/$dir/$dscfile\">$dscfile</a></li>" >> $out
# Handle native packages
test -n "$difffile" && echo "<li><a href=\"$BASE_URL/$dir/$difffile\">$difffile</a></li>" >> $out
echo "<li><a href=\"$BASE_URL/$dir/$origfile\">$origfile</a></li>" >> $out
echo "</ul>" >> $out
}
function display_links {
echo "<div id=\"right\">" >> $out
echo "<div id=\"links\">" >> $out
echo "<div id=\"links_title\">Links for $pkg</div>" >> $out
medibuntu_resources
external_resources
source_package
echo "</div>" >> $out
#google
echo "</div>" >> $out
}
function google {
echo "<div id=\"google\">" >> $out
echo "<script type=\"text/javascript\">" >> $out
echo "<!--" >> $out
echo "google_ad_client = \"pub-8132065110046054\";" >> $out
echo "/* 120x240,p.m.o */" >> $out
echo "google_ad_slot = \"9399206882\";" >> $out
echo "google_ad_width = 120;" >> $out
echo "google_ad_height = 240;" >> $out
echo "//-->" >> $out
echo "</script>" >> $out
echo "<script type=\"text/javascript\" " >> $out
echo "src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">" >> $out
echo "</script>" >> $out
echo "</div>" >> $out
}
function short_desc {
echo "<h2>" >> $out
grep-dctrl -n -s Description -X -P $pkg Packages-$ar | head -1 >> $out
echo "</h2>" >> $out
}
function long_desc {
echo "<div id=\"long_desc\">" >> $out
# Everybody stand back. I don't know regular expressions.
grep-dctrl -s Description -X -F Package $pkg Packages-$ar | tail -n+2 | sed 's/^ //' | sed 's/[ ]*$//' | sed 's/^\./<p><\/p>/' | perl -pe 's/(((\A|\n) [^\n]*)+)/<pre>$1<\/pre>/sgo' >> $out
echo "</div>" >> $out
}
function depends {
deps=$(grep-dctrl -n -s Depends -X -P $pkg Packages-$ar)
# Some arch: all packages may not depend on anything
if [ -n "$deps" ]; then
echo "<h2>Dependencies</h2>" >> $out
echo "<div id=\"depends\"><ul><li><span class=\"code\">" >> $out
echo $deps | sed 's/|/<\/span><\/li><li class=\"alt_deps\"><em>or<\/em><\/li><li><span class=\"code\">/g' | sed 's/,\ /<\/span><\/li><li><span class=\"code\">/g' >> $out
echo "</span></li></ul></div>" >> $out
fi
}
function downloads_header {
echo "<h2>Download $pkg</h2>" >> $out
echo "<div id=\"download\">" >> $out
echo "<p>If you have already enabled <a href=\"https://help.ubuntu.com/community/Medibuntu#Adding%20the%20Repositories\">Medibuntu</a>, <a href=\"apt://$pkg\">click here</a> to automatically install this package. For a manual download, use the table below.</p>" >> $out
echo "<table>" >> $out
echo "<tr>" >> $out
echo "<th>Architecture</th>" >> $out
echo "<th>Version</th>" >> $out
echo "<th>Package size</th>" >> $out
echo "<th>Installed Size</th>" >> $out
echo "<th>MD5Sum</th>" >> $out
echo "</tr>" >> $out
}
function download_link {
echo "<tr>" >> $out
# Link to the deb file
filename=$(grep-dctrl -n -s Filename -X -P $pkg Packages-$ar)
echo "<th><a href=\"$BASE_URL/$filename\">$ar</a></th>" >> $out
# Package version (can be different, for example when an arch builder is late)
echo "<td>$(grep-dctrl -n -s Version -X -P $pkg Packages-$ar)</td>" >> $out
# Package size
echo "<td>$(grep-dctrl -n -s Size -X -P $pkg Packages-$ar) B</td>" >> $out
# Installed size
echo "<td>$(grep-dctrl -n -s Installed-Size -X -P $pkg Packages-$ar) kB</td>" >> $out
# MD5Sum (if people want to check)
echo "<td>$(grep-dctrl -n -s MD5Sum -X -P $pkg Packages-$ar)</td>" >> $out
echo "</tr>" >> $out
}
function build_package_page {
if [ $# -ne 7 ]; then
echo 'Creates the page for the given package.'
echo 'Usage: build_package_page $package $arch $release $component $section $srcname $dirname'
exit 1
fi
pkg=$1
ar=$2
dist=$3
comp=$4
sect=$5
src=$6
dir=$7
out="$pkg.html"
# Write the header
cat ../../resources/package_header.html > $out
sed -i "s:@PACKAGE@:$pkg:g" $out
sed -i "s:@RELEASE@:$dist:g" $out
sed -i "s:@SECTION@:$sect:g" $out
# Then call all functions above
display_links
short_desc
long_desc
depends
downloads_header
download_link
# Do not write the footer now, so downloads for other architectures can be added
}
function append_arch_download {
if [ $# -ne 2 ]; then
echo 'Appends a download link to an existing package page.'
echo 'Usage: append_arch_download $package $arch'
exit 1
fi
pkg=$1
ar=$2
out="$pkg.html"
download_link
# Do not write the footer now, so downloads for other architectures ca be added
}
|