You are not logged in.

#1 2020-08-20 03:55:52

Toad39
Member
Registered: 2020-07-06
Posts: 60

[SOLVED] Autostart-patching dwm.c: Hunk #5 failed

Hello,
I am trying to add the autostart patch to the dwm aur package. I have the dwm.1 section in "autostart-1.patch", and the dwm.c section in "autostart-2.patch". I edited the PKGBUILD to look like this:

  6 pkgname=dwm
  7 pkgver=6.2
  8 pkgrel=1
  9 pkgdesc="A dynamic window manager for X"
 10 url="http://dwm.suckless.org"
 11 arch=('i686' 'x86_64')
 12 license=('MIT')
 13 options=(zipman)
 14 depends=('libx11' 'libxinerama' 'libxft' 'freetype2' 'st' 'dmenu')
 15 install=dwm.install
 16 source=(http://dl.suckless.org/dwm/dwm-$pkgver.tar.gz
 17     config.h
 18     dwm.desktop
 19     autostart-1.patch
 20     autostart-2.patch)
 21 sha256sums=('97902e2e007aaeaa3c6e3bed1f81785b817b7413947f1db1d3b62b8da4cd110e'
 22             'f440a5d449eebc5d5d811c670ee047ae72ff8f0aa25378addeccb24f24aa6bb5'
 23             'bc36426772e1471d6dd8c8aed91f288e16949e3463a9933fee6390ee0ccd3f81'
 24             'e982e60ff4bc9d53e1f698af510befba8ebdf1dcd867eb099e6495e607bafbbd'
 25             '79192ad83a4bbc86e34791bf5e43bb01f9b4f55f6dacc9960d9f273b8ca86c51')
 26
 27 prepare() {
 28   cd "$srcdir/$pkgname-$pkgver"
 29   cp "$srcdir/config.h" config.h
 30   # Patches
 31   cp "$srcdir/autostart-1.patch" .
 32   cp "$srcdir/autostart-2.patch" .
 33   echo "Patching dwm.1"
 34   patch --verbose -p1 dwm.1 autostart-1.patch
 35   echo "Patching dwm.c"
 36   patch --verbose -p1 dwm.c autostart-2.patch
 37 }
 38
 39 build() {
 40   cd "$srcdir/$pkgname-$pkgver"
 41   make X11INC=/usr/include/X11 X11LIB=/usr/lib/X11 FREETYPEINC=/usr/include/freetype2
 42 }
 43
 44 package() {
 45   cd "$srcdir/$pkgname-$pkgver"
 46   make PREFIX=/usr DESTDIR="$pkgdir" install
 47   install -m644 -D LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
 48   install -m644 -D README "$pkgdir/usr/share/doc/$pkgname/README"
 49   install -m644 -D "$srcdir/dwm.desktop" "$pkgdir/usr/share/xsessions/dwm.desktop"
 50 }

When I run makepkg:

==> Making package: dwm 6.2-1 (Wed 19 Aug 2020 07:57:19 PM PDT)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Downloading dwm-6.2.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 25273  100 25273    0     0  35899      0 --:--:-- --:--:-- --:--:-- 35848
  -> Found config.h
  -> Found dwm.desktop
  -> Found autostart-1.patch
  -> Found autostart-2.patch
==> Validating source files with sha256sums...
    dwm-6.2.tar.gz ... Passed
    config.h ... Passed
    dwm.desktop ... Passed
    autostart-1.patch ... Passed
    autostart-2.patch ... Passed
==> Extracting sources...
  -> Extracting dwm-6.2.tar.gz with bsdtar
==> Starting prepare()...
Patching dwm.1
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|index 13b3729..9533aa6 100644
|--- a/dwm.1
|+++ b/dwm.1
--------------------------
patching file dwm.1
Using Plan A...
Hunk #1 succeeded at 30.
Hunk #2 succeeded at 160.
done
Patching dwm.c
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|index 4465af1..2156b49 100644
|--- a/dwm.c
|+++ b/dwm.c
--------------------------
patching file dwm.c
Using Plan A...
Hunk #1 succeeded at 29.
Hunk #2 succeeded at 194.
Hunk #3 succeeded at 237.
Hunk #4 succeeded at 1386 with fuzz 1.
Hunk #5 FAILED at 2225.
1 out of 5 hunks FAILED -- saving rejects to file dwm.c.rej
Hmm...  Ignoring the trailing garbage.
done
==> ERROR: A failure occurred in prepare().
    Aborting...

Here is the dwm.rej.c:

--- dwm.c
+++ dwm.c
@@ -2225,6 +2306,7 @@ main(int argc, char *argv[])
        die("pledge");
 #endif /* __OpenBSD__ */
    scan();
+   runautostart();
    run();
    cleanup();
    XCloseDisplay(dpy);

Taking a closer look at dwm.c, it seems like the patch might have the wrong line numbers. Here is the relevant part of dwm.c:

2210 int
2211 main(int argc, char *argv[])
2212 {
2213     if (argc == 2 && !strcmp("-v", argv[1]))
2214         die("dwm-"VERSION);
2215     else if (argc != 1)
2216         die("usage: dwm [-v]");
2217     if (!setlocale(LC_CTYPE, "") || !XSupportsLocale())
2218         fputs("warning: no locale support\n", stderr);
2219     if (!(dpy = XOpenDisplay(NULL)))
2220         die("dwm: cannot open display");
2221     checkotherwm();
2222     setup();
2223 #ifdef __OpenBSD__
2224     if (pledge("stdio rpath proc exec", NULL) == -1)
2225         die("pledge");
2226 #endif /* __OpenBSD__ */
2227     scan();
2228     run();
2229     cleanup();
2230     XCloseDisplay(dpy);
2231     return EXIT_SUCCESS;
2232 }

It seems like that hunk should go from 2225 to 2230, not 2225 to 2306. Therefore, I edited the patch, so the rejected portion looks like this:

116 @@ -2225,6 +2230,7 @@ main(int argc, char *argv[])
117         die("pledge");
118  #endif /* __OpenBSD__ */
119     scan();
120 +   runautostart();
121     run();
122     cleanup();
123     XCloseDisplay(dpy);

However, I get a similar error when building:

==> Making package: dwm 6.2-1 (Wed 19 Aug 2020 08:04:55 PM PDT)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Downloading dwm-6.2.tar.gz...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 25273  100 25273    0     0  49361      0 --:--:-- --:--:-- --:--:-- 49361
  -> Found config.h
  -> Found dwm.desktop
  -> Found autostart-1.patch
  -> Found autostart-2.patch
==> Validating source files with sha256sums...
    dwm-6.2.tar.gz ... Passed
    config.h ... Passed
    dwm.desktop ... Passed
    autostart-1.patch ... Passed
    autostart-2.patch ... Passed
==> Extracting sources...
  -> Extracting dwm-6.2.tar.gz with bsdtar
==> Starting prepare()...
Patching dwm.1
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|index 13b3729..9533aa6 100644
|--- a/dwm.1
|+++ b/dwm.1
--------------------------
patching file dwm.1
Using Plan A...
Hunk #1 succeeded at 30.
Hunk #2 succeeded at 160.
done
Patching dwm.c
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|index 4465af1..2156b49 100644
|--- a/dwm.c
|+++ b/dwm.c
--------------------------
patching file dwm.c
Using Plan A...
Hunk #1 succeeded at 29.
Hunk #2 succeeded at 194.
Hunk #3 succeeded at 237.
Hunk #4 succeeded at 1386 with fuzz 1.
Hunk #5 FAILED at 2308.
1 out of 5 hunks FAILED -- saving rejects to file dwm.c.rej
Hmm...  Ignoring the trailing garbage.
done
==> ERROR: A failure occurred in prepare().
    Aborting...

What did I do wrong? Thank you for your time.

Last edited by Toad39 (2020-08-20 15:48:29)

Offline

#2 2020-08-20 04:28:48

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,426
Website

Re: [SOLVED] Autostart-patching dwm.c: Hunk #5 failed

I've always found that it is much simpler to patch dwm by hand the first time you apply a series, and then once it is all working, create your own patchsets from there...

Also, you did remove the +, right?


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2020-08-20 04:41:26

loqs
Member
Registered: 2014-03-06
Posts: 19,048

Re: [SOLVED] Autostart-patching dwm.c: Hunk #5 failed

--- dwm.c
+++ dwm.c
@@ -2225,6 +2306,7 @@ main(int argc, char *argv[])
        die("pledge");
 #endif /* __OpenBSD__ */
    scan();
+   runautostart();
    run();
    cleanup();
    XCloseDisplay(dpy);

Is indented with spaces,  the original patch and the source use tabs.
Also why did you split the patch into two?

Offline

#4 2020-08-20 12:44:58

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,517
Website

Re: [SOLVED] Autostart-patching dwm.c: Hunk #5 failed

Sorry if this is a bit tangential, but do you really need this patch?  You can launch autostart scripts from xinitrc.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2020-08-20 15:47:59

Toad39
Member
Registered: 2020-07-06
Posts: 60

Re: [SOLVED] Autostart-patching dwm.c: Hunk #5 failed

Trilby wrote:

Sorry if this is a bit tangential, but do you really need this patch?  You can launch autostart scripts from xinitrc.

Unfortunately, Xsession doesn't end correctly if I start scripts from xinitrc.

loqs wrote:

Also why did you split the patch into two?

Oh. I didn't know that the file was an actual diff, it looked like just an email with the output of two git diff commands. I edited the PKGBULD:

  6 pkgname=dwm
  7 pkgver=6.2
  8 pkgrel=1
  9 pkgdesc="A dynamic window manager for X"
 10 url="http://dwm.suckless.org"
 11 arch=('i686' 'x86_64')
 12 license=('MIT')
 13 options=(zipman)
 14 depends=('libx11' 'libxinerama' 'libxft' 'freetype2' 'st' 'dmenu')
 15 install=dwm.install
 16 source=(http://dl.suckless.org/dwm/dwm-$pkgver.tar.gz
 17     config.h
 18     dwm.desktop
 19     #autostart-1.patch
 20     #autostart-2.patch
 21     autostart.patch)
 22 sha256sums=('97902e2e007aaeaa3c6e3bed1f81785b817b7413947f1db1d3b62b8da4cd110e'
 23             'f440a5d449eebc5d5d811c670ee047ae72ff8f0aa25378addeccb24f24aa6bb5'
 24             'bc36426772e1471d6dd8c8aed91f288e16949e3463a9933fee6390ee0ccd3f81'
 25             #'e982e60ff4bc9d53e1f698af510befba8ebdf1dcd867eb099e6495e607bafbbd'
 26             #'3d7c7dd0c484871c023313eb21b3ba66e50b27e54b6c8a8b74b2ef2190cccc43'
 27             '256d5177498184777221417291456d52284eb12ecf8fdfd1ba5348cdbcb2d1d6')
 28
 29 prepare() {
 30   cd "$srcdir/$pkgname-$pkgver"
 31   cp "$srcdir/config.h" config.h
 32   # Patches
 33   cp "$srcdir/autostart.patch" .
 34   cp "$srcdir/autostart-1.patch" .
 35   cp "$srcdir/autostart-2.patch" .
 36   patch --verbose -p1 < autostart.patch
 37   #echo "Patching dwm.1"
 38   #patch --verbose -p1 dwm.1 autostart-1.patch
 39   #echo "Patching dwm.c"
 40   #patch --verbose -p1 dwm.c autostart-2.patch
 41 }
 42
 43 build() {
 44   cd "$srcdir/$pkgname-$pkgver"
 45   make X11INC=/usr/include/X11 X11LIB=/usr/lib/X11 FREETYPEINC=/usr/include/freetype2
 46 }
 47
 48 package() {
 49   cd "$srcdir/$pkgname-$pkgver"
 50   make PREFIX=/usr DESTDIR="$pkgdir" install
 51   install -m644 -D LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
 52   install -m644 -D README "$pkgdir/usr/share/doc/$pkgname/README"
 53   install -m644 -D "$srcdir/dwm.desktop" "$pkgdir/usr/share/xsessions/dwm.desktop"
 54 }

However, I get a similar error:

==> Making package: dwm 6.2-1 (Thu 20 Aug 2020 08:33:44 AM PDT)
==> Checking runtime dependencies...
==> Checking buildtime dependencies...
==> Retrieving sources...
  -> Found dwm-6.2.tar.gz
  -> Found config.h
  -> Found dwm.desktop
  -> Found autostart.patch
==> Validating source files with sha256sums...
    dwm-6.2.tar.gz ... Passed
    config.h ... Passed
    dwm.desktop ... Passed
    autostart.patch ... Passed
==> Extracting sources...
  -> Extracting dwm-6.2.tar.gz with bsdtar
==> Starting prepare()...
Hmm...  Looks like a unified diff to me...
The text leading up to this was:
--------------------------
|From 37e970479dc5d40e57fc0cbfeaa5e39941483237 Mon Sep 17 00:00:00 2001
|From: Gan Ainm <gan.ainm.riomhphost@gmail.com>
|Date: Wed, 10 Jun 2020 10:59:02 +0000
|Subject: [PATCH] dwm-xdgautostart-6.2.diff
|
|===================================================================
|---
| dwm.1 | 23 +++++++++++++++++
| dwm.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
| 2 files changed, 105 insertions(+)
|
|diff --git a/dwm.1 b/dwm.1
|index 13b3729..9533aa6 100644
|--- a/dwm.1
|+++ b/dwm.1
--------------------------
patching file dwm.1
Using Plan A...
Hunk #1 succeeded at 30.
Hunk #2 succeeded at 160.
Hmm...  The next patch looks like a unified diff to me...
The text leading up to this was:
--------------------------
|diff --git a/dwm.c b/dwm.c
|index 4465af1..2156b49 100644
|--- a/dwm.c
|+++ b/dwm.c
--------------------------
patching file dwm.c
Using Plan A...
Hunk #1 succeeded at 29.
Hunk #2 succeeded at 194.
Hunk #3 succeeded at 237.
Hunk #4 succeeded at 1386 with fuzz 1.
Hunk #5 FAILED at 2225.
1 out of 5 hunks FAILED -- saving rejects to file dwm.c.rej
Hmm...  Ignoring the trailing garbage.
done
==> ERROR: A failure occurred in prepare().
    Aborting...
jasonwryan wrote:

I've always found that it is much simpler to patch dwm by hand the first time you apply a series, and then once it is all working, create your own patchsets from there...

Ok, I'll try that and post my results.

jasonwryan wrote:

Also, you did remove the +, right?

Sorry, but I don't understand what you mean. Which +?

loqs wrote:

Is indented with spaces,  the original patch and the source use tabs.

I didn't see that. Thanks! I have vim set to expand tabs, and I copy-pasted. This time, I saved the file, so it keeps the characters, and it patched successfully.

Offline

Board footer

Powered by FluxBB