0

I have created the following patch file using diff -u file1 file2 | file.patch and then edited out the --- line and changed the path:

ArkOS_Dev_Openbox.patch
+++ ~/.config/openbox/menu.xml  2016-07-28 21:21:55.683952870 +0200
@@ -5,7 +5,7 @@
 <item label="Terminal"><action name="Execute"><execute>lxterminal</execute></action></item>
 <item label="Browser"><action name="Execute"><execute>firefox</execute></action></item>
 <item label="File Manager"><action name="Execute"><execute>spacefm</execute></action></item>
-<item label="Editor"><action name="Execute"><execute>geany</execute></action></item>
+<item label="Editor"><action name="Execute"><execute>gksu geany</execute></action></item>

 <separator/>
 <menu id="applications" label="Applications" execute="xdg_menu --format openbox3-pipe --root-menu /etc/xdg/menus/arch-applications.menu" />

+++ /usr/share/applications/geany.desktop.bak   2016-07-29 22:43:43.483359679 +0200
@@ -130,7 +130,7 @@
 Comment[vi]=Một IDE nhanh và nhẹ nhàng dùng GTK+
 Comment[zh_CN]=GTK+ 编写的轻快的 IDE
 Comment[zh_TW]=一個快速且輕巧的 GTK+ 整合開發環境
-Exec=geany %F
+Exec=gksu geany %F
 Icon=geany
 Terminal=false
 Categories=GTK;Development;IDE;

And I try to run this patch with the following command.

sudo patch -d / -p0 < ArkOS_Dev_Openbox.patch

This results in the first file not being found due to the tilde. I've tried using $HOME as well to no avail.

I think I'm trying to use patches in a way what I think they're not meant for, a desktop environment instead of a package.

So my question is, can I use patches this way? Should I use patches this way? If so how? If not what should I use instead?

  • How did you create the patch? Did you get diff to output the first path with a tilde? (I also assume you mean $HOME and not $Home) – ilkkachu Jul 30 '16 at 10:38
  • diff output, took out the --- line and added a pathname, and also copy pasted the contents of the next patch into the first one. This works with the command above if I only need to patch system files. – Folatt Jul 30 '16 at 11:48
1

A quick check of the sources shows that GNU patch for instance does not expand tilde into home-directories. Likely none of the other implementations do, since most —all but perhaps some closed-source Unix versions — are based on earlier versions of GNU patch (as it evolved from Larry Wall's original).

You could handle this by a sed-script, e.g., something like this:

sed -e "s,~/,$HOME/," ArkOS_Dev_Openbox.patch | sudo patch -d / -p0

Further reading:

  • patch (background information for diffstat)
  • patch (POSIX)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.