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