OS/2, eCS & ArcaOS - Technical > Programming

Patch

(1/1)

karotlopj:
Can someone remind me how to apply patches? I used to be pretty good at this but have completely lost my way with applying them...

Here is an archive where I'm trying to apply patches:-

http://hobbes.nmsu.edu/download/pub/os2/dev/util/byacc.zip

It contains a patchfile - patches.os2. How do I apply it using gnupatch?

Dave Yeo:
Something like,

--- Code: ---patch -p0 < foo.patch
--- End code ---
or with git type diffs,

--- Code: ---patch -p1 < foo.patch
--- End code ---
There's also the dry-run option to see if it'll work depending on the -p option and the binary option if you need to preserve eg *nix line breaks,

--- Code: ---patch -p0 --binary --dry-run < foo.patch
--- End code ---

karotlopj:
Thanks, Dave. I knew it was fairly straightforward, just couldn't stumble across the correct syntax.

I was looking through some old code from long ago which probably took a couple of days to come up with and looking at it now I have no idea how it works:-


--- Quote ---if test -f $PATCHFILE; then
{

  patch -p`awk 'BEGIN {
      min_p = 1234567
    }

    $1 == "+++" || $1 == "***" {
      gsub (ARCHIVE ".*", "", $2)
      gsub (/[^/]/, "", $2)
      if (length($2) < min_p) min_p = length($2)
    }

  END {
    print min_p + 1
  }' ARCHIVE=$ARCHIVE $PATCHFILE` < $PATCHFILE

}

--- End quote ---

Dave Yeo:
Looks like just dynamically getting the -p value right. The -p is how many parent lines there are, usually 0 or 1

Navigation

[0] Message Index

Go to full version