Groups | Search | Server Info | Login | Register


Groups > alt.os.linux > #80336

Re: patch command not work

From marrgol <marrgol@address.invalid>
Newsgroups alt.os.linux
Subject Re: patch command not work
Date 2024-08-28 14:36 +0200
Organization A noiseless patient Spider
Message-ID <van5jp$3eoh2$1@dont-email.me> (permalink)
References <vamud2$3eld1$1@dont-email.me>

Show all headers | View raw


On 2024-08-28 at 12:33 alex wrote:
> /tmp/tmp.YI0xO6M46g
> ├── bugged
> │   └── file
> └── patched
>     ├── file
>     └── file.patch
> 
> $ patch --dry-run < patched/file.patch
> can't find file to patch at input line 3
> Perhaps you should have used the -p or --strip option?
> The text leading up to this was:
> --------------------------
> |--- /tmp/tmp.YI0xO6M46g/bugged/file    2024-08-28 12:15:12.742638522 +0200
> |+++ /tmp/tmp.YI0xO6M46g/patched/file    2024-08-28 12:15:27.908571446 +0200
> --------------------------
> 
> Why?

Because when run in the way you're trying, 'patch', for security reasons,
ignores filenames specified in the diff/patchfile if they contain absolute
paths (or '..').  Always treat the paths in patchfiles as relative to
the current directory (and best avoid absolute paths in them altogether)
and use -p option, like the man page and your example command above suggest.

To use your file.patch as is you can either change your working directory
to / or /tmp/ or /tmp/tmp.YI0xO6M46g/ and run 'patch' with -p1, -p2
or -p3 respectively (for / -p0 should work too), or, to be able to run
the command from anywhere, instruct 'patch' what its working directory
is to be using -d option, e.g:

patch -d/tmp/ -p2 --dry-run < /tmp/tmp.YI0xO6M46g/patched/file.patch

Back to alt.os.linux | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

patch command not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2024-08-28 12:33 +0200
  Re: patch command not work marrgol <marrgol@address.invalid> - 2024-08-28 14:36 +0200
    Re: patch command not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2024-08-28 16:29 +0200
      Re: patch command not work marrgol <marrgol@address.invalid> - 2024-08-28 19:34 +0200
        Re: patch command not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2024-08-29 10:42 +0200
          Re: patch command not work "J.O. Aho" <user@example.net> - 2024-08-29 12:05 +0200
            Re: patch command not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2024-08-29 15:37 +0200
              Re: patch command not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2024-08-31 10:05 +0200
                Re: patch command not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2024-08-31 10:24 +0200
                Re: patch command not work marrgol <marrgol@address.invalid> - 2024-08-31 13:37 +0200
                Re: patch command not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2024-08-31 15:09 +0200
                Re: patch command not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2024-09-02 09:24 +0200
                Re: patch command not work marrgol <marrgol@address.invalid> - 2024-09-02 18:41 +0200
                Re: patch command not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2024-09-03 11:22 +0200
                Re: patch command not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2024-09-06 09:08 +0200
          Re: patch command not work marrgol <marrgol@address.invalid> - 2024-08-29 12:08 +0200
            Re: patch command not work alex <1j9448a02@lnx159sneakemail.com.invalid> - 2024-08-29 15:48 +0200

csiph-web