The Following 34 Users Say Thank You to jakibaki For This Useful Post: | ||
|
2018-03-12
, 06:03
|
Community Council |
Posts: 4,920 |
Thanked: 12,867 times |
Joined on May 2012
@ Southerrn Finland
|
#2
|
|
2018-03-12
, 07:44
|
Posts: 592 |
Thanked: 1,167 times |
Joined on Jul 2012
|
#3
|
|
2018-03-12
, 10:25
|
Posts: 150 |
Thanked: 169 times |
Joined on Nov 2011
@ Sweden
|
#4
|
|
2018-03-12
, 12:38
|
Posts: 592 |
Thanked: 1,167 times |
Joined on Jul 2012
|
#5
|
Looking forward to trying this. Very good work on a very good idea. Taking a small hit in speed is a small price to pay weighted against the advantages.
The Following 5 Users Say Thank You to tortoisedoc For This Useful Post: | ||
|
2018-03-12
, 12:59
|
Posts: 120 |
Thanked: 843 times |
Joined on Jul 2015
@ Berlin, Germany
|
#6
|
|
2018-03-12
, 15:55
|
Posts: 120 |
Thanked: 843 times |
Joined on Jul 2015
@ Berlin, Germany
|
#7
|
|
2018-03-12
, 19:22
|
Posts: 33 |
Thanked: 65 times |
Joined on Jan 2014
|
#8
|
|
2018-03-12
, 19:39
|
Posts: 120 |
Thanked: 843 times |
Joined on Jul 2015
@ Berlin, Germany
|
#9
|
Very nice work
It would be even better if it could use coderus's Webcatalog, the patchfiles itself shouldn't be differnt, didn't they?
Maybe coderus can help integrating the api in your app and we all can call it patchmanger 2.5 or 3
|
2018-03-12
, 20:03
|
Posts: 281 |
Thanked: 679 times |
Joined on Feb 2010
|
#10
|
Tags |
patchmanager, prepatch, sailfish os |
|
Coderus is working on integrating the preload-method into patchmanger 3!
This will make prepatch pretty much redundant so I recommend every patch-dev to wait for pm3 instead of porting their patch as prepatch won't be maintained anymore when pm3 releases.
Patchmanager 3 is currently in closed alpha and you can request access by following the instructions here.
This is still in beta!
You may (or may not) still encounter issues. (please report them if you do)
What is this?
Prepatch is an alternative to patchmanager.
However unlike patchmanager prepatch doesn't modify any files on disk but instead replaces the "open"/"open64" function in order to make applications think that those files were modified.
Why should I use/not use prepatch instead of patchmanger?
Advantages
- Undoing patches is never a problem even if multiple patches were applied to a single file.
- Patches don't have to be reapplied if the patched file has been updated.
- System-Updates no longer break stuff if patches are applied and all patches which still work after the update will instantly be working again (no reenabling patches).
- An "apply-order" can be specified if patches which patch the same file need it.
- Prepatch can replace/add files if you're confident that the patched file should stay the same even if jolla updates it.
- It's generally "cleaner" to leave files of other applications alone.
DisadvantagesHow does it work?
Prepatch works by preloading a library into every binary (don't worry, the overhead is much smaller then it sounds) and replaces the open+open64 function in there.
If an application tries to open a file which doesn't have a patch (or tries to open the file for writing/as any user other then nemo) the replaced open function will just behave like the normal open function.
However if an application tries to open a file for which a patch has been installed (in most cases an qml-file) prepatch will apply the patch(es) to a temporary copy of the file and then open that one instead of the one the application requested.
That way the application will think that the file has been patched and behave that way while in reality the real file stays unmodified.
How do I install it?
Just install the prepatch package from openrepos.
How do I uninstall it?
To uninstall prepatch simply remove the prepatch package and you're done. No additional cleanup needed!
How do I install patches?
Just find the patch on openrepos and install it
For example here's my keyboard-swipe-patch.
In some cases restarting lipstick might be required.
How do I develop patches?
Developing patches for prepatch is easy
I'll explain it with my keyboard-swipe-patch as the example. Replace the names/path with yours as needed.
First we'll create the patch-folder (which will be placed into /usr/share/prepatch after we're done creating the patch).
If for example an other patch modifies the same file as yours but only works if your patch is applied before the other one you simply choose an lower number and your patch will always be applied first.
Don't cd into it yet.
First create two copies of the file which you want to modify.
One will stay the same and the other one will be modified.
If that's the case temporarily disable the other patch until you're done with this step.
Now edit the KeyboardBase-Modified.qml file according to your needs.
After that create the directory in which your patch will be located in.
In my case I have to run
Im my case:
If you want to add/completely replace a file instead of patching it you can simply place it inside the folder without the .patch extension. Please note that new files will not appear in directory-listings so ls /path/to/fakefile will not show the file but running cat /path/to/fakefile/file will print out its contents.
Now simply copy the 050-prepatch* folder to /usr/share/prepatch and your patch will be applied the next time the modified file is loaded!
If you want to package your patch you can take a look at my keyboard-swipe-repo, modify the folders+spec to your needs and package it by following this guide.
If you need to add an settings-page to your patch you can take the way it's done in this patch as a reference.
How do I convert patches from patchmanager to prepatch?
I've written a script which can automatically split patchmanager-patches into the prepatch-format.
Obviously the patch you're trying to port has to work with the SailfishOS-version you're on.
This script requires you to have patchutils installed on your computer (or your phone if you want to port this with your device ).
If you don't it's most likely availible in your package-sources on the os of your choice.
For example here's how you install patchutils on SailfishOS:
First create a working directory and cd there (not necessary but recommended).
Convert the unified_diff.patch to a patchmanager-patch like this:
If you want to create an rpm for publishing you can follow my development-instructions and just skip until after creating the patch.
If the patch has any settings-pages included you'll need to manually install them by creating an settings-page entry information like
this one and place it in /usr/share/jolla-settings/entries and place the main.qml file in /usr/share/jolla-settings/pages/YOUR_PAGE_NAME/main.qml and the icon (if there is any) in /usr/share/jolla-settings/pages/YOUR_PAGE_NAME/ICON_NAME.png.
Is it possible to run this alongside with patchmanager?
Yes it is. However all patches that are applied using prepatch will be "applied" after the patchmanager-patches.
What bugs/issues are currently known?
After that everything goes back to normal and performance doesn't seem to be affected in other apps so I suspect that this is caused by a bug in prepatch.
I want to help! How can I help?
What patches are availible?
If you want your patch listed here please open an issue on github or ask in this thread.
UPDATES:
Last edited by jakibaki; 2018-04-03 at 20:03.