gvsig-gdal / trunk / org.gvsig.gdal2 / org.gvsig.gdal2.app / org.gvsig.gdal2.app.mainplugin / org.gvsig.gdal2.app.mainplugin.lin.x86_64 / src / main / assembly / buildgdaltar.py @ 369
History | View | Annotate | Download (2.33 KB)
1 |
|
---|---|
2 |
import subprocess |
3 |
import os |
4 |
import sys |
5 |
import shutil |
6 |
|
7 |
excludes = ( |
8 |
"libc",
|
9 |
"libpthread",
|
10 |
"libz",
|
11 |
"libdl",
|
12 |
"libstdc++",
|
13 |
"libm",
|
14 |
"libgcc_s",
|
15 |
"libfreetype",
|
16 |
"libfontconfig",
|
17 |
"libsz",
|
18 |
"liblzma",
|
19 |
"libssl",
|
20 |
"libcrypto",
|
21 |
"librt",
|
22 |
"libresolv",
|
23 |
"libcrypt",
|
24 |
) |
25 |
|
26 |
def stdout(cmd): |
27 |
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
|
28 |
output = proc.communicate()[0]
|
29 |
return output
|
30 |
|
31 |
def main(): |
32 |
x = os.path.dirname(sys.argv[0])
|
33 |
if x!="": |
34 |
os.chdir(x) |
35 |
if not os.path.exists("../../../pom.xml"): |
36 |
print "No localizo la carpeta 'target'" |
37 |
os.exist(-1)
|
38 |
if not os.path.exists("../../../target"): |
39 |
os.mkdir("../../../target")
|
40 |
|
41 |
pack_sh_path = os.path.join(os.getcwd(),"pack.sh")
|
42 |
|
43 |
os.chdir("../../../target")
|
44 |
shutil.rmtree("native",True) |
45 |
os.makedirs("native/gdal")
|
46 |
os.chdir("native/gdal")
|
47 |
|
48 |
files = list()
|
49 |
output = stdout("ldd /usr/bin/gdalinfo")
|
50 |
for line in output.split("\n"): |
51 |
parts = line.split("=>")
|
52 |
if len(parts)>1: |
53 |
f = parts[1].strip().split(" ") |
54 |
f = f[0].strip()
|
55 |
x = os.path.basename(f).split(".")[0] |
56 |
if not x in excludes : |
57 |
print "copy ", f |
58 |
shutil.copy(f,os.path.join(os.getcwd(), os.path.basename(f))) |
59 |
|
60 |
uname_output = stdout("uname -a")
|
61 |
lsb_release_output = stdout("lsb_release -a")
|
62 |
os_name = stdout("lsb_release -si").lower().strip()
|
63 |
os_version = stdout("lsb_release -sr").strip()
|
64 |
os_arch = stdout("uname -m").strip()
|
65 |
gdal_version = stdout("gdal-config --version").strip()
|
66 |
gdal_datadir = stdout("gdal-config --datadir").strip()
|
67 |
|
68 |
f = open("gdal-version.txt","wt") |
69 |
f.write("#\n")
|
70 |
f.write("+ uname -a\n")
|
71 |
f.write(uname_output) |
72 |
f.write("+ lsb_release -a\n")
|
73 |
f.write(lsb_release_output) |
74 |
f.write("+ gdal-config --version\n")
|
75 |
f.write(gdal_version) |
76 |
f.write("\n#\n")
|
77 |
f.close() |
78 |
|
79 |
os.makedirs("data")
|
80 |
for fname in os.listdir(gdal_datadir): |
81 |
shutil.copy(os.path.join(gdal_datadir,fname),os.path.join("data", fname))
|
82 |
|
83 |
os.makedirs("java")
|
84 |
shutil.copy("/usr/share/java/gdal.jar","java/gdal.jar") |
85 |
|
86 |
f = open("pack.cfg","wt") |
87 |
f.write('gdal_groupId="org.gdal"\n')
|
88 |
f.write('gdal_artifactId="gdal"\n')
|
89 |
f.write('gdal_jar="java/gdal.jar"\n')
|
90 |
f.write('gdal_classifier="%s-%s-%s"\n' %(os_name, os_version, os_arch))
|
91 |
f.write('gdal_version="%s.1"\n' % gdal_version)
|
92 |
f.close() |
93 |
|
94 |
shutil.copy(pack_sh_path,"pack.sh")
|
95 |
|
96 |
|
97 |
main() |