else:
print 'Error: Fail to find valid profile (Please refer print_list option)'
return 1
- build_gbs(profile, args.force_bootstrap, args.verbose)
+ if build_gbs(profile, args.force_bootstrap, args.verbose):
+ subprocess.call([sys.executable, os.path.join(SCRIPT_PATH, 'install_rpm')])
else:
print 'Error: Cannot found any hint for build profile.'
parser.print_help()
print 'Build : profile=' + profile + ' architecture=' + arch
command = ['gbs', '--conf', os.path.join(SCRIPT_PATH, 'gbs.conf'), 'build',
'-P', profile, '--include-all', '-A', arch, '--incremental']
- subprocess.call(command)
- return True
+ return True if subprocess.call(command) == 0 else False
def find_architecture(profile):
if profile.startswith('tztv'):
--- /dev/null
+#!/usr/bin/env python
+
+import argparse
+import glob
+import os
+import subprocess
+import sys
+
+def main():
+ parser = argparse.ArgumentParser(description=('Install Programmable Web Runtime RPM'))
+ parser.add_argument('-r', '--root', help='Specify GBS root path', default='~/GBS-ROOT*')
+ parser.add_argument('-f', '--file', help='Specify RPM file to install')
+ args = parser.parse_args()
+
+ rpm_file = args.file if args.file else find_rpm(args.root)
+ if not rpm_file:
+ print 'Error: Fail to find RPM file in %s.' % args.root
+ return 1
+ elif not os.path.isfile(rpm_file):
+ print 'Error: RPM file (%s) is not exist.' % rpm_file
+ return 1
+
+ print 'Install RPM file (%s)' % rpm_file
+ if not install_rpm(rpm_file):
+ print 'Error: Fail to install RPM file.'
+ return 1
+ print 'Installation is done.'
+ return 0
+
+def find_rpm(root_path):
+ root_path = os.path.abspath(os.path.expanduser(root_path))
+ rpm_path = os.path.join(root_path, 'local', 'repos', '*', '*', 'RPMS')
+ command = ['find'] + glob.glob(rpm_path) + ['-name', '*.rpm']
+ for ex in ['*debug*', '*devel*']:
+ command += ['-and', '!', '-name', ex]
+ try:
+ files = subprocess.check_output(command).strip().split('\n')
+ files.sort(key=os.path.getmtime, reverse=True)
+ return files[0]
+ except subprocess.CalledProcessError:
+ return None
+
+def install_rpm(rpm_file):
+ name = os.path.basename(rpm_file)
+ units = name.split('.')
+ package = units[0]
+ if '-' in package:
+ package, _ = package.rsplit('-', 1)
+ arch = units[-2]
+ target_option = '-d' if arch == 'armv7l' or arch == 'aarch64' else '-e'
+ try:
+ subprocess.check_call(['sdb', target_option, 'root', 'on'])
+ subprocess.check_call(['sdb', target_option, 'push', rpm_file, '/opt/usr'])
+ subprocess.check_call(['sdb', target_option, 'shell', 'mount', '-o', 'remount,rw', os.sep])
+ subprocess.call(['sdb', target_option, 'shell', 'rpm', '-e', package])
+ subprocess.check_call(['sdb', target_option, 'shell', 'rpm', '-Uh', '--force', '--nodeps',
+ os.path.join(os.sep, 'opt', 'usr', name)])
+ subprocess.call(['sdb', target_option, 'shell', 'tpk-backend', '--preload', '-y',
+ 'org.tizen.' + package]) # TODO : check needs
+ subprocess.call(['sdb', target_option, 'shell', 'reboot', '-f'])
+ except subprocess.CalledProcessError:
+ return False
+ return True
+
+if __name__ == '__main__':
+ sys.exit(main())