[PATCH v1 2/4] livepatch-build: Allow a patch to introduce new subdirs

Mihails Strasuns posted 4 patches 3 years ago
[PATCH v1 2/4] livepatch-build: Allow a patch to introduce new subdirs
Posted by Mihails Strasuns 3 years ago
From: Raphael Ning <raphning@amazon.com>

Fix a bug in create_patch() where cp, strip, etc. will fail if the new
object file introduced by the patch is located in a new subdirectory:

 DEBUG: cp: cannot create regular file `output/xen/common/lu/lu.o': No such file or directory
 DEBUG: strip: 'output/xen/common/lu/lu.o': No such file

In this example, xen/common/lu/ does not exist in the original
(unpatched) Xen source tree. It needs to be created in output/ as well.

Signed-off-by: Raphael Ning <raphning@amazon.com>
Reviewed-by: Bjoern Doebel <doebel@amazon.de>
Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
---
 livepatch-build | 1 +
 1 file changed, 1 insertion(+)

diff --git a/livepatch-build b/livepatch-build
index f7d6471..444daa9 100755
--- a/livepatch-build
+++ b/livepatch-build
@@ -232,6 +232,7 @@ function create_patch()
 
     NEW_FILES=$(comm -23 <(cd patched/xen && find . -type f -name '*.o' | sort) <(cd original/xen && find . -type f -name '*.o' | sort))
     for i in $NEW_FILES; do
+        mkdir -p "output/$(dirname "$i")"
         cp "patched/$i" "output/$i"
         [[ $STRIP -eq 1 ]] && strip --strip-unneeded "output/$i"
         CHANGED=1
-- 
2.38.1




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879
Re: [PATCH v1 2/4] livepatch-build: Allow a patch to introduce new subdirs
Posted by Ross Lagerwall 2 years, 11 months ago
> From: Xen-devel <xen-devel-bounces@lists.xenproject.org> on behalf of Mihails Strasuns <mstrasun@amazon.com>
> Sent: Thursday, January 19, 2023 10:13 AM
> To: xen-devel@lists.xenproject.org <xen-devel@lists.xenproject.org>
> Cc: mstrasun@amazon.com <mstrasun@amazon.com>; Raphael Ning <raphning@amazon.com>; Bjoern Doebel <doebel@amazon.de>; Martin Pohlack <mpohlack@amazon.de>
> Subject: [PATCH v1 2/4] livepatch-build: Allow a patch to introduce new subdirs 
>  
> From: Raphael Ning <raphning@amazon.com>
> 
> Fix a bug in create_patch() where cp, strip, etc. will fail if the new
> object file introduced by the patch is located in a new subdirectory:
> 
>  DEBUG: cp: cannot create regular file `output/xen/common/lu/lu.o': No such file or directory
>  DEBUG: strip: 'output/xen/common/lu/lu.o': No such file
> 
> In this example, xen/common/lu/ does not exist in the original
> (unpatched) Xen source tree. It needs to be created in output/ as well.
> 
> Signed-off-by: Raphael Ning <raphning@amazon.com>
> Reviewed-by: Bjoern Doebel <doebel@amazon.de>
> Reviewed-by: Martin Pohlack <mpohlack@amazon.de>
> ---
>  livepatch-build | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/livepatch-build b/livepatch-build
> index f7d6471..444daa9 100755
> --- a/livepatch-build
> +++ b/livepatch-build
> @@ -232,6 +232,7 @@ function create_patch()
>  
>      NEW_FILES=$(comm -23 <(cd patched/xen && find . -type f -name '*.o' | sort) <(cd original/xen && find . -type f -name '*.o' | sort))
>      for i in $NEW_FILES; do
> +        mkdir -p "output/$(dirname "$i")"
>          cp "patched/$i" "output/$i"
>          [[ $STRIP -eq 1 ]] && strip --strip-unneeded "output/$i"
>          CHANGED=1

Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>