test1022.pl 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
  10. #
  11. # This software is licensed as described in the file COPYING, which
  12. # you should have received as part of this distribution. The terms
  13. # are also available at https://curl.se/docs/copyright.html.
  14. #
  15. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  16. # copies of the Software, and permit persons to whom the Software is
  17. # furnished to do so, under the terms of the COPYING file.
  18. #
  19. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  20. # KIND, either express or implied.
  21. #
  22. # SPDX-License-Identifier: curl
  23. #
  24. ###########################################################################
  25. # Determine if curl-config --version matches the curl --version
  26. if ( $#ARGV != 2 )
  27. {
  28. print "Usage: $0 curl-config-script curl-version-output-file version|vernum\n";
  29. exit 3;
  30. }
  31. my $what=$ARGV[2];
  32. # Read the output of curl --version
  33. open(CURL, "$ARGV[1]") || die "Can't open curl --version list in $ARGV[1]\n";
  34. $_ = <CURL>;
  35. chomp;
  36. /libcurl\/([\.\d]+((-DEV)|(-\d+))?)/;
  37. my $version = $1;
  38. close CURL;
  39. my $curlconfigversion;
  40. # Read the output of curl-config --version/--vernum
  41. open(CURLCONFIG, "sh $ARGV[0] --$what|") || die "Can't get curl-config --$what list\n";
  42. $_ = <CURLCONFIG>;
  43. chomp;
  44. my $filever=$_;
  45. if ( $what eq "version" ) {
  46. if($filever =~ /^libcurl ([\.\d]+((-DEV)|(-\d+))?)$/) {
  47. $curlconfigversion = $1;
  48. }
  49. else {
  50. $curlconfigversion = "illegal value";
  51. }
  52. }
  53. else { # "vernum" case
  54. # Convert hex version to decimal for comparison's sake
  55. if($filever =~ /^(..)(..)(..)$/) {
  56. $curlconfigversion = hex($1) . "." . hex($2) . "." . hex($3);
  57. }
  58. else {
  59. $curlconfigversion = "illegal value";
  60. }
  61. # Strip off the -DEV from the curl version if it's there
  62. $version =~ s/-\w*$//;
  63. }
  64. close CURLCONFIG;
  65. my $different = $version ne $curlconfigversion;
  66. if ($different || !$version) {
  67. print "Mismatch in --version:\n";
  68. print "curl: $version\n";
  69. print "curl-config: $curlconfigversion\n";
  70. exit 1;
  71. }