10-15-2016, 01:32 AM | #1 |
Junior Member
Posts: 5
Karma: 10
Join Date: Oct 2016
Device: none
|
How to update one .pyo file in pylib.zip?
I've made a little patch for calibre, importing book using hardlink instead of copy.
After runnig calibre with my source code by setting CALIBRE_DEVELOP_FROM, I got the .pyo file. I want to use this .pyo file to update the pylib.zip in the calibre binary directory. I've tried WinRAR and the zip in Ubuntu, but it can not run well. And also tried the setup.py script in the calibre sources, but stopped at the private QT header problems. Does anyone know how to repack the .zip file? I would be very grateful if anyone give me some advice. Or if you have a good calibre develop environment, just apply my patch and build the zip for me. Code:
import book using hardlink instead of copy diff --git a/src/calibre/db/backend.py b/src/calibre/db/backend.py index 357f690..463f690 100644 --- a/src/calibre/db/backend.py +++ b/src/calibre/db/backend.py @@ -1493,11 +1493,9 @@ class DB(object): traceback.print_exc() if (not getattr(stream, 'name', False) or not samefile(dest, stream.name)): - with lopen(dest, 'wb') as f: - shutil.copyfileobj(stream, f) - size = f.tell() - if mtime is not None: - os.utime(dest, (mtime, mtime)) + hardlink_file(stream.name, dest) + stream.seek(0, os.SEEK_END) + size = stream.tell() elif os.path.exists(dest): size = os.path.getsize(dest) if mtime is not None: Make calibre installer for Window Last edited by duxxil; 10-15-2016 at 01:36 AM. |
10-15-2016, 02:38 AM | #2 |
creator of calibre
Posts: 43,771
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
Just unzip, replace the file, and re-zip, making sure to disable compression when zipping.
|
10-15-2016, 06:15 AM | #3 | |
Junior Member
Posts: 5
Karma: 10
Join Date: Oct 2016
Device: none
|
Thants for your replay. I've tried, but might not in the right way.
Quote:
Thants for your replay. I've tried, but might not in the right way, it cannot run the right way like using source code by setting CALIBRE_DEVELOP_FROM. 1. I use WinRAR directly replace the .pyo in the pylib.zip(just drag the .pyo into pylib.zip's "calibre/db/" subdirectory). Code:
--- the orginal pylib.zip $ unzip -Z ../pylib.zip | grep backend -B3 ?rw------- 2.0 fat 17915 b- stor 16-Sep-30 08:46 calibre/customize/__init__.pyo -rw---- 2.0 fat 0 b- stor 16-Sep-30 08:46 calibre/db ?rw------- 2.0 fat 9008 b- stor 16-Sep-30 08:46 calibre/db/adding.pyo ?rw------- 2.0 fat 65606 b- stor 16-Sep-30 08:46 calibre/db/backend.pyo --- pylib.zip after replacing calibre/db/backend.pyo $ unzip -Z ../pylib-h.zip | grep backend -B3 ?rw------- 2.0 fat 17915 b- stor 16-Sep-30 08:46 calibre/customize/__init__.pyo -rw---- 2.0 fat 0 b- stor 16-Sep-30 08:46 calibre/db ?rw------- 2.0 fat 9008 b- stor 16-Sep-30 08:46 calibre/db/adding.pyo -rw-a-- 3.1 fat 70781 bx stor 16-Oct-13 23:06 calibre/db/backend.pyo 2. Directory structure problem like this cause the pylib.zip cannot extract the path, so I build the directory structure manually before unzip pylib.zip. This is the detail steps history: Code:
$ mkdir pylib && cd pylib $ unzip ../*.zip $ unzip -l ../*.zip $ unzip -l ../pylib.zip | grep -E "[0-9]{4}(-[0-9]{2}){2} [0-9]{2}:[0-9]{2}" | sed -e '/\.py/d' -e 's/^[ 0-9:\-]* \(.*\)$/\1/' | xargs mkdir $ unzip ../pylib.zip $ cp ../backend.pyo calibre/db/backend.pyo -f $ zip -r ../pylib-hardlink.zip . -0 $ unzip -Z pylib-hardlink.zip | grep backend -B3 -rw------- 3.0 unx 11359 bx stor 16-Sep-30 08:46 calibre/db/restore.pyo -rw------- 3.0 unx 15612 bx stor 16-Sep-30 08:46 calibre/db/utils.pyo -rw------- 3.0 unx 19342 bx stor 16-Sep-30 08:46 calibre/db/view.pyo -rw------- 3.0 unx 70781 bx stor 16-Oct-13 23:06 calibre/db/backend.pyo |
|
10-15-2016, 07:10 AM | #4 |
creator of calibre
Posts: 43,771
Karma: 22666666
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
I'n afraid I dont have the time to figure out how to use zip tools to replace files in a zip file for you. Just use CALIBRE_DEVELOP_FROM.
|
10-15-2016, 09:27 AM | #5 | |
Junior Member
Posts: 5
Karma: 10
Join Date: Oct 2016
Device: none
|
I just wanna use hardlink to save my disk space
Quote:
I suggest to add some opinions about how to setup the book library to the calibre UI, copy, symlink, hardlink or just record the original book path to the book entry. |
|
10-15-2016, 08:59 PM | #6 | ||
Grand Sorcerer
Posts: 24,908
Karma: 47303748
Join Date: Jul 2011
Location: Sydney, Australia
Device: Kobo:Touch,Glo, AuraH2O, GloHD,AuraONE, ClaraHD, Libra H2O; tolinoepos
|
Quote:
Quote:
|
||
10-16-2016, 12:08 AM | #7 |
Junior Member
Posts: 5
Karma: 10
Join Date: Oct 2016
Device: none
|
|
10-16-2016, 02:50 AM | #8 |
Junior Member
Posts: 5
Karma: 10
Join Date: Oct 2016
Device: none
|
|
Thread Tools | Search this Thread |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Invalid Zip file?? | Joop | Library Management | 1 | 02-12-2015 08:58 PM |
ZIP file problem | BlackJapan | Conversion | 6 | 09-19-2014 04:04 AM |
pylib.zip and zipfile.py | twobits | Calibre | 4 | 02-21-2013 02:05 AM |
Cannot Read .htm file auto-imported as zip file | Jimbo724 | Conversion | 2 | 07-24-2012 06:08 AM |
Where is the .exe file in the zip Calibre2opds file? | chilady1 | Related Tools | 4 | 09-17-2011 11:56 AM |