7 from subprocess import Popen
8 from subprocess import PIPE
13 log = logging.getLogger(__name__)
14 #log = logging.getLogger()
15 log.setLevel(logging.INFO)
17 def get_ceph_binary_url(package=None,
18 branch=None, tag=None, sha1=None, dist=None,
19 flavor=None, format=None, arch=None):
20 BASE = 'http://gitbuilder.ceph.com/{package}-{format}-{dist}-{arch}-{flavor}/'.format(
28 log.info('BASE: %s' % (BASE))
30 assert branch is None, "cannot set both sha1 and branch"
31 assert tag is None, "cannot set both sha1 and tag"
33 # gitbuilder uses remote-style ref names for branches, mangled to
34 # have underscores instead of slashes; e.g. origin_master
37 assert branch is None, "cannot set both branch and tag"
43 sha1_url = urlparse.urljoin(BASE, 'ref/{ref}/sha1'.format(ref=ref))
44 log.info('sha1_url: %s' % (sha1_url))
45 log.info('Translating ref to sha1 using url %s', sha1_url)
46 sha1_fp = urllib2.urlopen(sha1_url)
47 sha1 = sha1_fp.read().rstrip('\n')
50 log.debug('Using %s %s sha1 %s', package, format, sha1)
51 bindir_url = urlparse.urljoin(BASE, 'sha1/{sha1}/'.format(sha1=sha1))
52 log.info('sha1: %s bindir_url: %s' % (sha1, bindir_url))
53 return (sha1, bindir_url)
63 sha1,bindir_url = get_ceph_binary_url(package, branch,None,None,dist,flavor,format,arch)
64 log.info('sha1: %s bindir_url: %s' % (sha1, bindir_url))
67 'install', '-d', '-m0755', '--', '/tmp/hadooptest/binary'],
70 'uname', '-m',], stdin=p1.stdout, stdout=PIPE)
72 'sed', '-e', 's/^/ceph./; s/$/.tgz/',], stdin=p2.stdout, stdout=PIPE)
77 '--base={url}'.format(url=bindir_url),
78 # need to use --input-file to make wget respect --base
79 '--input-file=-',], stdin=p3.stdout, stdout=PIPE)
81 'tar', '-xzf', '-', '-C', '/tmp/hadooptest/binary',],
82 stdin=p4.stdout,stdout=PIPE)
85 log.info('copying libcephfs*.so to lib/')
88 'install', '-d', '-m0755', '--', 'lib'],
91 soFiles = glob.glob('/tmp/hadooptest/binary/usr/local/lib/libcephfs*.so')
92 for libFile in soFiles:
93 #log.info('soFile: %s' % libFile)
95 'cp', libFile, 'lib/'])
98 log.info('copying jars to lib/')
100 jarFiles = glob.glob('/tmp/hadooptest/binary/usr/local/share/java/*.jar')
101 for jarFile in jarFiles:
102 #log.info('soFile: %s' % libFile)
104 'cp', jarFile, 'lib/'])
107 if __name__ == "__main__":