Artifact
4356d9d94d2b5ed5e68f9f0c80c4df3048dd7617 :
File
tclinstaller.tcl
— part of check-in
[e54a49e264]
at
2007-05-03 20:06:11
on branch trunk
— fix from Gentoo for allowing TCLLIBDIR to be overridden in env (CVS 3911)
(user:
vapier
size: 1125)
0000: 23 20 54 68 69 73 20 73 63 72 69 70 74 20 61 74 # This script at
0010: 74 65 6d 70 74 73 20 74 6f 20 69 6e 73 74 61 6c tempts to instal
0020: 6c 20 53 51 4c 69 74 65 33 20 73 6f 20 74 68 61 l SQLite3 so tha
0030: 74 20 69 74 20 63 61 6e 20 62 65 20 75 73 65 64 t it can be used
0040: 0a 23 20 62 79 20 54 43 4c 2e 20 20 49 6e 76 6f .# by TCL. Invo
0050: 6b 65 20 74 68 69 73 20 73 63 72 69 70 74 20 77 ke this script w
0060: 69 74 68 20 73 69 6e 67 6c 65 20 61 72 67 75 6d ith single argum
0070: 65 6e 74 20 77 68 69 63 68 20 69 73 20 74 68 65 ent which is the
0080: 0a 23 20 76 65 72 73 69 6f 6e 20 6e 75 6d 62 65 .# version numbe
0090: 72 20 6f 66 20 53 51 4c 69 74 65 2e 20 20 45 78 r of SQLite. Ex
00a0: 61 6d 70 6c 65 3a 0a 23 0a 23 20 20 20 20 74 63 ample:.#.# tc
00b0: 6c 73 68 20 74 63 6c 69 6e 73 74 61 6c 6c 65 72 lsh tclinstaller
00c0: 2e 74 63 6c 20 33 2e 30 0a 23 0a 73 65 74 20 56 .tcl 3.0.#.set V
00d0: 45 52 53 49 4f 4e 20 5b 6c 69 6e 64 65 78 20 24 ERSION [lindex $
00e0: 61 72 67 76 20 30 5d 0a 73 65 74 20 4c 49 42 46 argv 0].set LIBF
00f0: 49 4c 45 20 2e 6c 69 62 73 2f 6c 69 62 74 63 6c ILE .libs/libtcl
0100: 73 71 6c 69 74 65 33 5b 69 6e 66 6f 20 73 68 61 sqlite3[info sha
0110: 72 65 64 6c 69 62 65 78 74 65 6e 73 69 6f 6e 5d redlibextension]
0120: 0a 69 66 20 7b 20 21 5b 69 6e 66 6f 20 65 78 69 .if { ![info exi
0130: 73 74 73 20 65 6e 76 28 44 45 53 54 44 49 52 29 sts env(DESTDIR)
0140: 5d 20 7d 20 7b 20 73 65 74 20 65 6e 76 28 44 45 ] } { set env(DE
0150: 53 54 44 49 52 29 20 22 22 20 7d 0a 69 66 20 7b STDIR) "" }.if {
0160: 20 21 5b 69 6e 66 6f 20 65 78 69 73 74 73 20 65 ![info exists e
0170: 6e 76 28 54 43 4c 4c 49 42 44 49 52 29 5d 20 7d nv(TCLLIBDIR)] }
0180: 20 7b 20 73 65 74 20 65 6e 76 28 54 43 4c 4c 49 { set env(TCLLI
0190: 42 44 49 52 29 20 5b 6c 69 6e 64 65 78 20 24 61 BDIR) [lindex $a
01a0: 75 74 6f 5f 70 61 74 68 20 30 5d 20 7d 0a 73 65 uto_path 0] }.se
01b0: 74 20 4c 49 42 44 49 52 20 24 65 6e 76 28 44 45 t LIBDIR $env(DE
01c0: 53 54 44 49 52 29 24 65 6e 76 28 54 43 4c 4c 49 STDIR)$env(TCLLI
01d0: 42 44 49 52 29 0a 73 65 74 20 4c 49 42 44 49 52 BDIR).set LIBDIR
01e0: 5f 49 4e 53 54 41 4c 4c 20 24 65 6e 76 28 54 43 _INSTALL $env(TC
01f0: 4c 4c 49 42 44 49 52 29 0a 73 65 74 20 4c 49 42 LLIBDIR).set LIB
0200: 4e 41 4d 45 20 5b 66 69 6c 65 20 74 61 69 6c 20 NAME [file tail
0210: 24 4c 49 42 46 49 4c 45 5d 0a 73 65 74 20 4c 49 $LIBFILE].set LI
0220: 42 20 24 4c 49 42 44 49 52 2f 73 71 6c 69 74 65 B $LIBDIR/sqlite
0230: 33 2f 24 4c 49 42 4e 41 4d 45 0a 73 65 74 20 4c 3/$LIBNAME.set L
0240: 49 42 5f 49 4e 53 54 41 4c 4c 20 24 4c 49 42 44 IB_INSTALL $LIBD
0250: 49 52 5f 49 4e 53 54 41 4c 4c 2f 73 71 6c 69 74 IR_INSTALL/sqlit
0260: 65 33 2f 24 4c 49 42 4e 41 4d 45 0a 0a 66 69 6c e3/$LIBNAME..fil
0270: 65 20 64 65 6c 65 74 65 20 2d 66 6f 72 63 65 20 e delete -force
0280: 24 4c 49 42 44 49 52 2f 73 71 6c 69 74 65 33 0a $LIBDIR/sqlite3.
0290: 66 69 6c 65 20 6d 6b 64 69 72 20 24 4c 49 42 44 file mkdir $LIBD
02a0: 49 52 2f 73 71 6c 69 74 65 33 0a 73 65 74 20 66 IR/sqlite3.set f
02b0: 64 20 5b 6f 70 65 6e 20 24 4c 49 42 44 49 52 2f d [open $LIBDIR/
02c0: 73 71 6c 69 74 65 33 2f 70 6b 67 49 6e 64 65 78 sqlite3/pkgIndex
02d0: 2e 74 63 6c 20 77 5d 0a 70 75 74 73 20 24 66 64 .tcl w].puts $fd
02e0: 20 22 70 61 63 6b 61 67 65 20 69 66 6e 65 65 64 "package ifneed
02f0: 65 64 20 73 71 6c 69 74 65 33 20 24 56 45 52 53 ed sqlite3 $VERS
0300: 49 4f 4e 20 5c 5b 6c 69 73 74 20 6c 6f 61 64 20 ION \[list load
0310: 24 4c 49 42 5f 49 4e 53 54 41 4c 4c 20 73 71 6c $LIB_INSTALL sql
0320: 69 74 65 33 5c 5d 22 0a 63 6c 6f 73 65 20 24 66 ite3\]".close $f
0330: 64 0a 0a 23 20 57 65 20 63 61 6e 6e 6f 74 20 75 d..# We cannot u
0340: 73 65 20 5b 66 69 6c 65 20 63 6f 70 79 5d 20 62 se [file copy] b
0350: 65 63 61 75 73 65 20 74 68 61 74 20 77 69 6c 6c ecause that will
0360: 20 6a 75 73 74 20 6d 61 6b 65 20 61 20 63 6f 70 just make a cop
0370: 79 20 6f 66 0a 23 20 61 20 73 79 6d 62 6f 6c 69 y of.# a symboli
0380: 63 20 6c 69 6e 6b 2e 20 20 57 65 20 68 61 76 65 c link. We have
0390: 20 74 6f 20 6f 70 65 6e 20 61 6e 64 20 63 6f 70 to open and cop
03a0: 79 20 74 68 65 20 66 69 6c 65 20 66 6f 72 20 6f y the file for o
03b0: 75 72 73 65 6c 76 65 73 2e 0a 23 0a 73 65 74 20 urselves..#.set
03c0: 69 6e 20 5b 6f 70 65 6e 20 24 4c 49 42 46 49 4c in [open $LIBFIL
03d0: 45 5d 0a 66 63 6f 6e 66 69 67 75 72 65 20 24 69 E].fconfigure $i
03e0: 6e 20 2d 74 72 61 6e 73 6c 61 74 69 6f 6e 20 62 n -translation b
03f0: 69 6e 61 72 79 0a 73 65 74 20 6f 75 74 20 5b 6f inary.set out [o
0400: 70 65 6e 20 24 4c 49 42 20 77 5d 0a 66 63 6f 6e pen $LIB w].fcon
0410: 66 69 67 75 72 65 20 24 6f 75 74 20 2d 74 72 61 figure $out -tra
0420: 6e 73 6c 61 74 69 6f 6e 20 62 69 6e 61 72 79 0a nslation binary.
0430: 70 75 74 73 20 2d 6e 6f 6e 65 77 6c 69 6e 65 20 puts -nonewline
0440: 24 6f 75 74 20 5b 72 65 61 64 20 24 69 6e 5d 0a $out [read $in].
0450: 63 6c 6f 73 65 20 24 69 6e 0a 63 6c 6f 73 65 20 close $in.close
0460: 24 6f 75 74 0a $out.