← Back to team overview

openlp-core team mailing list archive

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

 

Phill has proposed merging lp:~phill-ridout/openlp/sha256 into lp:openlp/ftw-data.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~phill-ridout/openlp/sha256/+merge/248804

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
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~phill-ridout/openlp/sha256 into lp:openlp/ftw-data.
=== modified file 'download.cfg'
--- download.cfg	2015-02-01 14:23:33 +0000
+++ download.cfg	2015-02-05 17:38:11 +0000
@@ -1,194 +1,223 @@
-# The most recent version should be added to http://openlp.org/files/frw/download.cfg
 [general]
-base url=https://downloads.sourceforge.net/project/openlp/resources/frw/
+base url = https://downloads.sourceforge.net/project/openlp/resources/frw/
 
 [songs]
-languages=en,de,ru
-directory=songs
+languages = en,de,ru
+directory = songs
 
 [songs_en]
-title=English
-filename=songs_en.sqlite
+title = English
+filename = songs_en.sqlite
+sha256 = 8a5e862f0ce651a9ae8cc93c938b0bb5059f2380ac445096a346480e928bb045
 
 [songs_de]
-title=Deutsch
-filename=songs_de.sqlite
+title = Deutsch
+filename = songs_de.sqlite
+sha256 = ebc5eb76c2f768d524bc997ced35ee28c38fe6b7d258ab5b174ac5be0e38bc28
 
 [songs_ru]
-title=Русский язык
-filename=songs_ru.sqlite
+title = Русский язык
+filename = songs_ru.sqlite
+sha256 = 1416c3e6b551c90c4e4cb797df368a617b7a5cfec814f0fad8882ab21024aee0
 
 [bibles]
-translations=afr,ang,asv,prk,csp,elb,esb,jo,kjv,krl,lse,lsb,l45,l12,ma,mb,sta,ssv,sp,uma
-languages=af,ar,cz,en,eo,es,de,fr,hu,nl,pt,tl,uma,sv
-directory=bibles
+translations = afr,ang,asv,prk,csp,elb,esb,jo,kjv,krl,lse,lsb,l45,l12,ma,mb,sta,ssv,sp,uma
+languages = af,ar,cz,en,eo,es,de,fr,hu,nl,pt,tl,uma,sv
+directory = bibles
 
 [bibles_af]
-title=Afrikaans
-translations=afr
+title = Afrikaans
+translations = afr
 
 [bibles_ar]
-title=العربية (Arabic)
-translations=sp
+title = العربية (Arabic)
+translations = sp
 
 [bibles_cz]
-title=Čeština (Czech)
-translations=prk,krl,csp
+title = Čeština (Czech)
+translations = prk,krl,csp
 
 [bibles_en]
-title=English
-translations=asv,kjv
+title = English
+translations = asv,kjv
 
 [bibles_eo]
-title=Esperanto
-translations=esb
+title = Esperanto
+translations = esb
 
 [bibles_es]
-title=Español
-translations=lse
+title = Español
+translations = lse
 
 [bibles_de]
-title=Deutsch
-translations=elb,l12,l45,mb
+title = Deutsch
+translations = elb,l12,l45,mb
 
 [bibles_fr]
-title=Français
-translations=lsb
+title = Français
+translations = lsb
 
 [bibles_hu]
-title=Magyar
-translations=ma
+title = Magyar
+translations = ma
 
 [bibles_nl]
-title=Nederlandse
-translations=sta
+title = Nederlandse
+translations = sta
 
 [bibles_pt]
-title=Português
-translations=jo
+title = Português
+translations = jo
 
 [bibles_sv]
-title=Slovak
-translations=ssv
+title = Slovak
+translations = ssv
 
 [bibles_tl]
-title=Tagalog
-translations=ang
+title = Tagalog
+translations = ang
 
 [bibles_uma]
-title=Uma (Indonesia)
-translations=uma
+title = Uma (Indonesia)
+translations = uma
 
 [bible_afr]
-title=Afrikaanse Bybel
-filename=Afrikaans_Bybel.sqlite
+title = Afrikaanse Bybel
+filename = Afrikaans_Bybel.sqlite
+sha256 = 46d5cae0c99133c0d974878ac7c10ac0719f7f92c78fe366ea3de4227f3dec09
 
 [bible_ang]
-title=Ang Dating
-filename=Ang_Dating_Biblia.sqlite
+title = Ang Dating
+filename = Ang_Dating_Biblia.sqlite
+sha256 = 3fd8db97955b2805d879b0a905f5b9e0025cedac82c5c2063ee7eb35de9681b5
 
 [bible_asv]
-title=American Standard Version
-filename=ASV.sqlite
+title = American Standard Version
+filename = ASV.sqlite
+sha256 = 27e1647acebd162271c40c7edaa730bc6c291968d21c7b20d79030a39be167a0
 
 [bible_csp]
-title=Český Studijní Překlad
-filename=Cesky_studijni_preklad.sqlite
+title = Český Studijní Překlad
+filename = Cesky_studijni_preklad.sqlite
+sha256 = 6a946fef7f1bb08664a6ab15d57c43a8ac68622bb51316852632a880b5cc8b6b
 
 [bible_elb]
-title=Elberfelder
-filename=Elberfelder_1905.sqlite
+title = Elberfelder
+filename = Elberfelder_1905.sqlite
+sha256 = 21b001becf8140408d80a2c33b1867579ba46c3aeb3bcfb7299f70f5e8cf9eed
 
 [bible_esb]
-title=Esperanto Biblio
-filename=Esperanto_Bible.sqlite 
+title = Esperanto Biblio
+filename = Esperanto_Bible.sqlite
+sha256 = 5f980603364c9f279b31998b7a646814fecb9f58a22709f2518350b2d90bed71
 
 [bible_jo]
-title=João Ferreira de Almeida Atualizada 
-filename=Jo_o_Ferreira_de_Almeida_Atualizada.sqlite
+title = João Ferreira de Almeida Atualizada
+filename = Jo_o_Ferreira_de_Almeida_Atualizada.sqlite
+sha256 = b188fe41fe63828c418a42655f88c717042565384d71e0fd755955118e4de9ef
 
 [bible_kjv]
-title=King James Version
-filename=KJV.sqlite
+title = King James Version
+filename = KJV.sqlite
+sha256 = 17be9730b017ea14f7b984718b37d6acce472a4056cfb32796c7395b748397da
 
 [bible_krl]
-title=Kralická Bible 1613
-filename=Kralicka_Bible_1613.sqlite
+title = Kralická Bible 1613
+filename = Kralicka_Bible_1613.sqlite
+sha256 = b5181277b5d5891974d21bf8fba5c86bc1d20dc2e9620deaaa536a5b8e91abab
 
 [bible_lse]
-title=Las Sagradas Escrituras
-filename=Las_Sagradas_Escrituras.sqlite
+title = Las Sagradas Escrituras
+filename = Las_Sagradas_Escrituras.sqlite
+sha256 = b45c8c60667f3cde466f7ddda7880d3d490fdf4a48ff09609c1687c302c483e3
 
 [bible_lsb]
-title=Louis Segon
-filename=Louis_Segon_Bible.sqlite
+title = Louis Segon
+filename = Louis_Segon_Bible.sqlite
+sha256 = 3d5465c7853448b343a177706d2658b6dcc5fc0d551b69f520220c4564e059d0
 
 [bible_l45]
-title=Luther 1545
-filename=Luther_1545.sqlite
+title = Luther 1545
+filename = Luther_1545.sqlite
+sha256 = 75aff8c0aabbbe61ef4dd6ae698d6b279f36ea0992b7b5502a8232ddcb1abe8e
 
 [bible_l12]
-title=Luther 1912
-filename=Luther_1912.sqlite
+title = Luther 1912
+filename = Luther_1912.sqlite
+sha256 = 2559b546f8808cc11a5937ac788d98e3ab1c6de1880f6ff6848b1fb192135bce
 
 [bible_ma]
-title=Magyar Újfordítású
-filename=Magyar_jford_t_s.sqlite
+title = Magyar Újfordítású
+filename = Magyar_jford_t_s.sqlite
+sha256 = 0f9a06046c8ffadb809fb250929551e568632de221c8df01c88336abf70c24db
 
 [bible_mb]
-title=Menge
-filename=Menge_Bibel.sqlite
+title = Menge
+filename = Menge_Bibel.sqlite
+sha256 = ff3d7ea9a60fcc9ccd0e9bade67f62589373c7109e8d06906b4be9ade8fbd656
 
 [bible_prk]
-title=Bible, Překlad 21. století
-filename=Bible_Preklad_21_stoleti.sqlite
+title = Bible, Překlad 21. století
+filename = Bible_Preklad_21_stoleti.sqlite
+sha256 = 1cb5b9d22bd58a533d57f1802eff3c197593e9b0544af62f2b108a9dc393b3e0
 
 [bible_sta]
-title=Statenvertaling
-filename=Statenvertaling.sqlite
+title = Statenvertaling
+filename = Statenvertaling.sqlite
+sha256 = ce274d7ba06adc245e79b89eae4974b1265b1b36e7cdfae517173b2d5a244f9d
 
 [bible_ssv]
-title=Sväté Písmo (Katolícky Preklad)
-filename=Sv_t_P_smo_Katol_cky_Preklad.sqlite
+title = Sväté Písmo (Katolícky Preklad)
+filename = Sv_t_P_smo_Katol_cky_Preklad.sqlite
+sha256 = 7bdbc0dc5875d58896136a6d205d65132273800e9e08439ae9d14ae932bbea2b
 
 [bible_sp]
-title=Syriac Peshitta
-filename=Syriac_Peshitta_NT.sqlite
+title = Syriac Peshitta
+filename = Syriac_Peshitta_NT.sqlite
+sha256 = 0f08ff3a7e2a0bb27365b99e2c50d659309628a11fde00cd0cdfb6f4c9dfc40d
 
-[bibles_uma]
-title=Uma Version
-filename=Uma_Version.sqlite
+[bible_uma]
+title = Uma Version
+filename = Uma_Version.sqlite
+sha256 = c9c4a67e0aa64dd304c2b3ecc3067401bde8d05a1d3f3e6d56eb71f30a35486c
 
 [themes]
-files=mot,swt,sr,wt,bb
-directory=themes
+files = mot,swt,sr,wt,bb,cl
+directory = themes
 
 [theme_mot]
-title=Moss on tree
-filename=Moss_on_tree.otz
-screenshot=Moss_on_tree.png
+title = Moss on tree
+filename = Moss_on_tree.otz
+screenshot = Moss_on_tree.png
+sha256 = b3b9d286610f7639fedf21a04670f011801f79c06004d7d4295c947a0c584462
 
 [theme_swt]
-title=Sea with trees
-filename=Sea_with_trees.otz
-screenshot=Sea_with_trees.png
+title = Sea with trees
+filename = Sea_with_trees.otz
+screenshot = Sea_with_trees.png
+sha256 = 66a9c831fa8c6805ba22502f2544469a717bf74c1f2a206a1b45e09b95493eed
 
 [theme_sr]
-title=Sunrise
-filename=Sunrise.otz
-screenshot=Sunrise.png
+title = Sunrise
+filename = Sunrise.otz
+screenshot = Sunrise.png
+sha256 = b22ddede83e269fa69e603ec75c2f5caae1cc580f45890f99ca960bf826a5d59
 
 [theme_wt]
-title=Wheat
-filename=Wheat.otz
-screenshot=Wheat.png
+title = Wheat
+filename = Wheat.otz
+screenshot = Wheat.png
+sha256 = 63fde97b7d35722c8fe06e1cfe8236e6d212d944d43c04f6b77f5156b83f5a3f
 
 [theme_bb]
-title=Blue Burst
-filename=BlueBurst.otz
-screenshot=BlueBurst.png
+title = Blue Burst
+filename = BlueBurst.otz
+screenshot = BlueBurst.png
+sha256 = 6105626b6da8b358adb8eedb9da986f1149667a1bff324f8bd4549345d2fad56
 
 [theme_cl]
-title=Clouds
-filename=Clouds.otz
-screenshot=Clouds.png
+title = Clouds
+filename = Clouds.otz
+screenshot = Clouds.png
+sha256 = d28eafd838be33df58e7ff160d29b0c3ec7024927b62fa2308aa5b259f31d5ea
+

=== added directory 'scripts'
=== added file 'scripts/hashgen.py'
--- scripts/hashgen.py	1970-01-01 00:00:00 +0000
+++ scripts/hashgen.py	2015-02-05 17:38:11 +0000
@@ -0,0 +1,84 @@
+#!/usr/bin/env python3
+# -*- coding: utf-8 -*-
+# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
+
+###############################################################################
+# OpenLP - Open Source Lyrics Projection                                      #
+# --------------------------------------------------------------------------- #
+# Copyright (c) 2008-2015 OpenLP Developers                                   #
+# --------------------------------------------------------------------------- #
+# This program is free software; you can redistribute it and/or modify it     #
+# under the terms of the GNU General Public License as published by the Free  #
+# Software Foundation; version 2 of the License.                              #
+#                                                                             #
+# This program is distributed in the hope that it will be useful, but WITHOUT #
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       #
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for    #
+# more details.                                                               #
+#                                                                             #
+# You should have received a copy of the GNU General Public License along     #
+# with this program; if not, write to the Free Software Foundation, Inc., 59  #
+# Temple Place, Suite 330, Boston, MA 02111-1307 USA                          #
+###############################################################################
+"""
+This script (re)generates a SHA256 hash for each file in the download.cfg file
+"""
+
+from configparser import ConfigParser
+from hashlib import sha256
+import os
+
+
+def hash_file(file_path, block_size=65536):
+    """
+    Hash the given file block by block for memory efficiency
+
+    :param file_path: Path to file to hash. Type str
+    :param block_size: Size of blocks to process the file in. Type int
+    :return: None
+    """
+    file = open(file_path, 'rb')
+    hasher = sha256()
+    buf = file.read(block_size)
+    while len(buf) > 0:
+        hasher.update(buf)
+        buf = file.read(block_size)
+    return hasher.hexdigest()
+
+
+def write_hash(section, path):
+    """
+    Get the name of the a file from a config section and write its hash back to the same section.
+
+    :param section: Config section to read the filename from and write the hash to. Type configparser.SectionProxy
+    :param path: Path to the folder containg the file to hash. Type str
+    :return: None
+    """
+    section['sha256'] = hash_file(os.path.join(path, section['filename']))
+
+
+def main():
+    cfg_file = os.path.join('..', 'download.cfg')
+    config = ConfigParser()
+    config.read(cfg_file)
+
+    song_folder = os.path.join('..', config['songs']['directory'])
+    for lang in config['songs']['languages'].split(','):
+        section = config['songs_{}'.format(lang)]
+        write_hash(section, song_folder)
+
+    bible_folder = os.path.join('..', config['bibles']['directory'])
+    for translation in config['bibles']['translations'].split(','):
+        section = config['bible_{}'.format(translation)]
+        write_hash(section, bible_folder)
+
+    theme_folder = os.path.join('..', config['themes']['directory'])
+    for file in config['themes']['files'].split(','):
+        section = config['theme_{}'.format(file)]
+        write_hash(section, theme_folder)
+
+    with open(cfg_file, 'w') as configfile:
+        config.write(configfile)
+
+if __name__ == '__main__':
+    main()