Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.installer / org.gvsig.desktop.installer.installjamer / src / main / packaging / gvspkg.bin / main.tcl @ 42300

History | View | Annotate | Download (9.37 KB)

1
proc main { } {
2
        global argc
3
        global argv
4

    
5
        if {$argc < 1} {
6
                help
7
                return 1
8
        }
9
        if {$::installkit::wrapped} {
10
                puts "Script embebido en el binario"
11
                # Cuando se da esta condicion he palmado el argv de 0,
12
                # y no se de donde sacarlo., con lo que se perdio el command
13
                puts "argv: $argv"
14
                puts "tcl_argv: $::tcl_argv"
15
        }
16

    
17
        set cmd [lindex $argv 0]
18
        # puts "command: $cmd"
19
        #puts "argv: $argv"
20
        #puts "tcl_argv: $::tcl_argv"
21
        switch $cmd {
22
                "help" {
23
                        help
24
                }
25
                "ls" {
26
                        set install_file  [ lindex $argv 1 ]
27
                        ls $install_file
28
                }
29
                "addmain" {
30
                        set install_file  [ lindex $argv 1 ]
31
                        set main_file  [ lindex $argv 2 ]
32
                        addmain $install_file $main_file
33
                }
34
                "addpks" {
35
                        set install_file  [ lindex $argv 1 ]
36
                        set package_set  [ lindex $argv 2 ]
37
                        addpks $install_file $package_set
38
                }
39
                "addjrelin" {
40
                        set install_file  [ lindex $argv 1 ]
41
                        set jre_installer  [ lindex $argv 2 ]
42
                        addjrelin $install_file $jre_installer
43
                }
44
                "addjrewin" {
45
                        set install_file  [ lindex $argv 1 ]
46
                        set jre_installer  [ lindex $argv 2 ]
47
                        addjrewin $install_file $jre_installer
48
                }
49
                "extractpks" {
50
                        set install_file  [ lindex $argv 1 ]
51
                        set folder  [ lindex $argv 2 ]
52
                        extractpks $install_file $folder
53
                }
54
                "extractjrelin" {
55
                        set install_file  [ lindex $argv 1 ]
56
                        set folder  [ lindex $argv 2 ]
57
                        extractjrelin $install_file $folder
58
                }
59
               "extractjrewin" {
60
                        set install_file  [ lindex $argv 1 ]
61
                        set folder  [ lindex $argv 2 ]
62
                        extractjrewin $install_file $folder
63
                }
64
                default {
65
                        puts "unknow command $cmd"
66
                        help
67
                }
68
        }
69
}
70

    
71

    
72
proc help {} {
73
        global argv0
74
        puts "Usage: [ file tail $argv0 ] command args"
75
        puts "Command are:"
76
        ls_help
77
        addpks_help
78
        addmain_help
79
        addjrelin_help
80
        addjrewin_help
81
        extractpks_help
82
        extractjrelin_help
83
        extractjrewin_help
84
}
85

    
86
proc addmain_help {} {
87
        puts ""
88
        puts "addmain installkit main-file"
89
        puts "  Add the main file to the installkit"
90
        puts "  If main.tcl already in installkit it is replaced"
91
}
92

    
93
proc addmain { installkit_file main_file } {
94
	addfile $install_file $main_file "main.tcl" "Main"
95
}
96

    
97
proc addpks_help {} {
98
        puts ""
99
        puts "addpks gvsig-install-program package-set"
100
        puts "  Add the specified package set to the installation program"
101
        puts "  If package.gvspks was already previously added, it will be replaced"
102
}
103

    
104
proc addpks { install_file package_set } {
105
	addfile $install_file $package_set "package.gvspks" "Package set"
106
}
107

    
108
proc addjrelin_help {} {
109
        puts ""
110
        puts "addjrelin gvsig-install-program jre-installer"
111
        puts "  Add the specified jre linux installer to the installation program"
112
        puts "  If the jre installer was already previously added, it will be replaced"
113
}
114

    
115
proc addjrelin { install_file jre_installer } {
116
	addfile $install_file $jre_installer "jre-installer-lin.bin" "JRE installer"
117
}
118

    
119
proc addjrewin_help {} {
120
        puts ""
121
        puts "addjrewin gvsig-install-program jre-installer"
122
        puts "  Add the specified jre windows installer to the installation program"
123
        puts "  If the jre installer was already previously added, it will be replaced"
124
}
125

    
126
proc addjrewin { install_file jre_installer } {
127
	addfile $install_file $jre_installer "jre-installer-win.exe" "JRE installer"
128
}
129

    
130
proc addfile { install_file file_to_add file_name file_description } {
131
        if { [file writable $install_file] != 1 } {
132
                puts "Write access unavailable to the file $install_file"
133
                return
134
        }
135
        if { [file isfile $file_to_add] !=1 } {
136
                puts "The file to add is not a file: $file_to_add"
137
                return
138
        }
139
        set fp [ ::miniarc::open crap "$install_file" a ]
140
        ::miniarc::addfile $fp "$file_to_add"  -name "$file_name"
141
        ::miniarc::close $fp
142
        puts "$file_description added to installation program."
143
}
144

    
145
proc ls_help {} {
146
        puts ""
147
        puts "ls gvsig-install-program "
148
        puts "  list the files attached to the installkit or installation program especified"
149
}
150

    
151
proc ls { install_file } {
152
        if { [file isfile $install_file] != 1 } {
153
                puts "Can't access to file $install_file"
154
                return
155
        }
156
        set root /installkitunpackvfs
157
        crapvfs::mount $install_file $root
158

    
159
        set dirs [glob -nocomplain -type d $root/*]
160
        if { [llength $dirs] > 0 } {
161
            puts "Directories:"
162
            foreach d [lsort $dirs] {
163
                puts "    $d"
164
            }
165
        } else {
166
            puts "(no subdirectories)"
167
        }
168

    
169
        set files [glob -nocomplain -type f $root/*]
170
        if { [llength $files] > 0 } {
171
            puts "Files:"
172
            foreach f [lsort $files] {
173
                puts "    [file size $f] - $f"
174
            }
175
        } else {
176
            puts "(no files)"
177
        }
178

    
179
        crapvfs::unmount $root
180
}
181

    
182

    
183
proc extractpks_help {} {
184
        puts ""
185
        puts "extractpks gvsig-install-program folder"
186
        puts "  Extract the package set from the installation program to the especified folder"
187
        puts "  If the installation program has not a package set do nothing."
188
}
189

    
190
proc extractpks { install_file folder } {
191
        if { [file isfile $install_file] != 1 } {
192
                puts "Can't access to file $install_file"
193
                return
194
        }
195
        if { [file isdirectory $folder] !=1 } {
196
                puts "Can't access to folder $folder"
197
                return
198
        }
199
        set root /installkitunpackvfs
200
        set already_mounted true
201
        if { [file isdirectory $root] !=1 } {
202
                crapvfs::mount $install_file $root
203
                set already_mounted false
204
        }
205

    
206
        if { [file isfile "$root/package.gvspks"] == 1 } {
207
                file copy "$root/package.gvspks" "$folder/package.gvspks"
208
        }
209

    
210
        if { $already_mounted == false } {
211
                crapvfs::unmount $root
212
        }
213
        puts "Package set extracted to folder $folder"
214
}
215

    
216
proc extractjrelin_help {} {
217
        puts ""
218
        puts "extractjrelin gvsig-install-program folder"
219
        puts "  Extract the jre linux installer from the installation program to the especified folder"
220
        puts "  If the installation program has not a jre installer do nothing."
221
}
222

    
223
proc extractjrelin { install_file folder } {
224
        if { [file isfile $install_file] != 1 } {
225
                puts "Can't access to file $install_file"
226
                return
227
        }
228
        if { [file isdirectory $folder] !=1 } {
229
                puts "Can't access to folder $folder"
230
                return
231
        }
232
        set root /installkitunpackvfs
233
        set already_mounted true
234
        if { [file isdirectory $root] !=1 } {
235
                crapvfs::mount $install_file $root
236
                set already_mounted false
237
        }
238

    
239
        if { [file isfile "$root/jre-installer-lin.bin"] == 1 } {
240
                file copy "$root/jre-installer-lin.bin" "$folder/jre-installer-lin.bin"
241
                puts "JRE installer extracted to folder $folder"
242
        } else {
243
            puts "JRE installer (jre-installer-lin.bin) not available to be extracted"
244
        }
245

    
246
        if { $already_mounted == false } {
247
                crapvfs::unmount $root
248
        }
249
}
250

    
251
proc extractjrewin_help {} {
252
        puts ""
253
        puts "extractjrewin gvsig-install-program folder"
254
        puts "  Extract the jre windows installer from the installation program to the especified folder"
255
        puts "  If the installation program has not a jre installer do nothing."
256
}
257

    
258
proc extractjrewin { install_file folder } {
259
        if { [file isfile $install_file] != 1 } {
260
                puts "Can't access to file $install_file"
261
                return
262
        }
263
        if { [file isdirectory $folder] !=1 } {
264
                puts "Can't access to folder $folder"
265
                return
266
        }
267
        set root /installkitunpackvfs
268
        set already_mounted true
269
        if { [file isdirectory $root] !=1 } {
270
                crapvfs::mount $install_file $root
271
                set already_mounted false
272
        }
273

    
274
        if { [file isfile "$root/jre-installer-win.exe"] == 1 } {
275
                file copy "$root/jre-installer-win.exe" "$folder/jre-installer-win.exe"
276
            puts "JRE installer extracted to folder $folder"
277
        } else {
278
            puts "JRE installer (jre-installer-win.exe) not available to be extracted"
279
        }
280

    
281
        if { $already_mounted == false } {
282
                crapvfs::unmount $root
283
        }
284
}
285

    
286
main