1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
#!/usr/bin/env tclsh
# This one has to be run under Unix, because of autotools
# Download page:
# https://github.com/sqlcipher/sqlcipher/releases
set THE_URL "https://codeload.github.com/sqlcipher/sqlcipher/zip/v4.6.1"
proc process {} {
if {[catch {
wget $::THE_URL sqlite.zip
puts "Decompressing to 'sqlite' directory."
exec 7z x -osqlite sqlite.zip
set dir [lindex [glob -directory sqlite sqlcipher-*] 0]
puts "Running ./configure and make to generate sqlite3.c"
cd $dir
catch {exec ./configure --enable-fts5 --enable-json1 --enable-update-limit --enable-geopoly --enable-rtree --enable-session --enable-gcov --disable-tcl}
catch {exec make}
cd ../..
copy $dir/sqlite3.c
copy $dir/sqlite3.h
file rename -force sqlite3.c sqlcipher.c
file rename -force sqlite3.h sqlcipher.h
}]} {
puts $::errorInfo
}
file delete -force sqlite.zip sqlite
}
proc copy {file} {
set fd [open $file r]
set data [read $fd]
close $fd
set data [string map [list sqlite3 sqlcipher_sqlite3] $data]
set outFile [file tail $file]
puts "Copying $outFile"
set fd [open $outFile w+]
puts $fd $data
close $fd
}
proc wget {url {filename {}}} {
puts "Downloading $url"
package require http
if {[catch {package require twapi_crypto}]} {
package require tls
http::register https 443 [list ::tls::socket]
} else {
http::register https 443 [list ::twapi::tls_socket]
}
if {$filename == ""} {
set filename [file tail $url]
}
set r [http::geturl $url -binary 1]
set fo [open $filename w]
fconfigure $fo -translation binary
puts -nonewline $fo [http::data $r]
close $fo
::http::cleanup $r
}
process
|