Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Portage & Programming
  • Search

[SOLVED] Patching dwm the Gentoo Way

Problems with emerge or ebuilds? Have a basic programming question about C, PHP, Perl, BASH or something else?
Post Reply
Advanced search
15 posts • Page 1 of 1
Author
Message
alecStewart1
Apprentice
Apprentice
Posts: 257
Joined: Sun Jul 03, 2022 2:29 pm

[SOLVED] Patching dwm the Gentoo Way

  • Quote

Post by alecStewart1 » Mon Nov 07, 2022 4:38 am

Hello, friends!

I thought I'd give dwm a try and I like how I can put patches in /etc/portage/patches/x11-wm/dwm for patches!

I'm running into an issue installing dwm and applying the vanitygaps patch.

If you look at line 212 and 1671 in dwm.c, the vanitygaps patch removes those from dwm.c and adds them into it's vanitygaps.c.

However emerge doesn't seem to like those hunks in that patch and will fail at both of those hunks, failing to patch and install dwm.

So...what exactly do I do to get around that? I know I could fork dwm into my own git repo, add the patches and create my own local ebuild pointing to that git repo, but I'd rather try and do it the /etc/portage/patches way.
Last edited by alecStewart1 on Wed Nov 09, 2022 4:55 pm, edited 1 time in total.
Top
fedeliallalinea
Administrator
Administrator
User avatar
Posts: 31985
Joined: Sat Mar 08, 2003 11:15 pm
Location: here
Contact:
Contact fedeliallalinea
Website

  • Quote

Post by fedeliallalinea » Mon Nov 07, 2022 6:40 am

I tried dwm-vanitygaps-6.2.diff, the problem is that patch is created for 6.2 version and gentoo tree as 6.3 and 6.4.
Try this patch, it works for 6.3 version.
Questions are guaranteed in life; Answers aren't.

"Those who would give up essential liberty to purchase a little temporary safety,
deserve neither liberty nor safety."
- Ben Franklin
https://www.news.admin.ch/it/nsb?id=103968
Top
alecStewart1
Apprentice
Apprentice
Posts: 257
Joined: Sun Jul 03, 2022 2:29 pm

  • Quote

Post by alecStewart1 » Mon Nov 07, 2022 6:35 pm

fedeliallalinea wrote: Try this patch, it works for 6.3 version.
Thanks! That does work and dwm compiles fine. However, is this going to be an issue for other patches as well?

In total, I'm wanting to use the
  • statuscmd (to use dwmblocks)
    alt tab
    fullscreen
    shift tools
    xresources
    vanitygaps
    steam
    stacker
    sticky
    swallow
patches. On the suckless website for dwm, it looks like most of those have support of 6.2.

Is there going to be a lot of tinker with just patches before I can tinker with dwm?
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56076
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Mon Nov 07, 2022 6:49 pm

alecStewart1,

Try the patches and see.
Portage will tell you if they fail to apply.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
fedeliallalinea
Administrator
Administrator
User avatar
Posts: 31985
Joined: Sat Mar 08, 2003 11:15 pm
Location: here
Contact:
Contact fedeliallalinea
Website

  • Quote

Post by fedeliallalinea » Mon Nov 07, 2022 6:50 pm

alecStewart1 wrote:Thanks! That does work and dwm compiles fine. However, is this going to be an issue for other patches as well?
...
Is there going to be a lot of tinker with just patches before I can tinker with dwm?
Probably yes, but you should test it.
That's one of the reasons I chose a wm that had what I needed without having to waste time with patches.
Questions are guaranteed in life; Answers aren't.

"Those who would give up essential liberty to purchase a little temporary safety,
deserve neither liberty nor safety."
- Ben Franklin
https://www.news.admin.ch/it/nsb?id=103968
Top
alecStewart1
Apprentice
Apprentice
Posts: 257
Joined: Sun Jul 03, 2022 2:29 pm

  • Quote

Post by alecStewart1 » Mon Nov 07, 2022 10:11 pm

fedeliallalinea wrote:
alecStewart1 wrote:Thanks! That does work and dwm compiles fine. However, is this going to be an issue for other patches as well?
...
Is there going to be a lot of tinker with just patches before I can tinker with dwm?
Probably yes, but you should test it.
That's one of the reasons I chose a wm that had what I needed without having to waste time with patches.
Fair enough, but I think I've found one of those things that I stubbornly want to get to work and refuse to give up, lol.
NeddySeagoon wrote: Try the patches and see.
Portage will tell you if they fail to apply.
I'm finding that sometimes it's not hard to update patches and a total pain other times. I'm running into this problem now with the shift-tools patch.

Code: Select all

 * Applying 06-shift-tools.diff ...
patching file config.def.h
patch: **** malformed patch at line 29:  };
                                                                                                                                                                                                                                                       [ !! ]
 * ERROR: x11-wm/dwm-6.3::gentoo failed (prepare phase):
 *   patch -p1  failed with /etc/portage/patches/x11-wm/dwm/06-shift-tools.diff

Okay, so here's the hunk it's griping about:

Code: Select all

--- a/config.def.h	2022-11-07 15:48:11.352474594 -0600
+++ b/config.def.h	2022-11-07 15:52:52.046649301 -0600
@@ -93,2 +93,2 @@
 		{ "mfact",      	 	FLOAT,   &mfact },
 };

+#include "shift-tools.c"
+
 static Key keys[] = {
 	/* modifier                     key        function        argument */
 	{ MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
 	{ MODKEY|ShiftMask,             XK_Return, spawn,          {.v = termcmd } },
+	{ MODKEY,                       XK_o, shiftviewclients,    { .i = +1 } },
+	{ MODKEY|ShiftMask,             XK_o,	shiftview,         { .i = +1 } },
+	{ MODKEY|ShiftMask,             XK_i,	shiftview,         { .i = -1 } },
+	{ MODKEY,	                XK_i, shiftviewclients,    { .i = -1 } },
 	{ MODKEY,                       XK_b,      togglebar,      {0} },
 	{ MODKEY,                       XK_j,      focusstack,     {.i = +1 } },
 	{ MODKEY,                       XK_k,      focusstack,     {.i = -1 } },
@@ -104,6 +110,10 @@
 	{ MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
 	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
 	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
+	{ MODKEY|ShiftMask,		XK_h,      shiftboth,      { .i = -1 }	},
+	{ MODKEY|ControlMask,		XK_h,      shiftswaptags,  { .i = -1 }	},
+	{ MODKEY|ControlMask,		XK_l,      shiftswaptags,  { .i = +1 }	},
+	{ MODKEY|ShiftMask,             XK_l,      shiftboth,      { .i = +1 }	},
 	{ MODKEY,                       XK_Return, zoom,           {0} },
 	{ MODKEY,                       XK_q,	   view,           {0} },
 	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
It'd be nice if patch could give a little more hints as to what makes malformed. Here's the full patch file.
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56076
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Mon Nov 07, 2022 10:32 pm

alecStewart1,

This looks wrong to me.

Code: Select all

@@ -93,2 +93,2 @@
       { "mfact",             FLOAT,   &mfact },
 };

+#include "shift-tools.c"
+
 static Key keys[] = {
    /* modifier                     key        function        argument */
    { MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
    { MODKEY|ShiftMask,             XK_Return, spawn,          {.v = termcmd } },
+   { MODKEY,                       XK_o, shiftviewclients,    { .i = +1 } },
+   { MODKEY|ShiftMask,             XK_o,   shiftview,         { .i = +1 } },
+   { MODKEY|ShiftMask,             XK_i,   shiftview,         { .i = -1 } },
+   { MODKEY,                   XK_i, shiftviewclients,    { .i = -1 } },
    { MODKEY,                       XK_b,      togglebar,      {0} },
    { MODKEY,                       XK_j,      focusstack,     {.i = +1 } },
    { MODKEY,                       XK_k,      focusstack,     {.i = -1 } }, 

Code: Select all

@@ -93,2 +93,2 @@
tells patch that the hunk does not change the line count but it actually adds 6 lines. The lines prefixed with a +. There are no lines removed. They would have a - prefix.
The before and after line counts do not match what the patch actually does to the code.

Code: Select all

The next hunk @@ -104,6 +110,10 @@
 	{ MODKEY,                       XK_d,      incnmaster,     {.i = -1 } },
 	{ MODKEY,                       XK_h,      setmfact,       {.f = -0.05} },
 	{ MODKEY,                       XK_l,      setmfact,       {.f = +0.05} },
+	{ MODKEY|ShiftMask,		XK_h,      shiftboth,      { .i = -1 }	},
+	{ MODKEY|ControlMask,		XK_h,      shiftswaptags,  { .i = -1 }	},
+	{ MODKEY|ControlMask,		XK_l,      shiftswaptags,  { .i = +1 }	},
+	{ MODKEY|ShiftMask,             XK_l,      shiftboth,      { .i = +1 }	},
 	{ MODKEY,                       XK_Return, zoom,           {0} },
 	{ MODKEY,                       XK_q,	   view,           {0} },
 	{ MODKEY|ShiftMask,             XK_c,      killclient,     {0} },
is a confirmation.

Code: Select all

@@ -104,6 +110,10 @@
six lines at line 104 in the old file becomes 10 lines at line line 110 in the new file.
Looking at the shifs in start is that second hunk, its 6 lines. That will be the 6 lines added by the hunk above.
This hunk adds four lines hence the 6 becomes 10.

The

Code: Select all

@@ -93,2 +93,2 @@
is not consistent with what the hunk actually does.

Apply the changes by hand and remake the patch.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
alecStewart1
Apprentice
Apprentice
Posts: 257
Joined: Sun Jul 03, 2022 2:29 pm

  • Quote

Post by alecStewart1 » Wed Nov 09, 2022 4:55 pm

Thanks guys!

I haven't been able to tinker away much at some of the patches, but I'm making progress.

Just as a note, fedeliallalinea, that patch for vanitygaps seems to work for 6.4 as well. I'll try to remember to post a link to a repo of the updated patches here, in case anyone else comes across this in in the future.
Top
fedeliallalinea
Administrator
Administrator
User avatar
Posts: 31985
Joined: Sat Mar 08, 2003 11:15 pm
Location: here
Contact:
Contact fedeliallalinea
Website

  • Quote

Post by fedeliallalinea » Wed Nov 09, 2022 4:57 pm

alecStewart1 wrote:Just as a note, fedeliallalinea, that patch for vanitygaps seems to work for 6.4 as well. I'll try to remember to post a link to a repo of the updated patches here, in case anyone else comes across this in in the future.
This is a good idea!
Questions are guaranteed in life; Answers aren't.

"Those who would give up essential liberty to purchase a little temporary safety,
deserve neither liberty nor safety."
- Ben Franklin
https://www.news.admin.ch/it/nsb?id=103968
Top
Hammett
Apprentice
Apprentice
User avatar
Posts: 243
Joined: Wed Jan 26, 2005 10:37 pm
Location: Barcelona, Catalonia

  • Quote

Post by Hammett » Fri Nov 11, 2022 6:24 pm

If you want to apply several patches, some might fail because a previous patch has modified the file current patch is trying to modify...

I have gone through this myself and the approach I took was to download dwm source and apply the patches manually, fixing the errors on each patch. Then I renamed the patches to be applied in the correct order and moved those to /etc/portage/patches

If you're curious, I made a git repo for my dwm build... https://github.com/DasHammett/dwm
Not sure if it would build, but you will get an idea of how I did it.
I don't fear the people. I fear the demon inside them.
Top
jb1277976_
n00b
n00b
User avatar
Posts: 35
Joined: Mon Oct 30, 2023 3:50 am

  • Quote

Post by jb1277976_ » Wed Jan 31, 2024 9:17 pm

Hammett wrote:If you want to apply several patches, some might fail because a previous patch has modified the file current patch is trying to modify...

I have gone through this myself and the approach I took was to download dwm source and apply the patches manually, fixing the errors on each patch. Then I renamed the patches to be applied in the correct order and moved those to /etc/portage/patches

If you're curious, I made a git repo for my dwm build... https://github.com/DasHammett/dwm
Not sure if it would build, but you will get an idea of how I did it.
Hi,

I'm having this same error i apply a patch i know works and its fine. but when i try another patch it fails. i'm wondering if i have to keep the previous patch in place and the emerge ? if i download the source and patch its easy i just copy paste and re-compile and everything works. What would you do in this situation ?

Thanks

~ Joe B
Top
GDH-gentoo
Advocate
Advocate
User avatar
Posts: 2111
Joined: Sat Jul 20, 2019 7:02 pm
Location: South America

  • Quote

Post by GDH-gentoo » Wed Jan 31, 2024 10:17 pm

I'm still amazed by the fact that nobody seems to want to run unpatched DWM. Does it suck so bad (pun intended)?

The problem with the patches published at the project's website is that they are diffs against a specific upstream version. And that only really works flawlessly if you want to apply only one patch, to that unmodified specific version [1]. Makes sense for a quick bug fix. But doing what amounts to a nontrivial rewrite of the original software through a series of patches? Therefore, what I said in the first paragraph.

[1] So the second and later patches in a sequence are no longer applied to the unmodified version, but to code already modified by earlier patches. That only works by chance if you are lucky.
Last edited by GDH-gentoo on Wed Jan 31, 2024 10:58 pm, edited 5 times in total.
NeddySeagoon wrote:I'm not a witch, I'm a retired electronics engineer :)
Ionen wrote:As a packager I just don't want things to get messier with weird build systems and multiple toolchains requirements though :)
Top
Hu
Administrator
Administrator
Posts: 24380
Joined: Tue Mar 06, 2007 5:38 am

  • Quote

Post by Hu » Wed Jan 31, 2024 10:25 pm

jb1277976_ wrote:I'm having this same error i apply a patch i know works and its fine. but when i try another patch it fails.
Without more detail, it is hard for us to determine whether you did this correctly.
jb1277976_ wrote:i'm wondering if i have to keep the previous patch in place and the emerge ?
Yes, you need to keep active all the patches that you want to be active.
jb1277976_ wrote:if i download the source and patch its easy i just copy paste and re-compile and everything works. What would you do in this situation ?
I would use a project that has mastered the use of a configure system to enable and disable features via a dedicated configure phase, without resorting to source code patches for every commonly used feature.
Top
jb1277976_
n00b
n00b
User avatar
Posts: 35
Joined: Mon Oct 30, 2023 3:50 am

  • Quote

Post by jb1277976_ » Wed Jan 31, 2024 10:47 pm

Hu wrote:
jb1277976_ wrote:I'm having this same error i apply a patch i know works and its fine. but when i try another patch it fails.
Without more detail, it is hard for us to determine whether you did this correctly.
jb1277976_ wrote:i'm wondering if i have to keep the previous patch in place and the emerge ?
Yes, you need to keep active all the patches that you want to be active.
jb1277976_ wrote:if i download the source and patch its easy i just copy paste and re-compile and everything works. What would you do in this situation ?
I would use a project that has mastered the use of a configure system to enable and disable features via a dedicated configure phase, without resorting to source code patches for every commonly used feature.
When downloading dwm directly from suckless and apply patchces everything works fine.
I have to copy and paste code here and there but everything is working. I just wanted to try it the gentoo way since i'm on gentoo now.

Harder then it looks

This looks about right viewtopic-p-8815183.html#8815183
Top
NeddySeagoon
Administrator
Administrator
User avatar
Posts: 56076
Joined: Sat Jul 05, 2003 9:37 am
Location: 56N 3W

  • Quote

Post by NeddySeagoon » Sun Mar 03, 2024 12:59 pm

Moved from Desktop Environments to Portage & Programming.
Regards,

NeddySeagoon

Computer users fall into two groups:-
those that do backups
those that have never had a hard drive fail.
Top
Post Reply

15 posts • Page 1 of 1

Return to “Portage & Programming”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy