test1022.pl 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #!/usr/bin/env perl
  2. # Determine if curl-config --version matches the curl --version
  3. if ( $#ARGV != 2 )
  4. {
  5. print "Usage: $0 curl-config-script curl-version-output-file version|vernum\n";
  6. exit 3;
  7. }
  8. my $what=$ARGV[2];
  9. # Read the output of curl --version
  10. open(CURL, "$ARGV[1]") || die "Can't open curl --version list in $ARGV[1]\n";
  11. $_ = <CURL>;
  12. chomp;
  13. /libcurl\/([\.\d]+((-DEV)|(-\d+))?)/;
  14. my $version = $1;
  15. close CURL;
  16. my $curlconfigversion;
  17. # Read the output of curl-config --version/--vernum
  18. open(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config --$what list\n";
  19. $_ = <CURLCONFIG>;
  20. chomp;
  21. my $filever=$_;
  22. if ( $what eq "version" ) {
  23. if($filever =~ /^libcurl ([\.\d]+((-DEV)|(-\d+))?)$/) {
  24. $curlconfigversion = $1;
  25. }
  26. else {
  27. $curlconfigversion = "illegal value";
  28. }
  29. }
  30. else { # "vernum" case
  31. # Convert hex version to decimal for comparison's sake
  32. if($filever =~ /^(..)(..)(..)$/) {
  33. $curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3);
  34. }
  35. else {
  36. $curlconfigversion = "illegal value";
  37. }
  38. # Strip off the -DEV from the curl version if it's there
  39. $version =~ s/-\w*$//;
  40. }
  41. close CURLCONFIG;
  42. my $different = $version ne $curlconfigversion;
  43. if ($different || !$version) {
  44. print "Mismatch in --version:\n";
  45. print "curl: $version\n";
  46. print "curl-config: $curlconfigversion\n";
  47. exit 1;
  48. }