Ejemplo n.º 1
0
 def init_maybe(self, img_path, args, env):
     if (not self.needs_inject(args)):
         ch.VERBOSE("workarounds: init: instruction doesn't need injection")
         return
     if (self.init_done):
         ch.VERBOSE("workarounds: init: already initialized")
         return
     for (i, (test_cmd, init_cmd)) in enumerate(self.init, 1):
         ch.INFO("workarounds: init step %s: checking: $ %s" %
                 (i, test_cmd))
         args = ["/bin/sh", "-c", test_cmd]
         exit_code = ch.ch_run_modify(img_path, args, env, fail_ok=True)
         if (exit_code == 0):
             ch.INFO(
                 "workarounds: init step %d: exit code %d, step not needed"
                 % (i, exit_code))
         else:
             if (not self.inject_p):
                 ch.INFO("workarounds: init step %d: no --force, skipping" %
                         i)
             else:
                 ch.INFO("workarounds: init step %d: $ %s" % (i, init_cmd))
                 args = ["/bin/sh", "-c", init_cmd]
                 ch.ch_run_modify(img_path, args, env)
     self.init_done = True
Ejemplo n.º 2
0
def inject_first(img, env):
    c = config(img)
    if (c is None):
        return
    if (os.path.exists("%s/ch/fakeroot-first-run")):
        ch.DEBUG("fakeroot: already initialized")
        return
    ch.INFO("fakeroot: initializing for %s" % c["name"])
    for cl in c["first"]:
        ch.INFO("fakeroot: $ %s" % cl)
        args = ["/bin/sh", "-c", cl]
        ch.ch_run_modify(img, args, env)
Ejemplo n.º 3
0
 def execute_(self):
     rootfs = images[image_i].unpack_path
     fakeroot_config.init_maybe(rootfs, self.cmd, env.env_build)
     cmd = fakeroot_config.inject_run(self.cmd)
     exit_code = ch.ch_run_modify(rootfs,
                                  cmd,
                                  env.env_build,
                                  env.workdir,
                                  cli.bind,
                                  fail_ok=True)
     if (exit_code != 0):
         msg = "build failed: RUN command exited with %d" % exit_code
         if (cli.force):
             if (isinstance(fakeroot_config, fakeroot.Fakeroot_Noop)):
                 ch.FATAL(
                     msg, "--force specified, but no suitable config found")
             else:
                 ch.FATAL(
                     msg)  # --force inited OK but the build still failed
         elif (not cli.no_force_detect):
             if (fakeroot_config.init_done):
                 ch.FATAL(msg, "--force may fix it")
             else:
                 ch.FATAL(msg, "current version of --force wouldn't help")
         assert False, "unreachable code reached"
Ejemplo n.º 4
0
 def execute_(self):
    rootfs = images[image_i].unpack_path
    ch.ch_run_modify(rootfs, self.cmd, env.env_build, env.workdir)