// InstallApp is responsible for application installation func (f *rootfsFiller) InstallApp(pathToRootfsMp string) error { if err := archutils.Extract(f.pathToApplArchive, filepath.Join(pathToRootfsMp, "mnt/cf")); err != nil { return utils.FormatError(err) } if f.extractApplImage { return extractApplImage(pathToRootfsMp) } return nil }
func main() { ui := dialog_ui.NewDialogUi() ui.Shadow(false) ui.SetCancelLabel("Exit") gui.UiValidateUser(ui, 0) gui.UiWelcomeMsg(ui, defaultProductName) gui.UiEulaMsg(ui, filepath.Join(rootDir, ".EULA")) data := &deployer.CommonData{ RootDir: rootDir, RootfsMp: filepath.Join(rootDir, "rootfs_mnt"), DefaultExportDir: rootDir, VaName: defaultProductName, Arch: arch, Ui: ui, } if err := archutils.Extract(filepath.Join(rootDir, "comp/env.tgz"), filepath.Join(rootDir, "comp")); err != nil { ui.Output(dialog_ui.Error, err.Error()) } gui.UiDeploymentResult(ui, data.VaName+" installation completed successfully", gui.UiSelectEnv(data, []string{"Libvirt(KVM)", "OpenXen"}, []deployer.FlowCreator{new(libvirt_kvm.FlowCreator), new(openxen.FlowCreator)})) }
func (f *rootfsFiller) CustomizeRootfs(pathToRootfsMp string) error { unsquashfs, err := exec.LookPath("unsquashfs") if err != nil { unsquashfs = filepath.Join(f.pathToKitDir, "install/x86_64/bin/unsquashfs") } path := filepath.Join(pathToRootfsMp, "rootfs") exec.Command(unsquashfs, "-dest", path, f.pathToRootfsSquashfs).Run() dir, err := ioutil.ReadDir(path) if err != nil { return utils.FormatError(err) } for _, cont := range dir { exec.Command("cp", "-a", filepath.Join(path, cont.Name()), pathToRootfsMp).CombinedOutput() } if err := os.RemoveAll(path); err != nil { return utils.FormatError(err) } if f.pathToKernelModulesArchive != "" && f.pathToKernelArchive != "" { errCh := make(chan error, 2) defer close(errCh) go func() { errCh <- archutils.Extract(f.pathToKernelArchive, filepath.Join(pathToRootfsMp, "boot")) }() go func() { errCh <- archutils.Extract(f.pathToKernelModulesArchive, filepath.Join(pathToRootfsMp, "lib/modules")) }() if err := utils.WaitForResult(errCh, 2); err != nil { if !strings.Contains(err.Error(), ERROR_SKIP_B) { return utils.FormatError(err) } } modulesDir, err := filepath.Glob(filepath.Join(pathToRootfsMp, "lib/modules/*")) if err != nil { return utils.FormatError(err) } if len(modulesDir) == 0 { return errors.New("modules not found") } kernelVersion := filepath.Base(modulesDir[0]) if err := os.Symlink("/boot/vmlinuz-"+kernelVersion, filepath.Join(pathToRootfsMp, "vmlinuz")); err != nil { return utils.FormatError(err) } if err := os.Symlink("/boot/initrd.img-"+kernelVersion, filepath.Join(pathToRootfsMp, "initrd.img")); err != nil { return utils.FormatError(err) } } pathToCommonDir := filepath.Join(f.pathToKitDir, "comp/env/common/config") fd, err := os.Stat(pathToCommonDir) if err == nil && fd.IsDir() { if err := content.Customize(pathToRootfsMp, pathToCommonDir); err != nil { return utils.FormatError(err) } } if f.pathToConfigDir != "" { if err := content.Customize(pathToRootfsMp, f.pathToConfigDir); err != nil { return utils.FormatError(err) } } return nil }