]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - scrape.pl
perl script to get latest grsec version from rss.
[thirdparty/grsecurity-scrape.git] / scrape.pl
1 #!/usr/bin/perl
2
3 use warnings;
4 use strict;
5 use XML::Simple;
6 use LWP::Simple 'get', 'getstore';
7 use File::Basename 'dirname', 'basename';
8 use Cwd 'abs_path';
9
10 my $script_dir = abs_path(dirname(__FILE__));
11
12 print("Getting rss feed ...\n");
13 my $feed_raw = get("https://grsecurity.net/testing_rss.php");
14
15 my $feed = XMLin($feed_raw, ForceArray => ['item']);
16 my $filename;
17 my $link;
18 my $new_patches;
19
20 for(@{$feed->{channel}->{item}}) {
21 $link = $_->{link};
22 $filename = basename($link);
23 if ( ! -e $script_dir . "/test/". $filename ) {
24 $new_patches++;
25 print("Downloading ", $filename, " ...\n");
26 getstore($link . ".sig", $script_dir . "/test/" . $filename . ".sig");
27 getstore($link, $script_dir . "/test/" . $filename);
28 }
29 }
30 if ($new_patches) {
31 print("Downloading changelog-test.txt ...\n");
32 getstore("https://grsecurity.net/changelog-test.txt", $script_dir . "/test/changelog-test.txt");
33
34 system("git", "add", $script_dir . "/test/" . $filename, $script_dir . "/test/changelog-test.txt", $script_dir . "/test/" . $filename . ".sig");
35 system("git", "commit", "-a", "-m", "Auto commit, " . $new_patches . " new patch{es}.");
36 system("git", "push");
37 }
38