Revision 41292
trunk/org.gvsig.desktop/org.gvsig.desktop.installer/src/main/packaging/gvspkg | ||
---|---|---|
14 | 14 |
from os import system |
15 | 15 |
import ConfigParser |
16 | 16 |
import StringIO |
17 |
import re |
|
18 |
import urllib2 |
|
19 |
import time |
|
17 | 20 |
|
21 |
DEBUG = False |
|
22 |
DEBUG = False |
|
23 |
VERBOSE = False |
|
24 |
SEARCH_VERSIONS = list() |
|
25 |
|
|
26 |
LINUX_EXEC_EXTENSION=".run" # antes ".bin" |
|
27 |
|
|
28 |
def log(msg): |
|
29 |
f=open("/tmp/gvspkg.log","a") |
|
30 |
f.write(time.ctime()) |
|
31 |
f.write(": ") |
|
32 |
f.write(msg) |
|
33 |
f.write("\n") |
|
34 |
f.close() |
|
35 |
|
|
36 |
def message(msg): |
|
37 |
if VERBOSE: |
|
38 |
print msg |
|
39 |
log(msg) |
|
40 |
|
|
41 |
def msgerror(msg, err=None): |
|
42 |
print "ERROR: ", msg |
|
43 |
log("ERROR: "+msg) |
|
44 |
if err!=None : |
|
45 |
print "ERROR: ", str(err) |
|
46 |
log("ERROR: "+ str(err)) |
|
47 |
|
|
48 |
|
|
49 |
def msgwarn(msg): |
|
50 |
print "WARNING: ", msg |
|
51 |
log("WARNING: "+ msg) |
|
52 |
|
|
53 |
def debug(msg): |
|
54 |
if DEBUG: |
|
55 |
print "DEBUG: ", msg |
|
56 |
log("DEBUG: "+ msg) |
|
57 |
|
|
58 |
def acquire_file(name): |
|
59 |
files = list() |
|
60 |
folder = os.getcwd() |
|
61 |
while folder not in ( None, "", "/"): |
|
62 |
pathname = os.path.join(folder,name) |
|
63 |
if os.path.exists(pathname): |
|
64 |
files.append(pathname) |
|
65 |
folder = os.path.dirname(folder) |
|
66 |
return files |
|
67 |
|
|
68 |
def get_gvspkg_bin_folder(): |
|
69 |
files = list() |
|
70 |
if os.environ.get("HOME") != None : |
|
71 |
files.append(os.path.join(os.environ['HOME'],".gvspkg.bin")) |
|
72 |
files.extend( acquire_file(".gvspkg.bin") ) |
|
73 |
files.extend( acquire_file("gvspkg.bin") ) |
|
74 |
if len(files)<1 : |
|
75 |
return None |
|
76 |
debug( "gvspkg.bin = %s" % files[-1]) |
|
77 |
return files[-1] |
|
78 |
|
|
79 |
def search_GVSPKG_ROOT(): |
|
80 |
f = get_gvspkg_bin_folder() |
|
81 |
if f==None: |
|
82 |
return None |
|
83 |
return os.path.dirname(f) |
|
84 |
|
|
18 | 85 |
RWALL = stat.S_IWOTH | stat.S_IROTH | stat.S_IWUSR | stat.S_IRUSR | stat.S_IWGRP | stat.S_IRGRP |
86 |
RWXALL = RWALL | stat.S_IXUSR | stat.S_IXOTH | stat.S_IXGRP |
|
19 | 87 |
|
20 |
DEBUG = False |
|
21 |
VERBOSE = False |
|
22 | 88 |
VERSION = os.path.basename(os.getcwd()) |
23 |
GVSPKG_ROOT = "~/.gvspkg.bin"
|
|
89 |
GVSPKG_ROOT = search_GVSPKG_ROOT()
|
|
24 | 90 |
|
25 | 91 |
def getVersion(): |
26 | 92 |
return VERSION |
27 | 93 |
|
94 |
def getSearchVersions(): |
|
95 |
vers = list(); |
|
96 |
vers.extend(SEARCH_VERSIONS) |
|
97 |
vers.append(VERSION) |
|
98 |
return vers |
|
99 |
|
|
28 | 100 |
def getPackagesRoot(): |
29 | 101 |
return GVSPKG_ROOT |
30 | 102 |
|
... | ... | |
37 | 109 |
def getDist(): |
38 | 110 |
return getPackagesRoot() + "/dists/" +getVersion() |
39 | 111 |
|
40 |
def message(msg): |
|
41 |
if VERBOSE: |
|
42 |
print msg |
|
43 |
|
|
44 |
def msgerror(msg): |
|
45 |
print "ERROR: ", msg |
|
46 |
|
|
47 |
def msgwarn(msg): |
|
48 |
print "WARNING: ", msg |
|
49 |
|
|
50 |
def debug(msg): |
|
51 |
if DEBUG: |
|
52 |
print "DEBUG: ", msg |
|
53 |
|
|
54 | 112 |
def findfiles(root,filename): |
55 | 113 |
result=list() |
56 | 114 |
for wroot, dirs, files in os.walk(root): |
... | ... | |
80 | 138 |
f=file(filename,"r") |
81 | 139 |
for line in f.readlines(): |
82 | 140 |
line = line.strip() |
83 |
if line.startswith("#"): |
|
141 |
if line=="" or line.startswith("#"):
|
|
84 | 142 |
continue |
85 | 143 |
if line[-1] == "\n": |
86 | 144 |
line = line[:-1] |
... | ... | |
88 | 146 |
if n<0 : |
89 | 147 |
continue |
90 | 148 |
cmd = line[:n] |
91 |
args = line[n+1:] |
|
149 |
args = line[n+1:].strip()
|
|
92 | 150 |
|
93 |
self.defaultoptions[cmd] = self.defaultoptions.get(cmd,[]) + args.split(" ") |
|
151 |
if args != "": |
|
152 |
self.defaultoptions[cmd] = self.defaultoptions.get(cmd,[]) + args.split(" ") |
|
94 | 153 |
debug("add options: %s=%r" % (cmd, args.split(" "))) |
95 | 154 |
|
96 | 155 |
f.close() |
... | ... | |
99 | 158 |
if self.defaultoptions != None: |
100 | 159 |
return |
101 | 160 |
self.defaultoptions = dict() |
102 |
self.load_options( "%s/gvspkg.bin/options" % os.path.dirname(sys.argv[0])) |
|
103 |
self.load_options( "~/.gvspkg.bin/options") |
|
104 |
self.load_options("gvspkg.options") |
|
161 |
options = list(); |
|
162 |
if GVSPKG_ROOT != None: |
|
163 |
rootoptions = os.path.join(GVSPKG_ROOT,"gvspkg.bin/options") |
|
164 |
else: |
|
165 |
rootoptions = None |
|
166 |
if rootoptions != None and os.path.isfile(rootoptions): |
|
167 |
options.append(rootoptions) |
|
168 |
else: |
|
169 |
options.append("~/.gvspkg.bin/options") |
|
170 |
options.extend(acquire_file(".gvspkg.options")) |
|
171 |
options.extend(acquire_file("gvspkg.options")) |
|
172 |
for optionfile in options: |
|
173 |
self.load_options(optionfile) |
|
105 | 174 |
|
106 | 175 |
def getArgs(self,name): |
107 | 176 |
self.load_default_options() |
108 |
cmd = self.defaultoptions.get(name," ") |
|
109 |
l = list(cmd) |
|
177 |
l = list() |
|
178 |
cmd = self.defaultoptions.get(name,None) |
|
179 |
if cmd != None: |
|
180 |
l.extend(cmd) |
|
110 | 181 |
l.extend(self.args[1:]) |
111 | 182 |
return l |
112 | 183 |
|
184 |
def isDigit(s): |
|
185 |
if len(s)>1: |
|
186 |
s=s[0] |
|
187 |
return s in ("0","1","2","3","4","5","6","7","8","9") |
|
188 |
|
|
189 |
|
|
190 |
|
|
113 | 191 |
class PackageInfo(str): |
114 | 192 |
def __init__(self, filename): |
115 | 193 |
self._ini = None |
... | ... | |
122 | 200 |
self.gvsig_version = s[2] |
123 | 201 |
self.code = s[3] |
124 | 202 |
try: |
125 |
if s[5] == 'SNAPSHOT': |
|
203 |
# gvSIG-desktop-1.12.0-com.iver.cit.gvsig.cad-1.12.0-opencadtools-1418-final-all-all-j1_6.gvspkg |
|
204 |
# 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 |
|
205 |
# gvSIG-desktop-1.12.0-com.iver.cit.gvsig.cad-1.12.0-1418-final-all-all-j1_6.gvspkg |
|
206 |
# 0 - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 |
|
207 |
if isDigit(s[5]) : |
|
208 |
self.version = s[4] |
|
209 |
self.build = s[5] |
|
210 |
self.status = s[6] |
|
211 |
self.os = s[7] |
|
212 |
self.arch = s[8] |
|
213 |
else: |
|
126 | 214 |
self.version = s[4] + "-" + s[5] |
127 | 215 |
self.build = s[6] |
128 | 216 |
self.status = s[7] |
129 | 217 |
self.os = s[8] |
130 | 218 |
self.arch = s[9] |
131 |
else: |
|
132 |
self.version = s[4] |
|
133 |
self.build = s[5] |
|
134 |
self.status = s[6] |
|
135 |
self.os = s[7] |
|
136 |
self.arch = s[8] |
|
219 |
|
|
137 | 220 |
except Exception: |
138 | 221 |
self.build = "0" |
139 | 222 |
self.status = "unknow" |
... | ... | |
144 | 227 |
except: |
145 | 228 |
pass |
146 | 229 |
|
230 |
def getCode(self): |
|
231 |
return self.code |
|
232 |
|
|
233 |
def getOS(self): |
|
234 |
return self.os |
|
235 |
|
|
236 |
def getArch(self): |
|
237 |
return self.arch |
|
238 |
|
|
147 | 239 |
def getKey(self): |
148 | 240 |
return self.code+"-"+self.os+"-"+self.arch |
149 | 241 |
|
... | ... | |
151 | 243 |
return os.path.basename(self.filename) |
152 | 244 |
|
153 | 245 |
def getFullVersion(self): |
154 |
return "%s-%06d" %(self.version,self.build) |
|
246 |
if "-" in self.version : |
|
247 |
return "%s-%06d" %(self.version,self.build) |
|
248 |
else: |
|
249 |
return "%s-ZZZ-%06d" %(self.version,self.build) |
|
155 | 250 |
|
156 | 251 |
def getFilename(self): |
157 | 252 |
return self.filename + "." + self.type |
... | ... | |
173 | 268 |
ini = self.getIni() |
174 | 269 |
if ini.has_option(section, name): |
175 | 270 |
x = ini.get(section, name) |
176 |
x = x.replace("\\:", ":") |
|
271 |
x = x.replace("\\:", ":")
|
|
177 | 272 |
return x |
178 | 273 |
return default |
179 | 274 |
|
180 | 275 |
def getDescription(self): |
181 | 276 |
return self.getIniOption("description") |
182 | 277 |
|
278 |
def getCategories(self): |
|
279 |
return self.getIniOption("categories") |
|
280 |
|
|
183 | 281 |
def getName(self): |
184 | 282 |
return self.getIniOption("name") |
185 | 283 |
|
... | ... | |
229 | 327 |
|
230 | 328 |
files = findfiles(outputfolder, "package.info") |
231 | 329 |
if len(files) != 1: |
232 |
msgerror("Can't locate package.info in pool '%s'." % (index_name))
|
|
330 |
msgerror("Can't locate package.info in pool '%s'." % (index_path))
|
|
233 | 331 |
return None |
234 | 332 |
|
235 | 333 |
package_info = files[0] |
... | ... | |
270 | 368 |
f.close() |
271 | 369 |
mychmod(fname,RWALL) |
272 | 370 |
|
273 |
def build(self, pool, version): |
|
274 |
message( "Creating index list for version '%s' from '%s'" % (version, pool) ) |
|
371 |
def build(self, pool, versions):
|
|
372 |
message( "Creating index list for version '%s' from '%s'" % (versions, pool) )
|
|
275 | 373 |
packages=dict() |
276 | 374 |
for root, dirs, files in os.walk(pool): |
277 | 375 |
for f in files : |
278 |
fullpath = root+"/"+f |
|
279 |
info = PackageInfo(fullpath) |
|
280 |
if info.gvsig == "gvSIG-desktop" and info.gvsig_version == version : |
|
281 |
if packages.get(info.getKey()) == None: |
|
282 |
debug( "build: add " + repr(info)) |
|
283 |
packages[info.getKey()]=info |
|
376 |
if f[-7:].lower() in (".gvspki", ".gvspkg") : |
|
377 |
fullpath = root+"/"+f |
|
378 |
info = PackageInfo(fullpath) |
|
379 |
if info.gvsig == "gvSIG-desktop" and info.gvsig_version in versions : |
|
380 |
if packages.get(info.getKey()) == None: |
|
381 |
debug( "build: add " + repr(info)) |
|
382 |
packages[info.getKey()]=info |
|
383 |
else: |
|
384 |
oldinfo = packages[info.getKey()] |
|
385 |
debug("build: %s %s %s" % ( info.getKey(), oldinfo.getFullVersion(),info.getFullVersion())) |
|
386 |
if oldinfo.getFullVersion()<info.getFullVersion() : |
|
387 |
debug( "build: update "+ repr(oldinfo)) |
|
388 |
packages[info.getKey()]=info |
|
284 | 389 |
else: |
285 |
oldinfo = packages[info.getKey()] |
|
286 |
debug("build: %s %s %s" % ( info.getKey(), oldinfo.getFullVersion(),info.getFullVersion())) |
|
287 |
if oldinfo.getFullVersion()<info.getFullVersion() : |
|
288 |
debug( "build: update "+ repr(oldinfo)) |
|
289 |
packages[info.getKey()]=info |
|
290 |
else: |
|
291 |
debug( "build: skip "+ repr(info)) |
|
390 |
debug( "build: skip "+ repr(info)) |
|
292 | 391 |
self.extend(packages.values()) |
293 | 392 |
self.sort() |
294 | 393 |
|
... | ... | |
310 | 409 |
assert False, "unhandled option" |
311 | 410 |
|
312 | 411 |
indexes = IndexList() |
313 |
indexes.build(getPool(), getVersion())
|
|
412 |
indexes.build(getPool(), getSearchVersions())
|
|
314 | 413 |
|
315 | 414 |
for info in indexes: |
316 | 415 |
if info.hasPki(): |
... | ... | |
323 | 422 |
|
324 | 423 |
def installkit_add(cmd,arg1,arg2): |
325 | 424 |
|
326 |
folder = "%s/gvspkg.bin" % os.path.dirname(sys.argv[0])
|
|
425 |
folder = "%s/gvspkg.bin" % GVSPKG_ROOT
|
|
327 | 426 |
|
328 | 427 |
cmd = "%s/installkit %s/main.tcl %s %s %s" % ( |
329 | 428 |
folder, |
... | ... | |
344 | 443 |
help(args) |
345 | 444 |
sys.exit(2) |
346 | 445 |
|
446 |
#print "opts = ",opts |
|
447 |
#print "args = ",args |
|
347 | 448 |
addjrelin=False |
348 | 449 |
addjrewin=False |
349 | 450 |
jrelin=None |
... | ... | |
383 | 484 |
message("Creando %s..." % custom_name) |
384 | 485 |
shutil.copyfile(bin_name, custom_name) |
385 | 486 |
mychmod(custom_name,RWALL) |
386 |
message("Añadiendo %s..." % gvspks_name)
|
|
487 |
message("A�adiendo %s..." % gvspks_name)
|
|
387 | 488 |
installkit_add("addpks", custom_name, gvspks_name) |
388 | 489 |
|
389 | 490 |
if addjrelin: |
390 |
withjre_name = bin_name.replace("online", "standard-withjre")
|
|
491 |
withjre_name = bin_name.replace("online", distribution_name+"-withjre")
|
|
391 | 492 |
message("Creando %s..." % withjre_name) |
392 | 493 |
shutil.copyfile(custom_name, withjre_name) |
393 | 494 |
mychmod(withjre_name,RWALL) |
394 |
message("Añadiendo %s..." % jrelin)
|
|
495 |
message("A�adiendo %s..." % jrelin)
|
|
395 | 496 |
installkit_add("addjrelin", withjre_name, jrelin) |
396 | 497 |
|
397 | 498 |
|
398 | 499 |
if addjrewin: |
399 |
withjre_name = bin_name.replace("online", "standard-withjre")
|
|
500 |
withjre_name = bin_name.replace("online", distribution_name+"-withjre")
|
|
400 | 501 |
message("Creando %s..." % withjre_name) |
401 | 502 |
shutil.copyfile(custom_name, withjre_name) |
402 | 503 |
mychmod(withjre_name,RWALL) |
403 |
message("Añadiendo %s..." % jrewin)
|
|
504 |
message("A�adiendo %s..." % jrewin)
|
|
404 | 505 |
installkit_add("addjrewin", withjre_name, jrewin) |
405 | 506 |
|
406 | 507 |
|
407 | 508 |
def mks(args): |
408 | 509 |
cmd = Command(args) |
409 |
message(cmd.getArgs("mks")) |
|
410 | 510 |
try: |
411 |
opts, args = getopt.getopt(cmd.getArgs("mks"), "ixscI:", ["index-only","include-default-selection", "clear-list", "exclude=", "excludepki=", "excludepkg=", "include="])
|
|
511 |
opts, args = getopt.getopt(cmd.getArgs("mks"), "ixscI:p:", ["index-only","include-default-selection", "clear-list", "exclude=", "excludepki=", "excludepkg=", "include=", "platform="])
|
|
412 | 512 |
except getopt.GetoptError, err: |
413 | 513 |
# print help information and exit: |
414 | 514 |
print str(err) # will print something like "option -a not recognized" |
415 | 515 |
help(args) |
416 | 516 |
sys.exit(2) |
417 | 517 |
|
518 |
platforms = ("x86", "x86_64") |
|
519 |
oss = ("lin","win") |
|
418 | 520 |
default_selection = None |
419 | 521 |
index_only = False |
420 | 522 |
clear_list=False |
... | ... | |
426 | 528 |
clear_list = True |
427 | 529 |
elif opt in ("-s", "--include-default-selection"): |
428 | 530 |
default_selection = "defaultPackages" |
531 |
elif opt in ("-p", "--platform"): |
|
532 |
if arg == "amd64": |
|
533 |
arg = "x86_64" |
|
534 |
if not platform in ( "x86", "x86_64", "all"): |
|
535 |
msgerror("Unsuported platform value "+repr(platform)+". available values are x86, x86_64, amd64 or all") |
|
536 |
sys.exit(3) |
|
537 |
platforms = (arg,) |
|
429 | 538 |
elif opt in ("-x", "--exclude"): |
430 | 539 |
excludes_pki.append(arg) |
431 | 540 |
excludes_pkg.append(arg) |
... | ... | |
434 | 543 |
elif opt in ( "--excludepkg"): |
435 | 544 |
excludes_pkg.append(arg) |
436 | 545 |
elif opt in ( "--include", "-I"): |
437 |
includes.append(PackageInfo(arg)) |
|
546 |
if not os.path.isabs(arg) : |
|
547 |
arg = os.path.join(getPool(), arg) |
|
548 |
if arg.endswith(".*"): |
|
549 |
includes.append(PackageInfo(arg[:-2]+".gvspkg")) |
|
550 |
includes.append(PackageInfo(arg[:-2]+".gvspki")) |
|
551 |
else: |
|
552 |
includes.append(PackageInfo(arg)) |
|
438 | 553 |
elif opt in ("-i", "--index-only"): |
439 | 554 |
index_only = True |
440 | 555 |
else: |
... | ... | |
444 | 559 |
msgwarn("No se ha encontrado el fichero %r. la opcion -s/--include-default-selection sera ignorada." % default_selection) |
445 | 560 |
default_selection = None |
446 | 561 |
|
562 |
|
|
447 | 563 |
indexes = IndexList() |
448 | 564 |
|
449 | 565 |
packages_txt = getDist() +"/packages.txt" |
450 |
packages_gvspki = getDist() +"/packages.gvspki" |
|
451 |
packages_gvspks = getDist() +"/packages.gvspks" |
|
566 |
packages_gvspki = getDist() +"/packages.gvspki" |
|
452 | 567 |
|
453 | 568 |
message( "Creating 'packages.gvspki' for version '%s'" % getVersion() ) |
454 | 569 |
if not os.path.exists(getDist()): |
455 |
msgerror("Can't locate version folder '%s'." % getVersion())
|
|
570 |
msgerror("Can't locate version folder '%s'." % getDist())
|
|
456 | 571 |
sys.exit(3) |
457 | 572 |
|
458 | 573 |
if os.path.exists(packages_txt) and not clear_list: |
459 | 574 |
indexes.load(packages_txt) |
460 | 575 |
else: |
461 |
indexes.build(getPool(), getVersion())
|
|
576 |
indexes.build(getPool(), getSearchVersions())
|
|
462 | 577 |
indexes.save(packages_txt) |
463 | 578 |
|
464 | 579 |
for pkg in includes: |
465 | 580 |
indexes.append(pkg) |
466 | 581 |
|
582 |
# El indice de paquetes lleva los paquetes para todas las plataformas y sistemas |
|
583 |
# ya que al conectarnos a el desde el administrador de complementos ya |
|
584 |
# se encarga la aplicacion de seleccionar los correspondientes a la plataforma |
|
585 |
# sobre la que esta rodando gvSIG. |
|
467 | 586 |
message( "Writing 'packages.gvspki' to '%s'" % packages_gvspki ) |
468 | 587 |
set = zipfile.ZipFile(packages_gvspki,"w",zipfile.ZIP_STORED) |
469 | 588 |
for info in indexes: |
470 | 589 |
if not ( info.code in excludes_pki or info.getFullName() in excludes_pki ): |
590 |
debug("Add package '%s'" % info.getPkiFilename()) |
|
471 | 591 |
try: |
472 | 592 |
if info.hasPki() : |
473 | 593 |
set.write(info.getPkiFilename(), os.path.basename(info.getPkiFilename())) |
474 | 594 |
except Exception, ex: |
475 | 595 |
msgerror("Can't add index '%s', error %s" % (info, str(ex))) |
596 |
else: |
|
597 |
message("Exclude package '%s'" % info.getFullName()) |
|
476 | 598 |
if default_selection != None : |
477 | 599 |
set.write(default_selection,default_selection) |
478 | 600 |
set.close() |
479 | 601 |
mychmod(packages_gvspki,RWALL) |
480 | 602 |
|
603 |
md5sum(packages_gvspki,packages_gvspki+".md5") |
|
604 |
mychmod(packages_gvspki+".md5",RWALL) |
|
605 |
|
|
481 | 606 |
if not index_only : |
482 |
message( "Writing 'packages.gvspks' to '%s'" % packages_gvspks ) |
|
483 |
set = zipfile.ZipFile(packages_gvspks,"w",zipfile.ZIP_STORED) |
|
484 |
for info in indexes: |
|
485 |
if not ( info.code in excludes_pkg or info.getFullName() in excludes_pkg ): |
|
486 |
try: |
|
487 |
if info.hasPkg(): |
|
488 |
set.write(info.getPkgFilename(), os.path.basename(info.getPkgFilename())) |
|
489 |
except Exception, ex: |
|
490 |
msgerror("Can't add package '%s', error %s" % (index, str(ex))) |
|
491 |
if default_selection != None : |
|
492 |
set.write(default_selection,default_selection) |
|
493 |
set.close() |
|
494 |
mychmod(packages_gvspks,RWALL) |
|
607 |
for cur_os in oss: |
|
608 |
for cur_platform in platforms: |
|
609 |
packages_gvspks = getDist() +"/packages-"+cur_os+"-"+cur_platform+".gvspks" |
|
610 |
message( "Writing 'packages-"+cur_os+"-"+cur_platform+".gvspks' to '%s'" % packages_gvspks ) |
|
611 |
set = zipfile.ZipFile(packages_gvspks,"w",zipfile.ZIP_STORED) |
|
612 |
for info in indexes: |
|
613 |
if not ( info.code in excludes_pkg or info.getFullName() in excludes_pkg ): |
|
614 |
try: |
|
615 |
if info.hasPkg(): |
|
616 |
if cur_os == "all" or info.getOS() in ("all", cur_os) : |
|
617 |
if cur_platform == "all" or info.getArch() in ("all", cur_platform) : |
|
618 |
set.write(info.getPkgFilename(), os.path.basename(info.getPkgFilename())) |
|
619 |
except Exception, ex: |
|
620 |
msgerror("Can't add package '%s', error %s" % (index, str(ex))) |
|
621 |
else: |
|
622 |
message("Exclude package '%s'" % info.getFullName()) |
|
623 |
if default_selection != None : |
|
624 |
set.write(default_selection,default_selection) |
|
625 |
set.close() |
|
626 |
mychmod(packages_gvspks,RWALL) |
|
495 | 627 |
|
628 |
md5sum(packages_gvspks,packages_gvspks+".md5") |
|
629 |
mychmod(packages_gvspks+".md5",RWALL) |
|
630 |
|
|
496 | 631 |
message( "Created") |
497 | 632 |
|
633 |
def mkmirror(args): |
|
634 |
cmd = Command(args) |
|
635 |
try: |
|
636 |
opts, args = getopt.getopt(cmd.getArgs("mkmirrot"), "b:", [ "build="]) |
|
637 |
except getopt.GetoptError, err: |
|
638 |
# print help information and exit: |
|
639 |
print str(err) # will print something like "option -a not recognized" |
|
640 |
help(args) |
|
641 |
sys.exit(2) |
|
498 | 642 |
|
643 |
build = None |
|
644 |
for opt, arg in opts: |
|
645 |
if opt in ("-b", "--build"): |
|
646 |
build = arg |
|
647 |
else: |
|
648 |
assert False, "unhandled option %r" % opt |
|
649 |
|
|
650 |
if build == None: |
|
651 |
msgerror("Build number required.") |
|
652 |
sys.exit(3) |
|
653 |
domkmirror( getPackagesRoot(),getVersion(),build) |
|
654 |
|
|
655 |
def domkmirror(root_src, version, build): |
|
656 |
join = os.path.join |
|
657 |
|
|
658 |
def linkfile(src,dst): |
|
659 |
if os.path.lexists(dst): |
|
660 |
os.remove(dst) |
|
661 |
os.symlink(src,dst) |
|
662 |
if os.path.lexists(src+".md5") : |
|
663 |
if os.path.lexists(dst+".md5"): |
|
664 |
os.remove(dst+".md5") |
|
665 |
os.symlink(src+".md5",dst+".md5") |
|
666 |
|
|
667 |
|
|
668 |
build = str(build) |
|
669 |
root_target = join(root_src,"mirrors",version+"-"+build,"gvsig-desktop") |
|
670 |
build_src = join(root_src,"dists",version,"builds",build) |
|
671 |
build_target = join(root_target,"dists",version,"builds",build) |
|
672 |
pool_src = join(root_src,"pool") |
|
673 |
pool_target = join(root_target,"pool") |
|
674 |
|
|
675 |
if not os.path.isdir(root_target): |
|
676 |
os.makedirs(root_target) |
|
677 |
if not os.path.isdir(build_target): |
|
678 |
os.makedirs(build_target) |
|
679 |
if not os.path.isdir(pool_target): |
|
680 |
os.makedirs(pool_target) |
|
681 |
files = os.listdir(build_src) |
|
682 |
linkfile(join(build_src,"packages.gvspki"), join(root_target,"dists",version,"packages.gvspki")) |
|
683 |
for f in files: |
|
684 |
f_src = join(build_src,f) |
|
685 |
f_target = join(build_target,f) |
|
686 |
if os.path.isfile(f_src): |
|
687 |
linkfile(f_src,f_target) |
|
688 |
|
|
689 |
z = zipfile.ZipFile(join(build_src,"packages.gvspki")) |
|
690 |
pkgs = z.namelist() |
|
691 |
for pkgname in pkgs: |
|
692 |
if pkgname!='defaultPackages': |
|
693 |
pkg = PackageInfo(pkgname) |
|
694 |
if not os.path.exists(join(root_target,"pool",pkg.getCode())) : |
|
695 |
os.makedirs(join(root_target,"pool",pkg.getCode())) |
|
696 |
src = join(root_src,"pool",pkg.getCode(),pkg.getPkgFilename()) |
|
697 |
target = join(root_target,"pool",pkg.getCode(),pkg.getPkgFilename()) |
|
698 |
linkfile(src,target) |
|
699 |
cmd = "cd %s ; find . ! -type d >%s/files.lst" % (root_target, build_target) |
|
700 |
os.system(cmd) |
|
701 |
|
|
499 | 702 |
def mkhtml(args): |
500 | 703 |
def getCode(info): |
501 | 704 |
return info.code |
... | ... | |
503 | 706 |
|
504 | 707 |
cmd = Command(args) |
505 | 708 |
try: |
506 |
opts, args = getopt.getopt(cmd.getArgs("mks"), "xsc", ["clear-list", "exclude=", "excludepki=", "excludepkg=", "include="])
|
|
709 |
opts, args = getopt.getopt(cmd.getArgs("mkhtml"), "xsc", ["clear-list", "exclude=", "excludepki=", "excludepkg=", "include="])
|
|
507 | 710 |
except getopt.GetoptError, err: |
508 | 711 |
# print help information and exit: |
509 | 712 |
print str(err) # will print something like "option -a not recognized" |
... | ... | |
537 | 740 |
if os.path.exists(packages_txt) and not clear_list: |
538 | 741 |
indexes.load(packages_txt) |
539 | 742 |
else: |
540 |
indexes.build(getPool(), getVersion())
|
|
743 |
indexes.build(getPool(), getSearchVersions())
|
|
541 | 744 |
indexes.save(packages_txt) |
542 | 745 |
|
543 | 746 |
for pkg in includes: |
... | ... | |
552 | 755 |
mkpkihtml(basepath, info) |
553 | 756 |
allpackages.append(info) |
554 | 757 |
except Exception, ex: |
555 |
msgerror("Can't add index '%s', error %s" % (info, str(ex)))
|
|
758 |
msgerror("Can't create html '%s', error %s" % (info, str(ex)))
|
|
556 | 759 |
|
557 | 760 |
html = ''' |
558 | 761 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
... | ... | |
607 | 810 |
<td>%s</td> |
608 | 811 |
<td>%s</td> |
609 | 812 |
</tr>\n'''%( |
610 |
"../../../web/" + item.getFullName() + ".html", |
|
813 |
"../../../web/" + item.getFullName() + ".html?height=400&width=600",
|
|
611 | 814 |
item.getName(), |
612 | 815 |
item.version, |
613 | 816 |
item.os, |
... | ... | |
615 | 818 |
item.getType(), |
616 | 819 |
item.getOwner() |
617 | 820 |
) |
618 |
|
|
619 |
|
|
620 | 821 |
html += """ </tbody>\n </table> |
621 |
<!--javascript para la visualización de la tabla y carga dinámica del contenido del enlace -->
|
|
822 |
<!--javascript para la visualizaci�n de la tabla y carga din�mica del contenido del enlace -->
|
|
622 | 823 |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script> |
623 | 824 |
<script src="http://datatables.net/release-datatables/media/js/jquery.dataTables.js" type="text/javascript"></script> |
624 | 825 |
<script type="text/javascript" src="js/thickbox-compressed.js"></script> |
625 | 826 |
|
626 |
<!-- inicialización de la tabla con cosas chachis -->
|
|
827 |
<!-- inicializaci�n de la tabla con cosas chachis -->
|
|
627 | 828 |
<script type="text/javascript"> |
628 | 829 |
$(document).ready(function() { |
629 | 830 |
$('#pkglist').dataTable( { |
... | ... | |
656 | 857 |
<title>%s</title> |
657 | 858 |
<!-- estilos para las tablas --> |
658 | 859 |
<style type="text/css" title="currentStyle"> |
659 |
@import "../dist/%s/web/css/demo_table.css"; |
|
860 |
@import "../dists/%s/web/css/demo_table.css";
|
|
660 | 861 |
#pkgdetails{ |
661 | 862 |
width:600px; |
662 | 863 |
clear:both; |
... | ... | |
689 | 890 |
else: |
690 | 891 |
html += " <tr><td></td><td>Sources</td></tr>\n" |
691 | 892 |
|
692 |
html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Dependencies", info.getDependencies().replace("\:",":")) |
|
893 |
if info.getDependencies() == None: |
|
894 |
html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Dependencies", "") |
|
895 |
else: |
|
896 |
html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Dependencies", info.getDependencies().replace("\:",":")) |
|
693 | 897 |
html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Type", info.getType()) |
694 | 898 |
html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Official", info.getOfficial()) |
695 |
description = info.getDescription().replace("\\n", "<br>") |
|
899 |
html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("O.S.", info.getOS()) |
|
900 |
html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Architecture", info.getArch()) |
|
901 |
html += ' <tr><th valing="top">%s </th><td>%s</td></tr>\n'%("Categories", info.getCategories()) |
|
902 |
|
|
903 |
description = info.getDescription() |
|
904 |
if description == None: |
|
905 |
description = "" |
|
906 |
description = description.replace("\\n", "<br>") |
|
696 | 907 |
description = description.replace("\:",":") |
697 | 908 |
html += ' <tr valing="top"><th valing="top">%s </th><td>%s</td></tr>\n'%("Description", description) |
698 | 909 |
html += """ </tbody>\n</table>\n""" |
699 | 910 |
html += """ |
700 |
<!-- javascript para la visualización de la tabla -->
|
|
911 |
<!-- javascript para la visualizaci�n de la tabla -->
|
|
701 | 912 |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script> |
702 | 913 |
<script src="http://datatables.net/release-datatables/media/js/jquery.dataTables.js" type="text/javascript"></script> |
703 |
<!-- inicialización de la tabla con cosas chachis -->
|
|
914 |
<!-- inicializaci�n de la tabla con cosas chachis -->
|
|
704 | 915 |
<script type="text/javascript"> |
705 | 916 |
$(document).ready(function() { |
706 | 917 |
$('#pkgdetails').dataTable( { |
... | ... | |
723 | 934 |
except Exception, ex: |
724 | 935 |
raise ex |
725 | 936 |
|
937 |
def mkdist(args): |
|
938 |
cmd = Command(args) |
|
939 |
try: |
|
940 |
opts, args = getopt.getopt(cmd.getArgs("mkdist"), "b:s:p:", [ "build=", "state=", "distribution_name=", "platform" ]) |
|
941 |
except getopt.GetoptError, err: |
|
942 |
# print help information and exit: |
|
943 |
print str(err) # will print something like "option -a not recognized" |
|
944 |
help(args) |
|
945 |
sys.exit(2) |
|
946 |
|
|
947 |
build=None |
|
948 |
state=None |
|
949 |
distribution_name = "standard" |
|
950 |
platforms = ("x86", "x86_64") |
|
951 |
oss = ("lin", "win") |
|
952 |
|
|
953 |
for opt, arg in opts: |
|
954 |
if opt in ("-b", "--build"): |
|
955 |
build=arg |
|
956 |
elif opt in ("-s", "--state"): |
|
957 |
state=arg |
|
958 |
elif opt in ("-N", "--distrinution-name"): |
|
959 |
distribution_name = arg |
|
960 |
elif opt in ("-p", "--platform"): |
|
961 |
if args == "amd64": |
|
962 |
# Aceptamos la plataforma amd64 como sinonimo de x86_64 |
|
963 |
args = "x86_64" |
|
964 |
if not arg in ("x86","x86_64"): |
|
965 |
print "Unsuported platform "+repr(platform)+", must be x86, x86_64 or amd64." |
|
966 |
help(args) |
|
967 |
sys.exit(2) |
|
968 |
platforms = (arg,) |
|
969 |
else: |
|
970 |
assert False, "unhandled option %r" % opt |
|
971 |
|
|
972 |
if build == None: |
|
973 |
print "Requiered option --build not found." |
|
974 |
help(args) |
|
975 |
sys.exit(2) |
|
976 |
|
|
977 |
if state == None: |
|
978 |
print "Requiered option --state not found." |
|
979 |
help(args) |
|
980 |
sys.exit(2) |
|
981 |
|
|
982 |
# |
|
983 |
# Independientemente de la plataforma, los binarios de la version online a utilizar |
|
984 |
# que usamos son siempre los de x86, con lo que el instalador siempre sera para x86. |
|
985 |
# Si hemos especificado que queremos una instalacion para x86, este llevara solo paquetes |
|
986 |
# multiplataforma, "all", y "x86". |
|
987 |
# Si hemos especificado que queremos una instalacion para x86_64, este llevara solo paquetes |
|
988 |
# multiplataforma, "all", y "x86_64". |
|
989 |
# |
|
990 |
|
|
991 |
if not os.path.isdir("builds/"+build): |
|
992 |
print "Can't access the build folder builds/"+build+"." |
|
993 |
sys.exit(2) |
|
994 |
|
|
995 |
message( "Generating distribution for build "+ build + "...") |
|
996 |
executeCommand("mks", "-s", "-c") |
|
997 |
executeCommand("mkhtml" ) |
|
998 |
|
|
999 |
gvspki_filename = "builds/"+build+"/packages.gvspki" |
|
1000 |
message( "Coping packages.gvspki to "+ gvspki_filename) |
|
1001 |
shutil.copyfile("packages.gvspki", gvspki_filename) |
|
1002 |
shutil.copyfile("packages.gvspki.md5", gvspki_filename +".md5") |
|
1003 |
|
|
1004 |
exec_extensions = { |
|
1005 |
"lin" : LINUX_EXEC_EXTENSION, |
|
1006 |
"win" : ".exe" |
|
1007 |
} |
|
1008 |
|
|
1009 |
for cur_os in oss: |
|
1010 |
exec_extension = exec_extensions[cur_os] |
|
1011 |
for cur_platform in platforms: |
|
1012 |
message( "Process "+cur_os+"/"+cur_platform) |
|
1013 |
gvspks_filename = "builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+cur_os+"-"+cur_platform+".gvspks" |
|
1014 |
online_filename = "builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+cur_os+"-x86-online" + exec_extension |
|
1015 |
|
|
1016 |
if not os.path.isfile(online_filename): |
|
1017 |
msgwarn("Can't access the online installable for "+cur_os+"/"+cur_platform + " ("+online_filename+").") |
|
1018 |
continue |
|
1019 |
|
|
1020 |
message( "Coping packages-"+cur_os+"-"+cur_platform+"..gvspks to "+ gvspks_filename) |
|
1021 |
shutil.copyfile("packages-"+cur_os+"-"+cur_platform+".gvspks", gvspks_filename) |
|
1022 |
shutil.copyfile("packages-"+cur_os+"-"+cur_platform+".gvspks.md5", gvspks_filename +".md5") |
|
1023 |
|
|
1024 |
message( "Add execution permissions to online installables....") |
|
1025 |
mychmod(online_filename,RWXALL) |
|
1026 |
|
|
1027 |
md5sum(online_filename,online_filename+".md5") |
|
1028 |
mychmod(online_filename+".md5",RWALL) |
|
1029 |
|
|
1030 |
executeCommand("mkinstall" , "--addjre"+cur_os, online_filename, gvspks_filename) |
|
1031 |
|
|
1032 |
message( "Renaming files from custom to standard...") |
|
1033 |
target_filename = "builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+cur_os+"-"+cur_platform+"-"+distribution_name + exec_extension |
|
1034 |
shutil.move( |
|
1035 |
"builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+cur_os+"-x86-custom" + exec_extension, |
|
1036 |
target_filename |
|
1037 |
) |
|
1038 |
mychmod(target_filename,RWXALL) |
|
1039 |
|
|
1040 |
md5sum(target_filename,target_filename+".md5") |
|
1041 |
mychmod(target_filename+".md5",RWALL) |
|
1042 |
|
|
1043 |
target_filename = "builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+cur_os+"-"+cur_platform+"-"+distribution_name+"-withjre" + exec_extension |
|
1044 |
shutil.move( |
|
1045 |
"builds/"+build+"/gvSIG-desktop-" + VERSION + "-" + build+ "-" + state + "-"+cur_os+"-x86-custom-withjre" + exec_extension, |
|
1046 |
target_filename |
|
1047 |
) |
|
1048 |
mychmod(target_filename,RWXALL) |
|
1049 |
|
|
1050 |
md5sum(target_filename,target_filename+".md5") |
|
1051 |
mychmod(target_filename+".md5",RWALL) |
|
1052 |
|
|
1053 |
message( "Coping html index to browse paqueges of the distro.") |
|
1054 |
shutil.rmtree("builds/"+build+"/web", ignore_errors=True) |
|
1055 |
shutil.copytree("web", "builds/"+build+"/web") |
|
1056 |
f = file("builds/"+build+"/web/index.html","r") |
|
1057 |
contents = f.read() |
|
1058 |
f.close() |
|
1059 |
contents = contents.replace("href=\"../../../web/gvSIG-desktop-", "href=\"../../../../../web/gvSIG-desktop-") |
|
1060 |
f = file("builds/"+build+"/web/index.html","w") |
|
1061 |
f.write(contents) |
|
1062 |
f.close() |
|
1063 |
|
|
1064 |
message( "Process completed.") |
|
1065 |
|
|
1066 |
|
|
1067 |
|
|
1068 |
|
|
726 | 1069 |
def show(args): |
727 |
index_name=args[1] |
|
1070 |
cmd = Command(args) |
|
1071 |
try: |
|
1072 |
opts, args = getopt.getopt(cmd.getArgs("show"), "S", [ "verify"]) |
|
1073 |
except getopt.GetoptError, err: |
|
1074 |
# print help information and exit: |
|
1075 |
print str(err) # will print something like "option -a not recognized" |
|
1076 |
help(args) |
|
1077 |
sys.exit(2) |
|
1078 |
|
|
1079 |
eerify = False |
|
1080 |
for opt, arg in opts: |
|
1081 |
if opt in ("-V", "--verify"): |
|
1082 |
verify = True |
|
1083 |
else: |
|
1084 |
assert False, "unhandled option %r" % opt |
|
1085 |
|
|
1086 |
index_name=args[0] |
|
728 | 1087 |
message( "Show package.info from '%s'" % index_name) |
729 | 1088 |
files = findfiles(getPool(), index_name) |
730 | 1089 |
if len(files) != 1: |
... | ... | |
744 | 1103 |
f = file(package_info,"r") |
745 | 1104 |
s = f.read() |
746 | 1105 |
f.close() |
1106 |
print s |
|
1107 |
if verify: |
|
1108 |
verify_sign(package_info) |
|
747 | 1109 |
shutil.rmtree(outputfolder) |
748 |
print s |
|
749 | 1110 |
|
1111 |
def editall(args): |
|
1112 |
cmd = Command(args) |
|
1113 |
try: |
|
1114 |
opts, args = getopt.getopt(cmd.getArgs("editall"), "Scx:I:r:", ["clear-list", "exclude=", "excludepki=", "excludepkg=", "include=", "replace=", "sign"]) |
|
1115 |
except getopt.GetoptError, err: |
|
1116 |
# print help information and exit: |
|
1117 |
print str(err) # will print something like "option -a not recognized" |
|
1118 |
help(args) |
|
1119 |
sys.exit(2) |
|
1120 |
|
|
1121 |
index_only = False |
|
1122 |
clear_list=False |
|
1123 |
includes=list() |
|
1124 |
excludes_pki=list() |
|
1125 |
replaces = list() |
|
1126 |
excludes_pkg=list() |
|
1127 |
sign = False |
|
1128 |
interactive = True |
|
1129 |
for opt, arg in opts: |
|
1130 |
if opt in ("-c", "--clear-list"): |
|
1131 |
clear_list = True |
|
1132 |
elif opt in ("-x", "--exclude"): |
|
1133 |
excludes_pki.append(arg) |
|
1134 |
excludes_pkg.append(arg) |
|
1135 |
elif opt in ( "--excludepki"): |
|
1136 |
excludes_pki.append(arg) |
|
1137 |
elif opt in ( "--excludepkg"): |
|
1138 |
excludes_pkg.append(arg) |
|
1139 |
elif opt in ( "--include", "-I"): |
|
1140 |
includes.append(PackageInfo(arg)) |
|
1141 |
elif opt in ("-r", "--replace"): |
|
1142 |
interactive = False |
|
1143 |
replaces.append(arg) |
|
1144 |
elif opt in ("-S", "--sign"): |
|
1145 |
sign = True |
|
1146 |
else: |
|
1147 |
assert False, "unhandled option %r" % opt |
|
1148 |
|
|
1149 |
indexes = IndexList() |
|
1150 |
|
|
1151 |
packages_txt = getDist() +"/packages.txt" |
|
1152 |
if os.path.exists(packages_txt) and not clear_list: |
|
1153 |
indexes.load(packages_txt) |
|
1154 |
else: |
|
1155 |
indexes.build(getPool(), getSearchVersions()) |
|
1156 |
indexes.save(packages_txt) |
|
1157 |
|
|
1158 |
for pkg in includes: |
|
1159 |
indexes.append(pkg) |
|
1160 |
|
|
1161 |
allpackages = list() |
|
1162 |
for info in indexes: |
|
1163 |
if not ( info.code in excludes_pki or info.getFullName() in excludes_pki ): |
|
1164 |
try: |
|
1165 |
if info.hasPki() : |
|
1166 |
print info.getPkiFilename() |
|
1167 |
if interactive : |
|
1168 |
edit_pkginfo_of_package(info.getPkiFilename(), edit_ui) |
|
1169 |
elif len(replaces) < 1: |
|
1170 |
edit_pkginfo_of_package(info.getPkiFilename(), edit_replace, replaces) |
|
1171 |
|
|
1172 |
if sign: |
|
1173 |
edit_pkginfo_of_package(info.getPkiFilename(), edit_sign) |
|
1174 |
|
|
1175 |
except Exception, ex: |
|
1176 |
msgerror("Can't add index '%s', error %s" % (info, str(ex))) |
|
1177 |
|
|
750 | 1178 |
def edit(args): |
751 |
index_name=args[1] |
|
1179 |
cmd = Command(args) |
|
1180 |
try: |
|
1181 |
opts, args = getopt.getopt(cmd.getArgs("edit"), "Sr:", [ "replace=", "onlysign", "sign" ]) |
|
1182 |
except getopt.GetoptError, err: |
|
1183 |
# print help information and exit: |
|
1184 |
print str(err) # will print something like "option -a not recognized" |
|
1185 |
help(args) |
|
1186 |
sys.exit(2) |
|
1187 |
|
|
1188 |
replaces = list() |
|
1189 |
interactive = True |
|
1190 |
sign = False |
|
1191 |
for opt, arg in opts: |
|
1192 |
if opt in ("-r", "--replace"): |
|
1193 |
interactive = False |
|
1194 |
replaces.append(arg) |
|
1195 |
elif opt in ("--onlysign"): |
|
1196 |
interactive = False |
|
1197 |
sign = True |
|
1198 |
elif opt in ("-S", "--sign"): |
|
1199 |
sign = True |
|
1200 |
else: |
|
1201 |
assert False, "unhandled option %r" % opt |
|
1202 |
|
|
1203 |
index_name=args[0] |
|
752 | 1204 |
message( "Show package.info from '%s'" % index_name) |
753 | 1205 |
files = findfiles(getPool(), index_name) |
754 | 1206 |
if len(files) != 1: |
755 | 1207 |
msgerror("Can't locate package '%s' in pool '%s'." % (index_name, getPool())) |
756 | 1208 |
return |
757 | 1209 |
index_path = files[0] |
1210 |
if interactive: |
|
1211 |
edit_pkginfo_of_package(index_path, edit_ui) |
|
1212 |
elif len(replaces) < 1: |
|
1213 |
edit_pkginfo_of_package(index_path, edit_replace, replaces) |
|
1214 |
|
|
1215 |
if sign: |
|
1216 |
edit_pkginfo_of_package(index_path, edit_sign) |
|
1217 |
|
|
1218 |
def edit_ui(filename, args): |
|
1219 |
os.system('vi "%s"' % filename) |
|
1220 |
|
|
1221 |
def edit_replace(filename, args): |
|
1222 |
replaces = args[0] |
|
1223 |
f = open(filename) |
|
1224 |
s = f.read() |
|
1225 |
f.close() |
|
1226 |
for replace in replaces: |
|
1227 |
x = replace.split(replace[0]) |
|
1228 |
if len(x)==4: |
|
1229 |
s=re.sub(x[1],x[2],s) |
|
1230 |
f = open(filename,"w") |
|
1231 |
f.write(s) |
|
1232 |
f.close() |
|
1233 |
|
|
1234 |
def edit_sign(filename, args): |
|
1235 |
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' % ( |
|
1236 |
get_gvspkg_bin_folder(), |
|
1237 |
get_gvspkg_bin_folder(), |
|
1238 |
filename) |
|
1239 |
) |
|
1240 |
|
|
1241 |
def verify_sign(filename): |
|
1242 |
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' % ( |
|
1243 |
get_gvspkg_bin_folder(), |
|
1244 |
get_gvspkg_bin_folder(), |
|
1245 |
filename) |
|
1246 |
) |
|
1247 |
|
|
1248 |
def edit_pkginfo_of_package(pkg_path, operation, *args): |
|
758 | 1249 |
outputfolder="/tmp/gvspkg.%s" % os.getpid() |
759 | 1250 |
os.mkdir(outputfolder) |
760 |
os.system('unzip -q %s -d %s' % (index_path,outputfolder))
|
|
1251 |
os.system('unzip -q %s -d %s' % (pkg_path,outputfolder))
|
|
761 | 1252 |
|
762 | 1253 |
files = findfiles(outputfolder, "package.info") |
763 | 1254 |
if len(files) != 1: |
764 |
msgerror("Can't locate package.info in pool '%s'." % (index_name))
|
|
1255 |
msgerror("Can't locate package.info in pool '%s'." % (pkg_path))
|
|
765 | 1256 |
return |
766 | 1257 |
|
767 | 1258 |
package_info = files[0] |
768 | 1259 |
code = package_info.split("/")[-2] |
769 |
os.system('vi "%s"' % package_info) |
|
1260 |
operation(package_info, args) |
|
1261 |
|
|
1262 |
# zip -Dr kk.zip org.gvsig.wfs |
|
770 | 1263 |
temp_index_name = "/tmp/packages.gvspki.%s" % os.getpid() |
771 | 1264 |
temp_index = zipfile.ZipFile(temp_index_name,"w",zipfile.ZIP_STORED) |
772 | 1265 |
temp_index.write(package_info, "%s/package.info" % (code)) |
773 | 1266 |
temp_index.close() |
774 | 1267 |
shutil.rmtree(outputfolder) |
775 |
os.remove(index_path)
|
|
776 |
shutil.move(temp_index_name,index_path)
|
|
1268 |
os.remove(pkg_path)
|
|
1269 |
shutil.move(temp_index_name,pkg_path)
|
|
777 | 1270 |
|
1271 |
def install(args): |
|
1272 |
cmd = Command(args) |
|
1273 |
try: |
|
1274 |
opts, args = getopt.getopt(cmd.getArgs("install"), "f", [ "force" ]) |
|
1275 |
except getopt.GetoptError, err: |
|
1276 |
# print help information and exit: |
|
1277 |
print str(err) # will print something like "option -a not recognized" |
|
1278 |
help(args) |
|
1279 |
sys.exit(2) |
|
1280 |
|
|
1281 |
force = False |
|
1282 |
for opt, arg in opts: |
|
1283 |
if opt in ("-f", "--force"): |
|
1284 |
force = True |
|
1285 |
else: |
|
1286 |
assert False, "unhandled option %r" % opt |
|
1287 |
|
|
1288 |
url_pki = args[0] |
|
1289 |
message( "Download package index '%s'" % url_pki) |
|
1290 |
temppath_pki= os.path.join("/tmp",os.path.basename(url_pki)) |
|
1291 |
if not downloadFile(url_pki,temppath_pki): |
|
1292 |
msgerror("Can't download index.") |
|
1293 |
msgerror("Can't install '%s'." % url_pki) |
|
1294 |
print # force a newline |
|
1295 |
return 1 |
|
1296 |
pkg = PackageInfo(temppath_pki) |
|
1297 |
url_pkg = pkg.getUrl().replace("\\","") |
|
1298 |
if url_pkg[-7:] == ".gvspki" : |
|
1299 |
msgwarn("Suspicious download-url value. Ends with gvspki, expected gvspkg.") |
|
1300 |
msgwarn("download-url ='%s'." % url_pkg) |
|
1301 |
message( "Download package '%s'" % url_pkg) |
|
1302 |
temppath_pkg= os.path.join("/tmp",os.path.basename(url_pkg)) |
|
1303 |
if not downloadFile(url_pkg,temppath_pkg): |
|
1304 |
msgerror("Can't download package from download-url ('%s')." % url_pkg) |
|
1305 |
msgerror("Can't install '%s'," % url_pki) |
|
1306 |
print # force a newline |
|
1307 |
return 1 |
|
1308 |
folder = os.path.join(getPool(),pkg.getCode()) |
|
1309 |
if not os.path.isdir(folder) : |
|
1310 |
os.makedirs(folder) |
|
1311 |
pathname_pki = os.path.join(folder,os.path.basename(url_pki)) |
|
1312 |
if not force and os.path.isfile(pathname_pki) : |
|
1313 |
msgwarn("The package index alreade exist in the pool. Use -f to forrce install.") |
|
1314 |
print # force a newline |
|
1315 |
return 1 |
|
1316 |
pathname_pkg = os.path.join(folder,os.path.basename(url_pkg)) |
|
1317 |
if not force and os.path.isfile(pathname_pki) : |
|
1318 |
msgwarn("The package downloaded from download-url alredy exists in the pool. Use -f to force install.") |
|
1319 |
print # force a newline |
|
1320 |
return 1 |
|
1321 |
message( "installing package '%s'" % os.path.basename(pathname_pki)) |
|
1322 |
shutil.copyfile(temppath_pki, pathname_pki) |
|
1323 |
message( "installing package '%s'" % os.path.basename(pathname_pkg)) |
|
1324 |
shutil.copyfile(temppath_pkg, pathname_pkg) |
|
1325 |
|
|
1326 |
md5sum(pathname_pki, pathname_pki+".md5") |
|
1327 |
md5sum(pathname_pkg, pathname_pkg+".md5") |
|
1328 |
|
|
1329 |
|
|
1330 |
def md5sum(fin, fout): |
|
1331 |
message( "Calculating md5sum of %s..." % fin ) |
|
1332 |
system("md5sum -b %s >%s" % (fin, fout) ) |
|
1333 |
|
|
1334 |
def downloadFile(url,path): |
|
1335 |
try: |
|
1336 |
fsrc = urllib2.urlopen(url) |
|
1337 |
except urllib2.HTTPError,e: |
|
1338 |
msgerror("Error abriendo url '%s'." % url, e) |
|
1339 |
return False |
|
1340 |
fdst = file(path,"wb") |
|
1341 |
shutil.copyfileobj(fsrc,fdst) |
|
1342 |
fdst.close() |
|
1343 |
fsrc.close() |
|
1344 |
return True |
|
1345 |
|
|
1346 |
|
|
778 | 1347 |
def help(args): |
779 | 1348 |
print """ |
780 | 1349 |
usage: gvspkg [OPTIONS] COMMANDS |
... | ... | |
813 | 1382 |
-w | --addjrewin |
814 | 1383 |
|
815 | 1384 |
-N | --distribution-name=name |
816 |
|
|
817 | 1385 |
Nombre usado como sufijo del nuevo binario a generar. Por defecto si no se |
818 | 1386 |
indica valdra "custom". |
819 | 1387 |
|
... | ... | |
850 | 1418 |
directorio corriente, con los nombres de paquetes a seleccionar |
851 | 1419 |
por defecto. |
852 | 1420 |
|
1421 |
-p | --platform=name |
|
1422 |
Indica para que plataforma queremos generar el conjunto de paquetes. |
|
1423 |
Es un parametro opcional. |
|
1424 |
Sus valores pueden ser: |
|
1425 |
- all (Se incluiren los de todas las plataformas, no solo los multiplataforma) |
|
1426 |
- x86 |
|
1427 |
- x86_64 |
|
1428 |
- amd64 (sinonimo aceptado para x86_64) |
|
1429 |
Si no se indica plataforma se generara para "all". |
|
1430 |
El indice,"gvspki", siempre llevara los de todas las plataformas, esta opcion |
|
1431 |
solo afecta a la genracion del "gvspks". |
|
1432 |
|
|
1433 |
|
|
853 | 1434 |
-i | --index-only |
854 | 1435 |
No crea el fichero gvspks, solo crea el gvspki |
855 | 1436 |
|
856 | 1437 |
-I full-path-to-package | --include full-path-to-package |
857 |
Añade el paquete indicado a la lista de paquetes aunque no coincida para
|
|
1438 |
A�ade el paquete indicado a la lista de paquetes aunque no coincida para
|
|
858 | 1439 |
la version de gvSIG con la que se esta trabajando. |
859 | 1440 |
|
1441 |
mkdist [OPTIONS] |
|
1442 |
Crea los ficheros de la distribucion standard para el buil dindicado a partir de |
|
1443 |
la distribucion online y los paquetes que hayan en el pool para esta version. |
|
1444 |
Ejecuta un "mks" y un "mkhtml" automaticamente para preparar el conjunto de paquetes |
|
1445 |
a incluir en la distribucion, y una vez preparados ejecuta un "mkinsrall" por |
|
1446 |
S.O. (win y lin), renombrando los ficheros generados segun corresponda. |
|
1447 |
|
|
1448 |
OPTIONS: |
|
1449 |
-s STATE | --state=STATE |
|
1450 |
Indica el estado de la distribucion a generar, devel, alpha, ..., debe estar |
|
1451 |
deacuerdo con lo que diga el cihero online a usar como base. |
|
1452 |
|
|
1453 |
-b BUILD | --build=BUILD |
|
1454 |
Indica el numero de build de la destribucion a generar. Es usado para localizar |
|
1455 |
los ficheros en la carpeta builds de la distribucion y para saber donde debe |
|
1456 |
dejar los ficheros generados. |
|
1457 |
|
|
1458 |
-p | --platform=name |
|
1459 |
Indica para que plataforma queremos generar los instalables de gvSIG. |
|
1460 |
Es un parametro opcional. |
|
1461 |
Sus valores pueden ser: |
|
1462 |
- all (si se indica se generara para x86) |
|
1463 |
- x86 |
|
1464 |
- x86_64 |
|
1465 |
- amd64 (sinonimo aceptado para x86_64) |
|
1466 |
Si no se indica plataforma se generara para x86. |
|
1467 |
|
|
1468 |
-N | --distribution-name=name |
|
1469 |
Nombre usado como sufijo del nuevo binario a generar. Por defecto si no se |
|
1470 |
indica valdra "standard". |
|
1471 |
|
|
1472 |
|
|
1473 |
mkmirror [OPTIONS] |
|
1474 |
|
|
1475 |
Prepara una carpeta para hacer un mirror de un build en concreto. |
|
1476 |
|
|
1477 |
OPTIONS: |
|
1478 |
|
|
1479 |
-b | --build buildnumber |
|
1480 |
Indica el numero de build del que se quiere hacer un mirror. |
|
1481 |
|
|
860 | 1482 |
mkhtml [OPTIONS] |
861 | 1483 |
???? |
862 | 1484 |
|
... | ... | |
875 | 1497 |
--exclude pkgcode |
876 | 1498 |
No incluye el paquete indicado en los ficheros gvspkg y gvspki a generar |
877 | 1499 |
|
878 |
show package-index |
|
1500 |
show OPTIONS package-index
|
|
879 | 1501 |
Muestra el package.info del indice indicado como parametro. |
880 | 1502 |
|
881 |
edit package-index |
|
1503 |
OPTIONS |
|
1504 |
|
|
1505 |
--verify | -V |
|
1506 |
Comprueba la forma del packete. |
|
1507 |
|
|
1508 |
edit [OPTIONS] package-index |
|
882 | 1509 |
Edita el package.info del indice indicado como parametro. |
883 | 1510 |
|
1511 |
OPTIONS: |
|
1512 |
|
|
1513 |
--replace=@search@replace@ |
|
1514 |
Reemplaza en el package.info de cada paquete la cadena "search" por "replace" |
|
1515 |
todas las veces que aparezca. "@" puede ser cualquier caracter que no aparezca |
|
1516 |
en "search" y "replace". |
|
1517 |
Esta opcion puede indicarse tatas veces como reemplazos se deseen efectuar. |
|
1518 |
|
|
1519 |
--onlysign |
|
1520 |
firma el package.info sin editarlo de forma interactiva (no invoca al editor antes |
|
1521 |
de firmarlo). |
|
1522 |
|
|
1523 |
--sign | -S |
|
1524 |
Firma el package.info tras terminar la edicion (bach o interactiva) |
|
1525 |
|
|
1526 |
editall [OPTIONS] |
|
1527 |
Edita todos los package.info |
|
1528 |
|
|
1529 |
OPTIONS: |
|
1530 |
|
|
1531 |
-c | --clear-list |
|
1532 |
Elimina la lista de paquetes a utilizar recreandola a partir |
|
1533 |
de los paquetes del pool tomando el ultimo build de cada paquete. |
|
1534 |
|
|
1535 |
--excludepkg pkgcode |
|
1536 |
No incluye el paquete indicado en el fichero gvspkg a generar |
|
1537 |
|
|
1538 |
--excludepki pkgcode |
|
1539 |
No incluye el paquete indicado en el fichero gvspki a generar |
|
1540 |
|
|
1541 |
--exclude pkgcode |
|
1542 |
No incluye el paquete indicado en los ficheros gvspkg y gvspki a generar |
|
1543 |
|
|
1544 |
--replace=@search@replace@ |
|
1545 |
Reemplaza en el package.info de cada paquete la cadena "search" por "replace" |
|
1546 |
todas las veces que aparezca. "@" puede ser cualquier caracter que no aparezca |
|
1547 |
en "search" y "replace". |
|
1548 |
Esta opcion puede indicarse tatas veces como reemplazos se deseen efectuar. |
|
1549 |
|
|
1550 |
--sign | -S |
|
1551 |
Firma todos los paquetes que sean oficiales |
|
1552 |
|
|
1553 |
install [OPTIONS] url-to-pki |
|
1554 |
descarga de la url indicada un fichero gvspki e instala este junto con su correspondiente |
|
1555 |
pkg en el pool local. |
|
1556 |
|
|
1557 |
OPTIONS: |
|
1558 |
|
|
1559 |
-f | --force |
|
1560 |
fuerza la sobreescritura de los ficheros en caso de que estos ya existan. |
|
1561 |
|
|
884 | 1562 |
Si en la carpeta corriente encuentra un fichero gvspkg.options cargara los |
885 | 1563 |
flags indicados ahi como flags por defecto para cada comando. El formato del |
886 | 1564 |
fichero es: |
... | ... | |
902 | 1580 |
|
903 | 1581 |
""" % (VERSION, GVSPKG_ROOT) |
904 | 1582 |
|
1583 |
def executeCommand(*args): |
|
1584 |
command = "help" |
|
1585 |
if len(args)>0: |
|
1586 |
command=args[0] |
|
1587 |
|
|
1588 |
if command=="lsi" : |
|
1589 |
lsi(args) |
|
1590 |
elif command == "mks": |
|
1591 |
mks(args) |
|
1592 |
elif command == "edit": |
|
1593 |
edit(args) |
|
1594 |
elif command == "editall": |
|
1595 |
editall(args) |
|
1596 |
elif command == "show": |
|
1597 |
show(args) |
|
1598 |
elif command == "mkhtml": |
|
1599 |
mkhtml(args) |
|
1600 |
elif command == "mkinstall": |
|
1601 |
mkinstall(args) |
|
1602 |
elif command == "install": |
|
1603 |
install(args) |
|
1604 |
elif command == "mkdist": |
|
1605 |
mkdist(args) |
|
1606 |
elif command == "mkmirror": |
|
1607 |
mkmirror(args) |
|
1608 |
else: |
|
1609 |
help(args) |
|
1610 |
|
|
1611 |
|
|
905 | 1612 |
def main(): |
1613 |
global DEBUG |
|
906 | 1614 |
global VERSION |
907 | 1615 |
global VERBOSE |
908 | 1616 |
global GVSPKG_ROOT |
1617 |
global SEARCH_VERSIONS |
|
909 | 1618 |
|
910 | 1619 |
cmd = Command(sys.argv) |
911 | 1620 |
try: |
912 |
opts, args = getopt.getopt(cmd.getArgs("main"), "dhvr:", ["debug", "verbose", "version=", "package-root=","help"]) |
|
1621 |
opts, args = getopt.getopt(cmd.getArgs("main"), "dhvr:", ["debug", "verbose", "version=", "package-root=","help","search_versions="])
|
|
913 | 1622 |
except getopt.GetoptError, err: |
914 | 1623 |
# print help information and exit: |
915 | 1624 |
print str(err) # will print something like "option -a not recognized" |
... | ... | |
926 | 1635 |
VERBOSE = True |
927 | 1636 |
elif opt in ("--version"): |
928 | 1637 |
VERSION = arg |
1638 |
elif opt in ("--search_versions"): |
|
1639 |
SEARCH_VERSIONS.append(arg) |
|
929 | 1640 |
elif opt in ("-r", "--package-root"): |
930 | 1641 |
GVSPKG_ROOT = arg |
931 | 1642 |
else: |
932 | 1643 |
assert False, "unhandled option" |
933 | 1644 |
# |
934 |
message("VERSION=%s" % VERSION) |
|
935 |
message("GVSPKG_ROOT=%s" % GVSPKG_ROOT) |
|
936 |
|
|
937 |
command = "help" |
|
938 |
if len(args)>0: |
|
939 |
command=args[0] |
|
940 |
|
|
941 |
if command=="lsi" : |
|
942 |
lsi(args) |
|
943 |
elif command == "mks": |
|
944 |
mks(args) |
|
945 |
elif command == "edit": |
|
946 |
edit(args) |
|
947 |
elif command == "show": |
|
948 |
show(args) |
|
949 |
elif command == "mkhtml": |
|
950 |
mkhtml(args) |
|
951 |
elif command == "mkinstall": |
|
952 |
mkinstall(args) |
|
1645 |
debug("DEBUG=%s" % DEBUG) |
|
1646 |
debug("VERSION=%s" % VERSION) |
|
1647 |
debug("GVSPKG_ROOT=%s" % GVSPKG_ROOT) |
|
1648 |
if GVSPKG_ROOT == None: |
|
1649 |
help(None) |
|
953 | 1650 |
else: |
954 |
help(args)
|
|
1651 |
executeCommand(*args)
|
|
955 | 1652 |
|
956 |
|
|
957 | 1653 |
main() |
958 | 1654 |
|
Also available in: Unified diff