|
@@ -1,34 +1,59 @@
|
|
|
import os
|
|
|
from sys import argv
|
|
|
+from threading import Thread
|
|
|
+import apt
|
|
|
+
|
|
|
+OUTPUT = ''
|
|
|
+LOLCAT = False
|
|
|
+
|
|
|
+def check_lolcat():
|
|
|
+ global LOLCAT
|
|
|
+ LOLCAT = apt.Cache()['lolcat'].is_installed
|
|
|
+ if LOLCAT: print('lolcat detected!')
|
|
|
+def echo(text):
|
|
|
+ global OUTPUT
|
|
|
+ OUTPUT += text + '\n'
|
|
|
+def output_flush():
|
|
|
+ global OUTPUT
|
|
|
+ os.system(f"echo \"{OUTPUT[:-1]}\"{'| /usr/games/lolcat' if LOLCAT else ''}")
|
|
|
|
|
|
if os.getuid() != 0:
|
|
|
print('root rights required\nrun \'sudo python install.py\'')
|
|
|
exit(1)
|
|
|
path = 'src/ompl_src/'
|
|
|
+check_lolcat_thread = Thread(target=check_lolcat)
|
|
|
+check_lolcat_thread.start()
|
|
|
if 'r' in argv:
|
|
|
os.system(f'rm {path}obj/ -rf')
|
|
|
os.system(f'rm {path}lib/ -rf')
|
|
|
-print('building .c files to .o files')
|
|
|
-os.system(f'mkdir {path}obj/')
|
|
|
-os.system(f'mkdir {path}lib/')
|
|
|
+echo('building .c files to .o files')
|
|
|
+if not os.path.exists(f'{path}obj/'): os.system(f'mkdir {path}obj/')
|
|
|
+if not os.path.exists(f'{path}lib/'): os.system(f'mkdir {path}lib/')
|
|
|
name_ext = None
|
|
|
for f in os.listdir(f'{path}c'):
|
|
|
name_ext = os.path.splitext(f)
|
|
|
if name_ext[1] == '.c':
|
|
|
- print(f)
|
|
|
+ echo(f)
|
|
|
os.system(f'gcc -fPIC -c {path}c/{name_ext[0]}.c -o {path}obj/{name_ext[0]}.o')
|
|
|
-print('=' * 13)
|
|
|
-print('building .o files to .so libs')
|
|
|
+echo('=' * 13)
|
|
|
+echo('building .o files to .so libs')
|
|
|
for f in os.listdir(f'{path}obj'):
|
|
|
name_ext = os.path.splitext(f)[0]
|
|
|
- print(f)
|
|
|
+ echo(f)
|
|
|
os.system(f'gcc -shared {path}obj/{name_ext}.o -o {path}lib/{name_ext}.so')
|
|
|
-print('=' * 13)
|
|
|
-print('installing')
|
|
|
-print('copying src/main.py')
|
|
|
+echo('=' * 13)
|
|
|
+echo('installing')
|
|
|
+echo('copying src/main.py')
|
|
|
os.system(f'cp src/main.py /usr/bin/ompl')
|
|
|
os.system('chmod +x /usr/bin/ompl')
|
|
|
-print('copying src/ompl_src/')
|
|
|
+echo('copying src/ompl_src/')
|
|
|
os.system(f'cp src/ompl_src /usr/bin/ -r')
|
|
|
-print('=' * 13)
|
|
|
-print('done')
|
|
|
+echo('=' * 13)
|
|
|
+if 'c' in argv:
|
|
|
+ echo('cleaning')
|
|
|
+ echo('deleting lib/ and obj/ folders')
|
|
|
+ os.system('rm src/ompl_src/lib/ -r | rm src/ompl_src/obj/ -r')
|
|
|
+ echo('=' * 13)
|
|
|
+echo('done')
|
|
|
+check_lolcat_thread.join()
|
|
|
+output_flush()
|