Package br.com.objectos.rio.kdo.os

Source Code of br.com.objectos.rio.kdo.os.KdoOsPrepareEkernel

/*
* Copyright 2013 Objectos, Fábrica de Software LTDA.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package br.com.objectos.rio.kdo.os;

import java.io.File;

import br.com.objectos.rio.core.os.Chroot;
import br.com.objectos.rio.core.os.Mount;
import br.com.objectos.rio.core.os.Umount;
import br.com.objectos.way.base.io.Stdout;

/**
* @author marcio.endo@objectos.com.br (Marcio Endo)
*/
class KdoOsPrepareEkernel {

  private final KdoOsPrepareOptions options;

  public KdoOsPrepareEkernel(KdoOsPrepareOptions options) {
    this.options = options;
  }

  public void execute() {
    if (options.ekernel) {
      execute0();
    }
  }

  private void execute0() {
    File dir = options.getMountDir();

    Mount mount = Mount.at(dir).mount();

    try {
      tryToExecute();
    } finally {
      Umount umount = mount.umount();
      Stdout.print(umount);
    }
  }

  private void tryToExecute() {
    File dir = options.getMountDir();

    Chroot chroot = Chroot.at(dir)
        .add("source /etc/profile")
        .add("export PS1=\"(chroot) $PS1\"")
        .add("eselect profile set 4")
        .add("emerge -vu =gentoo-sources-3.10.17-gentoo")
        .add("eselect kernel set 1")
        .add("cd /usr/src/linux-3.10.17-gentoo")
        .add("make")
        .add("make modules_install")
        .add("cp arch/x86_64/boot/bzImage /boot/kernel-3.10.17-gentoo")
        .add("cp .config /boot/config-3.10.17-gentoo")
        .add("cp System.map /boot/System.map-3.10.17-gentoo")
        .exec();

    Stdout.print(chroot);
  }

}
TOP

Related Classes of br.com.objectos.rio.kdo.os.KdoOsPrepareEkernel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.