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

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

/*
* 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 KdoOsPrepareEworld {

  private final KdoOsPrepareOptions options;

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

  public void execute() {
    if (options.eworld) {
      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("emerge -vuDN world")
        .add("quickpkg \"*/*\"")
        .exec();

    Stdout.print(chroot);
  }

}
TOP

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

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.