summaryrefslogtreecommitdiff
path: root/contrib/source-checker/oe-checksums-sorter.py
blob: 2bab58c9fd85d6a80d804a4590a073b613e21f1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python
# ex:ts=4:sw=4:sts=4:et

# Copyright (C) 2007 OpenedHand
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

#
# OpenEmbedded source checksums sorter
#
# This script parse conf/checksums.ini and sorts it alphabetically by archive
# name source archive. Duplicate entries are removed.
#
# Run it:
#
# oe-checksums-sorter.py path-to-conf/checksums.ini
#
#


import sys

if len(sys.argv) < 2:
    print """
    OpenEmbedded source checksums script require argument:

    1. location of conf/checksums.ini
    """
    sys.exit(0)

import ConfigParser, os

checksums_parser = ConfigParser.ConfigParser()
checksums_parser.read(sys.argv[1])

item = 1;
files_total   = len(checksums_parser.sections())

new_list = []

for source in checksums_parser.sections():
    archive = source.split("/")[-1]
    md5 = checksums_parser.get(source, "md5")
    sha = checksums_parser.get(source, "sha256")

    if new_list.count([archive, source, md5, sha]) < 1:
        new_list += [[archive, source, md5, sha]]

new_list.sort()

for entry in new_list:
    print "[%s]\nmd5=%s\nsha256=%s\n" % (entry[1], entry[2], entry[3])