Other Help with patching

I'm trying to patch a file with a patch extracted from a forum post and it doesn't seem to be working or maybe I'm doing it wrongly.....
This is the source of the patch and I've cut the following out as a patchfile:-

Code:
-------------- next part --------------
--- DOCKSTAR    2017-03-31 12:30:26.752632000 +0200
+++ GOFLEX      2017-04-01 20:10:43.480437000 +0200
@@ -19,7 +19,7 @@
#
#NO_UNIVERSE

-ident          DOCKSTAR
+ident          GOFLEX

include        "std.arm"
include        "../mv/kirkwood/std.db88f6xxx"
@@ -31,9 +31,6 @@
options        INET6                   # IPv6 communications protocols
options        FFS                     # Berkeley Fast Filesystem
options        SOFTUPDATES             # Enable FFS soft updates support
-options        NFSCL                   # Network Filesystem Client
-options        NFSLOCKD                # Network Lock Manager
-#options       NFS_ROOT                # NFS usable as /, requires NFSCL
options        MSDOSFS                 # MSDOS Filesystem
options        CD9660                  # ISO 9660 filesystem
options        NULLFS                  # NULL filesystem
@@ -48,21 +45,10 @@
options        SYSVSEM                 # SYSV-style semaphores
options        _KPOSIX_PRIORITY_SCHEDULING # POSIX P1003_1B real-time extensions

-# Enable these options for nfs root configured via BOOTP.
-#options       BOOTP
-#options       BOOTP_NFSROOT
-#options       BOOTP_NFSV3
-#options       BOOTP_WIRED_TO=mge0
-
-# If not using BOOTP, use something like one of these...
-#options       ROOTDEVNAME=\"ufs:/dev/da0a\"
-options        ROOTDEVNAME=\"ufs:/dev/da0s1a\"
-#options       ROOTDEVNAME=\"ufs:/dev/da0p10\"
-#options       ROOTDEVNAME=\"nfs:192.168.0.254/dreamplug\"
+options        ROOTDEVNAME=\"ufs:/dev/ufs/kirkwoodroot\"

# Misc pseudo devices
device         bpf                     # Required for DHCP
-device         firmware                # firmware(9) required for USB wlan
device         gif                     # IPv6 and IPv4 tunneling
device         loop                    # Network loopback
device         md                      # Memory/malloc disk
@@ -71,7 +57,6 @@
device         tun                     # Packet tunnel.
device         ether                   # Required for all ethernet devices
device         vlan                    # 802.1Q VLAN support
-device         wlan                    # 802.11 WLAN support

# cam support for umass and ahci
device         scbus
@@ -92,23 +77,18 @@
device         usb                     # Basic usb support                    
device         ehci                    # USB host controller
device         umass                   # Mass storage
-device         uhid                    # Human-interface devices
-device         rum                     # Ralink Technology RT2501USB wireless NICs
-device         uath                    # Atheros AR5523 wireless NICs
-device         ural                    # Ralink Technology RT2500USB wireless NICs
-device         zyd                     # ZyDAS zb1211/zb1211b wireless NICs
-device         urtw                    # Realtek RTL8187B/L USB
-device         upgt                    # Conexant/Intersil PrismGT SoftMAC USB
-device         u3g                     # USB-based 3G modems (Option, Huawei, Sierra)

# I2C (TWSI)
device         iic
device         iicbus
device         twsi

-# Sound
-device         sound
-device         snd_uaudio
+# SATA
+device         mvs
+device         ahci
+
+# NAND
+#device                nand

#crypto
device         cesa                    # Marvell security engine
@@ -118,18 +98,13 @@
# IPSec
device         enc
options        IPSEC
-options        IPSEC_NAT_T
options        TCP_SIGNATURE           # include support for RFC 2385

-# IPFW
-options        IPFIREWALL
-options        IPFIREWALL_DEFAULT_TO_ACCEPT
-options        IPFIREWALL_VERBOSE
-options        IPFIREWALL_VERBOSE_LIMIT=100
-options        IPFIREWALL_NAT
-options        LIBALIAS
-options        DUMMYNET
-options        IPDIVERT
+# DTrace
+options         KDTRACE_HOOKS
+options         DDB_CTF
+makeoptions    DEBUG=-g
+makeoptions    WITH_CTF=1

#PF
device         pf
@@ -153,4 +128,4 @@
# Flattened Device Tree
options        FDT                     # Configure using FDT/DTB data
options        FDT_DTB_STATIC
-makeoptions    FDT_DTS_FILE=dockstar.dts
+makeoptions    FDT_DTS_FILE=goflex.dts
-------------- next part --------------

After removing the first and last lines and saving the above as PATCHFILE

can I just run patch < PATCHFILE and create a file called GOFLEX.

Obviously not since that doesn't work.

Any hints?
 
The header of you patch indicates that the patch will be applied to DOCKSTAR file – assuming it exists.
Minus signs mean "remove that line" from the original, plus signs mean "add that line".
If there is no original file, it won't work.
 
That's how I thought it worked but I got:-

Code:
7 out of 7 hunks failed--saving rejects to GOFLEX.rej

Seems like I wasn't using the correct version of DOCKSTAR....
 
One thing you need to watch for is differing versions of source.
The patch is from 2017 and the source may have changed since then.
So first confirm that no modification has been made to the source. The header shows the last edit date usually.
Patching works by line numbers and if they are not the same it rejects the patch.
That was why I mention hand patching.
Make a copy of DOCKSTAR and just modify it. Don't worry about renaming it.
You can also do the same with the SATA mods to the DTS file. Just backup dockstar.dts and hand patch.
The patch shows a couple of lines before and after where patchs goes.
So from that you should be able to place the patched code correctly.
 
Just a word about my advice. The reason you make a GOFLEX is because next time you upgrade source or Operating System it will overwrite your customized DOCKSTAR with the default new file.
So just make a copy of your custom files elsewhere on your disk so you can restore them for this reason.

I also wanted to point out that the mailing list post is adding DTrace. I don't know that will be needed and you can add it later if this fails. All that debugging stuff should be removed from your "final build'. It will only slow down the device and its scant resources.
Good stuff for now though. Just plan on making a cleanup up final version. Then it will be in appliance mode.
 
You can add the kernel configurations anywhere in the KERNCONF (Like the very end).
The DTS mod on the other hand has to go in the exact location as it uses a 'tree' structure.
Don't forget the curly braces either.}{
They segragate the code sections.
 
I have a patch, say mypatchfile and want to patch, say /abc/xzy/123/fileto-be-patched

Is there any way to apply mypatchfile from cwd or do I need to cd /abc/xyz/123 first?
 
It depends on the patch file. First two lines typically indicate the source files and their paths. If the source included the path, then no. Otherwise yes. You always have to be in the same location as where the patch file was created from.
 
I'm trying to create an inline patchfile using a heredoc and can't figure out how to redirect it into patch... something along the lines of:-
Code:
cat  <<EOF | patch
--- DOCKSTAR    2017-03-31 12:30:26.752632000 +0200
+++ DOCKSTARWOIPSECNATT 2017-04-01 10:33:02.845141000 +0200
@@ -118,7 +118,6 @@
 # IPSec
 device         enc
 options        IPSEC
-options        IPSEC_NAT_T
 options        TCP_SIGNATURE           # include support for RFC 2385

 # IPFW
EOF

but obviously this isn't working.... or maybe this sort of thing can't be done...
 
Works fine:
Code:
dice@armitage:~/test % cat patch.sh
cat << EOF | patch
--- hello.txt.orig      2019-04-03 12:34:40.979192000 +0200
+++ hello.txt   2019-04-03 12:34:47.672352000 +0200
@@ -1 +1 @@
-World
+Hello World
EOF
dice@armitage:~/test % cat hello.txt
World
dice@armitage:~/test % sh patch.sh
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|--- hello.txt.orig     2019-04-03 12:34:40.979192000 +0200
|+++ hello.txt  2019-04-03 12:34:47.672352000 +0200
--------------------------
Patching file hello.txt using Plan A...
Hunk #1 succeeded at 1.
done
dice@armitage:~/test % cat hello.txt
Hello World
dice@armitage:~/test % cat hello.txt.orig
World
dice@armitage:~/test %
 
Look at the "-p" option on patch, that allows to use the patch program when one is in a different part of the file hierarchy. To the inexperienced user, the results can be bewildering though.
 
I have a patch, say mypatchfile and want to patch, say /abc/xzy/123/fileto-be-patched

Is there any way to apply mypatchfile from cwd or do I need to cd /abc/xyz/123 first?

Well if you had bothered looking at patch() you may have noticed the -d option...

Code:
     -d    directory, --directory directory
         Causes patch to interpret the next    argument as a directory, and
         change the    working    directory to it    before doing anything else.
 
The header of you patch indicates that the patch will be applied to DOCKSTAR file – assuming it exists.
Minus signs mean "remove that line" from the original, plus signs mean "add that line".
If there is no original file, it won't work.

At the start of my patchfile I have:-
Code:
--- DOCKSTAR    2017-03-31 12:30:26.752632000 +0200
+++ GOFLEX      2017-04-01 20:10:43.480437000 +0200

and I was hoping that this would create a new file called GOFLEX with the changes, but instead the original file - DOCKSTAR is saved as DOCKSTAR.orig and the patched file remains as DOCKSTAR.

Maybe I've misunderstood how this works...
 
Patches typically don't create new files, they modify existing ones.
 
Back
Top