Skip to content

Commit ed8be10

Browse files
committed
Replace unzip with bsdtar
There are situations where a Zip archive from Sourcegraph causes the directory to be improperly recreated within the container. Using libarchive-tools fixes this.
1 parent b9e783a commit ed8be10

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

docker/batch-change-volume-workspace/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
FROM alpine:3.15.0@sha256:21a3deaa0d32a8057914f36584b5288d2e5ecc984380bc0118285c70fa8c9300
66

7-
RUN apk add --update git unzip
7+
RUN apk add --update git libarchive-tools

internal/batches/workspace/volume_workspace.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func (wc *dockerVolumeWorkspaceCreator) unzipRepoIntoVolume(ctx context.Context,
153153
opts,
154154
DockerVolumeWorkspaceImage,
155155
"sh", "-c",
156-
fmt.Sprintf("unzip /tmp/zip; rm /work/%s", dummy),
156+
fmt.Sprintf("bsdtar -xf /tmp/zip && rm /work/%s", dummy),
157157
)
158158

159159
if out, err := exec.CommandContext(ctx, "docker", opts...).CombinedOutput(); err != nil {

internal/batches/workspace/volume_workspace_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func TestVolumeWorkspaceCreator(t *testing.T) {
8585
"--user", "0:0",
8686
"--mount", "type=volume,source="+volumeID+",target=/work",
8787
DockerVolumeWorkspaceImage,
88-
"sh", "-c", "unzip /tmp/zip; rm /work/*",
88+
"sh", "-c", "bsdtar -xf /tmp/zip && rm /work/*",
8989
),
9090
expect.NewGlob(
9191
expect.Success,
@@ -122,7 +122,7 @@ func TestVolumeWorkspaceCreator(t *testing.T) {
122122
"--user", "0:0",
123123
"--mount", "type=volume,source="+volumeID+",target=/work",
124124
DockerVolumeWorkspaceImage,
125-
"sh", "-c", "unzip /tmp/zip; rm /work/*",
125+
"sh", "-c", "bsdtar -xf /tmp/zip && rm /work/*",
126126
),
127127
expect.NewGlob(
128128
expect.Success,
@@ -163,7 +163,7 @@ func TestVolumeWorkspaceCreator(t *testing.T) {
163163
"--user", "1:2",
164164
"--mount", "type=volume,source="+volumeID+",target=/work",
165165
DockerVolumeWorkspaceImage,
166-
"sh", "-c", "unzip /tmp/zip; rm /work/*",
166+
"sh", "-c", "bsdtar -xf /tmp/zip && rm /work/*",
167167
),
168168
expect.NewGlob(
169169
expect.Success,
@@ -242,7 +242,7 @@ func TestVolumeWorkspaceCreator(t *testing.T) {
242242
"--user", "0:0",
243243
"--mount", "type=volume,source="+volumeID+",target=/work",
244244
DockerVolumeWorkspaceImage,
245-
"sh", "-c", "unzip /tmp/zip; rm /work/*",
245+
"sh", "-c", "bsdtar -xf /tmp/zip && rm /work/*",
246246
),
247247
expect.NewGlob(
248248
expect.Behaviour{ExitCode: 1},
@@ -284,7 +284,7 @@ func TestVolumeWorkspaceCreator(t *testing.T) {
284284
"--user", "0:0",
285285
"--mount", "type=volume,source="+volumeID+",target=/work",
286286
DockerVolumeWorkspaceImage,
287-
"sh", "-c", "unzip /tmp/zip; rm /work/*",
287+
"sh", "-c", "bsdtar -xf /tmp/zip && rm /work/*",
288288
),
289289
},
290290
steps: []batcheslib.Step{
@@ -318,7 +318,7 @@ func TestVolumeWorkspaceCreator(t *testing.T) {
318318
"--user", "0:0",
319319
"--mount", "type=volume,source="+volumeID+",target=/work",
320320
DockerVolumeWorkspaceImage,
321-
"sh", "-c", "unzip /tmp/zip; rm /work/*",
321+
"sh", "-c", "bsdtar -xf /tmp/zip && rm /work/*",
322322
),
323323
expect.NewGlob(
324324
expect.Success,

0 commit comments

Comments
 (0)