@@ -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' ])
@@ -114,6 +117,25 @@ def generate_lockfile(tmpd, ostree_commit):
114117 return tmpf
115118
116119
120+ def generate_commitmeta (tmpd , ostree_commit ):
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+ rpmdb = []
124+ for line in out .splitlines ():
125+ if not line .startswith (' ' ):
126+ continue
127+
128+ # Do we have epoch in package names?
129+ n , v , ra = line .strip ().rsplit ('-' , 2 )
130+ r , a = ra .rsplit ('.' , 1 )
131+ rpmdb .append ([n , "0" , v , r , a ])
132+
133+ with open (tmpf , 'w' ) as f :
134+ json .dump ({ 'rpmostree.rpmdb.pkglist' : rpmdb }, f , indent = 2 )
135+
136+ return tmpf
137+
138+
117139def generate_build_meta (tmp_oci_archive , tmp_oci_manifest , metadata , ostree_commit ):
118140 name = metadata ['Labels' ]['com.coreos.osname' ]
119141 buildid = metadata ['Labels' ]['org.opencontainers.image.version' ]
@@ -170,7 +192,7 @@ def generate_build_meta(tmp_oci_archive, tmp_oci_manifest, metadata, ostree_comm
170192 return meta
171193
172194
173- def finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile ):
195+ def finalize_build (builds , build_meta , tmp_oci_archive , tmp_oci_manifest , tmp_lockfile , tmp_commitmeta ):
174196 buildid = build_meta ['buildid' ]
175197 arch = build_meta ['coreos-assembler.basearch' ]
176198
@@ -180,6 +202,7 @@ def finalize_build(builds, build_meta, tmp_oci_archive, tmp_oci_manifest, tmp_lo
180202 shutil .move (tmp_oci_archive , f'{ destdir } /{ build_meta ['images' ]['ostree' ]['path' ]} ' )
181203 shutil .move (tmp_oci_manifest , f'{ destdir } /{ build_meta ['images' ]['oci-manifest' ]['path' ]} ' )
182204 shutil .move (tmp_lockfile , f'{ destdir } /manifest-lock.generated.{ arch } .json' )
205+ shutil .move (tmp_commitmeta , f'{ destdir } /commitmeta.json' )
183206
184207 with open (f'{ destdir } /meta.json' , 'w' ) as f :
185208 json .dump (build_meta , f , indent = 4 )
0 commit comments