Skip to content

Commit

Permalink
[7.17] [build] Update copyAll implementation (#138692) (#160648)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `7.17`:
- [[build] Update copyAll implementation
(#138692)](#138692)

<!--- Backport version: 8.9.7 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Jonathan
Budzenski","email":"[email protected]"},"sourceCommit":{"committedDate":"2022-08-12T11:38:22Z","message":"[build]
Update copyAll implementation (#138692)\n\n* [build] Update copyAll
implementation\r\n\r\n* remove unused
copy","sha":"339f9068fc068ee0f7312206ace5acd7426a3478","branchLabelMapping":{"^v8.5.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Operations","release_note:skip","backport:skip","v8.5.0"],"number":138692,"url":"https://github.com/elastic/kibana/pull/138692","mergeCommit":{"message":"[build]
Update copyAll implementation (#138692)\n\n* [build] Update copyAll
implementation\r\n\r\n* remove unused
copy","sha":"339f9068fc068ee0f7312206ace5acd7426a3478"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.5.0","labelRegex":"^v8.5.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/138692","number":138692,"mergeCommit":{"message":"[build]
Update copyAll implementation (#138692)\n\n* [build] Update copyAll
implementation\r\n\r\n* remove unused
copy","sha":"339f9068fc068ee0f7312206ace5acd7426a3478"}}]}] BACKPORT-->

---------

Co-authored-by: Jonathan Budzenski <[email protected]>
  • Loading branch information
mistic and jbudz authored Jun 28, 2023
1 parent 36940cd commit d8acfdb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 32 deletions.
41 changes: 16 additions & 25 deletions src/dev/build/lib/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
import fs from 'fs';
import Fsp from 'fs/promises';
import { createHash } from 'crypto';
import { Writable } from 'stream';
import { pipeline } from 'stream/promises';
import { resolve, dirname, isAbsolute, sep } from 'path';
import { createGunzip } from 'zlib';
import { inspect } from 'util';

import archiver from 'archiver';
import vfs from 'vinyl-fs';
import File from 'vinyl';
import globby from 'globby';
import cpy from 'cpy';
import del from 'del';
import deleteEmpty from 'delete-empty';
import tar, { ExtractOptions } from 'tar';
Expand Down Expand Up @@ -155,32 +154,24 @@ export async function copyAll(
assertAbsolute(sourceDir);
assertAbsolute(destination);

await pipeline(
vfs.src(select, {
buffer: false,
cwd: sourceDir,
base: sourceDir,
dot,
}),
vfs.dest(destination)
);
const copiedFiles = await cpy(select, destination, {
cwd: sourceDir,
parents: true,
ignoreJunk: false,
dot,
});

// we must update access and modified file times after the file copy
// has completed, otherwise the copy action can effect modify times.
if (time) {
await pipeline(
vfs.src(select, {
buffer: false,
cwd: destination,
base: destination,
dot,
}),
new Writable({
objectMode: true,
write(file: File, _, cb) {
Fsp.utimes(file.path, time, time).then(() => cb(), cb);
},
})
const copiedDirectories = await globby(select, {
cwd: destination,
dot,
onlyDirectories: true,
absolute: true,
});
await Promise.all(
[...copiedFiles, ...copiedDirectories].map((entry) => Fsp.utimes(entry, time, time))
);
}
}
Expand Down
7 changes: 0 additions & 7 deletions src/dev/build/tasks/os_packages/docker_generator/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,6 @@ export async function runDockerGenerator(
dockerBuildDir
);

if (flags.ironbank) {
await copyAll(
config.resolveFromRepo('src/dev/build/tasks/os_packages/docker_generator/resources/ironbank'),
dockerBuildDir
);
}

// Build docker image into the target folder
// In order to do this we just call the file we
// created from the templates/build_docker_sh.template.js
Expand Down

0 comments on commit d8acfdb

Please sign in to comment.