#!/usr/bin/env python3 from os import getenv, environ from pathlib import Path from subprocess import run, PIPE from sys import argv import json if len(argv) != 2: print("JSON info files script requires ouput file as argument") exit(1) output_path = Path(argv[1]) assert getenv("WORK_DIR"), "$WORK_DIR required" work_dir = Path(getenv("WORK_DIR")) output = {} for json_file in work_dir.glob("*.json"): image_info = json.loads(json_file.read_text()) if not output: output.update(image_info) else: # get first (and only) profile in json file device_id = next(iter(image_info["profiles"].keys())) if device_id not in output["profiles"]: output["profiles"].update(image_info["profiles"]) else: output["profiles"][device_id]["images"].append( image_info["profiles"][device_id]["images"][0] ) if output: default_packages, output["arch_packages"] = run( [ "make", "--no-print-directory", "-C", "target/linux/{}".format(output['target'].split('/')[0]), "val.DEFAULT_PACKAGES", "val.ARCH_PACKAGES", ], stdout=PIPE, stderr=PIPE, check=True, env=environ.copy().update({"TOPDIR": Path().cwd()}), universal_newlines=True, ).stdout.splitlines() output["default_packages"] = default_packages.split() output_path.write_text(json.dumps(output, sort_keys=True, separators=(",", ":"))) else: print("JSON info file script could not find any JSON files for target") t/em-br6478acv2/lede/master-31e0f0ae/?h=do-work/Edimax-v2'>summaryrefslogtreecommitdiffstats
path: root/scripts/metadata.pm
blob: 5efef46924f66b3042531fa55eafc6669a69d4f3 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package metadata;
use base 'Exporter';
use strict;
use warnings;
our @EXPORT = qw(%package %srcpackage %category %subdir %preconfig %features clear_packages parse_package_metadata get_multiline);

our %package;
our %preconfig;
our %srcpackage;
our %category;
our %subdir;
our %features;

sub get_multiline {
	my $fh = shift;
	my $prefix = shift;
	my $str;
	while (<$fh>) {
		last if /^@@/;
		$str .= (($_ and $prefix) ? $prefix . $_ : $_);
	}

	return $str ? $str : "";
}

sub clear_packages() {
	%subdir = ();
	%preconfig = ();
	%package = ();
	%srcpackage = ();
	%category = ();