Ejemplo n.º 1
0
func (cnt *Img) copyConfd() {
	if err := os.MkdirAll(cnt.rootfs+"/etc/prestart/", 0755); err != nil {
		log.Get().Panic(err)
	}
	utils.CopyDir(cnt.path+CONFD_CONFIG, cnt.rootfs+"/etc/prestart/conf.d")
	utils.CopyDir(cnt.path+CONFD_TEMPLATE, cnt.rootfs+"/etc/prestart/templates")
}
Ejemplo n.º 2
0
func (cnt *Img) copyRunlevelsPrestart() {
	if err := os.MkdirAll(cnt.rootfs+"/etc/prestart/late-prestart.d", 0755); err != nil {
		log.Get().Panic(err)
	}
	if err := os.MkdirAll(cnt.rootfs+"/etc/prestart/early-prestart.d", 0755); err != nil {
		log.Get().Panic(err)
	}
	utils.CopyDir(cnt.path+RUNLEVELS_PRESTART, cnt.rootfs+"/etc/prestart/early-prestart.d")
	utils.CopyDir(cnt.path+RUNLEVELS_LATESTART, cnt.rootfs+"/etc/prestart/late-prestart.d")
}
Ejemplo n.º 3
0
func (aci *Aci) copyRunlevelsScripts() {
	logs.WithF(aci.fields).Debug("Copy Runlevels scripts")
	utils.CopyDir(aci.path+PATH_RUNLEVELS+PATH_BUILD, aci.target+PATH_RUNLEVELS+PATH_BUILD)
	utils.CopyDir(aci.path+PATH_RUNLEVELS+PATH_BUILD_LATE, aci.target+PATH_RUNLEVELS+PATH_BUILD_LATE)
	utils.CopyDir(aci.path+PATH_RUNLEVELS+PATH_BUILD_SETUP, aci.target+PATH_RUNLEVELS+PATH_BUILD_SETUP)
	utils.CopyDir(aci.path+PATH_RUNLEVELS+PATH_PRESTART_EARLY, aci.target+PATH_RUNLEVELS+PATH_PRESTART_EARLY)
	utils.CopyDir(aci.path+PATH_RUNLEVELS+PATH_PRESTART_LATE, aci.target+PATH_RUNLEVELS+PATH_PRESTART_LATE)

	utils.CopyDir(aci.path+PATH_RUNLEVELS+PATH_PRESTART_EARLY, aci.target+PATH_ROOTFS+PATH_CNT+PATH_RUNLEVELS+PATH_PRESTART_EARLY)
	utils.CopyDir(aci.path+PATH_RUNLEVELS+PATH_PRESTART_LATE, aci.target+PATH_ROOTFS+PATH_CNT+PATH_RUNLEVELS+PATH_PRESTART_LATE)
	utils.CopyDir(aci.path+PATH_RUNLEVELS+PATH_INHERIT_BUILD_EARLY, aci.target+PATH_ROOTFS+PATH_CNT+PATH_RUNLEVELS+PATH_INHERIT_BUILD_EARLY)
	utils.CopyDir(aci.path+PATH_RUNLEVELS+PATH_INHERIT_BUILD_LATE, aci.target+PATH_ROOTFS+PATH_CNT+PATH_RUNLEVELS+PATH_INHERIT_BUILD_LATE)
}
Ejemplo n.º 4
0
func (cnt *Img) copyRunlevelsScripts() {
	log.Info("Copy Runlevels scripts")
	utils.CopyDir(cnt.path+PATH_RUNLEVELS+PATH_BUILD, cnt.target+PATH_RUNLEVELS+PATH_BUILD)
	utils.CopyDir(cnt.path+PATH_RUNLEVELS+PATH_BUILD_LATE, cnt.target+PATH_RUNLEVELS+PATH_BUILD_LATE)
	utils.CopyDir(cnt.path+PATH_RUNLEVELS+PATH_BUILD_SETUP, cnt.target+PATH_RUNLEVELS+PATH_BUILD_SETUP)
	utils.CopyDir(cnt.path+PATH_RUNLEVELS+PATH_PRESTART_EARLY, cnt.target+PATH_RUNLEVELS+PATH_PRESTART_EARLY)
	utils.CopyDir(cnt.path+PATH_RUNLEVELS+PATH_PRESTART_LATE, cnt.target+PATH_RUNLEVELS+PATH_PRESTART_LATE)

	utils.CopyDir(cnt.path+PATH_RUNLEVELS+PATH_PRESTART_EARLY, cnt.target+PATH_ROOTFS+PATH_CNT+PATH_RUNLEVELS+PATH_PRESTART_EARLY)
	utils.CopyDir(cnt.path+PATH_RUNLEVELS+PATH_PRESTART_LATE, cnt.target+PATH_ROOTFS+PATH_CNT+PATH_RUNLEVELS+PATH_PRESTART_LATE)
	utils.CopyDir(cnt.path+PATH_RUNLEVELS+PATH_INHERIT_BUILD_EARLY, cnt.target+PATH_ROOTFS+PATH_CNT+PATH_RUNLEVELS+PATH_INHERIT_BUILD_EARLY)
	utils.CopyDir(cnt.path+PATH_RUNLEVELS+PATH_INHERIT_BUILD_LATE, cnt.target+PATH_ROOTFS+PATH_CNT+PATH_RUNLEVELS+PATH_INHERIT_BUILD_LATE)
}
Ejemplo n.º 5
0
func (cnt *Img) prepareTestAci() (*Img, error) {
	files, err := ioutil.ReadDir(cnt.path + PATH_TESTS)
	if err != nil {
		return nil, err
	}

	utils.CopyDir(cnt.path+PATH_TESTS+PATH_FILES, cnt.target+PATH_TESTS+PATH_FILES)
	utils.CopyDir(cnt.path+PATH_TESTS+PATH_ATTRIBUTES, cnt.target+PATH_TESTS+PATH_ATTRIBUTES)
	utils.CopyDir(cnt.path+PATH_TESTS+PATH_CONFD, cnt.target+PATH_TESTS+PATH_CONFD)
	utils.CopyDir(cnt.path+PATH_TESTS+PATH_RUNLEVELS, cnt.target+PATH_TESTS+PATH_RUNLEVELS)

	os.MkdirAll(cnt.target+PATH_TESTS+PATH_FILES+PATH_TESTS, 0777)
	for _, f := range files {
		if !f.IsDir() {
			if err := utils.CopyFile(cnt.path+PATH_TESTS+"/"+f.Name(), cnt.target+PATH_TESTS+PATH_FILES+PATH_TESTS+"/"+f.Name()); err != nil {
				panic(err)
			}
		}
	}

	ExecScript := strings.Replace(TEST_INIT_SCRIPT, "%%COMMAND%%", "'"+strings.Join(cnt.manifest.Aci.App.Exec, "' '")+"'", 1)
	ExecScript = strings.Replace(ExecScript, "%%CWD%%", "'"+cnt.manifest.Aci.App.WorkingDirectory+"'", 2)

	ioutil.WriteFile(cnt.target+PATH_TESTS+PATH_FILES+"/init.sh", []byte(ExecScript), 0777)

	fullname, err := spec.NewACFullName(cnt.manifest.NameAndVersion.Name() + "_test:" + cnt.manifest.NameAndVersion.Version())
	if err != nil {
		panic(err)
	}

	resultMountName, _ := types.NewACName("result")
	testAci, err := NewAciWithManifest(cnt.target+PATH_TESTS, cnt.args, spec.AciManifest{
		Aci: spec.AciDefinition{
			App: &spec.CntApp{
				Exec:        []string{"/init.sh"},
				MountPoints: []types.MountPoint{{Path: PATH_RESULT, Name: *resultMountName}},
			},
			Dependencies: []spec.ACFullname{BATS_ACI, cnt.manifest.NameAndVersion},
		},
		NameAndVersion: *fullname,
	}, nil)
	if err != nil {
		panic("Cannot build test aci" + err.Error())
	}
	return testAci, nil
}
Ejemplo n.º 6
0
func (aci *Aci) copyFiles() {
	utils.CopyDir(aci.path+PATH_FILES, aci.rootfs)
}
Ejemplo n.º 7
0
func (aci *Aci) copyConfd() {
	utils.CopyDir(aci.path+PATH_CONFD+PATH_CONFDOTD, aci.rootfs+PATH_CNT+PATH_CONFDOTD)
	utils.CopyDir(aci.path+PATH_CONFD+PATH_TEMPLATES, aci.rootfs+PATH_CNT+PATH_TEMPLATES)
}
Ejemplo n.º 8
0
func (cnt *Img) copyAttributes() {
	utils.CopyDir(cnt.path+PATH_ATTRIBUTES, cnt.rootfs+PATH_CNT+PATH_ATTRIBUTES+"/"+cnt.manifest.NameAndVersion.ShortName())
}
Ejemplo n.º 9
0
func (cnt *Img) copyFiles() {
	utils.CopyDir(cnt.path+PATH_FILES, cnt.rootfs)
}
Ejemplo n.º 10
0
func (cnt *Img) copyConfd() {
	utils.CopyDir(cnt.path+PATH_CONFD+PATH_CONFDOTD, cnt.rootfs+PATH_CNT+PATH_CONFDOTD)
	utils.CopyDir(cnt.path+PATH_CONFD+PATH_TEMPLATES, cnt.rootfs+PATH_CNT+PATH_TEMPLATES)
}
Ejemplo n.º 11
0
func (cnt *Img) copyAttributes() {
	if err := os.MkdirAll(cnt.rootfs+"/etc/prestart/attributes/"+cnt.manifest.NameAndVersion.ShortName(), 0755); err != nil {
		log.Get().Panic(err)
	}
	utils.CopyDir(cnt.path+ATTRIBUTES, cnt.rootfs+"/etc/prestart/attributes/"+cnt.manifest.NameAndVersion.ShortName())
}
Ejemplo n.º 12
0
func (cnt *Img) copyRunlevelsScripts() {
	if err := os.MkdirAll(cnt.target+RUNLEVELS, 0755); err != nil {
		log.Get().Panic(err)
	}
	utils.CopyDir(cnt.path+RUNLEVELS, cnt.target+RUNLEVELS)
}