]>
git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - scrape.pl
5 use autodie qw
/ :all /;
7 use File
::Basename qw
/ fileparse /;
8 use File
::Path qw
/ rmtree /;
11 printf( "[INFO] >>> %s\n", join( ' ', @_ ) );
15 my ( $url, $save_to ) = @_;
17 my $ua = LWP
::UserAgent
->new;
19 einfo
( "Fetching $url ..." );
21 my $response = $ua->get( $url, 'Accept-Encoding' => 'gzip' );
23 if ( $response->is_success ) {
25 open( my $file, '>', $save_to );
27 my $content = $response->decoded_content;
29 if ( utf8
::is_utf8
( $content ) ) {
30 binmode( $file,':utf8' );
32 binmode( $file,':raw' );
39 return $response->decoded_content;
42 die "Fetch failed.\n";
46 my $script_dir = ( fileparse
( __FILE__
) )[1];
49 my $latest_patch = fetch
( 'https://grsecurity.net/latest_test_patch' );
50 chomp( $latest_patch );
51 einfo
"Latest patch $latest_patch";
53 my ( $grsec_major_version, $kernel_version, $grsec_patch_version ) = ( $latest_patch =~ m/^grsecurity-([0-9.]+)-([0-9.]+)-([0-9]+)\.patch$/ );
55 for my $var ( $grsec_major_version, $kernel_version, $grsec_patch_version ) {
56 die "Wrong patch file name?\n" unless defined( $var ) and length $var;
59 if ( -f
"test/$kernel_version/$latest_patch" ) {
60 einfo
"Already downloaded.";
69 fetch
( "https://grsecurity.net/test/$latest_patch", "tmp/$latest_patch" );
70 fetch
( "https://grsecurity.net/test/$latest_patch.sig", "tmp/$latest_patch.sig" );
71 fetch
( 'https://grsecurity.net/changelog-test.txt', 'tmp/changelog-test.txt' );
73 mkdir( "test/$kernel_version" ) if not ( -d
"test/$kernel_version" );
74 rename( "tmp/$latest_patch", "test/$kernel_version/$latest_patch" );
75 rename( "tmp/$latest_patch.sig", "test/$kernel_version/$latest_patch.sig" );
76 rename( 'tmp/changelog-test.txt', 'test/changelog-test.txt' );
81 "test/$kernel_version/$latest_patch",
82 "test/$kernel_version/$latest_patch.sig",
83 'test/changelog-test.txt'
86 einfo
'git commit ...';
88 "git", "commit", "-m", "Auto commit, $latest_patch added.",
89 "test/$kernel_version/$latest_patch",
90 "test/$kernel_version/$latest_patch.sig",
91 'test/changelog-test.txt'
95 system("git", "push");