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