From: Waldemar Kozaczuk <jwkozac...@gmail.com>
Committer: Waldemar Kozaczuk <jwkozac...@gmail.com>
Branch: master

externals: enhance setup.py to download aarch64 gcc and boost code and libraries

References #743

Signed-off-by: Waldemar Kozaczuk <jwkozac...@gmail.com>

---
diff --git a/.gitignore b/.gitignore
--- a/.gitignore
+++ b/.gitignore
@@ -49,3 +49,4 @@ modules/libyaml/usr.manifest
 modules/dl_tests/usr.manifest
 .idea
 compile_commands.json
+downloaded_packages
diff --git a/scripts/setup.py b/scripts/setup.py
--- a/scripts/setup.py
+++ b/scripts/setup.py
@@ -3,7 +3,7 @@
 # set up a development environment for OSv.  Run as root.
 
 import sys, argparse
-import subprocess
+import subprocess, os
 
 standard_ec2_packages = ['python-pip', 'wget']
 standard_ec2_post_install = ['pip install awscli &&'
@@ -64,6 +64,40 @@ class Fedora(object):
     test_packages = ['openssl-devel']
     ec2_post_install = standard_ec2_post_install
 
+    def aarch64_download(self, version):
+        gcc_packages = ['gcc',
+                        'glibc',
+                        'glibc-devel',
+                        'libgcc',
+                        'libstdc++',
+                        'libstdc++-devel',
+                        'libstdc++-static']
+        boost_packages = ['boost-devel',
+                          'boost-static',
+                          'boost-system']
+        osv_root = os.path.join(os.path.dirname(os.path.abspath(__file__)), 
'..')
+        script_path = '%s/scripts/download_rpm_package.sh' % osv_root
+        destination = '%s/downloaded_packages/aarch64' % osv_root
+        ##
+        # The setup.py is typically run as root to allow yum properly install 
packages
+        # This however would cause all files downloaded to 
downloaded_packages/aarch64 directory
+        # get created and owned by the root user which in most cases is not 
desirable
+        # To prevent that let us compare current process user id with the 
owner id of osv root
+        # directory and if different run all download command with the same 
user as the one owning
+        # the root directory
+        current_user_id = os.getuid()
+        osv_root_owner_id = os.stat(osv_root).st_uid
+        if current_user_id != osv_root_owner_id and current_user_id == 0:
+            command_prefix = "sudo -u '#%d'" % osv_root_owner_id # Most likely 
setup.py is run by root so let us use sudo
+        else:
+            command_prefix = ''
+
+        install_commands = ['%s %s %s %s %s/gcc' % (command_prefix, 
script_path, package, version, destination) for package in gcc_packages]
+        install_commands += ['%s %s %s %s %s/boost' % (command_prefix, 
script_path, package, version, destination) for package in boost_packages]
+        install_commands = ['%s rm -rf %s/gcc/install' % (command_prefix, 
destination),
+                            '%s rm -rf %s/boost/install' % (command_prefix, 
destination)] + install_commands
+        return ' && '.join(install_commands)
+
     class Fedora_25(object):
         packages = ['java-1.8.0-openjdk', 'python2-requests', 'openssl-devel', 
'lua-5.3.*', 'lua-devel-5.3.*']
         ec2_packages = []
@@ -361,6 +395,10 @@ def parse_file(f):
                 if cmdargs.test:
                     pkg += distro.test_packages + dver.test_packages
                 subprocess.check_call(distro.install + ' ' + str.join(' ', 
pkg), shell=True)
+                if 'aarch64_download' in dir(distro):
+                    print('Downloading aarch64 packages to cross-compile ARM 
version ...')
+                    
subprocess.check_call(distro.aarch64_download(dver.version), shell=True)
+                    print('Downloaded all aarch64 packages!')
                 if cmdargs.ec2:
                     if distro.ec2_post_install:
                         subprocess.check_call(distro.ec2_post_install, 
shell=True)

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/00000000000059fa59059fc3cb7d%40google.com.

Reply via email to