@@ -50,14 +50,14 @@ def main():
50
50
# import into the tmp/repo to get the ostree-commit but also so it's cached
51
51
ostree_commit = import_oci_archive (tmpd , tmp_oci_archive , buildid )
52
52
53
- # artificially recreate generated lockfile
54
- tmp_lockfile = generate_lockfile (tmpd , ostree_commit )
55
-
56
53
# create meta.json
57
54
build_meta = generate_build_meta (tmp_oci_archive , tmp_oci_manifest , metadata , ostree_commit )
58
55
56
+ # artificially recreate generated lockfile and commitmeta.json
57
+ tmp_lockfile , tmp_commitmeta = generate_lockfile_and_commitmeta (tmpd , ostree_commit , build_meta )
58
+
59
59
# move into official location
60
- finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile )
60
+ finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile , tmp_commitmeta )
61
61
62
62
if not args .skip_prune :
63
63
subprocess .check_call (['/usr/lib/coreos-assembler/cmd-prune' ])
@@ -95,23 +95,51 @@ def generate_oci_manifest(args, tmpd):
95
95
return tmpf
96
96
97
97
98
- def generate_lockfile (tmpd , ostree_commit ):
99
- tmpf = os .path .join (tmpd , 'lockfile.json' )
100
-
98
+ def generate_lockfile_and_commitmeta (tmpd , ostree_commit , build_meta ):
99
+ tmp_lockfile = os .path .join (tmpd , 'lockfile.json' )
100
+ tmp_commitmeta = os . path . join ( tmpd , 'commitmeta.json' )
101
101
out = subprocess .check_output (['rpm-ostree' , 'db' , 'list' , '--repo' , 'tmp/repo' , ostree_commit ], encoding = 'utf-8' )
102
102
rpmdb = {}
103
+ pkglist = []
104
+ ostree_linux = ""
103
105
for line in out .splitlines ():
104
106
if not line .startswith (' ' ):
105
107
continue
106
108
n , ev , ra = line .strip ().rsplit ('-' , 2 )
107
109
rpmdb [n ] = {'evra' : f'{ ev } -{ ra } ' }
108
110
109
- with open (tmpf , 'w' ) as f :
111
+ if ':' in ev :
112
+ e , v = ev .split (':' )
113
+ else :
114
+ e , v = ("0" , ev )
115
+ r , a = ra .rsplit ('.' , 1 )
116
+ pkglist .append ([n , e , v , r , a ])
117
+ if n == 'kernel' :
118
+ ostree_linux = f"{ v } -{ r } .{ a } "
119
+
120
+ commitmeta = {
121
+ 'coreos-assembler.config-gitrev' : build_meta .get ('coreos-assembler.container-config-git' , {}).get ('commit' , '' ),
122
+ 'coreos-assembler.basearch' : build_meta .get ('coreos-assembler.basearch' , '' ),
123
+ 'version' : build_meta .get ('buildid' , '' ),
124
+ 'ostree.bootable' : True if build_meta .get ('coreos-assembler.oci-imported-labels' , {}).get ('ostree.bootable' , '0' ) == '1' else False ,
125
+ 'ostree.linux' : ostree_linux ,
126
+ 'rpmostree.rpmdb.pkglist' : pkglist ,
127
+ 'synthetic' : True ,
128
+ }
129
+
130
+ stream = build_meta .get ('coreos-assembler.oci-imported-labels' , {}).get ('fedora-coreos.stream' , '' )
131
+ if stream != '' :
132
+ commitmeta ['fedora-coreos.stream' ] = stream
133
+
134
+ with open (tmp_commitmeta , 'w' ) as f :
135
+ json .dump (commitmeta , f , indent = 2 )
136
+
137
+ with open (tmp_lockfile , 'w' ) as f :
110
138
json .dump (fp = f , obj = {
111
139
'packages' : rpmdb
112
140
})
113
141
114
- return tmpf
142
+ return tmp_lockfile , tmp_commitmeta
115
143
116
144
117
145
def generate_build_meta (tmp_oci_archive , tmp_oci_manifest , metadata , ostree_commit ):
@@ -170,7 +198,7 @@ def generate_build_meta(tmp_oci_archive, tmp_oci_manifest, metadata, ostree_comm
170
198
return meta
171
199
172
200
173
- def finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile ):
201
+ def finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile , tmp_commitmeta ):
174
202
buildid = build_meta ['buildid' ]
175
203
arch = build_meta ['coreos-assembler.basearch' ]
176
204
@@ -180,6 +208,7 @@ def finalize_build(builds, build_meta, tmp_oci_archive, tmp_oci_manifest, tmp_lo
180
208
shutil .move (tmp_oci_archive , f'{ destdir } /{ build_meta ['images' ]['ostree' ]['path' ]} ' )
181
209
shutil .move (tmp_oci_manifest , f'{ destdir } /{ build_meta ['images' ]['oci-manifest' ]['path' ]} ' )
182
210
shutil .move (tmp_lockfile , f'{ destdir } /manifest-lock.generated.{ arch } .json' )
211
+ shutil .move (tmp_commitmeta , f'{ destdir } /commitmeta.json' )
183
212
184
213
with open (f'{ destdir } /meta.json' , 'w' ) as f :
185
214
json .dump (build_meta , f , indent = 4 )
0 commit comments