Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Cant apply swapfocus patch of dwm...
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Desktop Environments
View previous topic :: View next topic  
Author Message
vcmota
Guru
Guru


Joined: 19 Jun 2017
Posts: 351

PostPosted: Tue Sep 29, 2020 2:14 pm    Post subject: [SOLVED] Cant apply swapfocus patch of dwm... Reply with quote

I just cant apply the swapfocus patch for dwm. I am running the current stable version of dwm:

Code:

~> equery list dwm
 * Searching for dwm ...
[IP-] [  ] x11-wm/dwm-6.2:0
~>


and have already two other patches successfully applied to my dwm instance:

Code:

~> ls /etc/portage/patches/x11-wm/dwm/
01-dwm-hide_vacant_tags-6.2.patch  02-pertag-6.2.patch  03-swapfocus-6.2.patch
~>


this is the output of /var/tmp/portage/x11-wm/dwm-6.2/temp/build.log:

Code:

^[[32;01m * ^[[39;49;00mPackage:    x11-wm/dwm-6.2
^[[32;01m * ^[[39;49;00mRepository: gentoo
^[[32;01m * ^[[39;49;00mMaintainer: desktop-misc@gentoo.org
^[[32;01m * ^[[39;49;00mUSE:        abi_x86_64 amd64 elibc_glibc kernel_linux savedconfig userland_GNU
^[[32;01m * ^[[39;49;00mFEATURES:   network-sandbox nostrip preserve-libs sandbox selinux sesandbox splitdebug userpriv usersandbox
^[[32;01m * ^[[39;49;00mPackage:    x11-wm/dwm-6.2
^[[32;01m * ^[[39;49;00mRepository: gentoo
^[[32;01m * ^[[39;49;00mMaintainer: desktop-misc@gentoo.org
^[[32;01m * ^[[39;49;00mUSE:        abi_x86_64 amd64 elibc_glibc kernel_linux savedconfig userland_GNU
^[[32;01m * ^[[39;49;00mFEATURES:   network-sandbox nostrip preserve-libs sandbox selinux sesandbox splitdebug userpriv usersandbox
!!! Failed to set new SELinux execution context. Is your current SELinux context allowed to run Portage?
>>> Unpacking source...
>>> Unpacking dwm-6.2.tar.gz to /var/tmp/portage/x11-wm/dwm-6.2/work
>>> Source unpacked in /var/tmp/portage/x11-wm/dwm-6.2/work
!!! Failed to set new SELinux execution context. Is your current SELinux context allowed to run Portage?
>>> Preparing source in /var/tmp/portage/x11-wm/dwm-6.2/work/dwm-6.2 ...
 ^[[32;01m*^[[0m Applying 01-dwm-hide_vacant_tags-6.2.patch ...
^[[A^[[204C ^[[34;01m[ ^[[32;01mok^[[34;01m ]^[[0m
 ^[[32;01m*^[[0m Applying 02-pertag-6.2.patch ...
^[[A^[[204C ^[[34;01m[ ^[[32;01mok^[[34;01m ]^[[0m
 ^[[32;01m*^[[0m Applying 03-swapfocus-6.2.patch ...
patching file config.def.h
patching file dwm.c
Hunk #1 FAILED at 111.
Hunk #2 FAILED at 130.
Hunk #3 succeeded at 208 (offset 2 lines).
Hunk #4 succeeded at 283 with fuzz 2 (offset 11 lines).
Hunk #5 FAILED at 647.
Hunk #6 succeeded at 1049 (offset 31 lines).
Hunk #7 succeeded at 1691 (offset 31 lines).
Hunk #8 succeeded at 1790 (offset 31 lines).
Hunk #9 succeeded at 1798 (offset 31 lines).
Hunk #10 FAILED at 1780.
Hunk #11 succeeded at 1848 (offset 55 lines).
Hunk #12 FAILED at 2078.
Hunk #13 succeeded at 2238 (offset 81 lines).
5 out of 13 hunks FAILED -- saving rejects to file dwm.c.rej
^[[A^[[204C ^[[34;01m[ ^[[31;01m!!^[[34;01m ]^[[0m
 ^[[31;01m*^[[0m ERROR: x11-wm/dwm-6.2::gentoo failed (prepare phase):
 ^[[31;01m*^[[0m   patch -p1  failed with /etc/portage/patches/x11-wm/dwm/03-swapfocus-6.2.patch
 ^[[31;01m*^[[0m
 ^[[31;01m*^[[0m Call stack:
 ^[[31;01m*^[[0m               ebuild.sh, line  125:  Called src_prepare
 ^[[31;01m*^[[0m             environment, line 1301:  Called default
 ^[[31;01m*^[[0m      phase-functions.sh, line  855:  Called default_src_prepare
 ^[[31;01m*^[[0m      phase-functions.sh, line  920:  Called __eapi6_src_prepare
 ^[[31;01m*^[[0m             environment, line  204:  Called eapply_user
 ^[[31;01m*^[[0m             environment, line  500:  Called eapply '/etc/portage/patches/x11-wm/dwm/03-swapfocus-6.2.patch'
 ^[[31;01m*^[[0m             environment, line  470:  Called _eapply_patch '/etc/portage/patches/x11-wm/dwm/03-swapfocus-6.2.patch'
 ^[[31;01m*^[[0m             environment, line  408:  Called __helpers_die 'patch -p1  failed with /etc/portage/patches/x11-wm/dwm/03-swapfocus-6.2.patch'
 ^[[31;01m*^[[0m   isolated-functions.sh, line  112:  Called die
 ^[[31;01m*^[[0m The specific snippet of code:
 ^[[31;01m*^[[0m                die "$@"
 ^[[31;01m*^[[0m
 ^[[31;01m*^[[0m If you need support, post the output of `emerge --info '=x11-wm/dwm-6.2::gentoo'`,
 ^[[31;01m*^[[0m the complete build log and the output of `emerge -pqv '=x11-wm/dwm-6.2::gentoo'`.
 ^[[31;01m*^[[0m The complete build log is located at '/var/tmp/portage/x11-wm/dwm-6.2/temp/build.log'.
 ^[[31;01m*^[[0m The ebuild environment file is located at '/var/tmp/portage/x11-wm/dwm-6.2/temp/environment'.
 ^[[31;01m*^[[0m Working directory: '/var/tmp/portage/x11-wm/dwm-6.2/work/dwm-6.2'
 ^[[31;01m*^[[0m S: '/var/tmp/portage/x11-wm/dwm-6.2/work/dwm-6.2'



Although installing suckless patches is not a clear process in gentoo due to nearly total lack of documentation, this is the first time I have a patch failing in the compile phase.

Has anyone found similar issues?

Thank you all for your attention.


Last edited by vcmota on Thu Oct 01, 2020 2:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
389292
Guru
Guru


Joined: 26 Mar 2019
Posts: 504

PostPosted: Wed Sep 30, 2020 2:24 pm    Post subject: Reply with quote

These patches are bits and pieces of code which were developed independently by different developers, you can apply couple of them safely, but all subsequent ones will try to replace lines which aren't there anymore (because they were altered/moved by the previous patch). You can see how many offsets and FAILED you have in your log. offset means that the patch utility was smart enough to see that the lines it was looking for are just couple lines above or below where they were suppose to be, it then patches these places and notify about the offset, FAILED means the patch utility couldn't figure out what the hell it suppose to patch as the lines it was looking to patch were nowhere close or were missing altogether.
Your options are:
Try applying them in a different order, the chances are slim but it can work.
Or, patch the first two patches, then use diff tool and manually create the third patch on top of what you've already patched-in.
Back to top
View user's profile Send private message
vcmota
Guru
Guru


Joined: 19 Jun 2017
Posts: 351

PostPosted: Wed Sep 30, 2020 2:35 pm    Post subject: Reply with quote

etnull wrote:
These patches are bits and pieces of code which were developed independently by different developers, you can apply couple of them safely, but all subsequent ones will try to replace lines which aren't there anymore (because they were altered/moved by the previous patch). You can see how many offsets and FAILED you have in your log. offset means that the patch utility was smart enough to see that the lines it was looking for are just couple lines above or below where they were suppose to be, it then patches these places and notify about the offset, FAILED means the patch utility couldn't figure out what the hell it suppose to patch as the lines it was looking to patch were nowhere close or were missing altogether.


Thank you etmull for your reply. Yes, that makes a lot of sense. I just could not figure out in which part of the process I was making a mistake, I retried multiple times without success, and in fact yesterday I installed other patches without any difficulty.

But just one more question, regarding this:

etnull wrote:

Your options are:
Try applying them in a different order, the chances are slim but it can work.
Or, patch the first two patches, then use diff tool and manually create the third patch on top of what you've already patched-in.


Suppose I want to manually apply the patch to the .c file resulting of the first two patches, where do I find this file and how to make emerge find it?

Thank you again very much!
Back to top
View user's profile Send private message
389292
Guru
Guru


Joined: 26 Mar 2019
Posts: 504

PostPosted: Wed Sep 30, 2020 3:51 pm    Post subject: Reply with quote

Unfortunately I can't guide you in step by step manner, because I hardly recal how I did it myself (for other tool not dwm). But I can outline the general procedure I fallowed, maybe the keywords will lead you somewhere in your own search.
First it almost a given that for your own patches you would have to have your own overlay somewhere, you can make local one, or a remote git repo (I had a remote git repo because I feel more familiar to work with git and it's easy to add to your gentoo for portage to be aware of).
Then I usually search the http://gentoo.zugaina.org/ site for common ebuilds of other people, I don't want to write my own from scratch nor do I feel competent to do it myself. In the ebuild you can add the PATCHES= section, again look other ebuilds to get familiar with that. When your repo/overlay is ready and you can emerge your own version with emerge x11-wm/dwm-6.2::*your_repo_name*, you can start patching. It is better done locally. What I did (not saying it is conventional or the way it suppose to be done). I got two versions of the original sources in two different directories, a and b, for 'a' I applied all the patches which are applying successfully, and the 'b' is left unchanged, then I manually edited all files in 'a' referencing the diff file for the third patch. And the last step is to diff 'a' (contains all 3 patches), with 'b' original source, the diff file will be the modified 3rd patch based on top of the previous two. You can search how to work with patch and diff, which arrows in which direction should be passed, how to make the tree structure with your sources (a and b here are not arbitrary, I had difficulty making a working patch without a proper tree structure).
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 18850

PostPosted: Wed Sep 30, 2020 4:17 pm    Post subject: Reply with quote

Due to the nature of the process, whether you can mix any given combination of patches depends entirely on what they do and how close to one another. Sometimes you get lucky and there are a large number of wholly isolated patches that you can toggle in any combination you want. Other times, you get unlucky and two or more patches all touch the same area in different ways, and you cannot automatically apply some of the combinations.

If you want to manually apply the patches, the unpacked source files are in the usual PORTAGE_TMPDIR area. However, I would suggest instead unpacking the upstream archive yourself in a temporary area (under your home directory, or in a dedicated directory under /tmp, at your preference). Then, manually apply each of the non-conflicting patches to this temporary area. Next, create a copy of the temporary area. One of these will be the "before" version, and one will be the "after" version. Open the failed patch(es) in your preferred text editor/viewer. Open the source files that would have been patched in an editor. Use the text of the patch to guide you on what to change and where. Once you have manually modified the source file(s) in a way that you think matches what the patch would have done if it worked, save your changes, and use GNU diff to compute the difference between your "before" and "after" versions. Save the output of diff as a new patch file. Use this patch file in place of the patch file that Portage failed to apply. Take care to name it such that it is properly ordered, since it depends on the earlier non-failing patches to apply first.

If you need more help, post back with what you tried and what did not work.
Back to top
View user's profile Send private message
x90e
n00b
n00b


Joined: 30 Sep 2020
Posts: 40

PostPosted: Wed Sep 30, 2020 9:46 pm    Post subject: Reply with quote

I just place the .patch file with the diff's in /etc/portage/patches/<app-type>/<app>-<ver>

like pcie ACS override patch for gentoo kernel sources in /etc/portage/patches/sys-kernel/gentoo-sources-5.4.60/override_acs_caps.patch and it automatically applies it whenever I merge said package/said version. Obviously you need to keep track for future versions.
Back to top
View user's profile Send private message
vcmota
Guru
Guru


Joined: 19 Jun 2017
Posts: 351

PostPosted: Thu Oct 01, 2020 2:16 pm    Post subject: Reply with quote

Thank you etnull, Hu and x90e for your kind replies.

When I made this post I have also submitted a question regarding the patch for the suckless mail list, and today one of the maintainers of the patch replied. Apparently there are indeed issues with the patch, which fails to compile, and it appears it is going to be modified/removed from their website. They are suggesting that I consider a different one, the stacker patch, which I am going to do.

Since there is no solution possible, I will consider this post as SOLVED.

Thank you again for your replies, I learned a lot from them about patching, regardless of the issue in cause.
Back to top
View user's profile Send private message
vcmota
Guru
Guru


Joined: 19 Jun 2017
Posts: 351

PostPosted: Thu Oct 01, 2020 4:13 pm    Post subject: Reply with quote

Just for future reference, since this might be usefull for others: I installed stacker and it worked flawlessly. Not only it compiles without any issue, as it replaces swapfocus completely, with additional functionality in fact.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Desktop Environments All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum