Last change
on this file since 1485 was 5, checked in by Bruno Cornec, 17 years ago |
Lots of modifs to find the right way. Probably still not good
|
-
Property svn:executable
set to
*
|
File size:
1.1 KB
|
Rev | Line | |
---|
[2] | 1 | #!/usr/bin/perl -w
|
---|
| 2 | #
|
---|
| 3 | # Creates announces for new mondorescue version/tag
|
---|
| 4 | #
|
---|
| 5 | # $Id$
|
---|
| 6 | #
|
---|
| 7 | # Syntax : mkannounce announce-file
|
---|
| 8 | #
|
---|
| 9 |
|
---|
| 10 | use strict;
|
---|
| 11 | use Date::Manip;
|
---|
| 12 | use File::Basename;
|
---|
| 13 | use DBI;
|
---|
| 14 | use English;
|
---|
| 15 |
|
---|
| 16 |
|
---|
| 17 | # For date handling
|
---|
| 18 | $ENV{LANG}="C";
|
---|
| 19 |
|
---|
[5] | 20 | my $PBROOT;
|
---|
[2] | 21 | my $tmp = dirname($PROGRAM_NAME);
|
---|
| 22 | print "$tmp\n";
|
---|
| 23 | if ($tmp =~ /^\//) {
|
---|
[5] | 24 | $PBROOT = $tmp;
|
---|
[2] | 25 | }
|
---|
| 26 | else {
|
---|
[5] | 27 | $PBROOT = "$ENV{PWD}/$tmp";
|
---|
[2] | 28 | }
|
---|
| 29 |
|
---|
[5] | 30 | my $db="$PBROOT/../website/announces3.sql";
|
---|
[2] | 31 |
|
---|
| 32 | my $dbh = DBI->connect("dbi:SQLite:dbname=$db","","",
|
---|
| 33 | { RaiseError => 1, AutoCommit => 1 })
|
---|
| 34 | || die "Unable to connect to $db";
|
---|
| 35 |
|
---|
| 36 | my $date = &UnixDate("today","%Y-%m-%d");
|
---|
| 37 |
|
---|
| 38 | # To read whole file
|
---|
| 39 | local $/;
|
---|
| 40 | open(ANNOUNCE,$ARGV[0]) || die "Unable to open $ARGV[0] (read)";
|
---|
| 41 | my $announce = <ANNOUNCE>;
|
---|
| 42 | #$announce =~ s/\"/\"\"/g;
|
---|
| 43 | #$announce =~ s/!//g;
|
---|
| 44 | close(ANNOUNCE);
|
---|
| 45 |
|
---|
| 46 | print "INSERT INTO announces VALUES (NULL, $date, $announce)\n";
|
---|
| 47 | my $sth = $dbh->prepare(qq{INSERT INTO announces VALUES (NULL,?,?)})
|
---|
| 48 | || die "Unable to insert into $db";
|
---|
| 49 | $sth->execute($date, $announce);
|
---|
| 50 | #$dbh->do(qq(INSERT INTO announces VALUES (NULL, '$date', '$announce')))
|
---|
| 51 | #|| die "Unable to insert into $db";
|
---|
| 52 |
|
---|
| 53 | $dbh->disconnect;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.