示例#1
0
 def test_chroot_generate_daemon_config(self):
     self.use_temp_dir()
     chroot = ClickChroot("i386", "ubuntu-sdk-14.04")
     os.makedirs(os.path.join(self.temp_dir, "usr", "sbin"))
     daemon_policy = chroot._generate_daemon_policy(self.temp_dir)
     with open(daemon_policy) as f:
         self.assertEqual(f.read(), chroot.DAEMON_POLICY)
示例#2
0
def exists(parser, args):
    chroot = ClickChroot(args.architecture, args.framework, name=args.name)
    # return shell exit codes 0 on success, 1 on failure
    if chroot.exists():
        return 0
    else:
        return 1
示例#3
0
def destroy(parser, args):
    requires_root(parser)
    # ask for confirmation?
    chroot = ClickChroot(args.architecture, args.framework, name=args.name)
    with message_on_error(ClickChrootDoesNotExistException,
                          ErrorMessages.NOT_EXISTS):
        return chroot.destroy()
    # if we reach this point there was a error so return exit_status 1
    return 1
示例#4
0
 def test_chroot_maint(self):
     chroot = ClickChroot("i386", "ubuntu-sdk-14.04")
     with mock.patch("subprocess.call") as mock_call:
         mock_call.return_value = 0
         chroot.maint("foo", "bar")
         mock_call.assert_called_with([
             "schroot", "-u", "root",
             "-c", "source:"+chroot.full_name,
             "--",
             "foo", "bar"])
示例#5
0
 def test_chroot_generate_apt_conf_d(self):
     self.use_temp_dir()
     chroot = ClickChroot("i386", "ubuntu-sdk-14.04")
     apt_conf_f = chroot._generate_apt_proxy_file(
         self.temp_dir, "http://proxy.example.com")
     with open(apt_conf_f) as f:
         self.assertEqual(
             re.sub(r'\s+', ' ', f.read()),
             '// proxy settings copied by click chroot '
             'Acquire { HTTP { Proxy "http://proxy.example.com"; }; }; ')
示例#6
0
def end_session(parser, args):
    chroot = ClickChroot(args.architecture,
                         args.framework,
                         name=args.name,
                         session=args.session)
    with message_on_error(ClickChrootDoesNotExistException,
                          ErrorMessages.NOT_EXISTS):
        return chroot.end_session()
    # if we reach this point there was a error so return exit_status 1
    return 1
示例#7
0
def execute(parser, args):
    program = args.program
    if not program:
        program = ["/bin/bash"]
    chroot = ClickChroot(args.architecture,
                         args.framework,
                         name=args.name,
                         session=args.session)
    with message_on_error(ClickChrootDoesNotExistException,
                          ErrorMessages.NOT_EXISTS):
        return chroot.run(*program)
    # if we reach this point there was a error so return exit_status 1
    return 1
示例#8
0
def create(parser, args):
    if not osextras.find_on_path("debootstrap"):
        parser.error(
            "debootstrap not installed and configured; install click-dev and "
            "debootstrap")
    requires_root(parser)
    chroot = ClickChroot(args.architecture,
                         args.framework,
                         name=args.name,
                         series=args.series)
    with message_on_error(ClickChrootAlreadyExistsException,
                          ErrorMessages.EXISTS):
        return chroot.create(args.keep_broken_chroot)
    # if we reach this point there was a error so return exit_status 1
    return 1
示例#9
0
 def test_gen_sources_native(self):
     chroot = ClickChroot("i386", "ubuntu-sdk-14.04", series="trusty")
     chroot.native_arch = "i386"
     sources = generate_sources(
         chroot.series, chroot.native_arch, chroot.target_arch,
         "http://archive.ubuntu.com/ubuntu",
         "http://ports.ubuntu.com/ubuntu-ports",
         "main")
     self.assertEqual([
         'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty main',
         'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-updates main',
         'deb [arch=i386] http://archive.ubuntu.com/ubuntu trusty-security main',
         'deb-src http://archive.ubuntu.com/ubuntu trusty main',
         'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
         'deb-src http://archive.ubuntu.com/ubuntu trusty-security main',
     ], sources)
示例#10
0
 def test_gen_sources_ports_only(self):
     chroot = ClickChroot("armhf", "ubuntu-sdk-13.10", series="trusty")
     chroot.native_arch = "armel"
     sources = generate_sources(
         chroot.series, chroot.native_arch, chroot.target_arch,
         "http://archive.ubuntu.com/ubuntu",
         "http://ports.ubuntu.com/ubuntu-ports",
         "main")
     self.assertEqual([
         'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty main',
         'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-updates main',
         'deb [arch=armhf] http://ports.ubuntu.com/ubuntu-ports trusty-security main',
         'deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports trusty main',
         'deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports trusty-updates main',
         'deb [arch=armel] http://ports.ubuntu.com/ubuntu-ports trusty-security main',
         'deb-src http://archive.ubuntu.com/ubuntu trusty main',
         'deb-src http://archive.ubuntu.com/ubuntu trusty-updates main',
         'deb-src http://archive.ubuntu.com/ubuntu trusty-security main',
     ], sources)
示例#11
0
 def test_chroot_generate_finish_script(self):
     self.use_temp_dir()
     chroot = ClickChroot("i386", "ubuntu-sdk-14.04")
     finish_script = chroot._generate_finish_script(
         self.temp_dir,
         ["build-pkg-1", "build-pkg-2"])
     with open(finish_script) as f:
         self.assertEqual(f.read(), dedent("""\
         #!/bin/bash
         set -e
         # Configure target arch
         dpkg --add-architecture i386
         # Reload package lists
         apt-get update || true
         # Pull down signature requirements
         apt-get -y --force-yes install gnupg ubuntu-keyring
         # Reload package lists
         apt-get update || true
         # Disable debconf questions
         # so that automated builds won't prompt
         echo set debconf/frontend Noninteractive | debconf-communicate
         echo set debconf/priority critical | debconf-communicate
         apt-get -y --force-yes dist-upgrade
         # Install basic build tool set to match buildd
         apt-get -y --force-yes install build-pkg-1 build-pkg-2
         # Set up expected /dev entries
         if [ ! -r /dev/stdin ];  then
             ln -s /proc/self/fd/0 /dev/stdin
         fi
         if [ ! -r /dev/stdout ]; then
             ln -s /proc/self/fd/1 /dev/stdout
         fi
         if [ ! -r /dev/stderr ]; then
             ln -s /proc/self/fd/2 /dev/stderr
         fi
         # Clean up
         rm /finish.sh
         apt-get clean
         """))
示例#12
0
 def test_chroot_generate_apt_conf_d_empty(self):
     self.use_temp_dir()
     chroot = ClickChroot("i386", "ubuntu-sdk-14.04")
     apt_conf_f = chroot._generate_apt_proxy_file(self.temp_dir, "")
     self.assertFalse(os.path.exists(apt_conf_f))
示例#13
0
 def test_chroot_full_name(self):
     chroot = ClickChroot("i386", "ubuntu-sdk-14.04")
     self.assertEqual(chroot.full_name, "click-ubuntu-sdk-14.04-i386")
示例#14
0
 def test_framework_base_series(self):
     chroot = ClickChroot("i386", "ubuntu-sdk-14.04")
     self.assertEqual(chroot.framework_base, "ubuntu-sdk-14.04")
示例#15
0
 def test_make_cross_package_cross(self):
     chroot = ClickChroot("armhf", "ubuntu-sdk-14.04", series="trusty")
     chroot.native_arch = "amd64"
     self.assertEqual(
         "g++-arm-linux-gnueabihf", chroot._make_cross_package("g++"))
示例#16
0
 def test_get_native_arch_amd64_to_i386(self):
     chroot = ClickChroot("i386", "ubuntu-sdk-14.04", series="trusty")
     self.assertEqual("i386", chroot._get_native_arch("amd64", "i386"))
示例#17
0
 def test_dpkg_architecture_i386_to_armhf(self):
     self.set_dpkg_native_architecture("i386")
     chroot = ClickChroot("armhf", "ubuntu-sdk-14.04", series="trusty")
     self.assertEqual("i386", chroot.dpkg_architecture["DEB_BUILD_ARCH"])
     self.assertEqual("armhf", chroot.dpkg_architecture["DEB_HOST_ARCH"])
示例#18
0
 def test_chroot_series(self):
     chroot = ClickChroot("i386", "ubuntu-sdk-14.04")
     self.assertEqual(chroot.series, "trusty")