From b90672a55d258c7e5c6ed7e038b14f2874eecf6d Mon Sep 17 00:00:00 2001 From: Darren Duncan Date: Wed, 8 Dec 2010 05:09:33 +0000 Subject: [PATCH] upd getsqlite.pl to work with 3.7.4+ dist filenames --- Changes | 2 ++ util/getsqlite.pl | 31 +++++++++++++++++++++++++++---- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/Changes b/Changes index e191df6..1376795 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ Changes for Perl extension DBD-SQLite 1.32_01 to be released + - Made util/getsqlite.pl work with the amalg distro filename changes + introd by SQLite 3.7.4, and still with older ones also (DUNCAND) - Updated to SQLite 3.7.3 (DUNCAND) - Resolved #61355: Fails testing in parallel (ISHIGAKI) - Resolved #61361: Problems building 1.31 with system SQLite (ISHIGAKI) diff --git a/util/getsqlite.pl b/util/getsqlite.pl index 52fa9d4..d9bedf7 100644 --- a/util/getsqlite.pl +++ b/util/getsqlite.pl @@ -10,17 +10,40 @@ chdir(catdir($FindBin::Bin, updir())) or die "Failed to change to the dist root" my $version = shift || die "Usage: getsqlite.pl \n"; -print("downloading http://www.sqlite.org/sqlite-amalgamation-$version.tar.gz\n"); +# The http://www.sqlite.org/sqlite-amalgamation-$version.tar.gz name format changed starting with 3.7.4 +# We will let user specify any SQLite version in either the old or new format, and normalize. +my @version_parts; +if ($version =~ m/^[0-9](?:\.[0-9]+){0,3}$/) { + # $version is X.Y+.Z+.W+ style used for SQLite <= 3.7.3 + @version_parts = map { (0 + $_) } (split /\./, $version); +} +elsif ($version =~ m/^[0-9](?:[0-9]{2}){0,3}$/) { + # $version is XYYZZWW style used for SQLite >= 3.7.4 + @version_parts = map { 0 + $_ } ((substr $version, 0, 1), ((substr $version, 1) =~ m/[0-9]{2}/g)); +} +else { + die "improper format for [$version]\n"; +} +my $version_as_num = sprintf( q{%u%02u%02u%02u}, @version_parts ); +my $version_dotty = join '.', ($version_parts[3] ? @version_parts : @version_parts[0..2]); +my $is_pre_30704_style = ($version_as_num < 3070400); +my $version_for_url = $is_pre_30704_style ? $version_dotty : $version_as_num; + + +my $url_to_download = q{http://www.sqlite.org/sqlite-} + . ($is_pre_30704_style ? q{amalgamation} : q{autoconf}) + . qq{-$version_for_url.tar.gz}; +print("downloading $url_to_download\n"); my $rv = getstore( - "http://www.sqlite.org/sqlite-amalgamation-$version.tar.gz", + $url_to_download, "sqlite.tar.gz", ); die "Failed to download" if $rv != 200; print("done\n"); -rm_rf('sqlite') || rm_rf("sqlite-$version") || rm_rf("sqlite-amalgamation-$version"); +rm_rf('sqlite') || rm_rf("sqlite-$version_dotty") || rm_rf("sqlite-amalgamation-$version_dotty"); xsystem("tar zxvf sqlite.tar.gz"); -chdir("sqlite") || chdir("sqlite-$version") || chdir("sqlite-amalgamation-$version") || die "SQLite directory not found"; +chdir("sqlite") || chdir("sqlite-$version_dotty") || chdir("sqlite-amalgamation-$version_dotty") || die "SQLite directory not found";