@@ -56,8 +56,11 @@ def main():
56
56
# create meta.json
57
57
build_meta = generate_build_meta (tmp_oci_archive , tmp_oci_manifest , metadata , ostree_commit )
58
58
59
+ # create commitmeta.json
60
+ tmp_commitmeta = generate_commitmeta (tmpd , ostree_commit , build_meta )
61
+
59
62
# move into official location
60
- finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile )
63
+ finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile , tmp_commitmeta )
61
64
62
65
if not args .skip_prune :
63
66
subprocess .check_call (['/usr/lib/coreos-assembler/cmd-prune' ])
@@ -114,6 +117,38 @@ def generate_lockfile(tmpd, ostree_commit):
114
117
return tmpf
115
118
116
119
120
+ def generate_commitmeta (tmpd , ostree_commit , build_meta ):
121
+ tmpf = os .path .join (tmpd , 'commitmeta.json' )
122
+ out = subprocess .check_output (['rpm-ostree' , 'db' , 'list' , '--repo' , 'tmp/repo' , ostree_commit ], encoding = 'utf-8' )
123
+ ostree_linux = ''
124
+ rpmdb = []
125
+ for line in out .splitlines ():
126
+ if not line .startswith (' ' ):
127
+ continue
128
+
129
+ # Do we have epoch in package names?
130
+ n , v , ra = line .strip ().rsplit ('-' , 2 )
131
+ r , a = ra .rsplit ('.' , 1 )
132
+ rpmdb .append ([n , "0" , v , r , a ])
133
+ if n == 'kernel' :
134
+ ostree_linux = f"{ v } -{ r } .{ a } "
135
+
136
+ commitmeta = {
137
+ 'coreos-assembler.config-gitrev' : build_meta .get ('coreos-assembler.container-config-git' , {}).get ('commit' , '' ),
138
+ 'coreos-assembler.basearch' : build_meta .get ('coreos-assembler.basearch' , '' ),
139
+ 'fedora-coreos.stream' : build_meta .get ('coreos-assembler.oci-imported-labels' , {}).get ('fedora-coreos.stream' , '' ),
140
+ 'version' : build_meta .get ('buildid' , '' ),
141
+ 'ostree.bootable' : True if build_meta .get ('coreos-assembler.oci-imported-labels' , {}).get ('ostree.bootable' , '0' ) == '1' else False ,
142
+ 'ostree.linux' : ostree_linux ,
143
+ 'rpmostree.rpmdb.pkglist' : rpmdb ,
144
+ }
145
+
146
+ with open (tmpf , 'w' ) as f :
147
+ json .dump (commitmeta , f , indent = 2 )
148
+
149
+ return tmpf
150
+
151
+
117
152
def generate_build_meta (tmp_oci_archive , tmp_oci_manifest , metadata , ostree_commit ):
118
153
name = metadata ['Labels' ]['com.coreos.osname' ]
119
154
buildid = metadata ['Labels' ]['org.opencontainers.image.version' ]
@@ -170,7 +205,7 @@ def generate_build_meta(tmp_oci_archive, tmp_oci_manifest, metadata, ostree_comm
170
205
return meta
171
206
172
207
173
- def finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile ):
208
+ def finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile , tmp_commitmeta ):
174
209
buildid = build_meta ['buildid' ]
175
210
arch = build_meta ['coreos-assembler.basearch' ]
176
211
@@ -180,6 +215,7 @@ def finalize_build(builds, build_meta, tmp_oci_archive, tmp_oci_manifest, tmp_lo
180
215
shutil .move (tmp_oci_archive , f'{ destdir } /{ build_meta ['images' ]['ostree' ]['path' ]} ' )
181
216
shutil .move (tmp_oci_manifest , f'{ destdir } /{ build_meta ['images' ]['oci-manifest' ]['path' ]} ' )
182
217
shutil .move (tmp_lockfile , f'{ destdir } /manifest-lock.generated.{ arch } .json' )
218
+ shutil .move (tmp_commitmeta , f'{ destdir } /commitmeta.json' )
183
219
184
220
with open (f'{ destdir } /meta.json' , 'w' ) as f :
185
221
json .dump (build_meta , f , indent = 4 )
0 commit comments