@@ -56,8 +56,11 @@ def main():
5656 # create meta.json
5757 build_meta = generate_build_meta (tmp_oci_archive , tmp_oci_manifest , metadata , ostree_commit )
5858
59+ # create commitmeta.json
60+ tmp_commitmeta = generate_commitmeta (tmpd , ostree_commit )
61+
5962 # 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 )
6164
6265 if not args .skip_prune :
6366 subprocess .check_call (['/usr/lib/coreos-assembler/cmd-prune' ])
@@ -113,6 +116,26 @@ def generate_lockfile(tmpd, ostree_commit):
113116
114117 return tmpf
115118
119+ def generate_commitmeta (tmpd , ostree_commit ):
120+ tmpf = os .path .join (tmpd , 'commitmeta.json' )
121+ out = subprocess .check_output (['rpm-ostree' , 'db' , 'list' , '--repo' , 'tmp/repo' , ostree_commit ], encoding = 'utf-8' )
122+ rpmdb = []
123+ for line in out .splitlines ():
124+ if not line .startswith (' ' ):
125+ continue
126+
127+ # Do we have epoch in package names?
128+ n , v , ra = line .strip ().rsplit ('-' , 2 )
129+ r , a = ra .rsplit ('.' , 1 )
130+ rpmdb .append ([n , "0" , v , r , a ])
131+
132+ with open (tmpf , 'w' ) as f :
133+ json .dump ({
134+ 'rpmostree.rpmdb.pkglist' : rpmdb
135+ }, f , indent = 2 )
136+
137+ return tmpf
138+
116139
117140def generate_build_meta (tmp_oci_archive , tmp_oci_manifest , metadata , ostree_commit ):
118141 name = metadata ['Labels' ]['com.coreos.osname' ]
@@ -170,7 +193,7 @@ def generate_build_meta(tmp_oci_archive, tmp_oci_manifest, metadata, ostree_comm
170193 return meta
171194
172195
173- def finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile ):
196+ def finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile , tmp_commitmeta ):
174197 buildid = build_meta ['buildid' ]
175198 arch = build_meta ['coreos-assembler.basearch' ]
176199
@@ -180,6 +203,7 @@ def finalize_build(builds, build_meta, tmp_oci_archive, tmp_oci_manifest, tmp_lo
180203 shutil .move (tmp_oci_archive , f'{ destdir } /{ build_meta ['images' ]['ostree' ]['path' ]} ' )
181204 shutil .move (tmp_oci_manifest , f'{ destdir } /{ build_meta ['images' ]['oci-manifest' ]['path' ]} ' )
182205 shutil .move (tmp_lockfile , f'{ destdir } /manifest-lock.generated.{ arch } .json' )
206+ shutil .move (tmp_commitmeta , f'{ destdir } /commitmeta.json' )
183207
184208 with open (f'{ destdir } /meta.json' , 'w' ) as f :
185209 json .dump (build_meta , f , indent = 4 )
0 commit comments