Skip to content

Commit eace393

Browse files
committed
readies sync
1 parent b9a13fe commit eace393

File tree

8 files changed

+58
-9
lines changed

8 files changed

+58
-9
lines changed

opt/readies/paella/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def __setattr__(self,name,value):
2626

2727
#----------------------------------------------------------------------------------------------
2828

29-
Global.bb = bb
29+
Global.BB = bb
3030
Global.eprint = eprint
3131
Global.fatal = fatal
3232
Global.cwd = cwd

opt/readies/paella/debug.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33

44
#----------------------------------------------------------------------------------------------
55

6-
if 'PYDEBUG' in os.environ:
6+
pydebug = os.environ.get('PYDEBUG', '')
7+
if pydebug == '1' or pydebug == 'pudb':
78
try:
89
from pudb import set_trace as bb
910
except ImportError:
1011
from pdb import set_trace as bb
12+
elif pydebug == 'pdb':
13+
from pdb import set_trace as bb
1114
else:
1215
def bb(): pass
1316

opt/readies/paella/files.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,11 @@
22
from contextlib import contextmanager
33
import os
44
import os.path
5-
import urllib.request
65
import tempfile
6+
try:
7+
from urllib2 import urlopen
8+
except:
9+
from urllib.request import urlopen
710

811
#----------------------------------------------------------------------------------------------
912

@@ -38,7 +41,10 @@ def wget(url, dest="", tempdir=False):
3841
dest = tempfilepath()
3942
elif tempdir:
4043
dest = os.path.join('/tmp', dest)
41-
urllib.request.urlretrieve(url, dest)
44+
ufile = urlopen(url)
45+
data = ufile.read()
46+
with open(dest, "wb") as file:
47+
file.write(data)
4248
return os.path.abspath(dest)
4349

4450
#----------------------------------------------------------------------------------------------
@@ -59,3 +65,6 @@ def mkdir_p(dir):
5965
os.makedirs(dir, exist_ok=True)
6066

6167
#----------------------------------------------------------------------------------------------
68+
69+
def relpath(dir, rel):
70+
return os.path.abspath(os.path.join(dir, rel))

opt/readies/paella/platform.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
from __future__ import absolute_import
33
import platform
4+
import re
45

56
#----------------------------------------------------------------------------------------------
67

@@ -84,6 +85,12 @@ def __init__(self, strict=False):
8485
self.os = 'solaris'
8586
self.os_ver = ''
8687
self.dist = ''
88+
elif self.os == 'freebsd':
89+
self.dist = ''
90+
ver = sh('freebsd-version')
91+
m = re.search(r'([^-]*)-(.*)', ver)
92+
self.os_ver = self.full_os_ver = m.group(1)
93+
self.osnick = self.os + self.os_ver
8794
else:
8895
if strict:
8996
assert(False), "Cannot determine OS"
@@ -101,7 +108,7 @@ def __init__(self, strict=False):
101108
self.arch = 'arm32v7'
102109

103110
def is_debian_compat(self):
104-
return self.dist == 'debian' or self.dist == 'ubuntu'
111+
return self.dist == 'debian' or self.dist == 'ubuntu' or self.dist == 'linuxmint'
105112

106113
def is_redhat_compat(self):
107114
return self.dist == 'redhat' or self.dist == 'centos' or self.dist == 'amzn'
@@ -154,6 +161,8 @@ def invoke(self):
154161
self.suse()
155162
elif dist == 'arch':
156163
self.arch()
164+
elif dist == 'linuxmint':
165+
self.linuxmint()
157166
elif dist == 'amzn':
158167
self.amzn()
159168
else:
@@ -190,7 +199,7 @@ def centos(self):
190199
def fedora(self):
191200
pass
192201

193-
def redhat_compat(self): # centos, rhel
202+
def redhat_compat(self): # centos, rhel, amzn, etc
194203
pass
195204

196205
def redhat(self):
@@ -214,5 +223,8 @@ def bsd_compat(self):
214223
def freebsd(self):
215224
pass
216225

226+
def linuxmint(self):
227+
pass
228+
217229
def amzn(self):
218230
pass

opt/readies/paella/setup.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@ def brew_install(self, packs, group=False, _try=False):
113113
for pack in packs.split():
114114
self.run("brew list {} &>/dev/null || brew install {}".format(pack, pack), output_on_error=True, _try=_try)
115115

116+
def pkg_install(self, packs, group=False, _try=False):
117+
self.run("pkg install -q -y " + packs, output_on_error=True, _try=_try)
118+
116119
def install(self, packs, group=False, _try=False):
117120
if self.os == 'linux':
118121
if self.dist == 'fedora': # also include centos 8
@@ -129,6 +132,8 @@ def install(self, packs, group=False, _try=False):
129132
Assert(False), "Cannot determine installer"
130133
elif self.os == 'macosx':
131134
self.brew_install(packs, group=group, _try=_try)
135+
elif self.os == 'freebsd':
136+
self.pkg_install(packs, group=group, _try=_try)
132137
else:
133138
Assert(False), "Cannot determine installer"
134139

@@ -219,3 +224,13 @@ def install_git_lfs_on_linux(self, _try=False):
219224
# elif self.platform.is_debian_compat():
220225
# self.run(cmd.format('deb'), _try=_try)
221226
# self.install("git-lfs", _try=_try)
227+
228+
def install_gnu_utils(self, _try=False):
229+
self.install("make findutils gnu-sed")
230+
for x in ['make', 'find', 'sed']:
231+
p = "/usr/local/bin/{}".format(x)
232+
if not os.path.exists(p):
233+
self.run("ln -sf /usr/local/bin/g{} {}".format(x, p))
234+
else:
235+
eprint("Warning: {} exists - not replaced".format(p))
236+

opt/readies/paella/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11

22
import sys
3-
from subprocess import Popen, PIPE
3+
import inspect
4+
import os.path
45

56
if (sys.version_info > (3, 0)):
67
from .utils3 import *
78
else:
89
from .utils2 import *
910

10-
def sh(cmd):
11-
return " ".join(Popen(cmd.split(), stdout=PIPE).communicate()[0].split("\n"))
11+
def current_filepath():
12+
return os.path.abspath(inspect.getfile(inspect.currentframe().f_back))

opt/readies/paella/utils2.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11

22
import sys
3+
from subprocess import Popen, PIPE
34

45
def eprint(*args, **kwargs):
56
print >> sys.stderr, ' '.join(map(lambda x: "%s" % x, args))
7+
8+
def sh(cmd):
9+
return " ".join(Popen(cmd.split(), stdout=PIPE).communicate()[0].split("\n"))

opt/readies/paella/utils3.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11

22
import sys
3+
from subprocess import Popen, PIPE
34

45
def eprint(*args, **kwargs):
56
print(*args, file = sys.stderr, **kwargs)
7+
8+
def sh(cmd):
9+
return " ".join(Popen(cmd.split(), stdout=PIPE).communicate()[0].decode('utf-8').split("\n"))
10+

0 commit comments

Comments
 (0)