From 038e001bbc4fdc5338a166b8ee364a86ad32d785 Mon Sep 17 00:00:00 2001 From: Jianfeng Jiang Date: Mon, 9 Oct 2023 16:49:00 +0800 Subject: [PATCH] Enable copy_bom to find dependences directories which ends with '/' --- tools/copy_bom/README.md | 2 +- tools/copy_bom/example.yaml | 8 ++++++++ tools/copy_bom/src/bom.rs | 6 +----- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tools/copy_bom/README.md b/tools/copy_bom/README.md index 8cce2772..1d9821a3 100644 --- a/tools/copy_bom/README.md +++ b/tools/copy_bom/README.md @@ -47,7 +47,7 @@ The second part in the line indicates where to find shared libraries. All paths # known limitations -- The use of wildcard(like *) in files or directories is not supported. It may result in `copy_bom` behaving incorrectly. +- The use of wildcard(like *) in files or directories is not supported. It may result in `copy_bom` behaving incorrectly. To achieve a similar purpose, directly add `/` after the directory name to copy all contents in the directory while not copying the directory itself. - If we create symbolic link in bom file, it will always delete the old link and create a new one. It will change the modification time of the symbolic link. - Environmental variables pointing to an empty value may fail to resolve. diff --git a/tools/copy_bom/example.yaml b/tools/copy_bom/example.yaml index 9f9c1af9..79f0d06d 100644 --- a/tools/copy_bom/example.yaml +++ b/tools/copy_bom/example.yaml @@ -36,3 +36,11 @@ targets: mkdirs: - python-occlum - python-occlum/bin + - target: /etc + copy: + - dirs: + # If there's a '/' as the postfix in directory name, copy the contents in + # directories, not including the directory itself. + # cp -r /etc/opt/ /etc + - /etc/opt/ + diff --git a/tools/copy_bom/src/bom.rs b/tools/copy_bom/src/bom.rs index 04606b1d..edc4ac58 100644 --- a/tools/copy_bom/src/bom.rs +++ b/tools/copy_bom/src/bom.rs @@ -461,11 +461,7 @@ impl BomManagement { // get all files in copydirs. filter directories and symlinks let mut files_in_copied_dirs = Vec::new(); for (src, dest) in dirs_to_copy { - let dirname = PathBuf::from(src) - .file_name() - .unwrap() - .to_string_lossy() - .to_string(); + let dirname = src.split('/').last().unwrap(); let dest_dir = PathBuf::from(dest) .join(dirname) .to_string_lossy()