Skip to content

Commit 62b9480

Browse files
chery-pick fix: check before copying cfg.SrpmsDir (#16447) (#16456)
Co-authored-by: Pawel Winogrodzki <pawelwi@microsoft.com>
1 parent ab3490a commit 62b9480

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

toolkit/tools/pkg/specreaderutils/specreaderutil.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,18 @@ func CreateChroot(chrootName, workerTar, buildDir, specsDir string, opts ...Chro
188188

189189
// If this is not a regular build then copy in all of the SPECs since there are no bind mounts.
190190
if !buildpipeline.IsRegularBuild() {
191-
dirsToCopy := []string{specsDir, cfg.SrpmsDir}
191+
dirsToCopy := []string{specsDir}
192+
if cfg.SrpmsDir != "" {
193+
dirsToCopy = append(dirsToCopy, cfg.SrpmsDir)
194+
}
192195
for _, dir := range dirsToCopy {
193196
dirInChroot := filepath.Join(chroot.RootDir(), dir)
194197
err = directory.CopyContents(dir, dirInChroot)
195198
if err != nil {
199+
logger.Log.Errorf("Failed to copy directory (%s) into chroot at (%s): %s", dir, dirInChroot, err)
196200
closeErr := chroot.Close(leaveFilesOnDisk)
197201
if closeErr != nil {
198-
logger.Log.Errorf("Failed to close chroot, err: %s", err)
202+
logger.Log.Errorf("Failed to close chroot, err: %s", closeErr)
199203
}
200204
return
201205
}

0 commit comments

Comments
 (0)