~sil2100/merge-o-matic/exclude-pkgs-from-stats

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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# update-sources.py - update the Sources files in a distribution's pool
#
# Copyright © 2008 Canonical Ltd.
# Author: Scott James Remnant <scott@ubuntu.com>.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of version 3 of the GNU General Public License 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, see <http://www.gnu.org/licenses/>.

from __future__ import print_function

import os
import sys

from momlib import (
    get_pool_distros,
    ROOT,
    run,
    update_pool_sources,
    )


def main(options, args):
    if len(args):
        distros = args
    else:
        distros = get_pool_distros()

    # Iterate the pool directory of the given distributions
    for distro in distros:
        try:
            hparts = os.listdir("%s/pool/%s" % (ROOT, distro))
        except OSError as e:
            print(e, "(continuing)", file=sys.stderr)
            continue
        for hpart in hparts:
            for package in os.listdir("%s/pool/%s/%s" % (ROOT, distro, hpart)):
                update_pool_sources(distro, package)


if __name__ == "__main__":
    run(main, usage="%prog [DISTRO...]",
        description="update the Sources file in a distribution's pool")