@@ -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 )
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,25 @@ def generate_lockfile(tmpd, ostree_commit):
114
117
return tmpf
115
118
116
119
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
+
117
139
def generate_build_meta (tmp_oci_archive , tmp_oci_manifest , metadata , ostree_commit ):
118
140
name = metadata ['Labels' ]['com.coreos.osname' ]
119
141
buildid = metadata ['Labels' ]['org.opencontainers.image.version' ]
@@ -170,7 +192,7 @@ def generate_build_meta(tmp_oci_archive, tmp_oci_manifest, metadata, ostree_comm
170
192
return meta
171
193
172
194
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 ):
174
196
buildid = build_meta ['buildid' ]
175
197
arch = build_meta ['coreos-assembler.basearch' ]
176
198
@@ -180,6 +202,7 @@ def finalize_build(builds, build_meta, tmp_oci_archive, tmp_oci_manifest, tmp_lo
180
202
shutil .move (tmp_oci_archive , f'{ destdir } /{ build_meta ['images' ]['ostree' ]['path' ]} ' )
181
203
shutil .move (tmp_oci_manifest , f'{ destdir } /{ build_meta ['images' ]['oci-manifest' ]['path' ]} ' )
182
204
shutil .move (tmp_lockfile , f'{ destdir } /manifest-lock.generated.{ arch } .json' )
205
+ shutil .move (tmp_commitmeta , f'{ destdir } /commitmeta.json' )
183
206
184
207
with open (f'{ destdir } /meta.json' , 'w' ) as f :
185
208
json .dump (build_meta , f , indent = 4 )
0 commit comments