svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.installer / src / main / packaging / gvspkg @ 43000
History | View | Annotate | Download (61.3 KB)
1 | 40435 | jjdelcerro | #!/usr/bin/python |
---|---|---|---|
2 | 42725 | jjdelcerro | # -*- coding: utf-8 -*- |
3 | # |
||
4 | 40435 | jjdelcerro | import sys |
5 | import os |
||
6 | import os.path |
||
7 | import fnmatch |
||
8 | import shutil |
||
9 | 42725 | jjdelcerro | import zipfile |
10 | 40435 | jjdelcerro | import stat |
11 | import getopt |
||
12 | from os.path import dirname |
||
13 | import shutil |
||
14 | from os import system |
||
15 | import ConfigParser |
||
16 | import StringIO |
||
17 | 41292 | jjdelcerro | import re |
18 | import urllib2 |
||
19 | import time |
||
20 | 40435 | jjdelcerro | |
21 | 41292 | jjdelcerro | DEBUG = False |
22 | DEBUG = False |
||
23 | VERBOSE = False |
||
24 | SEARCH_VERSIONS = list() |
||
25 | |||
26 | 42775 | jjdelcerro | class Platform: |
27 | 42946 | jjdelcerro | def __init__(self,os,arch,exe,onlinefamily=None, portableSufix=""): |
28 | 42886 | jjdelcerro | self.osfamily = None |
29 | self.osname = None |
||
30 | self.osversion = None |
||
31 | 42775 | jjdelcerro | self.os = os |
32 | self.arch = arch |
||
33 | self.exe_extension = exe |
||
34 | 42946 | jjdelcerro | self.portableSufix = portableSufix |
35 | 42886 | jjdelcerro | if "_" in self.os: |
36 | ss=self.os.split("_") |
||
37 | self.osfamily = ss[0] |
||
38 | if len(ss)>1: |
||
39 | self.osname = ss[1] |
||
40 | if len(ss)>2: |
||
41 | self.osversion= ss[2] |
||
42 | else: |
||
43 | self.osfamily = self.os |
||
44 | 42946 | jjdelcerro | if onlinefamily == None: |
45 | self.onlinefamily = self.osfamily |
||
46 | else: |
||
47 | self.onlinefamily = onlinefamily |
||
48 | 42824 | jjdelcerro | |
49 | def getOS(self): |
||
50 | 42775 | jjdelcerro | return self.os |
51 | 42824 | jjdelcerro | |
52 | 42886 | jjdelcerro | def getOSFamily(self): |
53 | return self.osfamily |
||
54 | |||
55 | 42902 | jjdelcerro | def getOSFamilyForOnlineInstaller(self): |
56 | return self.onlinefamily |
||
57 | 42946 | jjdelcerro | |
58 | 42886 | jjdelcerro | def getOSName(self): |
59 | return self.osname |
||
60 | |||
61 | def getOSVersion(self): |
||
62 | return self.osversion |
||
63 | |||
64 | 42824 | jjdelcerro | def getArch(self): |
65 | 42775 | jjdelcerro | return self.arch |
66 | 42824 | jjdelcerro | |
67 | def getExeExtension(self): |
||
68 | 42775 | jjdelcerro | return self.exe_extension |
69 | |||
70 | 42946 | jjdelcerro | def getPortableSufix(self): |
71 | return self.portableSufix |
||
72 | |||
73 | 42824 | jjdelcerro | platforms = ( |
74 | 42946 | jjdelcerro | Platform("darwin_macos_10.11","x86_64",".run",onlinefamily="lin", portableSufix=".app"), |
75 | 42902 | jjdelcerro | Platform("lin_ubuntu_16.04","x86_64",".run"), |
76 | 42775 | jjdelcerro | Platform("lin","x86",".run"), |
77 | Platform("lin","x86_64",".run"), |
||
78 | Platform("win","x86",".exe"), |
||
79 | Platform("win","x86_64",".exe") |
||
80 | ) |
||
81 | |||
82 | |||
83 | 41292 | jjdelcerro | def log(msg): |
84 | f=open("/tmp/gvspkg.log","a") |
||
85 | f.write(time.ctime()) |
||
86 | f.write(": ") |
||
87 | f.write(msg) |
||
88 | f.write("\n") |
||
89 | f.close() |
||
90 | |||
91 | def message(msg): |
||
92 | if VERBOSE: |
||
93 | print msg |
||
94 | 42725 | jjdelcerro | sys.stdout.flush() |
95 | 41292 | jjdelcerro | log(msg) |
96 | |||
97 | def msgerror(msg, err=None): |
||
98 | print "ERROR: ", msg |
||
99 | log("ERROR: "+msg) |
||
100 | if err!=None : |
||
101 | print "ERROR: ", str(err) |
||
102 | 42725 | jjdelcerro | sys.stdout.flush() |
103 | 41292 | jjdelcerro | log("ERROR: "+ str(err)) |
104 | |||
105 | |||
106 | def msgwarn(msg): |
||
107 | print "WARNING: ", msg |
||
108 | 42725 | jjdelcerro | sys.stdout.flush() |
109 | 41292 | jjdelcerro | log("WARNING: "+ msg) |
110 | |||
111 | def debug(msg): |
||
112 | if DEBUG: |
||
113 | print "DEBUG: ", msg |
||
114 | 42725 | jjdelcerro | sys.stdout.flush() |
115 | 41292 | jjdelcerro | log("DEBUG: "+ msg) |
116 | |||
117 | def acquire_file(name): |
||
118 | files = list() |
||
119 | folder = os.getcwd() |
||
120 | while folder not in ( None, "", "/"): |
||
121 | pathname = os.path.join(folder,name) |
||
122 | if os.path.exists(pathname): |
||
123 | files.append(pathname) |
||
124 | folder = os.path.dirname(folder) |
||
125 | return files |
||
126 | |||
127 | 42725 | jjdelcerro | def get_gvspkg_bin_folder(): |
128 | 41292 | jjdelcerro | files = list() |
129 | if os.environ.get("HOME") != None : |
||
130 | files.append(os.path.join(os.environ['HOME'],".gvspkg.bin")) |
||
131 | files.extend( acquire_file(".gvspkg.bin") ) |
||
132 | files.extend( acquire_file("gvspkg.bin") ) |
||
133 | if len(files)<1 : |
||
134 | return None |
||
135 | debug( "gvspkg.bin = %s" % files[-1]) |
||
136 | return files[-1] |
||
137 | |||
138 | def search_GVSPKG_ROOT(): |
||
139 | f = get_gvspkg_bin_folder() |
||
140 | if f==None: |
||
141 | return None |
||
142 | return os.path.dirname(f) |
||
143 | |||
144 | 42725 | jjdelcerro | RWALL = stat.S_IWOTH | stat.S_IROTH | stat.S_IWUSR | stat.S_IRUSR | stat.S_IWGRP | stat.S_IRGRP |
145 | RWXALL = RWALL | stat.S_IXUSR | stat.S_IXOTH | stat.S_IXGRP |
||
146 | 40435 | jjdelcerro | |
147 | VERSION = os.path.basename(os.getcwd()) |
||
148 | 41292 | jjdelcerro | GVSPKG_ROOT = search_GVSPKG_ROOT() |
149 | 40435 | jjdelcerro | |
150 | def getVersion(): |
||
151 | return VERSION |
||
152 | |||
153 | 41292 | jjdelcerro | def getSearchVersions(): |
154 | vers = list(); |
||
155 | vers.extend(SEARCH_VERSIONS) |
||
156 | vers.append(VERSION) |
||
157 | return vers |
||
158 | |||
159 | 40435 | jjdelcerro | def getPackagesRoot(): |
160 | return GVSPKG_ROOT |
||
161 | |||
162 | def getPool(): |
||
163 | return getPackagesRoot() + "/pool" |
||
164 | |||
165 | def getWeb(): |
||
166 | return getPackagesRoot() + "/web" |
||
167 | |||
168 | def getDist(): |
||
169 | return getPackagesRoot() + "/dists/" +getVersion() |
||
170 | |||
171 | def findfiles(root,filename): |
||
172 | result=list() |
||
173 | for wroot, dirs, files in os.walk(root): |
||
174 | for f in files : |
||
175 | if fnmatch.fnmatch(f,filename): |
||
176 | result.append(wroot+"/"+f) |
||
177 | result.sort() |
||
178 | return result |
||
179 | |||
180 | def mychmod(filename, perms): |
||
181 | try: |
||
182 | os.chmod(filename,perms) |
||
183 | except Exception, ex: |
||
184 | msgwarn("Can't change permissions of file '%s', error %s" % (filename, str(ex))) |
||
185 | |||
186 | 42725 | jjdelcerro | def makedirs(path): |
187 | if not os.path.isdir(path) : |
||
188 | os.makedirs(path) |
||
189 | |||
190 | 40435 | jjdelcerro | class Command: |
191 | |||
192 | def __init__(self, args): |
||
193 | self.args = args |
||
194 | self.defaultoptions = None |
||
195 | |||
196 | def load_options(self,filename): |
||
197 | debug("loading option from %s" % filename) |
||
198 | if not os.path.isfile(filename): |
||
199 | debug("filename %s not found" % filename) |
||
200 | return |
||
201 | f=file(filename,"r") |
||
202 | for line in f.readlines(): |
||
203 | line = line.strip() |
||
204 | 41292 | jjdelcerro | if line=="" or line.startswith("#"): |
205 | 40435 | jjdelcerro | continue |
206 | if line[-1] == "\n": |
||
207 | line = line[:-1] |
||
208 | n = line.find("=") |
||
209 | if n<0 : |
||
210 | continue |
||
211 | cmd = line[:n] |
||
212 | 41292 | jjdelcerro | args = line[n+1:].strip() |
213 | 40435 | jjdelcerro | |
214 | 41292 | jjdelcerro | if args != "": |
215 | self.defaultoptions[cmd] = self.defaultoptions.get(cmd,[]) + args.split(" ") |
||
216 | 40435 | jjdelcerro | debug("add options: %s=%r" % (cmd, args.split(" "))) |
217 | |||
218 | f.close() |
||
219 | |||
220 | def load_default_options(self): |
||
221 | if self.defaultoptions != None: |
||
222 | return |
||
223 | self.defaultoptions = dict() |
||
224 | 41292 | jjdelcerro | options = list(); |
225 | if GVSPKG_ROOT != None: |
||
226 | rootoptions = os.path.join(GVSPKG_ROOT,"gvspkg.bin/options") |
||
227 | else: |
||
228 | rootoptions = None |
||
229 | if rootoptions != None and os.path.isfile(rootoptions): |
||
230 | options.append(rootoptions) |
||
231 | else: |
||
232 | options.append("~/.gvspkg.bin/options") |
||
233 | options.extend(acquire_file(".gvspkg.options")) |
||
234 | options.extend(acquire_file("gvspkg.options")) |
||
235 | for optionfile in options: |
||
236 | self.load_options(optionfile) |
||
237 | 40435 | jjdelcerro | |
238 | def getArgs(self,name): |
||
239 | self.load_default_options() |
||
240 | 41292 | jjdelcerro | l = list() |
241 | cmd = self.defaultoptions.get(name,None) |
||
242 | if cmd != None: |
||
243 | l.extend(cmd) |
||
244 | 40435 | jjdelcerro | l.extend(self.args[1:]) |
245 | return l |
||
246 | |||
247 | 41292 | jjdelcerro | def isDigit(s): |
248 | if len(s)>1: |
||
249 | s=s[0] |
||
250 | return s in ("0","1","2","3","4","5","6","7","8","9") |
||
251 | |||
252 | |||
253 | |||
254 | 40435 | jjdelcerro | class PackageInfo(str): |
255 | def __init__(self, filename): |
||
256 | self._ini = None |
||
257 | self.filename = filename[:-7] |
||
258 | self.type = filename[-6:] |
||
259 | s = os.path.basename(self.filename) |
||
260 | s = s.split("-") |
||
261 | #print "## PackageInfo ", repr(s) |
||
262 | self.gvsig = s[0] + "-" + s[1] |
||
263 | self.gvsig_version = s[2] |
||
264 | self.code = s[3] |
||
265 | try: |
||
266 | 42725 | jjdelcerro | # gvSIG-desktop-1.12.0-com.iver.cit.gvsig.cad-1.12.0-opencadtools-1418-final-all-all-j1_6.gvspkg |
267 | # 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 |
||
268 | # gvSIG-desktop-1.12.0-com.iver.cit.gvsig.cad-1.12.0-1418-final-all-all-j1_6.gvspkg |
||
269 | # 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 |
||
270 | |||
271 | if isDigit(s[5]) : |
||
272 | 41292 | jjdelcerro | self.version = s[4] |
273 | self.build = s[5] |
||
274 | self.status = s[6] |
||
275 | self.os = s[7] |
||
276 | self.arch = s[8] |
||
277 | else: |
||
278 | 40435 | jjdelcerro | self.version = s[4] + "-" + s[5] |
279 | self.build = s[6] |
||
280 | self.status = s[7] |
||
281 | self.os = s[8] |
||
282 | self.arch = s[9] |
||
283 | 41292 | jjdelcerro | |
284 | 40435 | jjdelcerro | except Exception: |
285 | self.build = "0" |
||
286 | self.status = "unknow" |
||
287 | self.os = "all" |
||
288 | self.arch = "all" |
||
289 | 42725 | jjdelcerro | try: |
290 | self.build = int(self.build) |
||
291 | except: |
||
292 | pass |
||
293 | 40435 | jjdelcerro | |
294 | 41292 | jjdelcerro | def getCode(self): |
295 | return self.code |
||
296 | |||
297 | def getOS(self): |
||
298 | return self.os |
||
299 | |||
300 | def getArch(self): |
||
301 | return self.arch |
||
302 | |||
303 | 40435 | jjdelcerro | def getKey(self): |
304 | return self.code+"-"+self.os+"-"+self.arch |
||
305 | |||
306 | def getFullName(self): |
||
307 | return os.path.basename(self.filename) |
||
308 | |||
309 | def getFullVersion(self): |
||
310 | 42725 | jjdelcerro | try: |
311 | r = re.compile("([0-9]+)[.]([0-9]+)[.]([0-9]+)-([a-zA-Z0-0]+)$") |
||
312 | m = r.match(self.version) |
||
313 | if m == None: |
||
314 | clasificador="ZZZZZZZZ" |
||
315 | r = re.compile("([0-9]+)[.]([0-9]+)[.]([0-9]+)$") |
||
316 | m = r.match(self.version) |
||
317 | else: |
||
318 | clasificador=m.group(4) |
||
319 | v1=int(m.group(1)) |
||
320 | v2=int(m.group(2)) |
||
321 | v3=int(m.group(3)) |
||
322 | return "%06d.%06d.%06d-%s-%06d" % (v1,v2,v3,clasificador,self.build) |
||
323 | except: |
||
324 | if "-" in self.version : |
||
325 | return "%s-%06d" %(self.version,self.build) |
||
326 | else: |
||
327 | return "%s-ZZZZZZZZ-%06d" %(self.version,self.build) |
||
328 | 40435 | jjdelcerro | |
329 | def getFilename(self): |
||
330 | return self.filename + "." + self.type |
||
331 | |||
332 | def hasPki(self): |
||
333 | return os.path.isfile( self.getPkiFilename() ) |
||
334 | |||
335 | def getPkiFilename(self): |
||
336 | return self.filename + ".gvspki" |
||
337 | |||
338 | def hasPkg(self): |
||
339 | return os.path.isfile( self.getPkgFilename() ) |
||
340 | |||
341 | def getPkgFilename(self): |
||
342 | return self.filename + ".gvspkg" |
||
343 | |||
344 | def getIniOption(self, name, default=None): |
||
345 | section = "general" |
||
346 | ini = self.getIni() |
||
347 | if ini.has_option(section, name): |
||
348 | x = ini.get(section, name) |
||
349 | 42725 | jjdelcerro | x = x.replace("\\:", ":") |
350 | return x |
||
351 | return default |
||
352 | 42726 | jjdelcerro | |
353 | 40435 | jjdelcerro | def getDescription(self): |
354 | return self.getIniOption("description") |
||
355 | |||
356 | 41292 | jjdelcerro | def getCategories(self): |
357 | return self.getIniOption("categories") |
||
358 | |||
359 | 40435 | jjdelcerro | def getName(self): |
360 | return self.getIniOption("name") |
||
361 | |||
362 | def getOwner(self): |
||
363 | ini = self.getIni() |
||
364 | if ini.has_option("general","owner"): |
||
365 | return ini.get("general","owner") |
||
366 | return None |
||
367 | |||
368 | def getUrl(self): |
||
369 | ini = self.getIni() |
||
370 | if ini.has_option("general","download-url"): |
||
371 | return ini.get("general","download-url") |
||
372 | return None |
||
373 | |||
374 | def getSourceUrl(self): |
||
375 | ini = self.getIni() |
||
376 | if ini.has_option("general","source-url"): |
||
377 | return ini.get("general","source-url") |
||
378 | return None |
||
379 | |||
380 | def getDependencies(self): |
||
381 | ini = self.getIni() |
||
382 | if ini.has_option("general","dependencies"): |
||
383 | return ini.get("general","dependencies") |
||
384 | return None |
||
385 | |||
386 | def getType(self): |
||
387 | ini = self.getIni() |
||
388 | if ini.has_option("general","type"): |
||
389 | return ini.get("general","type") |
||
390 | return None |
||
391 | |||
392 | def getOfficial(self): |
||
393 | ini = self.getIni() |
||
394 | if ini.has_option("general","official"): |
||
395 | return ini.get("general","official") |
||
396 | return None |
||
397 | |||
398 | def getIni(self): |
||
399 | if self._ini != None: |
||
400 | return self._ini |
||
401 | index_path = self.getPkiFilename() |
||
402 | outputfolder="/tmp/gvspkg.%s" % os.getpid() |
||
403 | os.mkdir(outputfolder) |
||
404 | os.system('unzip -q %s -d %s' % (index_path,outputfolder)) |
||
405 | |||
406 | files = findfiles(outputfolder, "package.info") |
||
407 | if len(files) != 1: |
||
408 | 41292 | jjdelcerro | msgerror("Can't locate package.info in pool '%s'." % (index_path)) |
409 | 40435 | jjdelcerro | return None |
410 | |||
411 | package_info = files[0] |
||
412 | self._ini = ConfigParser.ConfigParser() |
||
413 | f = file(package_info,"r") |
||
414 | ss = f.read() |
||
415 | self._ini.readfp(StringIO.StringIO("[general]\n"+ss)) |
||
416 | f.close() |
||
417 | shutil.rmtree(outputfolder) |
||
418 | return self._ini |
||
419 | |||
420 | def __str__(self): |
||
421 | return self.filename |
||
422 | |||
423 | def __repr__(self): |
||
424 | return "filename=%r:gvsig=%r:gvsig_version=%r:code=%r:version=%r:build=%r:status=%r" % ( |
||
425 | self.filename, self.gvsig, self.gvsig_version, self.code, self.version, self.build, self.status ) |
||
426 | |||
427 | class IndexList(list): |
||
428 | |||
429 | def load(self, fname): |
||
430 | message( "Loading index list from '%s'." % fname) |
||
431 | f=file(fname,"r") |
||
432 | lines=f.readlines() |
||
433 | f.close() |
||
434 | for line in lines: |
||
435 | if line[-1] == "\n": |
||
436 | line = line[:-1] |
||
437 | 42726 | jjdelcerro | |
438 | 40435 | jjdelcerro | info = PackageInfo(line) |
439 | self.append(info) |
||
440 | |||
441 | def save(self,fname): |
||
442 | message( "Saving index list from '%s'." % fname) |
||
443 | f=file(fname,"w") |
||
444 | for index in self: |
||
445 | f.write("%s\n" % index.getFilename()) |
||
446 | f.close() |
||
447 | mychmod(fname,RWALL) |
||
448 | |||
449 | 41292 | jjdelcerro | def build(self, pool, versions): |
450 | message( "Creating index list for version '%s' from '%s'" % (versions, pool) ) |
||
451 | 40435 | jjdelcerro | packages=dict() |
452 | for root, dirs, files in os.walk(pool): |
||
453 | for f in files : |
||
454 | 41292 | jjdelcerro | if f[-7:].lower() in (".gvspki", ".gvspkg") : |
455 | fullpath = root+"/"+f |
||
456 | info = PackageInfo(fullpath) |
||
457 | if info.gvsig == "gvSIG-desktop" and info.gvsig_version in versions : |
||
458 | if packages.get(info.getKey()) == None: |
||
459 | debug( "build: add " + repr(info)) |
||
460 | packages[info.getKey()]=info |
||
461 | else: |
||
462 | oldinfo = packages[info.getKey()] |
||
463 | debug("build: %s %s %s" % ( info.getKey(), oldinfo.getFullVersion(),info.getFullVersion())) |
||
464 | if oldinfo.getFullVersion()<info.getFullVersion() : |
||
465 | debug( "build: update "+ repr(oldinfo)) |
||
466 | packages[info.getKey()]=info |
||
467 | 40435 | jjdelcerro | else: |
468 | 41292 | jjdelcerro | debug( "build: skip "+ repr(info)) |
469 | 40435 | jjdelcerro | self.extend(packages.values()) |
470 | self.sort() |
||
471 | |||
472 | def lsi(args): |
||
473 | cmd = Command(args) |
||
474 | try: |
||
475 | opts, args = getopt.getopt(cmd.getArgs("lsi"), "l", ["long-format"]) |
||
476 | except getopt.GetoptError, err: |
||
477 | # print help information and exit: |
||
478 | print str(err) # will print something like "option -a not recognized" |
||
479 | 42725 | jjdelcerro | shorthelp(args) |
480 | 40435 | jjdelcerro | sys.exit(2) |
481 | |||
482 | long_format=False |
||
483 | for opt, arg in opts: |
||
484 | if opt in ("-l", "--long-format"): |
||
485 | long_format = True |
||
486 | else: |
||
487 | assert False, "unhandled option" |
||
488 | |||
489 | indexes = IndexList() |
||
490 | 41292 | jjdelcerro | indexes.build(getPool(), getSearchVersions()) |
491 | 40435 | jjdelcerro | |
492 | for info in indexes: |
||
493 | if info.hasPki(): |
||
494 | if long_format: |
||
495 | print "["+os.path.basename(info.getPkiFilename())+"]" |
||
496 | print "# ", info.getPkiFilename() |
||
497 | show(["show", os.path.basename(info.getPkiFilename())]) |
||
498 | else: |
||
499 | print info.getPkiFilename() |
||
500 | |||
501 | |||
502 | 42725 | jjdelcerro | def installer_add(cmd,arg1,arg2): |
503 | installer_add_use_zip(cmd,arg1,arg2) |
||
504 | 42726 | jjdelcerro | |
505 | 42725 | jjdelcerro | def installer_add_use_zip(cmd,arg1,arg2): |
506 | if cmd == "addjrelin": |
||
507 | return |
||
508 | 42726 | jjdelcerro | |
509 | 42725 | jjdelcerro | if cmd == "addjrewin": |
510 | return |
||
511 | 42726 | jjdelcerro | |
512 | 42725 | jjdelcerro | if cmd == "addpks": |
513 | zip = zipfile.ZipFile(arg1,"a",zipfile.ZIP_STORED) |
||
514 | zip.write(arg2,"package.gvspks") |
||
515 | zip.close() |
||
516 | 42726 | jjdelcerro | |
517 | 42725 | jjdelcerro | def installer_add_use_installkit(cmd,arg1,arg2): |
518 | 41292 | jjdelcerro | folder = "%s/gvspkg.bin" % GVSPKG_ROOT |
519 | 40435 | jjdelcerro | |
520 | cmd = "%s/installkit %s/main.tcl %s %s %s" % ( |
||
521 | 42725 | jjdelcerro | "/mnt/data0/public-files/gvsig-desktop/gvspkg.bin", |
522 | 40435 | jjdelcerro | folder, |
523 | cmd, |
||
524 | arg1, |
||
525 | arg2 |
||
526 | ) |
||
527 | system(cmd) |
||
528 | |||
529 | def mkinstall(args): |
||
530 | cmd = Command(args) |
||
531 | try: |
||
532 | opts, args = getopt.getopt(cmd.getArgs("mkinstall"), "N:lL:wW:", ["addjrewin", "addjrelin", "jrelin=", "jrewin=", "distribution-name="]) |
||
533 | except getopt.GetoptError, err: |
||
534 | # print help information and exit: |
||
535 | print str(err) # will print something like "option -a not recognized" |
||
536 | 42725 | jjdelcerro | shorthelp(args) |
537 | 40435 | jjdelcerro | sys.exit(2) |
538 | |||
539 | 41292 | jjdelcerro | #print "opts = ",opts |
540 | #print "args = ",args |
||
541 | 40435 | jjdelcerro | addjrelin=False |
542 | addjrewin=False |
||
543 | jrelin=None |
||
544 | jrewin=None |
||
545 | distribution_name = "custom" |
||
546 | for opt, arg in opts: |
||
547 | if opt in ("-L", "--jrelin"): |
||
548 | jrelin = arg |
||
549 | elif opt in ("-W", "--jrewin"): |
||
550 | jrewin = arg |
||
551 | elif opt in ("-l", "--addjrelin"): |
||
552 | addjrelin = True |
||
553 | elif opt in ("-w", "--addjrewin"): |
||
554 | addjrewin = True |
||
555 | elif opt in ("-N", "--distrinution-name"): |
||
556 | distribution_name = arg |
||
557 | else: |
||
558 | assert False, "unhandled option" |
||
559 | |||
560 | 42726 | jjdelcerro | |
561 | 40435 | jjdelcerro | if len(args) != 2 : |
562 | 42725 | jjdelcerro | shorthelp(args) |
563 | 40435 | jjdelcerro | sys.exit(4) |
564 | |||
565 | bin_name = args[0] |
||
566 | gvspks_name = args[1] |
||
567 | custom_name = bin_name.replace("online", distribution_name) |
||
568 | |||
569 | if not "online" in bin_name : |
||
570 | print "gvspkg mkinstall: binary file name must contain 'online'" |
||
571 | sys.exit(3) |
||
572 | |||
573 | if addjrelin and addjrewin : |
||
574 | print "gvspkg mkinstall: only one of addjrelin or addjrewin is allowed." |
||
575 | sys.exit(4) |
||
576 | |||
577 | 42725 | jjdelcerro | message("Creating %s..." % custom_name) |
578 | 40435 | jjdelcerro | shutil.copyfile(bin_name, custom_name) |
579 | mychmod(custom_name,RWALL) |
||
580 | 42725 | jjdelcerro | message("Adding %s..." % gvspks_name) |
581 | installer_add("addpks", custom_name, gvspks_name) |
||
582 | 42726 | jjdelcerro | |
583 | 42725 | jjdelcerro | """ |
584 | 40435 | jjdelcerro | if addjrelin: |
585 | 41292 | jjdelcerro | withjre_name = bin_name.replace("online", distribution_name+"-withjre") |
586 | 42725 | jjdelcerro | message("Creating %s..." % withjre_name) |
587 | 40435 | jjdelcerro | shutil.copyfile(custom_name, withjre_name) |
588 | mychmod(withjre_name,RWALL) |
||
589 | 42725 | jjdelcerro | message("Adding %s..." % jrelin) |
590 | installer_add("addjrelin", withjre_name, jrelin) |
||
591 | 40435 | jjdelcerro | |
592 | |||
593 | if addjrewin: |
||
594 | 41292 | jjdelcerro | withjre_name = bin_name.replace("online", distribution_name+"-withjre") |
595 | 42725 | jjdelcerro | message("Creating %s..." % withjre_name) |
596 | 40435 | jjdelcerro | shutil.copyfile(custom_name, withjre_name) |
597 | mychmod(withjre_name,RWALL) |
||
598 | 42725 | jjdelcerro | message("Adding %s..." % jrewin) |
599 | installer_add("addjrewin", withjre_name, jrewin) |
||
600 | """ |
||
601 | 40435 | jjdelcerro | |
602 | def mks(args): |
||
603 | cmd = Command(args) |
||
604 | try: |
||
605 | 42775 | jjdelcerro | opts, args = getopt.getopt(cmd.getArgs("mks"), "ixscI:", ["index-only","include-default-selection", "clear-list", "exclude=", "excludepki=", "excludepkg=", "include="]) |
606 | 40435 | jjdelcerro | except getopt.GetoptError, err: |
607 | # print help information and exit: |
||
608 | print str(err) # will print something like "option -a not recognized" |
||
609 | 42725 | jjdelcerro | shorthelp(args) |
610 | 40435 | jjdelcerro | sys.exit(2) |
611 | |||
612 | default_selection = None |
||
613 | index_only = False |
||
614 | clear_list=False |
||
615 | includes=list() |
||
616 | excludes_pki=list() |
||
617 | excludes_pkg=list() |
||
618 | for opt, arg in opts: |
||
619 | if opt in ("-c", "--clear-list"): |
||
620 | clear_list = True |
||
621 | elif opt in ("-s", "--include-default-selection"): |
||
622 | default_selection = "defaultPackages" |
||
623 | elif opt in ("-x", "--exclude"): |
||
624 | excludes_pki.append(arg) |
||
625 | excludes_pkg.append(arg) |
||
626 | elif opt in ( "--excludepki"): |
||
627 | excludes_pki.append(arg) |
||
628 | elif opt in ( "--excludepkg"): |
||
629 | excludes_pkg.append(arg) |
||
630 | elif opt in ( "--include", "-I"): |
||
631 | 41292 | jjdelcerro | if not os.path.isabs(arg) : |
632 | arg = os.path.join(getPool(), arg) |
||
633 | if arg.endswith(".*"): |
||
634 | includes.append(PackageInfo(arg[:-2]+".gvspkg")) |
||
635 | includes.append(PackageInfo(arg[:-2]+".gvspki")) |
||
636 | else: |
||
637 | includes.append(PackageInfo(arg)) |
||
638 | 40435 | jjdelcerro | elif opt in ("-i", "--index-only"): |
639 | index_only = True |
||
640 | else: |
||
641 | assert False, "unhandled option %r" % opt |
||
642 | |||
643 | if default_selection!=None and not os.path.isfile(default_selection) : |
||
644 | msgwarn("No se ha encontrado el fichero %r. la opcion -s/--include-default-selection sera ignorada." % default_selection) |
||
645 | default_selection = None |
||
646 | |||
647 | 42726 | jjdelcerro | |
648 | 40435 | jjdelcerro | indexes = IndexList() |
649 | |||
650 | packages_txt = getDist() +"/packages.txt" |
||
651 | 42726 | jjdelcerro | packages_gvspki = getDist() +"/packages.gvspki" |
652 | 40435 | jjdelcerro | |
653 | 42725 | jjdelcerro | message( "Creating 'packages.gvspki' for version '%s'" % getVersion() + "...") |
654 | 40435 | jjdelcerro | if not os.path.exists(getDist()): |
655 | 41292 | jjdelcerro | msgerror("Can't locate version folder '%s'." % getDist()) |
656 | 40435 | jjdelcerro | sys.exit(3) |
657 | 42726 | jjdelcerro | |
658 | 40435 | jjdelcerro | if os.path.exists(packages_txt) and not clear_list: |
659 | indexes.load(packages_txt) |
||
660 | else: |
||
661 | 41292 | jjdelcerro | indexes.build(getPool(), getSearchVersions()) |
662 | 40435 | jjdelcerro | indexes.save(packages_txt) |
663 | |||
664 | for pkg in includes: |
||
665 | indexes.append(pkg) |
||
666 | |||
667 | 41292 | jjdelcerro | # El indice de paquetes lleva los paquetes para todas las plataformas y sistemas |
668 | # ya que al conectarnos a el desde el administrador de complementos ya |
||
669 | # se encarga la aplicacion de seleccionar los correspondientes a la plataforma |
||
670 | # sobre la que esta rodando gvSIG. |
||
671 | 40435 | jjdelcerro | message( "Writing 'packages.gvspki' to '%s'" % packages_gvspki ) |
672 | set = zipfile.ZipFile(packages_gvspki,"w",zipfile.ZIP_STORED) |
||
673 | for info in indexes: |
||
674 | if not ( info.code in excludes_pki or info.getFullName() in excludes_pki ): |
||
675 | 41292 | jjdelcerro | debug("Add package '%s'" % info.getPkiFilename()) |
676 | 40435 | jjdelcerro | try: |
677 | if info.hasPki() : |
||
678 | set.write(info.getPkiFilename(), os.path.basename(info.getPkiFilename())) |
||
679 | except Exception, ex: |
||
680 | msgerror("Can't add index '%s', error %s" % (info, str(ex))) |
||
681 | 41292 | jjdelcerro | else: |
682 | 42725 | jjdelcerro | debug("Exclude package '%s'" % info.getFullName()) |
683 | 40435 | jjdelcerro | if default_selection != None : |
684 | set.write(default_selection,default_selection) |
||
685 | set.close() |
||
686 | mychmod(packages_gvspki,RWALL) |
||
687 | |||
688 | 41292 | jjdelcerro | md5sum(packages_gvspki,packages_gvspki+".md5") |
689 | mychmod(packages_gvspki+".md5",RWALL) |
||
690 | |||
691 | 40435 | jjdelcerro | if not index_only : |
692 | 42775 | jjdelcerro | for platform in platforms: |
693 | packages_gvspks = getDist() +"/packages-"+platform.getOS()+"-"+platform.getArch()+".gvspks" |
||
694 | message( "Writing 'packages-"+platform.getOS()+"-"+platform.getArch()+".gvspks' to '%s'" % packages_gvspks ) |
||
695 | set = zipfile.ZipFile(packages_gvspks,"w",zipfile.ZIP_STORED) |
||
696 | for info in indexes: |
||
697 | if not ( info.code in excludes_pkg or info.getFullName() in excludes_pkg ): |
||
698 | try: |
||
699 | if info.hasPkg(): |
||
700 | if info.getOS() in ("all", platform.getOS()) : |
||
701 | if info.getArch() in ("all", platform.getArch()) : |
||
702 | set.write(info.getPkgFilename(), os.path.basename(info.getPkgFilename())) |
||
703 | except Exception, ex: |
||
704 | msgerror("Can't add package '%s', error %s" % (index, str(ex))) |
||
705 | else: |
||
706 | debug("Exclude package '%s'" % info.getFullName()) |
||
707 | if default_selection != None : |
||
708 | set.write(default_selection,default_selection) |
||
709 | set.close() |
||
710 | mychmod(packages_gvspks,RWALL) |
||
711 | 40435 | jjdelcerro | |
712 | 42775 | jjdelcerro | md5sum(packages_gvspks,packages_gvspks+".md5") |
713 | mychmod(packages_gvspks+".md5",RWALL) |
||
714 | 41292 | jjdelcerro | |
715 | 42725 | jjdelcerro | message( "Createds package indexes.\n") |
716 | 40435 | jjdelcerro | |
717 | 41292 | jjdelcerro | def mkmirror(args): |
718 | cmd = Command(args) |
||
719 | try: |
||
720 | opts, args = getopt.getopt(cmd.getArgs("mkmirrot"), "b:", [ "build="]) |
||
721 | except getopt.GetoptError, err: |
||
722 | # print help information and exit: |
||
723 | print str(err) # will print something like "option -a not recognized" |
||
724 | 42725 | jjdelcerro | shorthelp(args) |
725 | 41292 | jjdelcerro | sys.exit(2) |
726 | 40435 | jjdelcerro | |
727 | 41292 | jjdelcerro | build = None |
728 | for opt, arg in opts: |
||
729 | if opt in ("-b", "--build"): |
||
730 | build = arg |
||
731 | else: |
||
732 | assert False, "unhandled option %r" % opt |
||
733 | |||
734 | if build == None: |
||
735 | msgerror("Build number required.") |
||
736 | sys.exit(3) |
||
737 | domkmirror( getPackagesRoot(),getVersion(),build) |
||
738 | 42725 | jjdelcerro | |
739 | def linkfile(src,dst): |
||
740 | if os.path.lexists(dst): |
||
741 | os.remove(dst) |
||
742 | os.symlink(src,dst) |
||
743 | if os.path.lexists(src+".md5") : |
||
744 | if os.path.lexists(dst+".md5"): |
||
745 | os.remove(dst+".md5") |
||
746 | os.symlink(src+".md5",dst+".md5") |
||
747 | 42726 | jjdelcerro | |
748 | 41292 | jjdelcerro | def domkmirror(root_src, version, build): |
749 | join = os.path.join |
||
750 | |||
751 | build = str(build) |
||
752 | root_target = join(root_src,"mirrors",version+"-"+build,"gvsig-desktop") |
||
753 | build_src = join(root_src,"dists",version,"builds",build) |
||
754 | build_target = join(root_target,"dists",version,"builds",build) |
||
755 | pool_src = join(root_src,"pool") |
||
756 | pool_target = join(root_target,"pool") |
||
757 | 42726 | jjdelcerro | |
758 | 42725 | jjdelcerro | makedirs(root_target) |
759 | makedirs(build_target) |
||
760 | makedirs(pool_target) |
||
761 | 41292 | jjdelcerro | files = os.listdir(build_src) |
762 | linkfile(join(build_src,"packages.gvspki"), join(root_target,"dists",version,"packages.gvspki")) |
||
763 | for f in files: |
||
764 | f_src = join(build_src,f) |
||
765 | f_target = join(build_target,f) |
||
766 | if os.path.isfile(f_src): |
||
767 | linkfile(f_src,f_target) |
||
768 | |||
769 | z = zipfile.ZipFile(join(build_src,"packages.gvspki")) |
||
770 | pkgs = z.namelist() |
||
771 | for pkgname in pkgs: |
||
772 | if pkgname!='defaultPackages': |
||
773 | pkg = PackageInfo(pkgname) |
||
774 | 42725 | jjdelcerro | makedirs(join(root_target,"pool",pkg.getCode())) |
775 | 41292 | jjdelcerro | src = join(root_src,"pool",pkg.getCode(),pkg.getPkgFilename()) |
776 | target = join(root_target,"pool",pkg.getCode(),pkg.getPkgFilename()) |
||
777 | linkfile(src,target) |
||
778 | cmd = "cd %s ; find . ! -type d >%s/files.lst" % (root_target, build_target) |
||
779 | os.system(cmd) |
||
780 | |||
781 | 40435 | jjdelcerro | def mkhtml(args): |
782 | def getCode(info): |
||
783 | return info.code |
||
784 | |||
785 | |||
786 | cmd = Command(args) |
||
787 | try: |
||
788 | 41292 | jjdelcerro | opts, args = getopt.getopt(cmd.getArgs("mkhtml"), "xsc", ["clear-list", "exclude=", "excludepki=", "excludepkg=", "include="]) |
789 | 40435 | jjdelcerro | except getopt.GetoptError, err: |
790 | # print help information and exit: |
||
791 | print str(err) # will print something like "option -a not recognized" |
||
792 | 42725 | jjdelcerro | shorthelp(args) |
793 | 40435 | jjdelcerro | sys.exit(2) |
794 | |||
795 | index_only = False |
||
796 | clear_list=False |
||
797 | includes=list() |
||
798 | excludes_pki=list() |
||
799 | excludes_pkg=list() |
||
800 | for opt, arg in opts: |
||
801 | if opt in ("-c", "--clear-list"): |
||
802 | clear_list = True |
||
803 | elif opt in ("-x", "--exclude"): |
||
804 | excludes_pki.append(arg) |
||
805 | excludes_pkg.append(arg) |
||
806 | elif opt in ( "--excludepki"): |
||
807 | excludes_pki.append(arg) |
||
808 | elif opt in ( "--excludepkg"): |
||
809 | excludes_pkg.append(arg) |
||
810 | elif opt in ( "--include", "-I"): |
||
811 | includes.append(PackageInfo(arg)) |
||
812 | else: |
||
813 | assert False, "unhandled option %r" % opt |
||
814 | |||
815 | 42725 | jjdelcerro | message("Creating html pages...") |
816 | 40435 | jjdelcerro | indexes = IndexList() |
817 | |||
818 | packages_txt = getDist() +"/packages.txt" |
||
819 | 42726 | jjdelcerro | |
820 | 40435 | jjdelcerro | if os.path.exists(packages_txt) and not clear_list: |
821 | indexes.load(packages_txt) |
||
822 | else: |
||
823 | 41292 | jjdelcerro | indexes.build(getPool(), getSearchVersions()) |
824 | 40435 | jjdelcerro | indexes.save(packages_txt) |
825 | |||
826 | for pkg in includes: |
||
827 | indexes.append(pkg) |
||
828 | |||
829 | allpackages = list() |
||
830 | basepath = getWeb() |
||
831 | for info in indexes: |
||
832 | if not ( info.code in excludes_pki or info.getFullName() in excludes_pki ): |
||
833 | try: |
||
834 | if info.hasPki() : |
||
835 | mkpkihtml(basepath, info) |
||
836 | allpackages.append(info) |
||
837 | except Exception, ex: |
||
838 | 41292 | jjdelcerro | msgerror("Can't create html '%s', error %s" % (info, str(ex))) |
839 | 40435 | jjdelcerro | |
840 | html = ''' |
||
841 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
||
842 | <html xmlns="http://www.w3.org/1999/xhtml"> |
||
843 | <head> |
||
844 | <meta http-equiv="Content-Type" content= "text/html; charset=us-ascii" /> |
||
845 | <title>"%s" package list</title>'''% getVersion() # Title |
||
846 | |||
847 | 42726 | jjdelcerro | html += ''' |
848 | 40435 | jjdelcerro | <!-- estilos para las tablas --> |
849 | <style type="text/css" title="currentStyle"> |
||
850 | @import "css/demo_table.css"; |
||
851 | @import "css/thickbox.css"; |
||
852 | #pkglist{ |
||
853 | width:100%; |
||
854 | clear:both; |
||
855 | font-family:Arial,Helvetica,sans-serif; |
||
856 | } |
||
857 | #pkgdetails{ |
||
858 | width:600px !important; |
||
859 | clear:both; |
||
860 | } |
||
861 | #pkgdetails table th{ |
||
862 | text-algin:right; |
||
863 | } |
||
864 | </style> |
||
865 | 42725 | jjdelcerro | </head>''' |
866 | 40435 | jjdelcerro | |
867 | html += ''' |
||
868 | <body> |
||
869 | <h1>%s package list</h1> |
||
870 | <table id="pkglist" summary="%s package list" width="100%%" > |
||
871 | <thead> |
||
872 | <tr> |
||
873 | <td>Package name</td> |
||
874 | <td>Version</td> |
||
875 | <td>O.S.</td> |
||
876 | <td>Official</td> |
||
877 | <td>Type</td> |
||
878 | <td>Owner</td> |
||
879 | </tr> |
||
880 | </thead> |
||
881 | <tbody>'''%(getVersion(),getVersion()) |
||
882 | |||
883 | # sort allpackages |
||
884 | for item in sorted(allpackages, key=getCode): |
||
885 | html += '''\n <tr> |
||
886 | <td><a class="thickbox" href="%s">%s</a></td> |
||
887 | <td>%s</td> |
||
888 | <td>%s</td> |
||
889 | <td>%s</td> |
||
890 | <td>%s</td> |
||
891 | <td>%s</td> |
||
892 | </tr>\n'''%( |
||
893 | 42725 | jjdelcerro | "../../../web/" + item.getFullName() + ".html?height=400&width=600", |
894 | 40435 | jjdelcerro | item.getName(), |
895 | 42725 | jjdelcerro | item.version, |
896 | item.os, |
||
897 | item.getOfficial(), |
||
898 | item.getType(), |
||
899 | item.getOwner() |
||
900 | 40435 | jjdelcerro | ) |
901 | html += """ </tbody>\n </table> |
||
902 | 42824 | jjdelcerro | <!--javascript para la visualizacion de la tabla y carga dinamica del contenido del enlace --> |
903 | 40435 | jjdelcerro | <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script> |
904 | <script src="http://datatables.net/release-datatables/media/js/jquery.dataTables.js" type="text/javascript"></script> |
||
905 | <script type="text/javascript" src="js/thickbox-compressed.js"></script> |
||
906 | |||
907 | 42888 | jjdelcerro | <!-- inicializacion de la tabla con cosas chachis --> |
908 | 40435 | jjdelcerro | <script type="text/javascript"> |
909 | $(document).ready(function() { |
||
910 | $('#pkglist').dataTable( { |
||
911 | "bPaginate": false, |
||
912 | "bLengthChange": true, |
||
913 | "bFilter": true, |
||
914 | "bSort": true, |
||
915 | "bInfo": true, |
||
916 | "bAutoWidth": true |
||
917 | }); |
||
918 | } ); |
||
919 | </script> |
||
920 | </body> |
||
921 | </html>""" |
||
922 | |||
923 | # generate index.html |
||
924 | try: |
||
925 | f=file(getDist()+"/web/index.html","w") |
||
926 | f.write(html) |
||
927 | f.close() |
||
928 | except Exception, ex: |
||
929 | raise ex |
||
930 | |||
931 | 42725 | jjdelcerro | message("html pages createds.\n") |
932 | 42726 | jjdelcerro | |
933 | |||
934 | 40435 | jjdelcerro | def mkpkihtml(basepath, info): |
935 | html='''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
||
936 | <html xmlns="http://www.w3.org/1999/xhtml"> |
||
937 | <head> |
||
938 | <meta http-equiv="Content-Type" content="text/html; charset=us-ascii"> |
||
939 | <title>%s</title> |
||
940 | <!-- estilos para las tablas --> |
||
941 | <style type="text/css" title="currentStyle"> |
||
942 | 41292 | jjdelcerro | @import "../dists/%s/web/css/demo_table.css"; |
943 | 40435 | jjdelcerro | #pkgdetails{ |
944 | width:600px; |
||
945 | clear:both; |
||
946 | } |
||
947 | #pkgdetails table th{ |
||
948 | text-algin:right; |
||
949 | } |
||
950 | </style> |
||
951 | </head> |
||
952 | <body>\n'''%(info.getIniOption("name"), getVersion()) |
||
953 | html += ' <table id="pkgdetails" summary=%s >\n'%info.getIniOption("name") |
||
954 | html += ' <thead>\n <tr>\n <th>%s </th>\n <td>%s</td>\n </tr>\n </thead>\n'%("Name", info.getIniOption("name")) |
||
955 | html += ' <tbody><tr><th>%s </th><td>%s</td></tr>\n'%("Code", info.code) |
||
956 | html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Version", info.version) |
||
957 | html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("State", info.getIniOption("state")) |
||
958 | html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Build", info.build) |
||
959 | html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Owner", info.getOwner()) |
||
960 | |||
961 | #url = info.getUrl() |
||
962 | url = info.getIniOption("download-url") |
||
963 | if url != None: |
||
964 | html += ' <tr><th valing="top">Downloads</th><td><a href ="%s">Binaries</a></td></tr>\n'%(url) |
||
965 | else: |
||
966 | html += ' <tr><th valing="top">Downloads</th><td>Binaries</td></tr>\n' |
||
967 | |||
968 | sourceUrl = info.getSourceUrl() |
||
969 | |||
970 | if sourceUrl != None: |
||
971 | html += ' <tr><td></td><td><a href ="%s">Sources</a></td></tr>\n'%(sourceUrl) |
||
972 | else: |
||
973 | html += " <tr><td></td><td>Sources</td></tr>\n" |
||
974 | |||
975 | 41292 | jjdelcerro | if info.getDependencies() == None: |
976 | html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Dependencies", "") |
||
977 | else: |
||
978 | html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Dependencies", info.getDependencies().replace("\:",":")) |
||
979 | 40435 | jjdelcerro | html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Type", info.getType()) |
980 | html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Official", info.getOfficial()) |
||
981 | 41292 | jjdelcerro | html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("O.S.", info.getOS()) |
982 | html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Architecture", info.getArch()) |
||
983 | html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Categories", info.getCategories()) |
||
984 | |||
985 | description = info.getDescription() |
||
986 | if description == None: |
||
987 | description = "" |
||
988 | description = description.replace("\\n", "<br>") |
||
989 | 40435 | jjdelcerro | description = description.replace("\:",":") |
990 | 42725 | jjdelcerro | html += ' <tr valing="top"><th valing="top">%s </th><td>%s</td></tr>\n'%("Description", description) |
991 | 40435 | jjdelcerro | html += """ </tbody>\n</table>\n""" |
992 | 42725 | jjdelcerro | html += """ |
993 | 42824 | jjdelcerro | <!-- javascript para la visualizacion de la tabla --> |
994 | 40435 | jjdelcerro | <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script> |
995 | <script src="http://datatables.net/release-datatables/media/js/jquery.dataTables.js" type="text/javascript"></script> |
||
996 | 42888 | jjdelcerro | <!-- inicializacion de la tabla con cosas chachis --> |
997 | 40435 | jjdelcerro | <script type="text/javascript"> |
998 | $(document).ready(function() { |
||
999 | $('#pkgdetails').dataTable( { |
||
1000 | "bPaginate": false, |
||
1001 | "bLengthChange": true, |
||
1002 | "bFilter": false, |
||
1003 | "bSort": false, |
||
1004 | "bInfo": false, |
||
1005 | "bAutoWidth": true |
||
1006 | }); |
||
1007 | }); |
||
1008 | </script> |
||
1009 | </body>\n</html>""" |
||
1010 | |||
1011 | |||
1012 | try: |
||
1013 | f = file(getWeb() + "/" + info.getFullName() + ".html","w") |
||
1014 | f.write(html) |
||
1015 | f.close() |
||
1016 | except Exception, ex: |
||
1017 | raise ex |
||
1018 | |||
1019 | 42725 | jjdelcerro | def extract_make_portable(zfile, targetfolder): |
1020 | 42849 | jjdelcerro | print "Extracting 'make-portable' from %r to %r" % (zfile,targetfolder) |
1021 | 42725 | jjdelcerro | zf = zipfile.ZipFile(zfile) |
1022 | 42768 | jjdelcerro | data = zf.read("tools/make-portable") |
1023 | 42725 | jjdelcerro | f = open(os.path.join(targetfolder,"make-portable"),"wb") |
1024 | f.write(data) |
||
1025 | f.close() |
||
1026 | zf.close() |
||
1027 | |||
1028 | 42824 | jjdelcerro | |
1029 | def extract_mkexec(zfile, targetfolder): |
||
1030 | print "extract_mkexec: zfile=%s, target=%s" % (zfile, os.path.join(targetfolder,"mkexec")) |
||
1031 | zf = zipfile.ZipFile(zfile) |
||
1032 | data = zf.read("tools/mkexec") |
||
1033 | f = open(os.path.join(targetfolder,"mkexec"),"wb") |
||
1034 | f.write(data) |
||
1035 | f.close() |
||
1036 | zf.close() |
||
1037 | |||
1038 | |||
1039 | 42725 | jjdelcerro | def prepare_portable(args): |
1040 | cmd = Command(args) |
||
1041 | try: |
||
1042 | opts, args = getopt.getopt(cmd.getArgs("prepare-portable"), "b:s:", [ "build=", "state=" ]) |
||
1043 | except getopt.GetoptError, err: |
||
1044 | # print help information and exit: |
||
1045 | print str(err) # will print something like "option -a not recognized" |
||
1046 | shorthelp(args) |
||
1047 | sys.exit(2) |
||
1048 | |||
1049 | build=None |
||
1050 | state=None |
||
1051 | for opt, arg in opts: |
||
1052 | if opt in ("-b", "--build"): |
||
1053 | build=arg |
||
1054 | elif opt in ("-s", "--state"): |
||
1055 | state=arg |
||
1056 | else: |
||
1057 | assert False, "unhandled option %r" % opt |
||
1058 | |||
1059 | if build == None: |
||
1060 | print "Requiered option --build not found." |
||
1061 | shorthelp(args) |
||
1062 | sys.exit(2) |
||
1063 | |||
1064 | if state == None: |
||
1065 | print "Requiered option --state not found." |
||
1066 | shorthelp(args) |
||
1067 | sys.exit(2) |
||
1068 | 42726 | jjdelcerro | |
1069 | 42725 | jjdelcerro | join = os.path.join |
1070 | build_folder = join(getPackagesRoot(),"dists",getVersion(),"builds",build) |
||
1071 | if not os.path.isdir(build_folder): |
||
1072 | print "Can't access the build folder "+build_folder+"." |
||
1073 | sys.exit(2) |
||
1074 | |||
1075 | do_prepare_portable(build,state) |
||
1076 | |||
1077 | def do_prepare_portable(build,state): |
||
1078 | join = os.path.join |
||
1079 | build_folder = join(getPackagesRoot(),"dists",getVersion(),"builds",build) |
||
1080 | portable_folder = join(build_folder,"misc","portable") |
||
1081 | makedirs(portable_folder) |
||
1082 | makedirs(join(portable_folder,"packages","custom")) |
||
1083 | makedirs(join(portable_folder,"standard")) |
||
1084 | makedirs(join(portable_folder,"patchs")) |
||
1085 | f=open(join(portable_folder,"packages","excludes"),"w") |
||
1086 | 42726 | jjdelcerro | f.write("""EPSG_v6 |
1087 | EPSG_v8_4 |
||
1088 | 42768 | jjdelcerro | EPSG_v8_5 |
1089 | EPSG_v8_6 |
||
1090 | 42725 | jjdelcerro | org.gvsig.app.document.layout1.app.mainplugin |
1091 | org.gvsig.dyschromatopsia.app.extension |
||
1092 | org.gvsig.educa.portableview.app.editor |
||
1093 | org.gvsig.educa.portableview.app.viewer |
||
1094 | org.gvsig.projection.app.cresques |
||
1095 | org.gvsig.projection.app.proj4j |
||
1096 | org.gvsig.editing.app.mainplugin |
||
1097 | org.gvsig.downloader.app.mainplugin |
||
1098 | 42949 | jjdelcerro | org.gvsig.publish.app.mainplugin |
1099 | org.gvsig.mapsheets.app.mainplugin |
||
1100 | org.gvsig.customize.app.mainplugin |
||
1101 | org.gvsig.timesupport.app.viewfilter |
||
1102 | org.gvsig.timesupport.app.animation |
||
1103 | 42725 | jjdelcerro | """) |
1104 | f.close() |
||
1105 | fname_base = "gvSIG-desktop-%s-%s-%s" % (getVersion(),build,state) |
||
1106 | 42775 | jjdelcerro | for platform in platforms : |
1107 | linkfile( |
||
1108 | join(build_folder,fname_base + "-" + platform.getOS() + "-" + platform.getArch() + "-online.zip"), |
||
1109 | join(portable_folder,"standard",fname_base + "-" + platform.getOS() + "-" + platform.getArch() + "-online.zip") |
||
1110 | ) |
||
1111 | linkfile( |
||
1112 | 42849 | jjdelcerro | join(build_folder,fname_base + "-" + platform.getOS() + "-" + platform.getArch() + ".gvspks"), |
1113 | 42775 | jjdelcerro | join(portable_folder,"standard",fname_base + "-" + platform.getOS() + "-" + platform.getArch() + ".gvspks") |
1114 | ) |
||
1115 | 42725 | jjdelcerro | extract_make_portable( |
1116 | 42768 | jjdelcerro | join(build_folder,fname_base + "-lin-x86_64-online.zip"), |
1117 | 42725 | jjdelcerro | join(portable_folder) |
1118 | ) |
||
1119 | mychmod(join(portable_folder,"make-portable"),RWXALL) |
||
1120 | 42726 | jjdelcerro | |
1121 | 42725 | jjdelcerro | def zipfolder(source,target): |
1122 | def zipdir(path, zip): |
||
1123 | for root, dirs, files in os.walk(path): |
||
1124 | for file in files: |
||
1125 | zip.write(os.path.join(root, file)) |
||
1126 | zipf = zipfile.ZipFile(target, 'w') |
||
1127 | zipdir(source, zipf) |
||
1128 | zipf.close() |
||
1129 | |||
1130 | def removefile(filename): |
||
1131 | if os.path.exists(filename): |
||
1132 | os.remove(filename) |
||
1133 | 42726 | jjdelcerro | |
1134 | 42725 | jjdelcerro | def mkportable(args): |
1135 | cmd = Command(args) |
||
1136 | try: |
||
1137 | opts, args = getopt.getopt(cmd.getArgs("mkportable"), "b:s:", [ "build=", "state=" ]) |
||
1138 | except getopt.GetoptError, err: |
||
1139 | # print help information and exit: |
||
1140 | print str(err) # will print something like "option -a not recognized" |
||
1141 | shorthelp(args) |
||
1142 | sys.exit(2) |
||
1143 | |||
1144 | build=None |
||
1145 | state=None |
||
1146 | for opt, arg in opts: |
||
1147 | if opt in ("-b", "--build"): |
||
1148 | build=arg |
||
1149 | elif opt in ("-s", "--state"): |
||
1150 | state=arg |
||
1151 | else: |
||
1152 | assert False, "unhandled option %r" % opt |
||
1153 | |||
1154 | if build == None: |
||
1155 | print "Requiered option --build not found." |
||
1156 | shorthelp(args) |
||
1157 | sys.exit(2) |
||
1158 | |||
1159 | if state == None: |
||
1160 | print "Requiered option --state not found." |
||
1161 | shorthelp(args) |
||
1162 | sys.exit(2) |
||
1163 | 42726 | jjdelcerro | |
1164 | 42725 | jjdelcerro | join = os.path.join |
1165 | build_folder = join(getPackagesRoot(),"dists",getVersion(),"builds",build) |
||
1166 | if not os.path.isdir(build_folder): |
||
1167 | print "Can't access the build folder "+build_folder+"." |
||
1168 | sys.exit(2) |
||
1169 | 42726 | jjdelcerro | |
1170 | 42725 | jjdelcerro | portable_folder = join(build_folder,"misc","portable") |
1171 | if not os.path.isdir(portable_folder) : |
||
1172 | do_prepare_portable(build,state) |
||
1173 | os.system('cd %s ; ./make-portable' % (portable_folder)) |
||
1174 | 42824 | jjdelcerro | |
1175 | 42725 | jjdelcerro | message("Removing previos portable zip files") |
1176 | 42775 | jjdelcerro | for platform in platforms : |
1177 | 42994 | jjdelcerro | removefile(join(build_folder,"gvSIG-desktop-%s-%s-%s-%s-%s%s.zip" % ( |
1178 | getVersion(),build,state,platform.getOS(),platform.getArch(), platform.getPortableSufix() |
||
1179 | ))) |
||
1180 | 42726 | jjdelcerro | |
1181 | 42725 | jjdelcerro | target_folder = join(getPackagesRoot(),"dists",getVersion(),"builds",build,"misc","portable","target") |
1182 | 42775 | jjdelcerro | for platform in platforms : |
1183 | 43000 | jjdelcerro | message("Moving zip gvSIG-desktop-%s-%s-%s-%s-%s%s.zip" % ( |
1184 | getVersion(),build,state,platform.getOS(),platform.getArch(), platform.getPortableSufix() |
||
1185 | )) |
||
1186 | 42775 | jjdelcerro | shutil.move( |
1187 | 42946 | jjdelcerro | join(portable_folder,"target","gvSIG-desktop-%s-%s-%s-%s-%s%s.zip" % ( |
1188 | 42994 | jjdelcerro | getVersion(), build, state, platform.getOS(), platform.getArch(), platform.getPortableSufix() |
1189 | ) |
||
1190 | ), |
||
1191 | 42775 | jjdelcerro | build_folder |
1192 | ) |
||
1193 | 42824 | jjdelcerro | message("Remove temporary folders") |
1194 | shutil.rmtree(target_folder) |
||
1195 | 42725 | jjdelcerro | |
1196 | 42824 | jjdelcerro | def mkexec(version, build, state, distribution_name, folder): |
1197 | fname = "gvSIG-desktop-%s-%s-%s-lin-x86_64-online.zip" % (version,build,state) |
||
1198 | extract_mkexec(os.path.join(folder,fname), folder) |
||
1199 | mychmod(os.path.join(folder,"mkexec"),RWXALL) |
||
1200 | cmd = 'cd %s ; ./mkexec "%s" "%s" "%s" "%s" "%s"' % (folder,version, build, state, distribution_name, folder) |
||
1201 | print "mkexec: cmd=", cmd |
||
1202 | os.system(cmd) |
||
1203 | os.remove(os.path.join(folder,"mkexec")) |
||
1204 | |||
1205 | 41292 | jjdelcerro | def mkdist(args): |
1206 | cmd = Command(args) |
||
1207 | try: |
||
1208 | 42775 | jjdelcerro | opts, args = getopt.getopt(cmd.getArgs("mkdist"), "b:s:", [ "build=", "state=", "distribution_name=" ]) |
1209 | 41292 | jjdelcerro | except getopt.GetoptError, err: |
1210 | # print help information and exit: |
||
1211 | print str(err) # will print something like "option -a not recognized" |
||
1212 | 42725 | jjdelcerro | shorthelp(args) |
1213 | 41292 | jjdelcerro | sys.exit(2) |
1214 | |||
1215 | build=None |
||
1216 | state=None |
||
1217 | distribution_name = "standard" |
||
1218 | 42726 | jjdelcerro | |
1219 | 41292 | jjdelcerro | for opt, arg in opts: |
1220 | if opt in ("-b", "--build"): |
||
1221 | build=arg |
||
1222 | elif opt in ("-s", "--state"): |
||
1223 | state=arg |
||
1224 | elif opt in ("-N", "--distrinution-name"): |
||
1225 | distribution_name = arg |
||
1226 | else: |
||
1227 | assert False, "unhandled option %r" % opt |
||
1228 | |||
1229 | if build == None: |
||
1230 | print "Requiered option --build not found." |
||
1231 | 42725 | jjdelcerro | shorthelp(args) |
1232 | 41292 | jjdelcerro | sys.exit(2) |
1233 | |||
1234 | if state == None: |
||
1235 | print "Requiered option --state not found." |
||
1236 | 42725 | jjdelcerro | shorthelp(args) |
1237 | 41292 | jjdelcerro | sys.exit(2) |
1238 | |||
1239 | if not os.path.isdir("builds/"+build): |
||
1240 | print "Can't access the build folder builds/"+build+"." |
||
1241 | sys.exit(2) |
||
1242 | 42726 | jjdelcerro | |
1243 | 41292 | jjdelcerro | message( "Generating distribution for build "+ build + "...") |
1244 | 42725 | jjdelcerro | message("Recreating index of packages...") |
1245 | 41292 | jjdelcerro | executeCommand("mks", "-s", "-c") |
1246 | 42726 | jjdelcerro | |
1247 | 41292 | jjdelcerro | executeCommand("mkhtml" ) |
1248 | |||
1249 | gvspki_filename = "builds/"+build+"/packages.gvspki" |
||
1250 | 42725 | jjdelcerro | message( "Coping packages.gvspki to "+ gvspki_filename + "\n") |
1251 | 41292 | jjdelcerro | shutil.copyfile("packages.gvspki", gvspki_filename) |
1252 | shutil.copyfile("packages.gvspki.md5", gvspki_filename +".md5") |
||
1253 | 42726 | jjdelcerro | |
1254 | 42775 | jjdelcerro | for platform in platforms: |
1255 | 42824 | jjdelcerro | message( "Creating installers for platform "+platform.getOS()+"/"+platform.getArch()+"...") |
1256 | 42775 | jjdelcerro | gvspks_filename = "builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+platform.getOS()+"-"+platform.getArch()+".gvspks" |
1257 | online_filename = "builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+platform.getOS()+"-"+platform.getArch() + "-online.jar" |
||
1258 | 42726 | jjdelcerro | |
1259 | 41292 | jjdelcerro | if not os.path.isfile(online_filename): |
1260 | 42902 | jjdelcerro | osfamily=platform.getOSFamilyForOnlineInstaller() |
1261 | 42946 | jjdelcerro | message("Coping standard online installer from os family (%s) to %s." % (osfamily, online_filename)) |
1262 | 42886 | jjdelcerro | shutil.copyfile( |
1263 | 42902 | jjdelcerro | "builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+osfamily+"-"+platform.getArch() + "-online.jar", |
1264 | 42886 | jjdelcerro | online_filename |
1265 | ) |
||
1266 | |||
1267 | if not os.path.isfile(online_filename): |
||
1268 | msgwarn("Can't access the online installer for "+platform.getOS()+"/"+platform.getArch() + " ("+online_filename+").") |
||
1269 | 41292 | jjdelcerro | continue |
1270 | 42726 | jjdelcerro | |
1271 | 42775 | jjdelcerro | message( "Coping packages-"+platform.getOS()+"-"+platform.getArch()+".gvspks to "+ gvspks_filename) |
1272 | shutil.copyfile("packages-"+platform.getOS()+"-"+platform.getArch()+".gvspks", gvspks_filename) |
||
1273 | shutil.copyfile("packages-"+platform.getOS()+"-"+platform.getArch()+".gvspks.md5", gvspks_filename +".md5") |
||
1274 | 41292 | jjdelcerro | |
1275 | 42886 | jjdelcerro | message( "Add execution permissions to online installers....") |
1276 | 41292 | jjdelcerro | mychmod(online_filename,RWXALL) |
1277 | |||
1278 | md5sum(online_filename,online_filename+".md5") |
||
1279 | mychmod(online_filename+".md5",RWALL) |
||
1280 | |||
1281 | 42726 | jjdelcerro | |
1282 | 42824 | jjdelcerro | executeCommand("mkinstall" , online_filename, gvspks_filename) |
1283 | 41292 | jjdelcerro | |
1284 | message( "Renaming files from custom to standard...") |
||
1285 | 42775 | jjdelcerro | target_filename = "builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+platform.getOS()+"-"+platform.getArch()+"-"+distribution_name + ".jar" |
1286 | 41292 | jjdelcerro | shutil.move( |
1287 | 42775 | jjdelcerro | "builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+platform.getOS()+"-"+platform.getArch() + "-custom.jar", |
1288 | 41292 | jjdelcerro | target_filename |
1289 | ) |
||
1290 | mychmod(target_filename,RWXALL) |
||
1291 | |||
1292 | md5sum(target_filename,target_filename+".md5") |
||
1293 | mychmod(target_filename+".md5",RWALL) |
||
1294 | |||
1295 | 42775 | jjdelcerro | message( "Createds installers for platform "+platform.getOS()+"/"+platform.getArch()+"\n") |
1296 | 42726 | jjdelcerro | |
1297 | 42824 | jjdelcerro | mkexec(VERSION, build, state, distribution_name, os.path.join(os.getcwd(), "builds", build)) |
1298 | |||
1299 | 42725 | jjdelcerro | message( "Coping html index to browse paqueges of the distro.") |
1300 | shutil.rmtree("builds/"+build+"/web", ignore_errors=True) |
||
1301 | shutil.copytree("web", "builds/"+build+"/web") |
||
1302 | f = file("builds/"+build+"/web/index.html","r") |
||
1303 | contents = f.read() |
||
1304 | f.close() |
||
1305 | contents = contents.replace("href=\"../../../web/gvSIG-desktop-", "href=\"../../../../../web/gvSIG-desktop-") |
||
1306 | f = file("builds/"+build+"/web/index.html","w") |
||
1307 | f.write(contents) |
||
1308 | f.close() |
||
1309 | 41292 | jjdelcerro | |
1310 | 42725 | jjdelcerro | message( "\nCreation of distribution completed.\n") |
1311 | 41292 | jjdelcerro | |
1312 | 42726 | jjdelcerro | |
1313 | 40435 | jjdelcerro | def show(args): |
1314 | 41292 | jjdelcerro | cmd = Command(args) |
1315 | try: |
||
1316 | opts, args = getopt.getopt(cmd.getArgs("show"), "S", [ "verify"]) |
||
1317 | except getopt.GetoptError, err: |
||
1318 | # print help information and exit: |
||
1319 | print str(err) # will print something like "option -a not recognized" |
||
1320 | 42725 | jjdelcerro | shorthelp(args) |
1321 | 41292 | jjdelcerro | sys.exit(2) |
1322 | |||
1323 | eerify = False |
||
1324 | for opt, arg in opts: |
||
1325 | if opt in ("-V", "--verify"): |
||
1326 | verify = True |
||
1327 | else: |
||
1328 | assert False, "unhandled option %r" % opt |
||
1329 | |||
1330 | index_name=args[0] |
||
1331 | 40435 | jjdelcerro | message( "Show package.info from '%s'" % index_name) |
1332 | files = findfiles(getPool(), index_name) |
||
1333 | if len(files) != 1: |
||
1334 | msgerror("Can't locate package '%s' in pool '%s'." % (index_name, getPool())) |
||
1335 | return |
||
1336 | index_path = files[0] |
||
1337 | outputfolder="/tmp/gvspkg.%s" % os.getpid() |
||
1338 | os.mkdir(outputfolder) |
||
1339 | os.system('unzip -q %s -d %s' % (index_path,outputfolder)) |
||
1340 | |||
1341 | files = findfiles(outputfolder, "package.info") |
||
1342 | if len(files) != 1: |
||
1343 | msgerror("Can't locate package.info in pool '%s'." % (index_name)) |
||
1344 | return |
||
1345 | |||
1346 | package_info = files[0] |
||
1347 | f = file(package_info,"r") |
||
1348 | s = f.read() |
||
1349 | f.close() |
||
1350 | 41292 | jjdelcerro | print s |
1351 | if verify: |
||
1352 | verify_sign(package_info) |
||
1353 | 40435 | jjdelcerro | shutil.rmtree(outputfolder) |
1354 | |||
1355 | 41292 | jjdelcerro | def editall(args): |
1356 | cmd = Command(args) |
||
1357 | 42726 | jjdelcerro | try: |
1358 | 41292 | jjdelcerro | opts, args = getopt.getopt(cmd.getArgs("editall"), "Scx:I:r:", ["clear-list", "exclude=", "excludepki=", "excludepkg=", "include=", "replace=", "sign"]) |
1359 | except getopt.GetoptError, err: |
||
1360 | # print help information and exit: |
||
1361 | print str(err) # will print something like "option -a not recognized" |
||
1362 | 42725 | jjdelcerro | shorthelp(args) |
1363 | 41292 | jjdelcerro | sys.exit(2) |
1364 | |||
1365 | index_only = False |
||
1366 | clear_list=False |
||
1367 | includes=list() |
||
1368 | excludes_pki=list() |
||
1369 | replaces = list() |
||
1370 | excludes_pkg=list() |
||
1371 | sign = False |
||
1372 | interactive = True |
||
1373 | for opt, arg in opts: |
||
1374 | if opt in ("-c", "--clear-list"): |
||
1375 | clear_list = True |
||
1376 | elif opt in ("-x", "--exclude"): |
||
1377 | excludes_pki.append(arg) |
||
1378 | excludes_pkg.append(arg) |
||
1379 | elif opt in ( "--excludepki"): |
||
1380 | excludes_pki.append(arg) |
||
1381 | elif opt in ( "--excludepkg"): |
||
1382 | excludes_pkg.append(arg) |
||
1383 | elif opt in ( "--include", "-I"): |
||
1384 | includes.append(PackageInfo(arg)) |
||
1385 | elif opt in ("-r", "--replace"): |
||
1386 | interactive = False |
||
1387 | replaces.append(arg) |
||
1388 | elif opt in ("-S", "--sign"): |
||
1389 | sign = True |
||
1390 | else: |
||
1391 | assert False, "unhandled option %r" % opt |
||
1392 | |||
1393 | indexes = IndexList() |
||
1394 | |||
1395 | packages_txt = getDist() +"/packages.txt" |
||
1396 | if os.path.exists(packages_txt) and not clear_list: |
||
1397 | indexes.load(packages_txt) |
||
1398 | else: |
||
1399 | indexes.build(getPool(), getSearchVersions()) |
||
1400 | indexes.save(packages_txt) |
||
1401 | |||
1402 | for pkg in includes: |
||
1403 | indexes.append(pkg) |
||
1404 | |||
1405 | allpackages = list() |
||
1406 | for info in indexes: |
||
1407 | if not ( info.code in excludes_pki or info.getFullName() in excludes_pki ): |
||
1408 | try: |
||
1409 | if info.hasPki() : |
||
1410 | 42725 | jjdelcerro | print info.getPkiFilename() |
1411 | 41292 | jjdelcerro | if interactive : |
1412 | edit_pkginfo_of_package(info.getPkiFilename(), edit_ui) |
||
1413 | elif len(replaces) < 1: |
||
1414 | edit_pkginfo_of_package(info.getPkiFilename(), edit_replace, replaces) |
||
1415 | |||
1416 | if sign: |
||
1417 | edit_pkginfo_of_package(info.getPkiFilename(), edit_sign) |
||
1418 | |||
1419 | except Exception, ex: |
||
1420 | msgerror("Can't add index '%s', error %s" % (info, str(ex))) |
||
1421 | |||
1422 | 40435 | jjdelcerro | def edit(args): |
1423 | 41292 | jjdelcerro | cmd = Command(args) |
1424 | try: |
||
1425 | opts, args = getopt.getopt(cmd.getArgs("edit"), "Sr:", [ "replace=", "onlysign", "sign" ]) |
||
1426 | except getopt.GetoptError, err: |
||
1427 | # print help information and exit: |
||
1428 | print str(err) # will print something like "option -a not recognized" |
||
1429 | 42725 | jjdelcerro | shorthelp(args) |
1430 | 41292 | jjdelcerro | sys.exit(2) |
1431 | |||
1432 | replaces = list() |
||
1433 | interactive = True |
||
1434 | sign = False |
||
1435 | for opt, arg in opts: |
||
1436 | if opt in ("-r", "--replace"): |
||
1437 | interactive = False |
||
1438 | replaces.append(arg) |
||
1439 | elif opt in ("--onlysign"): |
||
1440 | interactive = False |
||
1441 | sign = True |
||
1442 | elif opt in ("-S", "--sign"): |
||
1443 | sign = True |
||
1444 | else: |
||
1445 | assert False, "unhandled option %r" % opt |
||
1446 | |||
1447 | index_name=args[0] |
||
1448 | 40435 | jjdelcerro | message( "Show package.info from '%s'" % index_name) |
1449 | files = findfiles(getPool(), index_name) |
||
1450 | if len(files) != 1: |
||
1451 | msgerror("Can't locate package '%s' in pool '%s'." % (index_name, getPool())) |
||
1452 | return |
||
1453 | index_path = files[0] |
||
1454 | 41292 | jjdelcerro | if interactive: |
1455 | edit_pkginfo_of_package(index_path, edit_ui) |
||
1456 | elif len(replaces) < 1: |
||
1457 | edit_pkginfo_of_package(index_path, edit_replace, replaces) |
||
1458 | |||
1459 | if sign: |
||
1460 | edit_pkginfo_of_package(index_path, edit_sign) |
||
1461 | |||
1462 | def edit_ui(filename, args): |
||
1463 | os.system('vi "%s"' % filename) |
||
1464 | |||
1465 | def edit_replace(filename, args): |
||
1466 | replaces = args[0] |
||
1467 | f = open(filename) |
||
1468 | s = f.read() |
||
1469 | f.close() |
||
1470 | for replace in replaces: |
||
1471 | x = replace.split(replace[0]) |
||
1472 | if len(x)==4: |
||
1473 | s=re.sub(x[1],x[2],s) |
||
1474 | f = open(filename,"w") |
||
1475 | f.write(s) |
||
1476 | f.close() |
||
1477 | |||
1478 | def edit_sign(filename, args): |
||
1479 | os.system('java -cp "%s/commons-codec-1.6.jar:%s/org.gvsig.installer.lib.impl-1.0.1-SNAPSHOT.jar" org.gvsig.installer.lib.impl.utils.SignUtil sign %s' % ( |
||
1480 | get_gvspkg_bin_folder(), |
||
1481 | get_gvspkg_bin_folder(), |
||
1482 | filename) |
||
1483 | ) |
||
1484 | |||
1485 | def verify_sign(filename): |
||
1486 | os.system('java -cp "%s/commons-codec-1.6.jar:%s/org.gvsig.installer.lib.impl-1.0.1-SNAPSHOT.jar" org.gvsig.installer.lib.impl.utils.SignUtil verify %s' % ( |
||
1487 | get_gvspkg_bin_folder(), |
||
1488 | get_gvspkg_bin_folder(), |
||
1489 | filename) |
||
1490 | ) |
||
1491 | |||
1492 | def edit_pkginfo_of_package(pkg_path, operation, *args): |
||
1493 | 40435 | jjdelcerro | outputfolder="/tmp/gvspkg.%s" % os.getpid() |
1494 | os.mkdir(outputfolder) |
||
1495 | 41292 | jjdelcerro | os.system('unzip -q %s -d %s' % (pkg_path,outputfolder)) |
1496 | 40435 | jjdelcerro | |
1497 | files = findfiles(outputfolder, "package.info") |
||
1498 | if len(files) != 1: |
||
1499 | 41292 | jjdelcerro | msgerror("Can't locate package.info in pool '%s'." % (pkg_path)) |
1500 | 40435 | jjdelcerro | return |
1501 | |||
1502 | package_info = files[0] |
||
1503 | code = package_info.split("/")[-2] |
||
1504 | 41292 | jjdelcerro | operation(package_info, args) |
1505 | |||
1506 | # zip -Dr kk.zip org.gvsig.wfs |
||
1507 | 40435 | jjdelcerro | temp_index_name = "/tmp/packages.gvspki.%s" % os.getpid() |
1508 | temp_index = zipfile.ZipFile(temp_index_name,"w",zipfile.ZIP_STORED) |
||
1509 | temp_index.write(package_info, "%s/package.info" % (code)) |
||
1510 | temp_index.close() |
||
1511 | shutil.rmtree(outputfolder) |
||
1512 | 41292 | jjdelcerro | os.remove(pkg_path) |
1513 | shutil.move(temp_index_name,pkg_path) |
||
1514 | 40435 | jjdelcerro | |
1515 | 41292 | jjdelcerro | def install(args): |
1516 | cmd = Command(args) |
||
1517 | try: |
||
1518 | 42725 | jjdelcerro | opts, args = getopt.getopt(cmd.getArgs("install"), "fS", [ "force","nohttps" ]) |
1519 | 41292 | jjdelcerro | except getopt.GetoptError, err: |
1520 | # print help information and exit: |
||
1521 | print str(err) # will print something like "option -a not recognized" |
||
1522 | 42725 | jjdelcerro | shorthelp(args) |
1523 | 41292 | jjdelcerro | sys.exit(2) |
1524 | |||
1525 | force = False |
||
1526 | 42725 | jjdelcerro | nohttps = False |
1527 | 41292 | jjdelcerro | for opt, arg in opts: |
1528 | if opt in ("-f", "--force"): |
||
1529 | force = True |
||
1530 | 42725 | jjdelcerro | if opt in ("-S", "--nohttps"): |
1531 | nohttps = True |
||
1532 | 41292 | jjdelcerro | else: |
1533 | assert False, "unhandled option %r" % opt |
||
1534 | |||
1535 | url_pki = args[0] |
||
1536 | 42725 | jjdelcerro | if url_pki.startswith("https:") and nohttps : |
1537 | url_pki = "http:" + url_pki[6:] |
||
1538 | 42726 | jjdelcerro | |
1539 | 41292 | jjdelcerro | message( "Download package index '%s'" % url_pki) |
1540 | temppath_pki= os.path.join("/tmp",os.path.basename(url_pki)) |
||
1541 | if not downloadFile(url_pki,temppath_pki): |
||
1542 | msgerror("Can't download index.") |
||
1543 | msgerror("Can't install '%s'." % url_pki) |
||
1544 | print # force a newline |
||
1545 | return 1 |
||
1546 | pkg = PackageInfo(temppath_pki) |
||
1547 | url_pkg = pkg.getUrl().replace("\\","") |
||
1548 | if url_pkg[-7:] == ".gvspki" : |
||
1549 | msgwarn("Suspicious download-url value. Ends with gvspki, expected gvspkg.") |
||
1550 | msgwarn("download-url ='%s'." % url_pkg) |
||
1551 | 42726 | jjdelcerro | |
1552 | 42725 | jjdelcerro | if url_pkg.startswith("https:") and nohttps : |
1553 | url_pkg = "http:" + url_pkg[6:] |
||
1554 | 42726 | jjdelcerro | |
1555 | 41292 | jjdelcerro | message( "Download package '%s'" % url_pkg) |
1556 | temppath_pkg= os.path.join("/tmp",os.path.basename(url_pkg)) |
||
1557 | if not downloadFile(url_pkg,temppath_pkg): |
||
1558 | msgerror("Can't download package from download-url ('%s')." % url_pkg) |
||
1559 | msgerror("Can't install '%s'," % url_pki) |
||
1560 | print # force a newline |
||
1561 | return 1 |
||
1562 | folder = os.path.join(getPool(),pkg.getCode()) |
||
1563 | 42725 | jjdelcerro | makedirs(folder) |
1564 | 41292 | jjdelcerro | pathname_pki = os.path.join(folder,os.path.basename(url_pki)) |
1565 | if not force and os.path.isfile(pathname_pki) : |
||
1566 | msgwarn("The package index alreade exist in the pool. Use -f to forrce install.") |
||
1567 | print # force a newline |
||
1568 | return 1 |
||
1569 | pathname_pkg = os.path.join(folder,os.path.basename(url_pkg)) |
||
1570 | if not force and os.path.isfile(pathname_pki) : |
||
1571 | msgwarn("The package downloaded from download-url alredy exists in the pool. Use -f to force install.") |
||
1572 | 42726 | jjdelcerro | print # force a newline |
1573 | 41292 | jjdelcerro | return 1 |
1574 | message( "installing package '%s'" % os.path.basename(pathname_pki)) |
||
1575 | shutil.copyfile(temppath_pki, pathname_pki) |
||
1576 | message( "installing package '%s'" % os.path.basename(pathname_pkg)) |
||
1577 | shutil.copyfile(temppath_pkg, pathname_pkg) |
||
1578 | |||
1579 | md5sum(pathname_pki, pathname_pki+".md5") |
||
1580 | md5sum(pathname_pkg, pathname_pkg+".md5") |
||
1581 | |||
1582 | |||
1583 | def md5sum(fin, fout): |
||
1584 | message( "Calculating md5sum of %s..." % fin ) |
||
1585 | system("md5sum -b %s >%s" % (fin, fout) ) |
||
1586 | |||
1587 | def downloadFile(url,path): |
||
1588 | try: |
||
1589 | fsrc = urllib2.urlopen(url) |
||
1590 | except urllib2.HTTPError,e: |
||
1591 | msgerror("Error abriendo url '%s'." % url, e) |
||
1592 | return False |
||
1593 | fdst = file(path,"wb") |
||
1594 | shutil.copyfileobj(fsrc,fdst) |
||
1595 | fdst.close() |
||
1596 | fsrc.close() |
||
1597 | return True |
||
1598 | |||
1599 | 42725 | jjdelcerro | def shorthelp(args): |
1600 | print """ |
||
1601 | usage: gvspkg [OPTIONS] COMMANDS |
||
1602 | OPTIONS: |
||
1603 | 41292 | jjdelcerro | |
1604 | 42725 | jjdelcerro | -h,--help Muestra esta ayuda |
1605 | -v,--verbose Activa el modo verbose |
||
1606 | -d,--debug Activa el modo debug. |
||
1607 | --version ver Fija la version con la que van a trabajar. |
||
1608 | -r,--package-root root Fija la carpeta del raiz del sistema de paquetes |
||
1609 | 42726 | jjdelcerro | |
1610 | 42725 | jjdelcerro | COMMANDS: |
1611 | |||
1612 | mkinstall [OPTIONS] install-file packages-file |
||
1613 | -L, --jrelin=path |
||
1614 | -W, --jrewin=path |
||
1615 | -l, --addjrelin |
||
1616 | -w, --addjrewin |
||
1617 | -N, --distribution-name=name |
||
1618 | |||
1619 | lsi [OPTIONS] |
||
1620 | -l, --long-format |
||
1621 | |||
1622 | mks [OPTIONS] |
||
1623 | -c, --clear-list |
||
1624 | --excludepkg pkgcode |
||
1625 | --excludepki pkgcode |
||
1626 | --exclude pkgcode |
||
1627 | -s, --include-default-selection |
||
1628 | -i, --index-only |
||
1629 | -I full-path-to-package, --include full-path-to-package |
||
1630 | |||
1631 | mkdist [OPTIONS] |
||
1632 | -s STATE, --state=STATE |
||
1633 | -b BUILD, --build=BUILD |
||
1634 | -N, --distribution-name=name |
||
1635 | 42726 | jjdelcerro | |
1636 | 42725 | jjdelcerro | mkmirror [OPTIONS] |
1637 | -b, --build buildnumber |
||
1638 | |||
1639 | mkhtml [OPTIONS] |
||
1640 | -c, --clear-list |
||
1641 | --excludepkg pkgcode |
||
1642 | --excludepki pkgcode |
||
1643 | --exclude pkgcode |
||
1644 | |||
1645 | show OPTIONS package-index |
||
1646 | --verify, -V |
||
1647 | |||
1648 | edit [OPTIONS] package-index |
||
1649 | --replace=@search@replace@ |
||
1650 | --onlysign |
||
1651 | --sign, -S |
||
1652 | |||
1653 | editall [OPTIONS] |
||
1654 | -c, --clear-list |
||
1655 | --excludepkg pkgcode |
||
1656 | --excludepki pkgcode |
||
1657 | --exclude pkgcode |
||
1658 | --replace=@search@replace@ |
||
1659 | --sign, -S |
||
1660 | |||
1661 | install [OPTIONS] url-to-pki |
||
1662 | -f, --force |
||
1663 | |||
1664 | prepare-portable [OPTIONS] |
||
1665 | -b, --build |
||
1666 | -s, --state |
||
1667 | |||
1668 | mkportable [OPTIONS] |
||
1669 | -b, --build |
||
1670 | -s, --state |
||
1671 | |||
1672 | La version actual a utilizar es: |
||
1673 | %s |
||
1674 | |||
1675 | El directorio root de la estructura de packetes actual es: |
||
1676 | %s |
||
1677 | """ % (VERSION, GVSPKG_ROOT) |
||
1678 | |||
1679 | |||
1680 | 40435 | jjdelcerro | def help(args): |
1681 | print """ |
||
1682 | usage: gvspkg [OPTIONS] COMMANDS |
||
1683 | |||
1684 | OPTIONS: |
||
1685 | |||
1686 | -h|--help |
||
1687 | Muestra esta ayuda |
||
1688 | |||
1689 | -v|--verbose |
||
1690 | Activa el modo verbose |
||
1691 | |||
1692 | -d|--debug |
||
1693 | Activa el modo debug. Se muestran mensajes que pueden ser |
||
1694 | utilies de cara a depuracion. |
||
1695 | |||
1696 | --version version |
||
1697 | Fija la version con la que van a trabajar los comandos indicados. |
||
1698 | |||
1699 | -r|--package-root package-root |
||
1700 | Fija la carpeta en la que va a buscar el raiz del sistema de paquetes |
||
1701 | con el que trabajar |
||
1702 | 42726 | jjdelcerro | |
1703 | 40435 | jjdelcerro | COMMANDS: |
1704 | |||
1705 | mkinstall [OPTIONS] install-file packages-file |
||
1706 | |||
1707 | OPTIONS: |
||
1708 | |||
1709 | -L | --jrelin=path |
||
1710 | |||
1711 | -W | --jrewin=path |
||
1712 | |||
1713 | -l | --addjrelin |
||
1714 | |||
1715 | -w | --addjrewin |
||
1716 | 42726 | jjdelcerro | |
1717 | 40435 | jjdelcerro | -N | --distribution-name=name |
1718 | Nombre usado como sufijo del nuevo binario a generar. Por defecto si no se |
||
1719 | indica valdra "custom". |
||
1720 | |||
1721 | |||
1722 | lsi [OPTIONS] |
||
1723 | Lista los indices disponibles de la version |
||
1724 | |||
1725 | OPTIONS: |
||
1726 | |||
1727 | -l | --long-format |
||
1728 | Muestra para cada paquete la informacion del package.info |
||
1729 | |||
1730 | mks [OPTIONS] |
||
1731 | Crea el fichero packages.gvspki con los indices de la |
||
1732 | version y packages.gvspkg con los paquetes. |
||
1733 | |||
1734 | OPTIONS: |
||
1735 | |||
1736 | -c | --clear-list |
||
1737 | Elimina la lista de paquetes a utilizar recreandola a partir |
||
1738 | de los paquetes del pool tomando el ultimo build de cada paquete. |
||
1739 | |||
1740 | --excludepkg pkgcode |
||
1741 | No incluye el paquete indicado en el fichero gvspkg a generar |
||
1742 | |||
1743 | --excludepki pkgcode |
||
1744 | No incluye el paquete indicado en el fichero gvspki a generar |
||
1745 | |||
1746 | --exclude pkgcode |
||
1747 | No incluye el paquete indicado en los ficheros gvspkg y gvspki a generar |
||
1748 | |||
1749 | -s | --include-default-selection |
||
1750 | Incluye el fichero "defaultPackages", que se debe encontrar en el |
||
1751 | directorio corriente, con los nombres de paquetes a seleccionar |
||
1752 | por defecto. |
||
1753 | |||
1754 | -i | --index-only |
||
1755 | No crea el fichero gvspks, solo crea el gvspki |
||
1756 | |||
1757 | 42725 | jjdelcerro | -I full-path-to-package | --include full-path-to-package |
1758 | 42824 | jjdelcerro | Agrega el paquete indicado a la lista de paquetes aunque no coincida para |
1759 | 40435 | jjdelcerro | la version de gvSIG con la que se esta trabajando. |
1760 | |||
1761 | 41292 | jjdelcerro | mkdist [OPTIONS] |
1762 | 42725 | jjdelcerro | Crea los ficheros de la distribucion standard para el buil dindicado a partir de |
1763 | 41292 | jjdelcerro | la distribucion online y los paquetes que hayan en el pool para esta version. |
1764 | Ejecuta un "mks" y un "mkhtml" automaticamente para preparar el conjunto de paquetes |
||
1765 | a incluir en la distribucion, y una vez preparados ejecuta un "mkinsrall" por |
||
1766 | S.O. (win y lin), renombrando los ficheros generados segun corresponda. |
||
1767 | |||
1768 | OPTIONS: |
||
1769 | -s STATE | --state=STATE |
||
1770 | Indica el estado de la distribucion a generar, devel, alpha, ..., debe estar |
||
1771 | deacuerdo con lo que diga el cihero online a usar como base. |
||
1772 | |||
1773 | -b BUILD | --build=BUILD |
||
1774 | Indica el numero de build de la destribucion a generar. Es usado para localizar |
||
1775 | los ficheros en la carpeta builds de la distribucion y para saber donde debe |
||
1776 | dejar los ficheros generados. |
||
1777 | |||
1778 | -N | --distribution-name=name |
||
1779 | Nombre usado como sufijo del nuevo binario a generar. Por defecto si no se |
||
1780 | indica valdra "standard". |
||
1781 | |||
1782 | 42726 | jjdelcerro | |
1783 | 41292 | jjdelcerro | mkmirror [OPTIONS] |
1784 | |||
1785 | Prepara una carpeta para hacer un mirror de un build en concreto. |
||
1786 | |||
1787 | OPTIONS: |
||
1788 | |||
1789 | -b | --build buildnumber |
||
1790 | Indica el numero de build del que se quiere hacer un mirror. |
||
1791 | |||
1792 | 40435 | jjdelcerro | mkhtml [OPTIONS] |
1793 | ???? |
||
1794 | |||
1795 | OPTIONS: |
||
1796 | |||
1797 | -c | --clear-list |
||
1798 | Elimina la lista de paquetes a utilizar recreandola a partir |
||
1799 | de los paquetes del pool tomando el ultimo build de cada paquete. |
||
1800 | |||
1801 | --excludepkg pkgcode |
||
1802 | No incluye el paquete indicado en el fichero gvspkg a generar |
||
1803 | |||
1804 | --excludepki pkgcode |
||
1805 | No incluye el paquete indicado en el fichero gvspki a generar |
||
1806 | |||
1807 | --exclude pkgcode |
||
1808 | No incluye el paquete indicado en los ficheros gvspkg y gvspki a generar |
||
1809 | |||
1810 | 41292 | jjdelcerro | show OPTIONS package-index |
1811 | 40435 | jjdelcerro | Muestra el package.info del indice indicado como parametro. |
1812 | |||
1813 | 41292 | jjdelcerro | OPTIONS |
1814 | |||
1815 | --verify | -V |
||
1816 | Comprueba la forma del packete. |
||
1817 | |||
1818 | edit [OPTIONS] package-index |
||
1819 | 40435 | jjdelcerro | Edita el package.info del indice indicado como parametro. |
1820 | |||
1821 | 41292 | jjdelcerro | OPTIONS: |
1822 | |||
1823 | --replace=@search@replace@ |
||
1824 | Reemplaza en el package.info de cada paquete la cadena "search" por "replace" |
||
1825 | todas las veces que aparezca. "@" puede ser cualquier caracter que no aparezca |
||
1826 | en "search" y "replace". |
||
1827 | Esta opcion puede indicarse tatas veces como reemplazos se deseen efectuar. |
||
1828 | |||
1829 | --onlysign |
||
1830 | 42725 | jjdelcerro | firma el package.info sin editarlo de forma interactiva (no invoca al editor antes |
1831 | 41292 | jjdelcerro | de firmarlo). |
1832 | |||
1833 | --sign | -S |
||
1834 | Firma el package.info tras terminar la edicion (bach o interactiva) |
||
1835 | |||
1836 | editall [OPTIONS] |
||
1837 | 42725 | jjdelcerro | Edita todos los package.info |
1838 | 41292 | jjdelcerro | |
1839 | OPTIONS: |
||
1840 | |||
1841 | -c | --clear-list |
||
1842 | Elimina la lista de paquetes a utilizar recreandola a partir |
||
1843 | de los paquetes del pool tomando el ultimo build de cada paquete. |
||
1844 | |||
1845 | --excludepkg pkgcode |
||
1846 | No incluye el paquete indicado en el fichero gvspkg a generar |
||
1847 | |||
1848 | --excludepki pkgcode |
||
1849 | No incluye el paquete indicado en el fichero gvspki a generar |
||
1850 | |||
1851 | --exclude pkgcode |
||
1852 | No incluye el paquete indicado en los ficheros gvspkg y gvspki a generar |
||
1853 | |||
1854 | --replace=@search@replace@ |
||
1855 | Reemplaza en el package.info de cada paquete la cadena "search" por "replace" |
||
1856 | todas las veces que aparezca. "@" puede ser cualquier caracter que no aparezca |
||
1857 | en "search" y "replace". |
||
1858 | Esta opcion puede indicarse tatas veces como reemplazos se deseen efectuar. |
||
1859 | |||
1860 | --sign | -S |
||
1861 | Firma todos los paquetes que sean oficiales |
||
1862 | |||
1863 | install [OPTIONS] url-to-pki |
||
1864 | descarga de la url indicada un fichero gvspki e instala este junto con su correspondiente |
||
1865 | pkg en el pool local. |
||
1866 | |||
1867 | OPTIONS: |
||
1868 | |||
1869 | -f | --force |
||
1870 | fuerza la sobreescritura de los ficheros en caso de que estos ya existan. |
||
1871 | |||
1872 | 40435 | jjdelcerro | Si en la carpeta corriente encuentra un fichero gvspkg.options cargara los |
1873 | 42725 | jjdelcerro | flags indicados ahi como flags por defecto para cada comando. El formato del |
1874 | 40435 | jjdelcerro | fichero es: |
1875 | main=OPCION-POR-DEFECTO |
||
1876 | mks=OPCOPNES-POR-DEFECTO |
||
1877 | Donde main indica las opciones por defecto generales, independientes del comando |
||
1878 | 42725 | jjdelcerro | a ejecutar. "mks" indica las opciones por defecto a usar en el comando "mks", y |
1879 | 40435 | jjdelcerro | asi sucesivamente, indicando el nombre del comando seguido de un "=" y las opciones |
1880 | por defecto para ese comando. |
||
1881 | |||
1882 | 42725 | jjdelcerro | Por defecto la version la obtiene del nombre de la carpeta |
1883 | 40435 | jjdelcerro | corriente (%s). Las opciones indicadas en el fichero gvspkg.options tienen prioridad |
1884 | sobre este valor. |
||
1885 | |||
1886 | El directorio root de la estructura de packetes lo buscara en el |
||
1887 | sitio indicado por la variable de entorno GVPKG_ROOT, y si esta no |
||
1888 | 42725 | jjdelcerro | esta establecida usara "%s". Las opciones indicadas en el fichero gvspkg.options |
1889 | 40435 | jjdelcerro | tienen prioridad sobre este valor. |
1890 | |||
1891 | """ % (VERSION, GVSPKG_ROOT) |
||
1892 | |||
1893 | 41292 | jjdelcerro | def executeCommand(*args): |
1894 | 42725 | jjdelcerro | command = "shorthelp" |
1895 | 41292 | jjdelcerro | if len(args)>0: |
1896 | command=args[0] |
||
1897 | |||
1898 | 42725 | jjdelcerro | r=1 |
1899 | 41292 | jjdelcerro | if command=="lsi" : |
1900 | 42725 | jjdelcerro | r=lsi(args) |
1901 | 41292 | jjdelcerro | elif command == "mks": |
1902 | 42725 | jjdelcerro | r=mks(args) |
1903 | 41292 | jjdelcerro | elif command == "edit": |
1904 | 42725 | jjdelcerro | r=edit(args) |
1905 | 41292 | jjdelcerro | elif command == "editall": |
1906 | 42725 | jjdelcerro | r=editall(args) |
1907 | 41292 | jjdelcerro | elif command == "show": |
1908 | 42725 | jjdelcerro | r=show(args) |
1909 | 41292 | jjdelcerro | elif command == "mkhtml": |
1910 | 42725 | jjdelcerro | r=mkhtml(args) |
1911 | 41292 | jjdelcerro | elif command == "mkinstall": |
1912 | 42725 | jjdelcerro | r=mkinstall(args) |
1913 | 41292 | jjdelcerro | elif command == "install": |
1914 | 42725 | jjdelcerro | r=install(args) |
1915 | 41292 | jjdelcerro | elif command == "mkdist": |
1916 | 42725 | jjdelcerro | r=mkdist(args) |
1917 | 41292 | jjdelcerro | elif command == "mkmirror": |
1918 | 42725 | jjdelcerro | r=mkmirror(args) |
1919 | elif command == "mkportable": |
||
1920 | r=mkportable(args) |
||
1921 | elif command == "prepare-portable": |
||
1922 | r=prepare_portable(args) |
||
1923 | elif command == "help": |
||
1924 | r=help(args) |
||
1925 | 41292 | jjdelcerro | else: |
1926 | 42725 | jjdelcerro | r=shorthelp(args) |
1927 | return r |
||
1928 | 41292 | jjdelcerro | |
1929 | 40435 | jjdelcerro | def main(): |
1930 | 41292 | jjdelcerro | global DEBUG |
1931 | 40435 | jjdelcerro | global VERSION |
1932 | global VERBOSE |
||
1933 | global GVSPKG_ROOT |
||
1934 | 41292 | jjdelcerro | global SEARCH_VERSIONS |
1935 | 40435 | jjdelcerro | |
1936 | cmd = Command(sys.argv) |
||
1937 | try: |
||
1938 | 41292 | jjdelcerro | opts, args = getopt.getopt(cmd.getArgs("main"), "dhvr:", ["debug", "verbose", "version=", "package-root=","help","search_versions="]) |
1939 | 40435 | jjdelcerro | except getopt.GetoptError, err: |
1940 | # print help information and exit: |
||
1941 | print str(err) # will print something like "option -a not recognized" |
||
1942 | 42725 | jjdelcerro | shorthelp(None) |
1943 | 40435 | jjdelcerro | sys.exit(2) |
1944 | |||
1945 | for opt, arg in opts: |
||
1946 | if opt in ("-h", "--help"): |
||
1947 | 42725 | jjdelcerro | shorthelp(args) |
1948 | 40435 | jjdelcerro | sys.exit() |
1949 | elif opt in ("-d", "--debug"): |
||
1950 | DEBUG = True |
||
1951 | elif opt in ("-v", "--verbose"): |
||
1952 | VERBOSE = True |
||
1953 | elif opt in ("--version"): |
||
1954 | VERSION = arg |
||
1955 | 41292 | jjdelcerro | elif opt in ("--search_versions"): |
1956 | SEARCH_VERSIONS.append(arg) |
||
1957 | 40435 | jjdelcerro | elif opt in ("-r", "--package-root"): |
1958 | GVSPKG_ROOT = arg |
||
1959 | else: |
||
1960 | assert False, "unhandled option" |
||
1961 | 42725 | jjdelcerro | # |
1962 | 41292 | jjdelcerro | debug("DEBUG=%s" % DEBUG) |
1963 | debug("VERSION=%s" % VERSION) |
||
1964 | debug("GVSPKG_ROOT=%s" % GVSPKG_ROOT) |
||
1965 | if GVSPKG_ROOT == None: |
||
1966 | 42725 | jjdelcerro | shorthelp(None) |
1967 | 40435 | jjdelcerro | else: |
1968 | 42725 | jjdelcerro | r=executeCommand(*args) |
1969 | sys.exit(r) |
||
1970 | 40435 | jjdelcerro | |
1971 | 42849 | jjdelcerro | main() |
1972 | |||
1973 | 42886 | jjdelcerro | |
1974 | |||
1975 | 42902 | jjdelcerro |