blob: de28575d92a7429d18ed265380801427f3b093e9 (
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
|
#!/usr/bin/perl
#
# upload.pl - upload files to the xine "Download" page
#
# usage: upload.pl [-y] [-r<release-version>] [-s<section>] <file> [...]
#
# OPTIONS: release-version: the version number of this file. If omitted, the
# newest version on the page is used.
# Only the last -r option counts.
#
# section: the heading under which this file should appear. If
# omitted, we'll try to autodetect it from the file suffix:
# .rpm => "RPMs"
# .tar.gz => "source tarball"
# .deb => "Debian"
# .dsc => "Debian"
#
# -y: don't ask for upload confirmation
#
# EXAMPLE:
# ./upload.pl -r1.0 xine_1.0_i386.deb -sSlackware xine-1.0.tar.gz
#
## begin configuration ######################################################
$UPLOAD_HOST = "xine.sourceforge.net";
$UPLOAD_PATH = "/home/groups/x/xi/xine/htdocs";
$INDEX_FILE = "download.html";
$FILE_SUBDIR = "files";
$TMP_DIR = "/tmp/xine-upload.$$";
$PROGRAM_NAME = "xine";
$LINK_FONT = '<font face="Verdana,Helvetica,Arial" size=4>';
$END_FONT = '</font>';
## end of configuration #####################################################
mkdir $TMP_DIR, 0755 || die "could not mkdir $TMP_DIR";
mkdir "$TMP_DIR/$FILE_SUBDIR", 0755;
print "fetching old Download page...\n";
system ("scp $UPLOAD_HOST:$UPLOAD_PATH/$INDEX_FILE $TMP_DIR");
open(IN, "$TMP_DIR/$INDEX_FILE") || die "unable to open $TMP_DIR/$INDEX_FILE";
if (!read(IN, $thepage, 409600)) {
die "unable to read $TMP_DIR/$INDEX_FILE";
}
close(IN);
if ($thepage =~ /<h1>\s*$PROGRAM_NAME\s+(\S+)\s*<\/h1>/si) {
$current_release=$1;
print "current release is $current_release.\n";
}
else {
$current_release="(unknown version)";
print "WARNING: could not find current release in download page.\n";
}
## parse command line
$section = "source tarball";
$release = $current_release;
%files = ();
$yes = 0;
foreach (@ARGV) {
if (/^\-r/) {
$release = $_;
$release =~ s/\-r//;
}
elsif (/^\-s/) {
$section = $_;
$section =~ s/\-s//;
}
elsif (/^\-y/) {
$yes = 1;
}
else {
die "$_: no such file" unless -f $_;
$filen = $_;
$filen =~ s/^.*?([^\/]*)$/\1/;
$files{$section} .= " $filen";
print "will add $filen to section $section.\n";
system("cp $_ '$TMP_DIR/$FILE_SUBDIR'");
}
}
print "using release id $release.\n";
## add new files to the page
sub ensureSection() { #$section, $release
$rel = $thepage;
$rel =~ s/^.*<h1>\s*$PROGRAM_NAME\s+$release\s*<\/h1>//si;
$rel =~ s/<h1>.*$//si;
if ($rel =~ /<h2>\s*$section\s*<\/h2>/si) {
return;
}
else {
print "creating new section \"$section\" for release $release.\n";
unless ($thepage =~ /<h1>\s*$PROGRAM_NAME\s+$release\s*<\/h1>/si) {
$thepage = "<h1>$PROGRAM_NAME $release</h1>\n" . $thepage;
}
$newSection = "<h2>$section</h2>\n\n$LINK_FONT\n$END_FONT\n\n\n";
$thepage =~ /^(.*<h1>\s*$PROGRAM_NAME\s+$release\s*<\/h1>.*?)(<h1>.*)$/is;
$thepage = $1.$newSection.$2;
return;
}
}
print "editing Download page...\n";
foreach (keys(%files)) {
$section = $_;
ensureSection();
$newLinks = $files{$section};
print "file list for \"$section\": $newLinks\n";
$newLinks =~ s/ (\S*)/<a href=\"$FILE_SUBDIR\/\1\">\1<\/a> <br>\n/sg;
$thepage =~ /^(.*<h1>\s*$PROGRAM_NAME\s+$release\s*<\/h1>.*?<h2>\s*$section\s*<\/h2>.*?)($END_FONT.*)$/is;
$thepage = $1 . $newLinks . $2;
}
open(OUT, ">$TMP_DIR/$INDEX_FILE");
print OUT $thepage;
close(OUT);
unless ($yes) {
print "\nAre you sure you want to upload files? [no] ";
$answer = <STDIN>;
$yes = 1 if $answer =~ /^y/i;
}
if ($yes) {
system("scp -r '$TMP_DIR/$INDEX_FILE' '$TMP_DIR/$FILE_SUBDIR' '$UPLOAD_HOST:$UPLOAD_PATH'");
}
system("rm -r $TMP_DIR");
|