annotate tools/pkg-install.py @ 4238:bdcbb82d57e2

pkg-install.py: fail pkg build if configure fails (Bug #49503) * tools/pkg-install.py: check status of configure call and raise exeption on error
author John D
date Thu, 03 Nov 2016 03:48:05 -0400
parents d53c492ab48d
children 223b967a2d40
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
1 #!/usr/bin/python
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
2 import sys
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
3 import os
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
4 import re
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
5 import tempfile
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
6 import shutil
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
7 import fnmatch
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
8 import subprocess
4084
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
9 import glob
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
10
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
11 class Env:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
12 mkoctfile = "mkoctfile";
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
13 octave_config = "octave-config";
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
14 make = "make"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
15 verbose = True;
4102
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
16 prefix = "";
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
17 pkg = "";
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
18 arch = "";
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
19 tmp = "/tmp";
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
20 apiversion = "";
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
21 bin_dir = "";
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
22 m_dir = "";
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
23 arch_dir = "";
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
24 cleanup = False;
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
25
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
26 def show_usage():
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
27 print sys.argv(0), "[options] pkg1 [pkg2]"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
28
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
29 def verify_directory(dirname):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
30 for f in [ "COPYING", "DESCRIPTION" ]:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
31 if os.path.isfile(dirname + "/" + f) == False:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
32 raise Exception, "package is missing file " + f
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
33
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
34 def get_description(descfile):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
35 with open(descfile, 'r') as f:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
36 lines = f.read().splitlines()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
37 d = dict(s.split(': ',1) for s in lines if s.find(': ') != -1)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
38 return d
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
39
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
40 def extract_pkg(filename, nm):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
41 pkg = []
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
42 with open(filename, 'r') as f:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
43 lines = f.read().splitlines()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
44 for l in lines:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
45 so = re.search(nm, l, re.M|re.S)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
46 if so:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
47 pkg.append(str(so.group(1)))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
48 return pkg
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
49
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
50 def write_index_file(env, desc, index_nm):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
51
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
52 with open(index_nm, 'w') as f:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
53 files = os.listdir(env.m_dir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
54 classes = fnmatch.filter(files, "@*")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
55
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
56 # check classes
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
57 for c in classes:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
58 class_name = c
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
59 class_path = env.m_dir + "/" + c;
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
60 if os.path.isdir(class_path) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
61 class_files = list(class_name + "/" + a for a in os.listdir(class_path))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
62 files += class_files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
63
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
64 # arch dependant
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
65 if os.path.exists(env.arch_dir) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
66 archfiles = os.listdir(env.arch_dir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
67 files += archfiles
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
68
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
69 functions = []
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
70 for a in files:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
71 if a.endswith(".m"):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
72 functions.append( str(a[0:len(a)-2]) )
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
73 elif a.endswith(".oct"):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
74 functions.append( str(a[0:len(a)-4]) )
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
75
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
76 f.write(env.pkg + " >> " + desc['Title'] + "\n");
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
77 f.write(desc['Categories'].replace(",", " ") + "\n")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
78 for a in functions:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
79 f.write(" " + a + "\n")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
80
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
81 def finish_installation(env, packdir):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
82 # octave would run post_install.m here - instead we will copy the post_install.m
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
83 # somewhere and then on initial startup, run the post_install
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
84 if os.path.isfile(packdir + "/post_install.m") == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
85 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
86 print "Copying .. post_install.m"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
87 destdir = env.prefix + "/share/octave/site/m/once_only"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
88 if os.path.exists(destdir) == False:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
89 os.makedirs(destdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
90 shutil.copy2(packdir + "/post_install.m", destdir + "/" + env.pkg + "-post_install.m")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
91
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
92 def create_pkgadddel (env, packdir, nm):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
93 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
94 print "Creating...", nm
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
95
4111
d53c492ab48d pkg-install.py append to inst/PKG_ADD/DEL it it exists (Bug #47481)
John Donoghue
parents: 4102
diff changeset
96 instfid = open(env.m_dir + "/" + nm, "a")
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
97 if os.path.exists(env.arch_dir) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
98 archfid = open(env.arch_dir + "/" + nm, "w")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
99 else:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
100 archfid = instfid
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
101
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
102 # search inst .m files for PKG_ commands
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
103 instdir = packdir + "/inst"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
104 files = list(instdir + "/" + a for a in os.listdir(instdir))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
105 m_files = fnmatch.filter(files, "*.m")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
106 for f in m_files:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
107 for a in extract_pkg(f, '^[#%][#%]* *' + nm + ': *(.*)$'):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
108 instfid.write("%s\n" % str(a))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
109
4111
d53c492ab48d pkg-install.py append to inst/PKG_ADD/DEL it it exists (Bug #47481)
John Donoghue
parents: 4102
diff changeset
110 # search src .cc files for PKG_ commands
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
111 if os.path.exists(packdir + "/src") == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
112 srcdir = packdir + "/src"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
113 files = list(srcdir + "/" + a for a in os.listdir(srcdir))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
114 c_files = fnmatch.filter(files, "*.cc")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
115 for f in c_files:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
116 for a in extract_pkg(f, '^//* *' + nm + ': *(.*)$'):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
117 archfid.write("%s\n" % str(a))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
118 for a in extract_pkg(f, '^/\** *' + nm + ': *(.*) *\*/$'):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
119 archfid.write("%s\n" % a)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
120
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
121 # add PKG_XXX from packdir if exists
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
122 if os.path.isfile(packdir + "/" + nm) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
123 with open(packdir + "/" + nm, 'r') as f:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
124 lines = f.read().splitlines()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
125 for a in lines:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
126 archfid.write("%s\n" % a)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
127
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
128 # close files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
129 if archfid != instfid:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
130 archfid.close()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
131 if os.stat(env.arch_dir + "/" + nm).st_size == 0:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
132 os.remove(env.arch_dir + "/" + nm)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
133 instfid.close()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
134 if os.stat(env.m_dir + "/" + nm).st_size == 0:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
135 os.remove(env.m_dir + "/" + nm)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
136
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
137 def generate_lookfor_cache (env):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
138 # TODO create doc-cache
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
139 pass
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
140
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
141 def copyfile(files, destdir):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
142 if os.path.exists(destdir) == False:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
143 os.mkdir(destdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
144 for a in files:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
145 if os.path.isfile(a):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
146 shutil.copy2(a, destdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
147 if os.path.isdir(a):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
148 name= os.path.basename(a)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
149 morefiles=(a + "/" + b for b in os.listdir(a))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
150 copyfile(morefiles, destdir + "/" + name)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
151
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
152 def copy_files(env, pkgdir):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
153 if os.path.exists(env.m_dir) == False:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
154 os.makedirs(env.m_dir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
155 instdir = pkgdir + "/inst"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
156
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
157 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
158 print "Copying m files ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
159
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
160 files = list(instdir + "/" + a for a in os.listdir(instdir))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
161 # filter for arch folder
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
162 if os.path.exists(instdir + "/" + env.arch) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
163 files.remove(instdir + "/" + env.arch)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
164
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
165 copyfile(files, env.m_dir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
166
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
167 if os.path.exists(instdir + "/" + env.arch) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
168 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
169 print "Copying arch files ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
170 files = list(instdir + "/" + env.arch + "/" + a for a in os.listdir(instdir + "/" + env.arch))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
171 if len(files) > 0:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
172 if os.path.exists(env.arch_dir) == False:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
173 os.makedirs(env.arch_dir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
174 copyfile(files, env.arch_dir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
175 shutil.rmtree(instdir + "/" + env.arch)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
176
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
177 # packinfo
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
178 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
179 print "Copying packinfo files ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
180 if os.path.exists(env.m_dir + "/packinfo") == False:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
181 os.makedirs(env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
182 copyfile([pkgdir + "/DESCRIPTION"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
183 copyfile([pkgdir + "/COPYING"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
184 copyfile([pkgdir + "/CITATION"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
185 copyfile([pkgdir + "/NEWS"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
186 copyfile([pkgdir + "/ONEWS"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
187 copyfile([pkgdir + "/ChangeLog"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
188
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
189 # index file
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
190 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
191 print "Copying/creating INDEX ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
192 if os.path.isfile(pkgdir + "/INDEX") == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
193 copyfile([pkgdir + "/INDEX"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
194 else:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
195 desc = get_description(pkgdir + "/DESCRIPTION")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
196 write_index_file(env, desc, env.m_dir + "/packinfo/INDEX")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
197
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
198 copyfile([pkgdir + "on_uninstall.m"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
199
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
200 # doc dir ?
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
201 docdir = pkgdir + "/doc"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
202 if os.path.exists(docdir) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
203 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
204 print "Copying doc files ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
205 files = (docdir + "/" + a for a in os.listdir(docdir))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
206 copyfile(files, env.m_dir + "/doc")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
207
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
208 # bin dir ?
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
209 bindir = pkgdir + "/bin"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
210 if os.path.exists(bindir) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
211 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
212 print "Copying bin files ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
213 files = (bindir + "/" + a for a in os.listdir(bindir))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
214 copyfile(files, env.m_dir + "/bin")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
215
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
216 def configure_make(env, packdir):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
217 if os.path.isdir(packdir + "/inst") == False:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
218 os.mkdir(packdir + "/inst")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
219
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
220 if os.path.isdir(packdir + "/src") == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
221 src = packdir + "/src"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
222 os.chdir(src)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
223
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
224 if os.path.isfile(src + "/configure") == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
225 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
226 print "running ./configure " + env.config_opts
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
227
4238
bdcbb82d57e2 pkg-install.py: fail pkg build if configure fails (Bug #49503)
John D
parents: 4111
diff changeset
228 if os.system("./configure " + env.config_opts + "") != 0:
bdcbb82d57e2 pkg-install.py: fail pkg build if configure fails (Bug #49503)
John D
parents: 4111
diff changeset
229 raise Exception, "configure failed - stopping install"
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
230
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
231 if os.path.isfile(src + "/Makefile") == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
232 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
233 print "running make ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
234 if os.system(env.make + " --directory '" + src + "'" ) != 0:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
235 raise Exception, "make failed during build - stopping install"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
236
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
237 # copy files to inst and inst arch
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
238 files = src + "/FILES"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
239 instdir = packdir + "/inst"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
240 archdir = instdir + "/" + env.arch
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
241
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
242 if os.path.isfile(files) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
243 pass # TODO yet
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
244 else:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
245 # get .m, .oct and .mex files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
246 files = os.listdir(src)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
247 m_files = fnmatch.filter(files, "*.m")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
248 mex_files = fnmatch.filter(files, "*.mex")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
249 oct_files = fnmatch.filter(files, "*.oct")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
250 files = m_files + mex_files + oct_files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
251 files = list(src + "/" + s for s in files)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
252
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
253 # split files into arch and non arch files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
254 archdependant = fnmatch.filter(files, "*.mex") + fnmatch.filter(files,"*.oct")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
255 archindependant = list( x for x in files if x not in archdependant )
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
256
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
257 # copy the files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
258 copyfile(archindependant, instdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
259 copyfile(archdependant, archdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
260
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
261 def add_package_list(env, desc):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
262 #pkglist = env.prefix + "/share/octave/octave_packages"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
263 #with open(pkglist, 'r') as f:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
264 # lines = f.read().splitlines()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
265 # currently doing nothing for adding, will let installer do
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
266 pass
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
267
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
268 def uninstall_pkg(pkg,env):
4084
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
269 # uninstall existing directories
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
270
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
271 files=glob.glob(env.prefix + "/share/octave/packages/" + env.pkg + "-" + "*")
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
272 for f in files:
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
273 print "removing dir " + f
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
274 shutil.rmtree(f)
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
275
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
276 files=glob.glob(env.prefix + "/lib/octave/packages/" + env.pkg + "-" + "*")
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
277 for f in files:
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
278 print "removing dir " + f
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
279 shutil.rmtree(f)
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
280
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
281 pass
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
282
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
283 def install_pkg(pkg, env):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
284 pkg = os.path.abspath(pkg)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
285 currdir = os.getcwd()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
286
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
287 try:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
288 ## Check that the directory in prefix exist. If it doesn't: create it!
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
289 tmpdir = tempfile.mkdtemp("-pkg","tmp", env.tmp)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
290 os.chdir(tmpdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
291
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
292 # unpack dir
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
293 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
294 os.system("tar xzvf '" + pkg + "'")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
295 else:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
296 os.system("tar xzf '" + pkg + "'")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
297
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
298 # get list for files creates
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
299 files=os.listdir(tmpdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
300 if len(files) != 1:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
301 print "Expected to unpack to only one directory"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
302
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
303 packdir = os.path.abspath(files[0])
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
304
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
305 # verify have expected min files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
306 verify_directory(packdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
307
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
308 # read the description file
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
309 desc = get_description(packdir + "/DESCRIPTION")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
310
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
311 # make the path names
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
312 env.pkg = desc['Name'].lower()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
313 env.m_dir = env.prefix + "/share/octave/packages/" + env.pkg + "-" + desc['Version'];
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
314 env.arch_dir = env.prefix + "/lib/octave/packages/" + env.pkg + "-" + desc['Version'] + "/" + env.arch + "-" + env.apiversion
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
315
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
316 configure_make (env, packdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
317
4084
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
318 # uninstall old packages
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
319 uninstall_pkg(pkg, env)
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
320
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
321 # install package files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
322 copy_files(env, packdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
323 create_pkgadddel (env, packdir, "PKG_ADD");
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
324 create_pkgadddel (env, packdir, "PKG_DEL");
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
325 finish_installation(env, packdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
326 generate_lookfor_cache (env);
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
327
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
328 # update package list
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
329 add_package_list(env, desc)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
330 finally:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
331 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
332 print "cleaning up"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
333 os.chdir(currdir)
4102
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
334
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
335 if env.cleanup:
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
336 shutil.rmtree(tmpdir)
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
337
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
338
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
339 def pkg (args):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
340 arch = ''
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
341
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
342 env = Env()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
343
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
344 files = []
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
345
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
346 for a in args:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
347 print a
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
348 c=a.split("=")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
349 key=c[0]
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
350 if len(c) > 1:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
351 val=c[1]
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
352 else:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
353 val=""
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
354
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
355 if key == "-verbose":
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
356 env.verbose = True;
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
357 elif key == "--verbose":
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
358 env.verbose = True;
4102
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
359 elif key == "-no-cleanup":
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
360 env.cleanup = False;
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
361 elif val == "":
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
362 files.append(key)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
363
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
364
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
365 if os.environ.get("OCTAVE_CONFIG") != None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
366 env.octave_config = os.environ["OCTAVE_CONFIG"]
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
367 if os.environ.get("MAKE") != None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
368 env.make = os.environ["MAKE"]
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
369 if os.environ.get("MKOCTFILE") != None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
370 env.mkoctfile = os.environ["MKOCTFILE"]
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
371 if os.environ.get("TMP") != None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
372 env.tmp = os.environ["TMP"]
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
373
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
374 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
375 env.mkoctfile = env.mkoctfile + " --verbose"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
376
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
377 # make sure we have these set up in env
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
378 os.environ['OCTAVE_CONFIG'] = env.octave_config;
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
379 os.environ['MAKE'] = env.make;
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
380 os.environ['MKOCTFILE'] = env.mkoctfile;
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
381 os.environ['TMP'] = env.tmp;
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
382 os.environ['OCTAVE'] = 'echo';
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
383
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
384 if os.environ.get("CC") == None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
385 os.environ['CC'] = os.popen(env.mkoctfile + " -p CC").read().rstrip("\r\n")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
386 if os.environ.get("CXX") == None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
387 os.environ['CXX'] = os.popen(env.mkoctfile + " -p CXX").read().rstrip("\r\n")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
388 if os.environ.get("AR") == None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
389 os.environ['AR'] = os.popen(env.mkoctfile + " -p AR").read().rstrip("\r\n")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
390 if os.environ.get("RANLIB") == None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
391 os.environ['RANLIB'] = os.popen(env.mkoctfile + " -p RANLIB").read().rstrip("\r\n")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
392
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
393 if os.environ.get("CONFIGURE_OPTIONS") != None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
394 env.config_opts = os.environ['CONFIGURE_OPTIONS']
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
395
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
396 # work out what arch is etc from mkoctfile/config
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
397 if env.prefix == "":
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
398 env.prefix = os.popen(env.octave_config + " -p PREFIX").read().rstrip("\r\n")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
399
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
400 env.arch = os.popen(env.octave_config + " -p CANONICAL_HOST_TYPE").read().rstrip("\r\n")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
401 env.apiversion = os.popen(env.octave_config + " -p API_VERSION").read().rstrip("\r\n")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
402 env.bindir = os.popen(env.octave_config + " -p BINDIR").read().rstrip("\r\n")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
403
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
404 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
405 print "mkoctfile=", env.mkoctfile
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
406 print "arch=", env.arch
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
407 print "apiversion=", env.apiversion
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
408 print "prefix=", env.prefix
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
409 print "files=", files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
410 print "verbose=", env.verbose
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
411
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
412 for a in files:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
413 install_pkg(a, env)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
414
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
415 return 0
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
416
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
417 if __name__ == "__main__":
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
418 if len(sys.argv) > 1:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
419 pkg(sys.argv[1:])
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
420 else:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
421 show_usage()