Browse Source

fix chroot setup due to various upstream bugs

* Ubuntu Precise failed to bootstrap, workaround used as per [1]
* CentOS 7 intermittently failed due to [2], use default mirror instead
* Install deltarpm to speed up updates on CentOS 7
* Mount /proc and /sys when doing initial setup in all chroot environments

[1] https://bugs.launchpad.net/ubuntu/+source/procps/+bug/602896/comments/17
[2] https://bugzilla.redhat.com/show_bug.cgi?id=1099101
Ashish Kulkarni 10 years ago
parent
commit
a364164885
1 changed files with 11 additions and 5 deletions
  1. 11 5
      scripts/build.py

+ 11 - 5
scripts/build.py

@@ -294,6 +294,8 @@ deb http://archive.ubuntu.com/ubuntu/ trusty-security main restricted universe m
 
 
     'precise': [
     'precise': [
         ('debootstrap', 'precise', 'http://archive.ubuntu.com/ubuntu/'),
         ('debootstrap', 'precise', 'http://archive.ubuntu.com/ubuntu/'),
+        ('write_file', 'usr/sbin/policy-rc.d', "#!/bin/bash\nexit 101\n"),
+        ('shell', 'chmod a+x /usr/sbin/policy-rc.d'),
         ('write_file', 'etc/apt/sources.list', """
         ('write_file', 'etc/apt/sources.list', """
 deb http://archive.ubuntu.com/ubuntu/ precise          main restricted universe multiverse
 deb http://archive.ubuntu.com/ubuntu/ precise          main restricted universe multiverse
 deb http://archive.ubuntu.com/ubuntu/ precise-updates  main restricted universe multiverse
 deb http://archive.ubuntu.com/ubuntu/ precise-updates  main restricted universe multiverse
@@ -337,6 +339,9 @@ deb http://archive.ubuntu.com/ubuntu/ precise-security main restricted universe
 
 
     'centos7:amd64': [
     'centos7:amd64': [
         ('rinse', 'centos-7'),
         ('rinse', 'centos-7'),
+        ('shell', 'yum install -y deltarpm'),
+        ('shell', "sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Base.repo"),
+        ('shell', "sed -i 's/#baseurl/baseurl/g' /etc/yum.repos.d/CentOS-Base.repo"),
         ('shell', 'yum update -y'),
         ('shell', 'yum update -y'),
         ('append_file', 'etc/yum.conf', 'exclude = *.i?86\n'),
         ('append_file', 'etc/yum.conf', 'exclude = *.i?86\n'),
         ('shell', 'yum install -y gcc gcc-c++ make diffutils perl ruby-devel rubygems rpm-build libffi-devel'),
         ('shell', 'yum install -y gcc gcc-c++ make diffutils perl ruby-devel rubygems rpm-build libffi-devel'),
@@ -756,9 +761,10 @@ def build_setup_schroot(config, basedir):
 
 
     for arch in ARCH:
     for arch in ARCH:
         message('******************* %s-%s\n' % (chroot, arch))
         message('******************* %s-%s\n' % (chroot, arch))
-        unmount  = False
         base_dir = os.environ.get('WKHTMLTOX_CHROOT') or '/var/chroot'
         base_dir = os.environ.get('WKHTMLTOX_CHROOT') or '/var/chroot'
         root_dir = os.path.join(base_dir, 'wkhtmltopdf-%s-%s' % (chroot, arch))
         root_dir = os.path.join(base_dir, 'wkhtmltopdf-%s-%s' % (chroot, arch))
+        os.system('umount %s/proc' % root_dir)
+        os.system('umount %s/sys'  % root_dir)
         rmdir(root_dir)
         rmdir(root_dir)
         mkdir_p(root_dir)
         mkdir_p(root_dir)
         for command in command_list:
         for command in command_list:
@@ -777,10 +783,11 @@ def build_setup_schroot(config, basedir):
                 cmd = (arch == 'i386' and 'linux32 chroot' or 'chroot')
                 cmd = (arch == 'i386' and 'linux32 chroot' or 'chroot')
                 shell('%s %s mount -t proc  proc  /proc' % (cmd, root_dir))
                 shell('%s %s mount -t proc  proc  /proc' % (cmd, root_dir))
                 shell('%s %s mount -t sysfs sysfs /sys'  % (cmd, root_dir))
                 shell('%s %s mount -t sysfs sysfs /sys'  % (cmd, root_dir))
-                unmount = True
             elif name == 'rinse':
             elif name == 'rinse':
                 cmd = (arch == 'i386' and 'linux32 rinse' or 'rinse')
                 cmd = (arch == 'i386' and 'linux32 rinse' or 'rinse')
                 shell('%s --arch %s --distribution %s --directory %s' % (cmd, arch, command[1], root_dir))
                 shell('%s --arch %s --distribution %s --directory %s' % (cmd, arch, command[1], root_dir))
+                shell('%s %s mount -t proc  proc  /proc' % (cmd, root_dir))
+                shell('%s %s mount -t sysfs sysfs /sys'  % (cmd, root_dir))
             elif name == 'shell':
             elif name == 'shell':
                 cmd = (arch == 'i386' and 'linux32 chroot' or 'chroot')
                 cmd = (arch == 'i386' and 'linux32 chroot' or 'chroot')
                 shell('%s %s %s' % (cmd, root_dir, command[1]))
                 shell('%s %s %s' % (cmd, root_dir, command[1]))
@@ -812,9 +819,8 @@ def build_setup_schroot(config, basedir):
                 if arch == 'i386' and 'amd64' in ARCH:
                 if arch == 'i386' and 'amd64' in ARCH:
                     cfg.write('personality=linux32\n')
                     cfg.write('personality=linux32\n')
                 cfg.close()
                 cfg.close()
-        if unmount:
-            shell('umount %s/proc' % root_dir)
-            shell('umount %s/sys'  % root_dir)
+        os.system('umount %s/proc' % root_dir)
+        os.system('umount %s/sys'  % root_dir)
 
 
 def check_update_schroot(config):
 def check_update_schroot(config):
     check_running_on_debian()
     check_running_on_debian()