示例#1
0
func setUtilNewPaths(i *image, u *Utils) error {
	dir, err := utils.UploadBinaries(i.client.Config.Common, u.Kpartx)
	if err != nil {
		return utils.FormatError(err)
	}
	i.utils = new(Utils)
	i.utils.Kpartx = filepath.Join(dir, filepath.Base(u.Kpartx))
	i.utils.dir = dir
	return nil
}
示例#2
0
func prepareFunc(c *Collector, sshconf *ssh.Config, lshwpath string) func() (string, error) {
	return func() (string, error) {
		if lshwpath == "" {
			out, err := c.Run("which lshw")
			if err != nil {
				return "", utils.FormatError(fmt.Errorf("%s [%v]", out, err))
			}
			return out, nil
		}
		if sshconf != nil {
			dir, err := utils.UploadBinaries(sshconf, lshwpath)
			if err != nil {
				return "", utils.FormatError(err)
			}
			return filepath.Join(dir, filepath.Base(lshwpath)), nil
		}
		return lshwpath, nil
	}
}