File: adjust-vendor

package info (click to toggle)
dput-ng 1.44
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,052 kB
  • sloc: python: 3,927; makefile: 154; sh: 10
file content (45 lines) | stat: -rwxr-xr-x 1,218 bytes parent folder | download | duplicates (3)
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
#!/usr/bin/env python3
# Copyright (c) Paul Tagliamonte <paultag@debian.org>, 2012 under the terms
# and conditions of the dput-ng project it's self.

import json
import sys

PROFILE_PATH = "./debian/dput-ng/etc/dput.d/profiles"

distrib = sys.argv[1]
default_target_vendor_table = {
    "Debian": "ftp-master",
    "Ubuntu": "ubuntu"
}

target = default_target_vendor_table[distrib]
fp = "%s/%s.json" % (PROFILE_PATH, target)


print("""I: === Adjusting Vendor ===
I:
I:  Hi there, log viewer.
I:
I:  This simple script takes the argument (which should come from dpkg-vendor),
I:  and uses it to modify the default profile to add an entry (default_host_main)
I:  to the default profile, so that dput correctly sets the default host.
I:
I:  Vendor:          {vendor}
I:  Profile default: {target}
I:  Path:            {fp}
I:
I: If you're currently debugging why the default target is wonky, check
I: me out (debian/bin/adjust-vendor)
I:
I:  Fondly,
I:    -- the dput-ng team""".format(vendor=distrib, target=target, fp=fp))

obj = {}
with open(fp, 'r') as fd:
    obj = json.load(fd)
    obj['default_host_main'] = target

with open(fp, 'w') as fd:
    json.dump(obj, fd, sort_keys=True, indent=4)
    fd.write('\n')