annotate tools/pkg-install.py @ 4408:eb8b37422e16

pkg-install.py: Check for OCTAVE_HOME, then PREFIX.
author John W. Eaton <jwe@octave.org>
date Mon, 10 Jul 2017 13:26:33 -0400
parents 3c02ca69cbe5
children 4eae7db624e8
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))
4348
223b967a2d40 * tools/pkg-install.py: look for pkd add/del in .cpp and cxx files
John D
parents: 4238
diff changeset
114 cc_files = fnmatch.filter(files, "*.cc")
223b967a2d40 * tools/pkg-install.py: look for pkd add/del in .cpp and cxx files
John D
parents: 4238
diff changeset
115 cpp_files = fnmatch.filter(files, "*.cpp")
223b967a2d40 * tools/pkg-install.py: look for pkd add/del in .cpp and cxx files
John D
parents: 4238
diff changeset
116 cxx_files = fnmatch.filter(files, "*.cxx")
223b967a2d40 * tools/pkg-install.py: look for pkd add/del in .cpp and cxx files
John D
parents: 4238
diff changeset
117 for f in cc_files + cpp_files + cxx_files:
4067
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" % str(a))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
120 for a in extract_pkg(f, '^/\** *' + nm + ': *(.*) *\*/$'):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
121 archfid.write("%s\n" % a)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
122
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
123 # add PKG_XXX from packdir if exists
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
124 if os.path.isfile(packdir + "/" + nm) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
125 with open(packdir + "/" + nm, 'r') as f:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
126 lines = f.read().splitlines()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
127 for a in lines:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
128 archfid.write("%s\n" % a)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
129
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
130 # close files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
131 if archfid != instfid:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
132 archfid.close()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
133 if os.stat(env.arch_dir + "/" + nm).st_size == 0:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
134 os.remove(env.arch_dir + "/" + nm)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
135 instfid.close()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
136 if os.stat(env.m_dir + "/" + nm).st_size == 0:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
137 os.remove(env.m_dir + "/" + nm)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
138
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
139 def generate_lookfor_cache (env):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
140 # TODO create doc-cache
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
141 pass
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
142
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
143 def copyfile(files, destdir):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
144 if os.path.exists(destdir) == False:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
145 os.mkdir(destdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
146 for a in files:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
147 if os.path.isfile(a):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
148 shutil.copy2(a, destdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
149 if os.path.isdir(a):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
150 name= os.path.basename(a)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
151 morefiles=(a + "/" + b for b in os.listdir(a))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
152 copyfile(morefiles, destdir + "/" + name)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
153
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
154 def copy_files(env, pkgdir):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
155 if os.path.exists(env.m_dir) == False:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
156 os.makedirs(env.m_dir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
157 instdir = pkgdir + "/inst"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
158
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
159 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
160 print "Copying m files ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
161
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
162 files = list(instdir + "/" + a for a in os.listdir(instdir))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
163 # filter for arch folder
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
164 if os.path.exists(instdir + "/" + env.arch) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
165 files.remove(instdir + "/" + env.arch)
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 copyfile(files, env.m_dir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
168
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
169 if os.path.exists(instdir + "/" + env.arch) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
170 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
171 print "Copying arch files ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
172 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
173 if len(files) > 0:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
174 if os.path.exists(env.arch_dir) == False:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
175 os.makedirs(env.arch_dir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
176 copyfile(files, env.arch_dir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
177 shutil.rmtree(instdir + "/" + env.arch)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
178
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
179 # packinfo
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
180 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
181 print "Copying packinfo files ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
182 if os.path.exists(env.m_dir + "/packinfo") == False:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
183 os.makedirs(env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
184 copyfile([pkgdir + "/DESCRIPTION"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
185 copyfile([pkgdir + "/COPYING"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
186 copyfile([pkgdir + "/CITATION"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
187 copyfile([pkgdir + "/NEWS"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
188 copyfile([pkgdir + "/ONEWS"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
189 copyfile([pkgdir + "/ChangeLog"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
190
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
191 # index file
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
192 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
193 print "Copying/creating INDEX ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
194 if os.path.isfile(pkgdir + "/INDEX") == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
195 copyfile([pkgdir + "/INDEX"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
196 else:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
197 desc = get_description(pkgdir + "/DESCRIPTION")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
198 write_index_file(env, desc, env.m_dir + "/packinfo/INDEX")
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 copyfile([pkgdir + "on_uninstall.m"], env.m_dir + "/packinfo")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
201
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
202 # doc dir ?
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
203 docdir = pkgdir + "/doc"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
204 if os.path.exists(docdir) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
205 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
206 print "Copying doc files ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
207 files = (docdir + "/" + a for a in os.listdir(docdir))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
208 copyfile(files, env.m_dir + "/doc")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
209
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
210 # bin dir ?
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
211 bindir = pkgdir + "/bin"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
212 if os.path.exists(bindir) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
213 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
214 print "Copying bin files ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
215 files = (bindir + "/" + a for a in os.listdir(bindir))
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
216 copyfile(files, env.m_dir + "/bin")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
217
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
218 def configure_make(env, packdir):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
219 if os.path.isdir(packdir + "/inst") == False:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
220 os.mkdir(packdir + "/inst")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
221
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
222 if os.path.isdir(packdir + "/src") == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
223 src = packdir + "/src"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
224 os.chdir(src)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
225
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
226 if os.path.isfile(src + "/configure") == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
227 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
228 print "running ./configure " + env.config_opts
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
229
4238
bdcbb82d57e2 pkg-install.py: fail pkg build if configure fails (Bug #49503)
John D
parents: 4111
diff changeset
230 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
231 raise Exception, "configure failed - stopping install"
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
232
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
233 if os.path.isfile(src + "/Makefile") == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
234 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
235 print "running make ..."
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
236 if os.system(env.make + " --directory '" + src + "'" ) != 0:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
237 raise Exception, "make failed during build - stopping install"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
238
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
239 # copy files to inst and inst arch
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
240 files = src + "/FILES"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
241 instdir = packdir + "/inst"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
242 archdir = instdir + "/" + env.arch
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
243
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
244 if os.path.isfile(files) == True:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
245 pass # TODO yet
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
246 else:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
247 # get .m, .oct and .mex files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
248 files = os.listdir(src)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
249 m_files = fnmatch.filter(files, "*.m")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
250 mex_files = fnmatch.filter(files, "*.mex")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
251 oct_files = fnmatch.filter(files, "*.oct")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
252 files = m_files + mex_files + oct_files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
253 files = list(src + "/" + s for s in files)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
254
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
255 # split files into arch and non arch files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
256 archdependant = fnmatch.filter(files, "*.mex") + fnmatch.filter(files,"*.oct")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
257 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
258
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
259 # copy the files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
260 copyfile(archindependant, instdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
261 copyfile(archdependant, archdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
262
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
263 def add_package_list(env, desc):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
264 #pkglist = env.prefix + "/share/octave/octave_packages"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
265 #with open(pkglist, 'r') as f:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
266 # lines = f.read().splitlines()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
267 # currently doing nothing for adding, will let installer do
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
268 pass
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
269
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
270 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
271 # uninstall existing directories
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
272
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
273 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
274 for f in files:
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
275 print "removing dir " + f
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
276 shutil.rmtree(f)
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
277
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
278 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
279 for f in files:
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
280 print "removing dir " + f
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
281 shutil.rmtree(f)
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
282
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
283 pass
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
284
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
285 def install_pkg(pkg, env):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
286 pkg = os.path.abspath(pkg)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
287 currdir = os.getcwd()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
288
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
289 try:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
290 ## 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
291 tmpdir = tempfile.mkdtemp("-pkg","tmp", env.tmp)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
292 os.chdir(tmpdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
293
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
294 # unpack dir
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
295 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
296 os.system("tar xzvf '" + pkg + "'")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
297 else:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
298 os.system("tar xzf '" + pkg + "'")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
299
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
300 # get list for files creates
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
301 files=os.listdir(tmpdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
302 if len(files) != 1:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
303 print "Expected to unpack to only one directory"
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 packdir = os.path.abspath(files[0])
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
306
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
307 # verify have expected min files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
308 verify_directory(packdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
309
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
310 # read the description file
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
311 desc = get_description(packdir + "/DESCRIPTION")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
312
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
313 # make the path names
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
314 env.pkg = desc['Name'].lower()
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
315 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
316 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
317
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
318 configure_make (env, packdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
319
4084
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
320 # uninstall old packages
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
321 uninstall_pkg(pkg, env)
fc806c8583a9 install: remove old octave pakages during intall of pkg
John Donoghue <john.donoghue@ieee.org>
parents: 4067
diff changeset
322
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
323 # install package files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
324 copy_files(env, packdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
325 create_pkgadddel (env, packdir, "PKG_ADD");
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
326 create_pkgadddel (env, packdir, "PKG_DEL");
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
327 finish_installation(env, packdir)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
328 generate_lookfor_cache (env);
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
329
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
330 # update package list
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
331 add_package_list(env, desc)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
332 finally:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
333 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
334 print "cleaning up"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
335 os.chdir(currdir)
4102
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
336
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
337 if env.cleanup:
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
338 shutil.rmtree(tmpdir)
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
339
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
340
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
341 def pkg (args):
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
342 arch = ''
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 env = Env()
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 files = []
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
347
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
348 for a in args:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
349 print a
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
350 c=a.split("=")
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
351 key=c[0]
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
352 if len(c) > 1:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
353 val=c[1]
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
354 else:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
355 val=""
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
356
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
357 if key == "-verbose":
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
358 env.verbose = True;
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
359 elif key == "--verbose":
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
360 env.verbose = True;
4102
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
361 elif key == "-no-cleanup":
3e78f9bcd779 pkg-install: add -no-cleanup option
John Donoghue
parents: 4084
diff changeset
362 env.cleanup = False;
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
363 elif val == "":
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
364 files.append(key)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
365
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
366
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
367 if os.environ.get("OCTAVE_CONFIG") != None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
368 env.octave_config = os.environ["OCTAVE_CONFIG"]
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
369 if os.environ.get("MAKE") != None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
370 env.make = os.environ["MAKE"]
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
371 if os.environ.get("MKOCTFILE") != None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
372 env.mkoctfile = os.environ["MKOCTFILE"]
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
373 if os.environ.get("TMP") != None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
374 env.tmp = os.environ["TMP"]
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
375
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
376 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
377 env.mkoctfile = env.mkoctfile + " --verbose"
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
378
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
379 # make sure we have these set up in env
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
380 os.environ['OCTAVE_CONFIG'] = env.octave_config;
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
381 os.environ['MAKE'] = env.make;
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
382 os.environ['MKOCTFILE'] = env.mkoctfile;
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
383 os.environ['TMP'] = env.tmp;
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
384 os.environ['OCTAVE'] = 'echo';
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
385
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
386 if os.environ.get("CC") == None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
387 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
388 if os.environ.get("CXX") == None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
389 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
390 if os.environ.get("AR") == None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
391 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
392 if os.environ.get("RANLIB") == None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
393 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
394
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
395 if os.environ.get("CONFIGURE_OPTIONS") != None:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
396 env.config_opts = os.environ['CONFIGURE_OPTIONS']
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
397
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
398 # work out what arch is etc from mkoctfile/config
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
399 if env.prefix == "":
4408
eb8b37422e16 pkg-install.py: Check for OCTAVE_HOME, then PREFIX.
John W. Eaton <jwe@octave.org>
parents: 4349
diff changeset
400 env.prefix = os.popen(env.octave_config + " -p OCTAVE_HOME").read().rstrip("\r\n")
eb8b37422e16 pkg-install.py: Check for OCTAVE_HOME, then PREFIX.
John W. Eaton <jwe@octave.org>
parents: 4349
diff changeset
401 if env.prefix == "":
4067
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
402 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
403
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
404 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
405 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
406 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
407
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
408 if env.verbose:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
409 print "mkoctfile=", env.mkoctfile
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
410 print "arch=", env.arch
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
411 print "apiversion=", env.apiversion
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
412 print "prefix=", env.prefix
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
413 print "files=", files
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
414 print "verbose=", env.verbose
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
415
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
416 for a in files:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
417 install_pkg(a, env)
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
418
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
419 return 0
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
420
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
421 if __name__ == "__main__":
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
422 if len(sys.argv) > 1:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
423 pkg(sys.argv[1:])
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
424 else:
bdcddfdc57d0 Install binary of-* packages
John Donoghue <john.donoghue@ieee.org>
parents:
diff changeset
425 show_usage()