Revision 43374 trunk/org.gvsig.desktop/org.gvsig.desktop.installer/src/main/packaging/gvspkg
gvspkg | ||
---|---|---|
178 | 178 |
result.sort() |
179 | 179 |
return result |
180 | 180 |
|
181 |
def getpackageUrl(path): |
|
182 |
return re.sub(".*/downloads/","http://downloads.gvsig.org/download/",path) |
|
183 |
|
|
181 | 184 |
def mychmod(filename, perms): |
182 | 185 |
try: |
183 | 186 |
os.chmod(filename,perms) |
... | ... | |
1515 | 1518 |
os.remove(pkg_path) |
1516 | 1519 |
shutil.move(temp_index_name,pkg_path) |
1517 | 1520 |
|
1521 |
|
|
1522 |
def crearpki(path_pkg, url_pkg): |
|
1523 |
z = zipfile.ZipFile(path_pkg,"r") |
|
1524 |
zi = z.infolist() |
|
1525 |
filename = None |
|
1526 |
contents = None |
|
1527 |
for info in zi : |
|
1528 |
if info.filename.endswith("/package.info"): |
|
1529 |
filename = info.filename |
|
1530 |
contents = z.read(filename) |
|
1531 |
if contents[-1:]!= "\n": |
|
1532 |
contents += "\n" |
|
1533 |
contents += "download-url=%s\n" % url_pkg.replace(":","\\:") |
|
1534 |
break |
|
1535 |
|
|
1536 |
z.close() |
|
1537 |
|
|
1538 |
if filename == None: |
|
1539 |
return |
|
1540 |
|
|
1541 |
fname = path_pkg[:-7]+".gvspki" |
|
1542 |
z = zipfile.ZipFile(fname,"w") |
|
1543 |
z.writestr(filename,contents) |
|
1544 |
z.close() |
|
1545 |
|
|
1546 |
return fname |
|
1547 |
|
|
1518 | 1548 |
def install(args): |
1519 | 1549 |
cmd = Command(args) |
1520 | 1550 |
try: |
... | ... | |
1546 | 1576 |
msgerror("Can't install '%s'." % url_pki) |
1547 | 1577 |
print # force a newline |
1548 | 1578 |
return 1 |
1549 |
pkg = PackageInfo(temppath_pki) |
|
1550 |
url_pkg = pkg.getUrl().replace("\\","") |
|
1551 |
if url_pkg[-7:] == ".gvspki" : |
|
1552 |
msgwarn("Suspicious download-url value. Ends with gvspki, expected gvspkg.") |
|
1553 |
msgwarn("download-url ='%s'." % url_pkg) |
|
1579 |
if temppath_pki.endswith(".gvspki"): |
|
1580 |
pkg = PackageInfo(temppath_pki) |
|
1581 |
url_pkg = pkg.getUrl().replace("\\","") |
|
1582 |
if url_pkg[-7:] == ".gvspki" : |
|
1583 |
msgwarn("Suspicious download-url value. Ends with gvspki, expected gvspkg.") |
|
1584 |
msgwarn("download-url ='%s'." % url_pkg) |
|
1554 | 1585 |
|
1555 |
if url_pkg.startswith("https:") and nohttps : |
|
1556 |
url_pkg = "http:" + url_pkg[6:] |
|
1586 |
if url_pkg.startswith("https:") and nohttps :
|
|
1587 |
url_pkg = "http:" + url_pkg[6:]
|
|
1557 | 1588 |
|
1558 |
message( "Download package '%s'" % url_pkg) |
|
1559 |
temppath_pkg= os.path.join("/tmp",os.path.basename(url_pkg)) |
|
1560 |
if not downloadFile(url_pkg,temppath_pkg): |
|
1561 |
msgerror("Can't download package from download-url ('%s')." % url_pkg) |
|
1562 |
msgerror("Can't install '%s'," % url_pki) |
|
1563 |
print # force a newline |
|
1589 |
message( "Download package '%s'" % url_pkg) |
|
1590 |
temppath_pkg= os.path.join("/tmp",os.path.basename(url_pkg)) |
|
1591 |
if not downloadFile(url_pkg,temppath_pkg): |
|
1592 |
msgerror("Can't download package from download-url ('%s')." % url_pkg) |
|
1593 |
msgerror("Can't install '%s'," % url_pki) |
|
1594 |
print # force a newline |
|
1595 |
return 1 |
|
1596 |
|
|
1597 |
elif temppath_pki.endswith(".gvspkg"): |
|
1598 |
temppath_pkg = temppath_pki |
|
1599 |
pkg = PackageInfo(temppath_pki) |
|
1600 |
url = getpackageUrl(getPool()+"/"+pkg.getCode()+"/"+os.path.basename(temppath_pkg)) |
|
1601 |
temppath_pki = crearpki(temppath_pkg,url) |
|
1602 |
|
|
1603 |
else: |
|
1604 |
msgerror("Can't install '%s', extension is not a gvspki or gvspkg.\n" % url_pki) |
|
1564 | 1605 |
return 1 |
1606 |
|
|
1565 | 1607 |
folder = os.path.join(getPool(),pkg.getCode()) |
1566 | 1608 |
makedirs(folder) |
1567 |
pathname_pki = os.path.join(folder,os.path.basename(url_pki))
|
|
1609 |
pathname_pki = os.path.join(folder,os.path.basename(temppath_pki))
|
|
1568 | 1610 |
if not force and os.path.isfile(pathname_pki) : |
1569 | 1611 |
msgwarn("The package index alreade exist in the pool. Use -f to forrce install.") |
1570 | 1612 |
print # force a newline |
1571 | 1613 |
return 1 |
1572 |
pathname_pkg = os.path.join(folder,os.path.basename(url_pkg))
|
|
1614 |
pathname_pkg = os.path.join(folder,os.path.basename(temppath_pkg))
|
|
1573 | 1615 |
if not force and os.path.isfile(pathname_pki) : |
1574 | 1616 |
msgwarn("The package downloaded from download-url alredy exists in the pool. Use -f to force install.") |
1575 | 1617 |
print # force a newline |
... | ... | |
1581 | 1623 |
|
1582 | 1624 |
md5sum(pathname_pki, pathname_pki+".md5") |
1583 | 1625 |
md5sum(pathname_pkg, pathname_pkg+".md5") |
1584 |
|
|
1585 |
|
|
1626 |
|
|
1586 | 1627 |
def md5sum(fin, fout): |
1587 | 1628 |
message( "Calculating md5sum of %s..." % fin ) |
1588 | 1629 |
system("md5sum -b %s >%s" % (fin, fout) ) |
... | ... | |
1972 | 2013 |
sys.exit(r) |
1973 | 2014 |
|
1974 | 2015 |
main() |
1975 |
|
|
1976 |
|
Also available in: Unified diff