1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
// Copyright (c) 2018-2023, Sylabs Inc. All rights reserved.
// This software is licensed under a 3-clause BSD license. Please consult the
// LICENSE.md file distributed with the sources of this project regarding your
// rights to use or distribute this software.
package sources
import (
"context"
"fmt"
"github.com/sylabs/singularity/v4/pkg/build/types"
"github.com/sylabs/singularity/v4/pkg/sylog"
"github.com/sylabs/singularity/v4/pkg/util/archive"
)
// SandboxPacker holds the locations of where to pack from and to
// Ext3Packer holds the locations of where to back from and to, as well as image offset info
type SandboxPacker struct {
srcdir string
b *types.Bundle
}
// Pack puts relevant objects in a Bundle!
func (p *SandboxPacker) Pack(context.Context) (*types.Bundle, error) {
rootfs := p.srcdir
// copy filesystem into bundle rootfs
sylog.Debugf("Copying file system from %s to %s in Bundle\n", rootfs, p.b.RootfsPath)
err := archive.CopyWithTar(rootfs+`/.`, p.b.RootfsPath, false)
if err != nil {
return nil, fmt.Errorf("copy Failed: %v", err)
}
return p.b, nil
}
|