@@ -50,14 +50,14 @@ def main():
5050 # import into the tmp/repo to get the ostree-commit but also so it's cached
5151 ostree_commit = import_oci_archive (tmpd , tmp_oci_archive , buildid )
5252
53- # artificially recreate generated lockfile
54- tmp_lockfile = generate_lockfile (tmpd , ostree_commit )
55-
5653 # create meta.json
5754 build_meta = generate_build_meta (tmp_oci_archive , tmp_oci_manifest , metadata , ostree_commit )
5855
56+ # artificially recreate generated lockfile and commitmeta.json
57+ tmp_lockfile , tmp_commitmeta = generate_lockfile_and_commitmeta (tmpd , ostree_commit , build_meta )
58+
5959 # 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 )
6161
6262 if not args .skip_prune :
6363 subprocess .check_call (['/usr/lib/coreos-assembler/cmd-prune' ])
@@ -95,23 +95,51 @@ def generate_oci_manifest(args, tmpd):
9595 return tmpf
9696
9797
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' )
101101 out = subprocess .check_output (['rpm-ostree' , 'db' , 'list' , '--repo' , 'tmp/repo' , ostree_commit ], encoding = 'utf-8' )
102102 rpmdb = {}
103+ pkglist = []
104+ ostree_linux = ""
103105 for line in out .splitlines ():
104106 if not line .startswith (' ' ):
105107 continue
106108 n , ev , ra = line .strip ().rsplit ('-' , 2 )
107109 rpmdb [n ] = {'evra' : f'{ ev } -{ ra } ' }
108110
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 :
110138 json .dump (fp = f , obj = {
111139 'packages' : rpmdb
112140 })
113141
114- return tmpf
142+ return tmp_lockfile , tmp_commitmeta
115143
116144
117145def 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
170198 return meta
171199
172200
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 ):
174202 buildid = build_meta ['buildid' ]
175203 arch = build_meta ['coreos-assembler.basearch' ]
176204
@@ -180,6 +208,7 @@ def finalize_build(builds, build_meta, tmp_oci_archive, tmp_oci_manifest, tmp_lo
180208 shutil .move (tmp_oci_archive , f'{ destdir } /{ build_meta ['images' ]['ostree' ]['path' ]} ' )
181209 shutil .move (tmp_oci_manifest , f'{ destdir } /{ build_meta ['images' ]['oci-manifest' ]['path' ]} ' )
182210 shutil .move (tmp_lockfile , f'{ destdir } /manifest-lock.generated.{ arch } .json' )
211+ shutil .move (tmp_commitmeta , f'{ destdir } /commitmeta.json' )
183212
184213 with open (f'{ destdir } /meta.json' , 'w' ) as f :
185214 json .dump (build_meta , f , indent = 4 )
0 commit comments