Merge lp:~phill-ridout/openlp/sha256 into lp:openlp/ftw-data

Proposed by Phill
Status: Merged
Merged at revision: 4
Proposed branch: lp:~phill-ridout/openlp/sha256
Merge into: lp:openlp/ftw-data
Diff against target: 420 lines (+216/-101)
2 files modified
download.cfg (+131/-101)
scripts/hashgen.py (+85/-0)
To merge this branch: bzr merge lp:~phill-ridout/openlp/sha256
Reviewer Review Type Date Requested Status
Raoul Snyman Approve
Review via email: mp+248862@code.launchpad.net

This proposal supersedes a proposal from 2015-02-05.

Description of the change

Part fixes bug1073931 "Corrupted databases stop OpenLP from starting"

Use a sha256 hash to verify downloaded files. See also: https://code.launchpad.net/~phill-ridout/openlp/bug1073931/+merge/248803

Created a script to automatically generate and store the sha256 hashes

To post a comment you must log in.
Revision history for this message
Raoul Snyman (raoul-snyman) : Posted in a previous version of this proposal
review: Approve
Revision history for this message
Raoul Snyman (raoul-snyman) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'download.cfg'
2--- download.cfg 2015-02-01 14:23:33 +0000
3+++ download.cfg 2015-02-06 08:05:35 +0000
4@@ -1,194 +1,224 @@
5 # The most recent version should be added to http://openlp.org/files/frw/download.cfg
6 [general]
7-base url=https://downloads.sourceforge.net/project/openlp/resources/frw/
8+base url = https://downloads.sourceforge.net/project/openlp/resources/frw/
9
10 [songs]
11-languages=en,de,ru
12-directory=songs
13+languages = en,de,ru
14+directory = songs
15
16 [songs_en]
17-title=English
18-filename=songs_en.sqlite
19+title = English
20+filename = songs_en.sqlite
21+sha256 = 8a5e862f0ce651a9ae8cc93c938b0bb5059f2380ac445096a346480e928bb045
22
23 [songs_de]
24-title=Deutsch
25-filename=songs_de.sqlite
26+title = Deutsch
27+filename = songs_de.sqlite
28+sha256 = ebc5eb76c2f768d524bc997ced35ee28c38fe6b7d258ab5b174ac5be0e38bc28
29
30 [songs_ru]
31-title=Русский язык
32-filename=songs_ru.sqlite
33+title = Русский язык
34+filename = songs_ru.sqlite
35+sha256 = 1416c3e6b551c90c4e4cb797df368a617b7a5cfec814f0fad8882ab21024aee0
36
37 [bibles]
38-translations=afr,ang,asv,prk,csp,elb,esb,jo,kjv,krl,lse,lsb,l45,l12,ma,mb,sta,ssv,sp,uma
39-languages=af,ar,cz,en,eo,es,de,fr,hu,nl,pt,tl,uma,sv
40-directory=bibles
41+translations = afr,ang,asv,prk,csp,elb,esb,jo,kjv,krl,lse,lsb,l45,l12,ma,mb,sta,ssv,sp,uma
42+languages = af,ar,cz,en,eo,es,de,fr,hu,nl,pt,tl,uma,sv
43+directory = bibles
44
45 [bibles_af]
46-title=Afrikaans
47-translations=afr
48+title = Afrikaans
49+translations = afr
50
51 [bibles_ar]
52-title=العربية (Arabic)
53-translations=sp
54+title = العربية (Arabic)
55+translations = sp
56
57 [bibles_cz]
58-title=Čeština (Czech)
59-translations=prk,krl,csp
60+title = Čeština (Czech)
61+translations = prk,krl,csp
62
63 [bibles_en]
64-title=English
65-translations=asv,kjv
66+title = English
67+translations = asv,kjv
68
69 [bibles_eo]
70-title=Esperanto
71-translations=esb
72+title = Esperanto
73+translations = esb
74
75 [bibles_es]
76-title=Español
77-translations=lse
78+title = Español
79+translations = lse
80
81 [bibles_de]
82-title=Deutsch
83-translations=elb,l12,l45,mb
84+title = Deutsch
85+translations = elb,l12,l45,mb
86
87 [bibles_fr]
88-title=Français
89-translations=lsb
90+title = Français
91+translations = lsb
92
93 [bibles_hu]
94-title=Magyar
95-translations=ma
96+title = Magyar
97+translations = ma
98
99 [bibles_nl]
100-title=Nederlandse
101-translations=sta
102+title = Nederlandse
103+translations = sta
104
105 [bibles_pt]
106-title=Português
107-translations=jo
108+title = Português
109+translations = jo
110
111 [bibles_sv]
112-title=Slovak
113-translations=ssv
114+title = Slovak
115+translations = ssv
116
117 [bibles_tl]
118-title=Tagalog
119-translations=ang
120+title = Tagalog
121+translations = ang
122
123 [bibles_uma]
124-title=Uma (Indonesia)
125-translations=uma
126+title = Uma (Indonesia)
127+translations = uma
128
129 [bible_afr]
130-title=Afrikaanse Bybel
131-filename=Afrikaans_Bybel.sqlite
132+title = Afrikaanse Bybel
133+filename = Afrikaans_Bybel.sqlite
134+sha256 = 46d5cae0c99133c0d974878ac7c10ac0719f7f92c78fe366ea3de4227f3dec09
135
136 [bible_ang]
137-title=Ang Dating
138-filename=Ang_Dating_Biblia.sqlite
139+title = Ang Dating
140+filename = Ang_Dating_Biblia.sqlite
141+sha256 = 3fd8db97955b2805d879b0a905f5b9e0025cedac82c5c2063ee7eb35de9681b5
142
143 [bible_asv]
144-title=American Standard Version
145-filename=ASV.sqlite
146+title = American Standard Version
147+filename = ASV.sqlite
148+sha256 = 27e1647acebd162271c40c7edaa730bc6c291968d21c7b20d79030a39be167a0
149
150 [bible_csp]
151-title=Český Studijní Překlad
152-filename=Cesky_studijni_preklad.sqlite
153+title = Český Studijní Překlad
154+filename = Cesky_studijni_preklad.sqlite
155+sha256 = 6a946fef7f1bb08664a6ab15d57c43a8ac68622bb51316852632a880b5cc8b6b
156
157 [bible_elb]
158-title=Elberfelder
159-filename=Elberfelder_1905.sqlite
160+title = Elberfelder
161+filename = Elberfelder_1905.sqlite
162+sha256 = 21b001becf8140408d80a2c33b1867579ba46c3aeb3bcfb7299f70f5e8cf9eed
163
164 [bible_esb]
165-title=Esperanto Biblio
166-filename=Esperanto_Bible.sqlite
167+title = Esperanto Biblio
168+filename = Esperanto_Bible.sqlite
169+sha256 = 5f980603364c9f279b31998b7a646814fecb9f58a22709f2518350b2d90bed71
170
171 [bible_jo]
172-title=João Ferreira de Almeida Atualizada
173-filename=Jo_o_Ferreira_de_Almeida_Atualizada.sqlite
174+title = João Ferreira de Almeida Atualizada
175+filename = Jo_o_Ferreira_de_Almeida_Atualizada.sqlite
176+sha256 = b188fe41fe63828c418a42655f88c717042565384d71e0fd755955118e4de9ef
177
178 [bible_kjv]
179-title=King James Version
180-filename=KJV.sqlite
181+title = King James Version
182+filename = KJV.sqlite
183+sha256 = 17be9730b017ea14f7b984718b37d6acce472a4056cfb32796c7395b748397da
184
185 [bible_krl]
186-title=Kralická Bible 1613
187-filename=Kralicka_Bible_1613.sqlite
188+title = Kralická Bible 1613
189+filename = Kralicka_Bible_1613.sqlite
190+sha256 = b5181277b5d5891974d21bf8fba5c86bc1d20dc2e9620deaaa536a5b8e91abab
191
192 [bible_lse]
193-title=Las Sagradas Escrituras
194-filename=Las_Sagradas_Escrituras.sqlite
195+title = Las Sagradas Escrituras
196+filename = Las_Sagradas_Escrituras.sqlite
197+sha256 = b45c8c60667f3cde466f7ddda7880d3d490fdf4a48ff09609c1687c302c483e3
198
199 [bible_lsb]
200-title=Louis Segon
201-filename=Louis_Segon_Bible.sqlite
202+title = Louis Segon
203+filename = Louis_Segon_Bible.sqlite
204+sha256 = 3d5465c7853448b343a177706d2658b6dcc5fc0d551b69f520220c4564e059d0
205
206 [bible_l45]
207-title=Luther 1545
208-filename=Luther_1545.sqlite
209+title = Luther 1545
210+filename = Luther_1545.sqlite
211+sha256 = 75aff8c0aabbbe61ef4dd6ae698d6b279f36ea0992b7b5502a8232ddcb1abe8e
212
213 [bible_l12]
214-title=Luther 1912
215-filename=Luther_1912.sqlite
216+title = Luther 1912
217+filename = Luther_1912.sqlite
218+sha256 = 2559b546f8808cc11a5937ac788d98e3ab1c6de1880f6ff6848b1fb192135bce
219
220 [bible_ma]
221-title=Magyar Újfordítású
222-filename=Magyar_jford_t_s.sqlite
223+title = Magyar Újfordítású
224+filename = Magyar_jford_t_s.sqlite
225+sha256 = 0f9a06046c8ffadb809fb250929551e568632de221c8df01c88336abf70c24db
226
227 [bible_mb]
228-title=Menge
229-filename=Menge_Bibel.sqlite
230+title = Menge
231+filename = Menge_Bibel.sqlite
232+sha256 = ff3d7ea9a60fcc9ccd0e9bade67f62589373c7109e8d06906b4be9ade8fbd656
233
234 [bible_prk]
235-title=Bible, Překlad 21. století
236-filename=Bible_Preklad_21_stoleti.sqlite
237+title = Bible, Překlad 21. století
238+filename = Bible_Preklad_21_stoleti.sqlite
239+sha256 = 1cb5b9d22bd58a533d57f1802eff3c197593e9b0544af62f2b108a9dc393b3e0
240
241 [bible_sta]
242-title=Statenvertaling
243-filename=Statenvertaling.sqlite
244+title = Statenvertaling
245+filename = Statenvertaling.sqlite
246+sha256 = ce274d7ba06adc245e79b89eae4974b1265b1b36e7cdfae517173b2d5a244f9d
247
248 [bible_ssv]
249-title=Sväté Písmo (Katolícky Preklad)
250-filename=Sv_t_P_smo_Katol_cky_Preklad.sqlite
251+title = Sväté Písmo (Katolícky Preklad)
252+filename = Sv_t_P_smo_Katol_cky_Preklad.sqlite
253+sha256 = 7bdbc0dc5875d58896136a6d205d65132273800e9e08439ae9d14ae932bbea2b
254
255 [bible_sp]
256-title=Syriac Peshitta
257-filename=Syriac_Peshitta_NT.sqlite
258+title = Syriac Peshitta
259+filename = Syriac_Peshitta_NT.sqlite
260+sha256 = 0f08ff3a7e2a0bb27365b99e2c50d659309628a11fde00cd0cdfb6f4c9dfc40d
261
262-[bibles_uma]
263-title=Uma Version
264-filename=Uma_Version.sqlite
265+[bible_uma]
266+title = Uma Version
267+filename = Uma_Version.sqlite
268+sha256 = c9c4a67e0aa64dd304c2b3ecc3067401bde8d05a1d3f3e6d56eb71f30a35486c
269
270 [themes]
271-files=mot,swt,sr,wt,bb
272-directory=themes
273+files = mot,swt,sr,wt,bb,cl
274+directory = themes
275
276 [theme_mot]
277-title=Moss on tree
278-filename=Moss_on_tree.otz
279-screenshot=Moss_on_tree.png
280+title = Moss on tree
281+filename = Moss_on_tree.otz
282+screenshot = Moss_on_tree.png
283+sha256 = b3b9d286610f7639fedf21a04670f011801f79c06004d7d4295c947a0c584462
284
285 [theme_swt]
286-title=Sea with trees
287-filename=Sea_with_trees.otz
288-screenshot=Sea_with_trees.png
289+title = Sea with trees
290+filename = Sea_with_trees.otz
291+screenshot = Sea_with_trees.png
292+sha256 = 66a9c831fa8c6805ba22502f2544469a717bf74c1f2a206a1b45e09b95493eed
293
294 [theme_sr]
295-title=Sunrise
296-filename=Sunrise.otz
297-screenshot=Sunrise.png
298+title = Sunrise
299+filename = Sunrise.otz
300+screenshot = Sunrise.png
301+sha256 = b22ddede83e269fa69e603ec75c2f5caae1cc580f45890f99ca960bf826a5d59
302
303 [theme_wt]
304-title=Wheat
305-filename=Wheat.otz
306-screenshot=Wheat.png
307+title = Wheat
308+filename = Wheat.otz
309+screenshot = Wheat.png
310+sha256 = 63fde97b7d35722c8fe06e1cfe8236e6d212d944d43c04f6b77f5156b83f5a3f
311
312 [theme_bb]
313-title=Blue Burst
314-filename=BlueBurst.otz
315-screenshot=BlueBurst.png
316+title = Blue Burst
317+filename = BlueBurst.otz
318+screenshot = BlueBurst.png
319+sha256 = 6105626b6da8b358adb8eedb9da986f1149667a1bff324f8bd4549345d2fad56
320
321 [theme_cl]
322-title=Clouds
323-filename=Clouds.otz
324-screenshot=Clouds.png
325+title = Clouds
326+filename = Clouds.otz
327+screenshot = Clouds.png
328+sha256 = d28eafd838be33df58e7ff160d29b0c3ec7024927b62fa2308aa5b259f31d5ea
329+
330
331=== added directory 'scripts'
332=== added file 'scripts/hashgen.py'
333--- scripts/hashgen.py 1970-01-01 00:00:00 +0000
334+++ scripts/hashgen.py 2015-02-06 08:05:35 +0000
335@@ -0,0 +1,85 @@
336+#!/usr/bin/env python3
337+# -*- coding: utf-8 -*-
338+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
339+
340+###############################################################################
341+# OpenLP - Open Source Lyrics Projection #
342+# --------------------------------------------------------------------------- #
343+# Copyright (c) 2008-2015 OpenLP Developers #
344+# --------------------------------------------------------------------------- #
345+# This program is free software; you can redistribute it and/or modify it #
346+# under the terms of the GNU General Public License as published by the Free #
347+# Software Foundation; version 2 of the License. #
348+# #
349+# This program is distributed in the hope that it will be useful, but WITHOUT #
350+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
351+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
352+# more details. #
353+# #
354+# You should have received a copy of the GNU General Public License along #
355+# with this program; if not, write to the Free Software Foundation, Inc., 59 #
356+# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
357+###############################################################################
358+"""
359+This script (re)generates a SHA256 hash for each file in the download.cfg file
360+"""
361+
362+from configparser import ConfigParser
363+from hashlib import sha256
364+import os
365+
366+
367+def hash_file(file_path, block_size=65536):
368+ """
369+ Hash the given file block by block for memory efficiency
370+
371+ :param file_path: Path to file to hash. Type str
372+ :param block_size: Size of blocks to process the file in. Type int
373+ :return: None
374+ """
375+ file = open(file_path, 'rb')
376+ hasher = sha256()
377+ buf = file.read(block_size)
378+ while len(buf) > 0:
379+ hasher.update(buf)
380+ buf = file.read(block_size)
381+ return hasher.hexdigest()
382+
383+
384+def write_hash(section, path):
385+ """
386+ Get the name of the a file from a config section and write its hash back to the same section.
387+
388+ :param section: Config section to read the filename from and write the hash to. Type configparser.SectionProxy
389+ :param path: Path to the folder containg the file to hash. Type str
390+ :return: None
391+ """
392+ section['sha256'] = hash_file(os.path.join(path, section['filename']))
393+
394+
395+def main():
396+ cfg_file = os.path.join('..', 'download.cfg')
397+ config = ConfigParser()
398+ config.read(cfg_file)
399+
400+ song_folder = os.path.join('..', config['songs']['directory'])
401+ for lang in config['songs']['languages'].split(','):
402+ section = config['songs_{}'.format(lang)]
403+ write_hash(section, song_folder)
404+
405+ bible_folder = os.path.join('..', config['bibles']['directory'])
406+ for translation in config['bibles']['translations'].split(','):
407+ section = config['bible_{}'.format(translation)]
408+ write_hash(section, bible_folder)
409+
410+ theme_folder = os.path.join('..', config['themes']['directory'])
411+ for file in config['themes']['files'].split(','):
412+ section = config['theme_{}'.format(file)]
413+ write_hash(section, theme_folder)
414+
415+ with open(cfg_file, 'w') as configfile:
416+ configfile.write('# The most recent version should be added to http://openlp.org/files/frw/download.cfg\n')
417+ config.write(configfile)
418+
419+if __name__ == '__main__':
420+ main()

Subscribers

People subscribed via source and target branches

to all changes: