This is an automated email from the git hooks/post-receive script. sebastic-guest pushed a commit to branch experimental in repository gdal.
commit eac5b1e6b78a7ad00228e64fa14621c1d1e388f2 Author: Bas Couwenberg <sebas...@xs4all.nl> Date: Fri Nov 7 20:19:32 2014 +0100 Update gdal-symbols.pl to also generate symbols files for new architectures. --- debian/changelog | 2 + debian/gdal-symbols.pl | 744 +++++++++++++++++++++++++++++++++++-------------- 2 files changed, 535 insertions(+), 211 deletions(-) diff --git a/debian/changelog b/debian/changelog index bd1d3df..679c11c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,8 @@ gdal (1.11.1+dfsg-1~exp2) UNRELEASED; urgency=medium * Update symbols for amd64, armel, armhf, i386, mips, mipsel, powerpc, s390x & sparc. * Don't exclude libhdf4-alt-dev from build dependencies on ppc64. + * Update gdal-symbols.pl to also generate symbols files for new + architectures. -- Bas Couwenberg <sebas...@xs4all.nl> Sat, 25 Oct 2014 01:13:07 +0200 diff --git a/debian/gdal-symbols.pl b/debian/gdal-symbols.pl index eda4643..0a32cbd 100755 --- a/debian/gdal-symbols.pl +++ b/debian/gdal-symbols.pl @@ -52,6 +52,7 @@ my %cfg = ( no_diff => 0, no_prompt => 0, yes => 0, + clean => 0, verbose => 0, help => 0, ); @@ -72,6 +73,7 @@ my $result = GetOptions( 'no-diff' => \$cfg{no_diff}, 'no-prompt' => \$cfg{no_prompt}, 'y|yes' => \$cfg{yes}, + 'c|clean' => \$cfg{clean}, 'v|verbose' => \$cfg{verbose}, 'h|help' => \$cfg{help}, ); @@ -93,10 +95,11 @@ if(!$result || $cfg{help} || !$cfg{package} || !$cfg{debian}) { print "-H, --sha512sum <PATH> Path to sha512sum ($cfg{sha512sum})\n"; print "-D, --pkgdir <PATH> Path to downloaded packages ($cfg{pkgdir})\n"; print "-d, --debian <PATH> Path to debian/ directory ($cfg{debian})\n"; + print "-f, --force Force writing into existing package directory\n"; print " --no-diff Don't display diff for new symbols files\n"; print " --no-prompt Don't prompt to select symbols, update manually\n"; print "-y, --yes Default to yes on prompts\n"; - print "-f, --force Force writing into existing package directory\n"; + print "-c, --clean Clean up temorary files after processing\n"; print "-v, --verbose Enable verbose output\n"; print "-h, --help Display this usage information\n"; @@ -156,8 +159,11 @@ if(-e $cfg{pkgdir} && !$cfg{force}) { $cfg{debian} .= '/' if(substr($cfg{debian}, -1, 1) ne '/'); $cfg{pkgdir} .= '/' if(substr($cfg{pkgdir}, -1, 1) ne '/'); +my @versions = get_versions(%cfg); + if(!$cfg{version} || $cfg{version} eq 'latest') { - $cfg{version} = latest_snapshot(); + $cfg{version} = $versions[-1]; + if(!$cfg{version}) { print "Error: Failed to determine latest version for: $cfg{package}\n"; exit 1; @@ -166,20 +172,31 @@ if(!$cfg{version} || $cfg{version} eq 'latest') { my %symbols = (); -download_packages(); -unpack_packages(); -create_new_symbols(); -create_patch_files(); -patch_files(); -split_files(); -compare_symbols(); -#create_complete_symbols(); +# Get binary packages for all architectures +download_packages(%cfg); +unpack_packages(%cfg); + +# Update symbols files for existing architectures +create_new_symbols(%cfg); +create_new_patch_files(%cfg); +patch_new_files(%cfg); +split_new_files(%cfg); +compare_new_symbols(%cfg); + +# Create symbols files for new architectures +new_architecture_symbols(%cfg); + +clean_temp_files(%cfg) if($cfg{clean}); + +exit 0; ################################################################################ # Subroutines -sub latest_snapshot { - my $url = 'http://snapshot.debian.org/mr/binary/'.uri_escape($cfg{package}).'/'; +sub get_versions { + my (%args) = @_; + + my $url = 'http://snapshot.debian.org/mr/binary/'.uri_escape($args{package}).'/'; my $req = HTTP::Request->new(GET => $url); print "Retrieving URL: $url ... " if($cfg{verbose}); @@ -204,7 +221,7 @@ sub latest_snapshot { print "\n" if($cfg{verbose}); - return $versions[-1]; + return @versions; } else { print "Failed!\n" if($cfg{verbose}); @@ -216,22 +233,30 @@ sub latest_snapshot { } sub download_packages { - my $dir = $cfg{pkgdir}; + my (%args) = @_; - if(!-e $cfg{pkgdir} || $cfg{force}) { - print "Downloading binary packages for: $cfg{package}, version: $cfg{version}, into: $cfg{pkgdir}\n"; + my $dir = $args{pkgdir}; + + if(!-e $args{pkgdir} || $args{force}) { + if($cfg{verbose}) { + print "Downloading binary packages for: $args{package}"; + print ", version: $args{version}" if($args{version}); + print ", architecture: $args{architecture}" if($args{architecture}); + print ", into: $args{pkgdir}\n"; + } my @cmd = (); push @cmd, $cfg{debsnap}; - push @cmd, ('--destdir', $cfg{pkgdir}); - push @cmd, '--force' if($cfg{force}); - push @cmd, '--verbose' if($cfg{verbose}); + push @cmd, ('--destdir', $args{pkgdir}); + push @cmd, '--force' if($args{force}); + push @cmd, '--verbose' if($args{verbose}); push @cmd, '--binary'; - push @cmd, $cfg{package}; - push @cmd, $cfg{version}; + push @cmd, ('--architecture', $args{architecture}) if($args{architecture}); + push @cmd, $args{package}; + push @cmd, $args{version} if($args{version} && $args{version} ne 'all'); - print "Exec: @cmd\n" if($cfg{verbose}); + print "Exec: @cmd\n" if($cfg{verbose}); my $exit = system(@cmd) >> 8; if($exit != 0) { @@ -248,7 +273,9 @@ sub download_packages { } sub unpack_packages { - my $dir = $cfg{pkgdir}; + my (%args) = @_; + + my $dir = $args{pkgdir}; if(-r $dir && -w $dir) { print "Extracting downloaded packages...\n" if($cfg{verbose}); @@ -256,7 +283,7 @@ sub unpack_packages { opendir(DIR, $dir) || die "Error: Cannot open directory: $dir ($!)"; while(readdir DIR) { # libgdal1h_1.10.1+dfsg-1_amd64.deb - if(/^($cfg{package})_(\S+)_(\S+)\.deb$/) { + if(/^($args{package})_(\S+)_(\S+)\.deb$/) { my $pkg = $1; my $version = $2; my $arch = $3; @@ -264,7 +291,7 @@ sub unpack_packages { my $pkgdir = $dir.$pkg.'_'.$version.'_'.$arch.'/'; next if($arch eq 'common'); - next if($version ne $cfg{version} && $cfg{version} ne 'all'); + next if($version ne $args{version} && $args{version} ne 'all'); next if(-r $pkgdir); # dpkg-deb -R libgdal1h_1.10.1+dfsg-1_amd64.deb libgdal1h_1.10.1+dfsg-1_amd64 @@ -283,7 +310,7 @@ sub unpack_packages { print "Error: Command failed: @cmd ($exit)\n"; exit $exit; } - } + } } closedir DIR; @@ -295,71 +322,16 @@ sub unpack_packages { } } -sub create_complete_symbols { - my $dir = $cfg{debian}; - - if(-r $dir && -w $dir) { - my $file = $dir.$cfg{package}.'.symbols.common'; - if(!-r $file) { - print "Error: Cannot read common symbols file: $file\n"; - return; - } - - print "Reading common symbols file: $file\n" if($cfg{verbose}); - - my $common = read_file($file); - - opendir(DIR, $dir) || die "Error: Cannot open directory: $dir ($!)"; - while(readdir DIR) { - # libgdal1h.symbols.amd64 - if(/^$cfg{package}.symbols.(\S+)$/) { - my $arch = $1; - - next if($arch eq 'common'); - next if($arch =~ /\.(new|diff|filt|patch|c\+\+|common|complete)$/); - - my $file = $dir.$_; - - print "Reading $arch symbols file: $file\n" if($cfg{verbose}); - - my $data = ''; - foreach(read_file($file)) { - # #include "libgdal1h.symbols.common" - if(/^#include "$cfg{package}.symbols.common"\s*$/) { - print "Including common symbols\n" if($cfg{verbose}); - - $data .= $common; - } - else { - $data .= $_; - } - } - - $file .= '.complete'; - - print "Saving complete symbols file: $file\n" if($cfg{verbose}); - - write_file($file, $data); - - print "\n" if($cfg{verbose}); - } - } - closedir DIR; - } - else { - print "Error: Cannot read/write directory: $dir\n"; - return; - } -} - sub create_new_symbols { - my $dir = $cfg{debian}; + my (%args) = @_; + + my $dir = $args{debian}; if(-r $dir && -w $dir) { opendir(DIR, $dir) || die "Error: Cannot open directory: $dir ($!)"; while(readdir DIR) { # libgdal1h.symbols.amd64 - if(/^($cfg{package}).symbols.(\S+)$/) { + if(/^($args{package}).symbols.(\S+)$/) { my $pkg = $1; my $arch = $2; my $file = $dir.$_; @@ -370,7 +342,7 @@ sub create_new_symbols { my $version = ''; my $library = ''; - my $pkg_dir = $cfg{pkgdir}; + my $pkg_dir = $args{pkgdir}; if(-r $pkg_dir) { print "Looking for $arch under: $pkg_dir\n" if($cfg{verbose}); @@ -381,12 +353,12 @@ sub create_new_symbols { print "Package directory: $_\n" if($cfg{verbose}); $version = $1; - - next if($version ne $cfg{version}); - $version =~ s/(\+dfsg\d*)?-\d+(\~\w+)?$//; + next if($version ne $args{version}); - $library = find_library($pkg_dir.$_.'/usr/lib/'); + $version = upstream_version($version); + + $library = find_library(%args, dir => $pkg_dir.$_.'/usr/lib/'); last; } @@ -400,7 +372,7 @@ sub create_new_symbols { } if(!$version) { - print "Error: Cannot determine package version!\n"; + print "Error: Cannot determine library version!\n"; print "\n" if($cfg{verbose}); next; } @@ -457,7 +429,12 @@ sub create_new_symbols { write_file($filt, $data); print "\n" if($cfg{verbose}); - } + + $symbols{$arch}{file} = $file; + $symbols{$arch}{new} = $output; + $symbols{$arch}{diff} = $diff; + $symbols{$arch}{filt} = $filt; + } } closedir DIR; } @@ -469,21 +446,23 @@ sub create_new_symbols { } sub find_library { - my $dir = shift; - my $depth = shift; + my (%args) = @_; + + my $dir = $args{dir}; + my $depth = $args{depth}; $depth = 0 if(!$depth); my $max_depth = 5; if($depth == $max_depth) { - print "Not looking further, maximum depth reached: $depth\n"; + print "Not looking further, maximum depth reached: $depth\n" if($args{verbose}); return; } my $library = ''; if(-r $dir) { - print "Reading directory: $dir\n" if($cfg{verbose}); + print "Reading directory: $dir\n" if($args{verbose}); opendir(my $dh, $dir) || die "Error: Cannot open directory: $dir ($!)"; while(readdir $dh) { @@ -492,7 +471,7 @@ sub find_library { my $entry = $dir.$_; if(-d $entry) { - $library = find_library($entry.'/', $depth+1); + $library = find_library(%args, dir => $entry.'/', depth => $depth+1); } elsif(-f $entry && $entry =~ /\.so\.\d+\.\d+/) { $library = $entry; @@ -501,7 +480,7 @@ sub find_library { } closedir $dh; - print "Library: $library\n" if($cfg{verbose}); + print "Library: $library\n" if($args{verbose}); } else { print "Error: Cannot read directory: $dir\n"; @@ -511,16 +490,18 @@ sub find_library { return $library; } -sub create_patch_files { +sub create_new_patch_files { + my (%args) = @_; + # Create c++filt symbols files - my $dir = $cfg{debian}; + my $dir = $args{debian}; if(-r $dir && -w $dir) { opendir(DIR, $dir) || die "Error: Cannot open directory: $dir ($!)"; while(readdir DIR) { # libgdal1h.symbols.amd64 - if(/^($cfg{package}).symbols.(\S+)$/) { + if(/^($args{package}).symbols.(\S+)$/) { my $pkg = $1; my $arch = $2; my $file = $dir.$_; @@ -536,59 +517,24 @@ sub create_patch_files { if(-r $diff_file && -r $new_file && -r $filt_file) { # Mark C++ symbols - my @cmd = ( - $cfg{diff}, - '-u', - $new_file, - $filt_file, - ); - - my $data = ''; - my $old = ''; - my $new = ''; - my $tmp = ''; - - foreach(`@cmd`) { - # --- debian/libgdal1h.symbols.amd64.new 2013-12-14 00:18:32.000000000 +0100 - if(/^\-\-\- (\S+\s+\d{4}.*?\S)\s*$/) { - $old = $1; - - $_ = ''; - } - # +++ debian/libgdal1h.symbols.amd64.new.filt 2013-12-14 01:44:01.000000000 +0100 - elsif(/^\+\+\+ (\S+\s+\d{4}.*?\S)\s*$/) { - $new = $1; - - $_ = '--- '. $new."\n" - . '+++ '. $old."\n" - ; - } - # + VRTSourcedRasterBand::ComputeRasterMinMax(int, double*)@GDAL_1.8 1.10.1 - elsif(/^\+ (.*?) (\d+\.\d+\.\d+\S*)\s*$/) { - # ignore - $_ = '+ (c++)"'.$1.'" '.$2." 1\n"; - } - # + VRTSourcedRasterBand::ComputeRasterMinMax(int, double*)@GDAL_1.8 1.10.1 1 - elsif(/^\+ (.*?) (\d+\.\d+\.\d+\S*)(\s+\d+)\s*$/) { - # ignore - $_ = '+ (c++)"'.$1.'" '.$2.$3."\n"; - } - - $data .= $_; - } + create_patch_file( + %args, + file1 => $new_file, + file2 => $filt_file, + patch => $patch_file, + ); - print "Saving rewritten patch: $patch_file\n" if($cfg{verbose}); - - write_file($patch_file, $data); + $symbols{$arch}{patch} = $patch_file; } else { print "Error: Cannot read all files: $diff_file, $new_file, $filt_file\n"; - print `ls -l $diff_file $new_file $filt_file`; next; } } } closedir DIR; + + print "\n" if($cfg{verbose}); } else { print "Error: Cannot read/write directory: $dir\n"; @@ -596,16 +542,70 @@ sub create_patch_files { } } -sub patch_files { +sub create_patch_file { + my (%args) = @_; + + return if(!$args{file1}); + return if(!$args{file2}); + return if(!$args{patch}); + + my @cmd = ( + $cfg{diff}, + '-u', + $args{file1}, + $args{file2}, + ); + + my $data = ''; + my $old = ''; + my $new = ''; + + foreach(`@cmd`) { + # --- debian/libgdal1h.symbols.amd64.new 2013-12-14 00:18:32.000000000 +0100 + if(/^\-\-\- (\S+\s+\d{4}.*?\S)\s*$/) { + $old = $1; + + $_ = ''; + } + # +++ debian/libgdal1h.symbols.amd64.new.filt 2013-12-14 01:44:01.000000000 +0100 + elsif(/^\+\+\+ (\S+\s+\d{4}.*?\S)\s*$/) { + $new = $1; + + $_ = '--- '. $new."\n" + . '+++ '. $old."\n" + ; + } + # + VRTSourcedRasterBand::ComputeRasterMinMax(int, double*)@GDAL_1.8 1.10.1 + elsif(/^\+ (.*?) (\d+\.\d+\.\d+\S*)\s*$/) { + # ignore + $_ = '+ (c++)"'.$1.'" '.$2." 1\n"; + } + # + VRTSourcedRasterBand::ComputeRasterMinMax(int, double*)@GDAL_1.8 1.10.1 1 + elsif(/^\+ (.*?) (\d+\.\d+\.\d+\S*)(\s+\d+)\s*$/) { + # ignore + $_ = '+ (c++)"'.$1.'" '.$2.$3."\n"; + } + + $data .= $_; + } + + print "Saving rewritten patch: $args{patch}\n" if($cfg{verbose}); + + write_file($args{patch}, $data); +} + +sub patch_new_files { + my (%args) = @_; + # Apply c++filt symbols patches - my $dir = $cfg{debian}; + my $dir = $args{debian}; if(-r $dir && -w $dir) { opendir(DIR, $dir) || die "Error: Cannot open directory: $dir ($!)"; while(readdir DIR) { # libgdal1h.symbols.amd64 - if(/^($cfg{package}).symbols.(\S+)$/) { + if(/^($args{package}).symbols.(\S+)$/) { my $pkg = $1; my $arch = $2; my $file = $dir.$_; @@ -621,31 +621,12 @@ sub patch_files { if(-r $diff_file && -r $new_file && -r $filt_file && -r $patch_file) { # Mark C++ symbols - my @cmd = ( - $cfg{patch}, - '-p1', - '-i'.$patch_file, - $new_file, + patch_file( + %args, + patch => $patch_file, + file => $new_file, ); - print "Exec: @cmd\n" if($cfg{verbose}); - - my $exit = system(@cmd) >> 8; - if($exit != 0) { - print "Error: Command failed: @cmd ($exit)\n"; - exit $exit; - } - - @cmd = ('rm', $patch_file); - - print "Exec: @cmd\n" if($cfg{verbose}); - - $exit = system(@cmd) >> 8; - if($exit != 0) { - print "Error: Command failed: @cmd ($exit)\n"; - exit $exit; - } - print "\n" if($cfg{verbose}); } else { @@ -664,16 +645,37 @@ sub patch_files { } } -sub split_files { +sub patch_file { + my (%args) = @_; + + my @cmd = ( + $cfg{patch}, + '-p1', + '-i'.$args{patch}, + $args{file}, + ); + + print "Exec: @cmd\n" if($cfg{verbose}); + + my $exit = system(@cmd) >> 8; + if($exit != 0) { + print "Error: Command failed: @cmd ($exit)\n"; + exit $exit; + } +} + +sub split_new_files { + my (%args) = @_; + # Split common and C++ symbols into seperate files. - my $dir = $cfg{debian}; + my $dir = $args{debian}; if(-r $dir && -w $dir) { opendir(DIR, $dir) || die "Error: Cannot open directory: $dir ($!)"; while(readdir DIR) { # libgdal1h.symbols.amd64 - if(/^($cfg{package}).symbols.(\S+)$/) { + if(/^($args{package}).symbols.(\S+)$/) { my $pkg = $1; my $arch = $2; my $file = $dir.$_; @@ -689,23 +691,13 @@ sub split_files { if(-r $diff_file && -r $new_file && -r $filt_file && !-r $patch_file) { print "Splitting files for: $file\n" if($cfg{verbose}); - my $common = ''; - my $cplus = ''; + my ($common, $cplus) = split_file( + %args, + file => $new_file, + ); - foreach(read_file($new_file)) { - if(/\(c\+\+\)/ || !/^ /) { - $cplus .= $_; - } - else { - $common .= $_; - } - } - - my $common_file = $new_file.'.common'; - my $cplus_file = $new_file.'.c++'; - - write_file($common_file, $common); - write_file($cplus_file, $cplus); + $symbols{$arch}{common} = $common; + $symbols{$arch}{cplus} = $cplus; } else { print "Error: Cannot read all files: $diff_file, $new_file, $filt_file, $patch_file\n"; @@ -723,14 +715,44 @@ sub split_files { } } -sub compare_symbols { - my $dir = $cfg{debian}; +sub split_file { + my (%args) = @_; + + return if(!$args{file}); + + if(-r $args{file}) { + my $common = ''; + my $cplus = ''; + + foreach(read_file($args{file})) { + if(/\(c\+\+\)/ || !/^ /) { + $cplus .= $_; + } + else { + $common .= $_; + } + } + + my $common_file = $args{file}.'.common'; + my $cplus_file = $args{file}.'.c++'; + + write_file($common_file, $common); + write_file($cplus_file, $cplus); + + return ($common_file, $cplus_file); + } +} + +sub compare_new_symbols { + my (%args) = @_; + + my $dir = $args{debian}; if(-r $dir && -w $dir) { my %checksum = (); my $arch = 'common'; - my $file = $dir.$cfg{package}.'.symbols.'.$arch; + my $file = $dir.$args{package}.'.symbols.'.$arch; print "Comparing symbols for: $file\n" if($cfg{verbose}); @@ -753,7 +775,7 @@ sub compare_symbols { opendir(DIR, $dir) || die "Error: Cannot open directory: $dir ($!)"; while(readdir DIR) { # libgdal1h.symbols.amd64.new.common - if(/^($cfg{package}).symbols.(\S+).new.common$/) { + if(/^($args{package}).symbols.(\S+).new.common$/) { my $pkg2 = $1; my $arch2 = $2; my $file2 = $dir.$_; @@ -785,18 +807,18 @@ sub compare_symbols { foreach my $file2 (@different) { my $old = $file; my $new = $file2; - + my @cmd = ( $cfg{diff}, '-u', $old, $new, ); - + print "Exec: @cmd\n" if($cfg{verbose}); - + my $exit = system(@cmd) >> 8; - + print "Exit: $exit\n" if($cfg{verbose}); } } @@ -850,7 +872,7 @@ sub compare_symbols { opendir(DIR, $dir) || die "Error: Cannot open directory: $dir ($!)"; while(readdir DIR) { # libgdal1h.symbols.amd64 - if(/^($cfg{package}).symbols.(\S+)$/) { + if(/^($args{package}).symbols.(\S+)$/) { my $pkg = $1; my $arch = $2; my $file = $dir.$_; @@ -879,21 +901,21 @@ sub compare_symbols { else { if(!$cfg{no_diff}) { my @cmd = ( - $cfg{diff}, - '-u', + $cfg{diff}, + '-u', $old, $new, ); - + print "Exec: @cmd\n" if($cfg{verbose}); - + my $exit = system(@cmd) >> 8; - + print "Exit: $exit\n" if($cfg{verbose}); - + print `@cmd | diffstat`; } - + print "New $arch symbols different from the current symbols, update required!\n" if($cfg{verbose}); if(!$cfg{no_prompt}) { @@ -906,11 +928,11 @@ sub compare_symbols { $help, $default, ); - + if($result) { my $file1 = $new; my $file2 = $old; - + if(-r $file1 && -w $file2) { print "Copy: $file1 -> $file2\n" if($cfg{verbose}); @@ -927,13 +949,11 @@ sub compare_symbols { } } } - + print "\n" if($cfg{verbose}); } } closedir DIR; - - print "\n" if($cfg{verbose}); } else { print "Error: Cannot read/write directory: $dir\n"; @@ -942,3 +962,305 @@ sub compare_symbols { } } +sub parse_symbols { + my (%args) = @_; + + return if (!$args{file} || !-r $args{file}); + + my %symbols = (); + + foreach(read_file($args{file})) { + # BSBClose@GDAL_1.8 1.8.0 + if(/^ (\S+)\s+(\d+\S+\d+)\s*$/) { + my $symbol = $1; + my $version = $2; + + $symbols{$symbol}{version} = $version; + } + # libgdal.so.1 libgdal1h #MINVER# + # | libgdal1h #MINVER#, libgdal.so.1-1.11.1 + # #include "libgdal1h.symbols.common" + # (c++)"PamGetProxy(char const*)@GDAL_1.8" 1.8.0 1 + elsif(/^ (\S+)\s+(\d+\S+\d+)\s*(\d+)\s*$/) { + my $symbol = $1; + my $version = $2; + my $template = $3; + + $symbols{$symbol}{version} = $version; + $symbols{$symbol}{template} = $template; + } + } + + return \%symbols; +} + +sub compare_common_symbols { + my (%args) = @_; + + return if(!$args{arch} || !$symbols{$args{arch}}{common} || !$symbols{common}{file}); + + if(!$symbols{common}{symbols}) { + $symbols{common}{symbols} = parse_symbols(%args, file => $symbols{common}{file}); + } + + $symbols{$args{arch}}{symbols} = parse_symbols(%args, file => $symbols{$args{arch}}{common}); + + print "Comparing symbols between $symbols{common}{file} and $symbols{$args{arch}}{common}...\n" if($cfg{verbose}); + + my %compare = (); + + foreach my $symbol (sort keys %{$symbols{common}{symbols}}) { + $compare{$symbol}{old} = $symbols{common}{symbols}{$symbol}; + } + foreach my $symbol (sort keys %{$symbols{$args{arch}}{symbols}}) { + $compare{$symbol}{new} = $symbols{$args{arch}}{symbols}{$symbol}; + } + + my $changes = 0; + + foreach my $symbol (sort keys %compare) { + if(!$compare{$symbol}{old} || !$compare{$symbol}{new}) { + if(!$compare{$symbol}{old}) { + print "Symbol not in old: $symbol ($symbols{common}{file})\n" if($cfg{verbose}); + } + if(!$compare{$symbol}{new}) { + print "Symbol not in new: $symbol ($symbols{$args{arch}}{common})\n" if($cfg{verbose}); + } + + $changes++; + } + } + + return $changes; +} + +sub new_architecture_symbols { + my (%args) = @_; + + my $dir = $args{pkgdir}; + + if(-r $dir && -w $dir) { + print "Creating symbols files for new architectures...\n" if($cfg{verbose}); + + my $new = 0; + + opendir(my $DIR, $dir) || die "Error: Cannot open directory: $dir ($!)"; + while(readdir $DIR) { + # libgdal1h_1.10.1+dfsg-1_amd64.deb + if(/^($args{package})_(\S+)_(\S+)\.deb$/) { + my $pkg = $1; + my $version = $2; + my $arch = $3; + my $file = $dir.$_; + my $pkgdir = $dir.$pkg.'_'.$version.'_'.$arch.'/'; + + my $upstream_version = upstream_version($version); + + next if($symbols{$arch}); + + # download all previous versions + download_packages(%args, architecture => $arch, version => 'all'); + + # unpack all previous versions + unpack_packages(%args, architecture => $arch, version => 'all'); + + # generate symbols for all versions + foreach my $version (@versions) { + my $library = ''; + + my $pkg_dir = $args{pkgdir}; + if(-r $pkg_dir) { + my $dir = $pkg_dir.$pkg.'_'.$version.'_'.$arch.'/'; + if(!-r $dir) { + print "Warning: Cannot read package directory: $dir\n"; + next; + } + + $library = find_library(%args, dir => $dir.'/usr/lib/', verbose => 0); + } + else { + print "Warning: Cannot read package directory: $pkg_dir\n"; + print "\n" if($cfg{verbose}); + next; + } + + if(!$library) { + print "Warning: Cannot find library!\n"; + print "\n" if($cfg{verbose}); + next; + } + + my $upstream_version = upstream_version($version); + + my $file = $args{debian}.$pkg.'.symbols.'.$arch; + my $diff = $file.'.diff'; + + # dpkg-gensymbols -plibgdal1h -aarmel -v1.10.1 -Odebian/libgdal1h.symbols.armel -ebinary-libgdal1h/libgdal1h_1.10.1+dfsg-1_armel/usr/lib/libgdal.so.1.17.1 + + my @cmd = ( + $cfg{gensymbols}, + '-p'.$pkg, + '-a'.$arch, + '-v'.$upstream_version, + '-O'.$file, + '-e'.$library, + ); + + print "Exec: @cmd > $diff 2>&1\n" if($cfg{verbose}); + + `@cmd > $diff 2>&1`; + + $symbols{$arch}{file} = $file; + $symbols{$arch}{diff} = $diff; + } + + # Mark C++ symbols using c++filt + if($symbols{$arch}{file}) { + # cat debian/libgdal1h.symbols.armel | c++filt > debian/libgdal1h.symbols.armel.filt + + my $filt = $symbols{$arch}{file}.'.filt'; + + print "Exec: cat $symbols{$arch}{file} | $cfg{cppfilt} > $filt 2>&1\n" if($cfg{verbose}); + + `cat $symbols{$arch}{file} | $cfg{cppfilt} > $filt 2>&1`; + + # libgdal.so.1 libgdal1h #MINVER# + # | libgdal1h #MINVER#, libgdal.so.1-1.10.1 + # #include "libgdal1h.symbols.common" + + my $data = ''; + + my $upstream_version = upstream_version($versions[-1]); + + my $i = 0; + foreach(read_file($filt)) { + if($i == 0 && /^ /) { + $_ = "#include \"${pkg}.symbols.common\"\n" . $_; + $_ = "| ${pkg} #MINVER#, libgdal.so.1-$upstream_version\n" . $_; + + $i++; + } + + $data .= $_; + } + + write_file($filt, $data); + + print "\n" if($cfg{verbose}); + + $symbols{$arch}{filt} = $filt; + } + + # Create & apply patch file for enhanced C++ symbols + if($symbols{$arch}{file} && $symbols{$arch}{filt}) { + my $patch_file = $symbols{$arch}{file}.'.patch'; + + create_patch_file( + %args, + file1 => $symbols{$arch}{file}, + file2 => $symbols{$arch}{filt}, + patch => $patch_file, + ); + + patch_file( + %args, + patch => $patch_file, + file => $symbols{$arch}{file}, + ); + + $symbols{$arch}{patch} = $patch_file; + } + + # split common & C++ symbols + if($symbols{$arch}{file} && $symbols{$arch}{filt} && $symbols{$arch}{patch}) { + my ($common, $cplus) = split_file( + %args, + file => $symbols{$arch}{file}, + ); + + $symbols{$arch}{common} = $common; + $symbols{$arch}{cplus} = $cplus; + } + + # compare with existing common symbols + if($symbols{$arch}{file} && $symbols{$arch}{common} && $symbols{$arch}{cplus}) { + if(!$symbols{common}{file}) { + $symbols{common}{file} = $args{debian}.$args{package}.'.symbols.common'; + } + + my $changes = compare_common_symbols( + %args, + arch => $arch, + ); + + if(!$changes) { + print "Current common symbols are identical to the $arch common symbols, no update required.\n" if($cfg{verbose}); + + # Replace architecture symbols file with C++ symbols only + + my $file1 = $symbols{$arch}{cplus}; + my $file2 = $symbols{$arch}{file}; + + if(-r $file1 && -w $file2) { + print "Copy: $file1 -> $file2\n" if($cfg{verbose}); + + copy($file1, $file2) || die "Error: Failed to copy $file1 to $file2 ($!)\n"; + } + else { + print "Warning: Cannot read $file1 and/or write $file2\n"; + next; + } + } + else { + print "New $arch common symbols different from the current common symbols, update required!\n" if($cfg{verbose}); + } + } + + $new++; + + print "\n" if($cfg{verbose}); + } + } + closedir $DIR; + + print "No new architectures found.\n" if(!$new && $cfg{verbose}); + } + else { + print "Error: Cannot read/write directory: $dir\n"; + return; + } +} + +sub clean_temp_files { + my (%args) = @_; + + print "Removing files:\n" if($cfg{verbose}); + + my $i = 0; + foreach my $arch (sort keys %symbols) { + next if($arch eq 'common'); + + foreach my $key (sort keys %{$symbols{$arch}}) { + next if($key eq 'file' || $key eq 'symbols' || !-r $symbols{$arch}{$key}); + + print " $symbols{$arch}{$key}" if($cfg{verbose}); + + unlink($symbols{$arch}{$key}) || die "Error: Failed to unlink: $symbols{$arch}{$key} ($!)"; + } + + $i++; + + print "\n" if($cfg{verbose}); + } + + print "\n" if($cfg{verbose}); +} + +sub upstream_version { + my $version = shift; + + $version =~ s/(\+dfsg\d*)?-\d+(\~\w+)?(\+b\d+)?$//; + + return $version; +} + -- Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/gdal.git _______________________________________________ Pkg-grass-devel mailing list Pkg-grass-devel@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-grass-devel