Solved How to resolve variable in patchfile

No.

If you give some context, someone could probably suggest an alternative solution for the actual problem.
 
I'll try to explain... Here are the first two lines of a patchfile.


Bash:
--- config.cfg.new   2023-04-26 06:52:40.000000000 +0100                                                                                                                                         
+++ /mnt/tmp/config.cfg    2023-11-06 12:37:47.976345000 +0000

The second file exists in a mounted directory which is defined in the shell script which will run the patch, as $MOUNTDIR.

It's location as per the script is $MOUNTDIR/config.cfg, but I can't out how to make this resolve...

Bash:
--- config.cfg.new   2023-04-26 06:52:40.000000000 +0100                                                                                                                                         
+++ $MOUNTDIR/config.cfg    2023-11-06 12:37:47.976345000 +0000

Hope this more clearly explains the situation...

Bash:
export MOUNTDIR="/mnt/tmp"                                                                                                                                                               
                                                                                                                                                                                                    
mkdir $MOUNTDIR                                                                                                                                                                                     
                                                                                                                                                                                                    
gpart destroy -F $USB                                                                                                                                                                               
gpart create -s mbr $USB                                                                                                                                                                           
gpart add -t fat32 $USB                                                                                                                                                                             
gpart set -a active -i 1 $USB                                                                                                                                                                       
newfs_msdos /dev/${USB}s1                                                                                                                                                                           
                                                                                                                                                                                                    
mount -t msdosfs /dev/${USB}s1 $MOUNTDIR                                                                                                                                                           
                                                                                                                                                                                                    
fetch --no-verify-peer -o - $SRCFILE | unzip -d $MOUNTDIR -                                                                                                                                 

patch < /config.cfg.diff
 
patch -d $MOUNTDIR < /config.cfg.diff ?
Many thanks for that. I was originally trying to include the variable in the patchfie, but your suggestion works just as I wanted, so I'll mark the thread as solved using this as the solution:

patch -d $MYDIR < patchfile
 
Back
Top